123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294 |
- /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
- /*================================================================
- *
- * Project : hel
- * Author : Terry 'Mongoose' Hendrix II
- * Website : http://www.westga.edu/~stu7440/
- * Email : stu7440@westga.edu
- * Object : ViewVolume
- * License : No use w/o permission (C) 2002 Mongoose
- * Comments: This is the viewing volume for culling use
- *
- *
- * This file was generated using Mongoose's C++
- * template generator script. <stu7440@westga.edu>
- *
- *-- Test Defines -----------------------------------------------
- *
- * UNIT_TEST_VIEWVOLUME - Builds ViewVolume class as a console unit test
- *
- *-- History ------------------------------------------------
- *
- * 2002.12.15:
- * Mongoose - Created
- ================================================================*/
-
-
- #ifndef GUARD__HEL_MONGOOSE_VIEWVOLUME_H_
- #define GUARD__HEL_MONGOOSE_VIEWVOLUME_H_
-
- #include <Matrix.h>
- #include <BoundingVolume.h>
-
- class ViewVolume
- {
- public:
-
- enum ViewVolumeSide
- {
- rightSide = 0, // Right
- leftSide = 1, // Left
- bottomSide = 2, // Bottom
- topSide = 3, // Top
- farSide = 4, // Back
- nearSide = 5 // Front
- };
-
- enum ViewVolumePlane
- {
- planeA = 0, // X value of normal
- planeB = 1, // Y value of normal
- planeC = 2, // Z value of normal
- planeD = 3 // Distance to origin
- };
-
-
- ////////////////////////////////////////////////////////////
- // Constructors
- ////////////////////////////////////////////////////////////
-
- ViewVolume();
- /*------------------------------------------------------
- * Pre :
- * Post : Constructs an object of ViewVolume
- *
- *-- History ------------------------------------------
- *
- * 2002.12.15:
- * Mongoose - Created
- ------------------------------------------------------*/
-
- ~ViewVolume();
- /*------------------------------------------------------
- * Pre : ViewVolume object is allocated
- * Post : Deconstructs an object of ViewVolume
- *
- *-- History ------------------------------------------
- *
- * 2002.12.15:
- * Mongoose - Created
- ------------------------------------------------------*/
-
-
- ////////////////////////////////////////////////////////////
- // Public Accessors
- ////////////////////////////////////////////////////////////
-
- bool isBoundingVolumeInFrustum(BoundingVolume bvol);
- /*------------------------------------------------------
- * Pre :
- * Post : Returns true if frustum contains the given
- * bounding volume
- *
- *-- History ------------------------------------------
- *
- * 2002.12.15:
- * Mongoose - Created
- ------------------------------------------------------*/
-
- bool isBoundingSphereInFrustum(BoundingSphere bvol);
- /*------------------------------------------------------
- * Pre :
- * Post : Returns true if frustum contains the given
- * bounding volume
- *
- *-- History ------------------------------------------
- *
- * 2002.12.15:
- * Mongoose - Created
- ------------------------------------------------------*/
-
- bool isBoundingBoxInFrustum(BoundingBox bvol);
- /*------------------------------------------------------
- * Pre :
- * Post : Returns true if frustum contains the given
- * bounding volume
- *
- *-- History ------------------------------------------
- *
- * 2002.12.15:
- * Mongoose - Created
- ------------------------------------------------------*/
-
- bool isPointInFrustum(vec_t x, vec_t y, vec_t z);
- /*------------------------------------------------------
- * Pre :
- * Post :
- *
- *-- History ------------------------------------------
- *
- * 2002.12.15:
- * Mongoose - Created
- ------------------------------------------------------*/
-
- bool isSphereInFrustum(vec_t x, vec_t y, vec_t z, vec_t radius);
- /*------------------------------------------------------
- * Pre : Abstract sphere is valid
- * Post : Returns true if abstract sphere in view volume
- *
- *-- History ------------------------------------------
- *
- * 2002.12.15:
- * Mongoose - Created
- ------------------------------------------------------*/
-
- bool isBboxInFrustum(vec3_t min, vec3_t max);
- /*------------------------------------------------------
- * Pre : Abstract bounding box is valid
- * Post : Returns true if abstract bounding box in view volume
- *
- *-- History ------------------------------------------
- *
- * 2002.12.15:
- * Mongoose - Created
- ------------------------------------------------------*/
-
- vec_t getDistToSphereFromNear(vec_t x, vec_t y, vec_t z, vec_t radius);
- /*------------------------------------------------------
- * Pre : Abstract sphere is valid
- * Post : Returns distance to abstract sphere
- * bounding volume
- *
- *-- History ------------------------------------------
- *
- * 2002.12.15:
- * Mongoose - Created
- ------------------------------------------------------*/
-
- vec_t getDistToBboxFromNear(vec3_t min, vec3_t max);
- /*------------------------------------------------------
- * Pre : Abstract bounding box is valid
- * Post : Returns distance to abstract box
- * bounding volume
- *
- *-- History ------------------------------------------
- *
- * 2002.12.15:
- * Mongoose - Created
- ------------------------------------------------------*/
-
- void getFrustum(vec_t frustum[6][4]);
- /*------------------------------------------------------
- * Pre : Frustum is allocated 6x4 vec_t
- * Post : Get a copy of the view volume
- *
- *-- History ------------------------------------------
- *
- * 2002.12.26:
- * Mongoose - Created
- ------------------------------------------------------*/
-
- void getPlane(ViewVolumeSide p, vec4_t plane);
- /*------------------------------------------------------
- * Pre :
- * Post : Get a copy of a given plane in view volume
- *
- *-- History ------------------------------------------
- *
- * 2002.12.26:
- * Mongoose - Created
- ------------------------------------------------------*/
-
-
- ////////////////////////////////////////////////////////////
- // Public Mutators
- ////////////////////////////////////////////////////////////
-
- void updateFrame(matrix_t proj, matrix_t mdl);
- /*------------------------------------------------------
- * Pre : Given valid projection and model matrices
- * Post : Updates view volume for this frame
- *
- *-- History ------------------------------------------
- *
- * 2002.12.15:
- * Mongoose - Created
- ------------------------------------------------------*/
-
- void updateFrame();
- /*------------------------------------------------------
- * Pre : Called setModel() and setProjection()
- * Post : Updates view volume for this frame
- *
- *-- History ------------------------------------------
- *
- * 2002.12.15:
- * Mongoose - Created
- ------------------------------------------------------*/
-
- void setModel(matrix_t mdl);
- /*------------------------------------------------------
- * Pre : It's valid model matrix
- * Post : Sets this class' model matrix
- *
- *-- History ------------------------------------------
- *
- * 2002.12.15:
- * Mongoose - Created
- ------------------------------------------------------*/
-
- void setProjection(matrix_t proj);
- /*------------------------------------------------------
- * Pre : It's the valid projection matrix
- * Post : Sets this class' projection matrix
- *
- *-- History ------------------------------------------
- *
- * 2002.12.15:
- * Mongoose - Created
- ------------------------------------------------------*/
-
- private:
-
- ////////////////////////////////////////////////////////////
- // Private Accessors
- ////////////////////////////////////////////////////////////
-
-
- ////////////////////////////////////////////////////////////
- // Private Mutators
- ////////////////////////////////////////////////////////////
-
- void updateClip();
- /*------------------------------------------------------
- * Pre : model and projection matrices are set
- * Post : Computes clipping matrix
- *
- *-- History ------------------------------------------
- *
- * 2002.12.15:
- * Mongoose - Created
- ------------------------------------------------------*/
-
- void updateFrustum();
- /*------------------------------------------------------
- * Pre : model, projection, clip matrices are set
- * Post : Computes planes of frustum
- *
- *-- History ------------------------------------------
- *
- * 2002.12.15:
- * Mongoose - Created
- ------------------------------------------------------*/
-
-
- Matrix mProjection; /* Projection matrix */
-
- Matrix mModel; /* Model matrix */
-
- Matrix mClip; /* Clipping matrix */
-
- vec_t mFrustum[6][4]; /* View volume */
- };
-
- #endif
|