Open Source Tomb Raider Engine
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

ViewVolume.h 8.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
  2. /*================================================================
  3. *
  4. * Project : hel
  5. * Author : Terry 'Mongoose' Hendrix II
  6. * Website : http://www.westga.edu/~stu7440/
  7. * Email : stu7440@westga.edu
  8. * Object : ViewVolume
  9. * License : No use w/o permission (C) 2002 Mongoose
  10. * Comments: This is the viewing volume for culling use
  11. *
  12. *
  13. * This file was generated using Mongoose's C++
  14. * template generator script. <stu7440@westga.edu>
  15. *
  16. *-- Test Defines -----------------------------------------------
  17. *
  18. * UNIT_TEST_VIEWVOLUME - Builds ViewVolume class as a console unit test
  19. *
  20. *-- History ------------------------------------------------
  21. *
  22. * 2002.12.15:
  23. * Mongoose - Created
  24. ================================================================*/
  25. #ifndef GUARD__HEL_MONGOOSE_VIEWVOLUME_H_
  26. #define GUARD__HEL_MONGOOSE_VIEWVOLUME_H_
  27. #include <Matrix.h>
  28. #include <BoundingVolume.h>
  29. class ViewVolume
  30. {
  31. public:
  32. enum ViewVolumeSide
  33. {
  34. rightSide = 0, // Right
  35. leftSide = 1, // Left
  36. bottomSide = 2, // Bottom
  37. topSide = 3, // Top
  38. farSide = 4, // Back
  39. nearSide = 5 // Front
  40. };
  41. enum ViewVolumePlane
  42. {
  43. planeA = 0, // X value of normal
  44. planeB = 1, // Y value of normal
  45. planeC = 2, // Z value of normal
  46. planeD = 3 // Distance to origin
  47. };
  48. ////////////////////////////////////////////////////////////
  49. // Constructors
  50. ////////////////////////////////////////////////////////////
  51. ViewVolume();
  52. /*------------------------------------------------------
  53. * Pre :
  54. * Post : Constructs an object of ViewVolume
  55. *
  56. *-- History ------------------------------------------
  57. *
  58. * 2002.12.15:
  59. * Mongoose - Created
  60. ------------------------------------------------------*/
  61. ~ViewVolume();
  62. /*------------------------------------------------------
  63. * Pre : ViewVolume object is allocated
  64. * Post : Deconstructs an object of ViewVolume
  65. *
  66. *-- History ------------------------------------------
  67. *
  68. * 2002.12.15:
  69. * Mongoose - Created
  70. ------------------------------------------------------*/
  71. ////////////////////////////////////////////////////////////
  72. // Public Accessors
  73. ////////////////////////////////////////////////////////////
  74. bool isBoundingVolumeInFrustum(BoundingVolume bvol);
  75. /*------------------------------------------------------
  76. * Pre :
  77. * Post : Returns true if frustum contains the given
  78. * bounding volume
  79. *
  80. *-- History ------------------------------------------
  81. *
  82. * 2002.12.15:
  83. * Mongoose - Created
  84. ------------------------------------------------------*/
  85. bool isBoundingSphereInFrustum(BoundingSphere bvol);
  86. /*------------------------------------------------------
  87. * Pre :
  88. * Post : Returns true if frustum contains the given
  89. * bounding volume
  90. *
  91. *-- History ------------------------------------------
  92. *
  93. * 2002.12.15:
  94. * Mongoose - Created
  95. ------------------------------------------------------*/
  96. bool isBoundingBoxInFrustum(BoundingBox bvol);
  97. /*------------------------------------------------------
  98. * Pre :
  99. * Post : Returns true if frustum contains the given
  100. * bounding volume
  101. *
  102. *-- History ------------------------------------------
  103. *
  104. * 2002.12.15:
  105. * Mongoose - Created
  106. ------------------------------------------------------*/
  107. bool isPointInFrustum(vec_t x, vec_t y, vec_t z);
  108. /*------------------------------------------------------
  109. * Pre :
  110. * Post :
  111. *
  112. *-- History ------------------------------------------
  113. *
  114. * 2002.12.15:
  115. * Mongoose - Created
  116. ------------------------------------------------------*/
  117. bool isSphereInFrustum(vec_t x, vec_t y, vec_t z, vec_t radius);
  118. /*------------------------------------------------------
  119. * Pre : Abstract sphere is valid
  120. * Post : Returns true if abstract sphere in view volume
  121. *
  122. *-- History ------------------------------------------
  123. *
  124. * 2002.12.15:
  125. * Mongoose - Created
  126. ------------------------------------------------------*/
  127. bool isBboxInFrustum(vec3_t min, vec3_t max);
  128. /*------------------------------------------------------
  129. * Pre : Abstract bounding box is valid
  130. * Post : Returns true if abstract bounding box in view volume
  131. *
  132. *-- History ------------------------------------------
  133. *
  134. * 2002.12.15:
  135. * Mongoose - Created
  136. ------------------------------------------------------*/
  137. vec_t getDistToSphereFromNear(vec_t x, vec_t y, vec_t z, vec_t radius);
  138. /*------------------------------------------------------
  139. * Pre : Abstract sphere is valid
  140. * Post : Returns distance to abstract sphere
  141. * bounding volume
  142. *
  143. *-- History ------------------------------------------
  144. *
  145. * 2002.12.15:
  146. * Mongoose - Created
  147. ------------------------------------------------------*/
  148. vec_t getDistToBboxFromNear(vec3_t min, vec3_t max);
  149. /*------------------------------------------------------
  150. * Pre : Abstract bounding box is valid
  151. * Post : Returns distance to abstract box
  152. * bounding volume
  153. *
  154. *-- History ------------------------------------------
  155. *
  156. * 2002.12.15:
  157. * Mongoose - Created
  158. ------------------------------------------------------*/
  159. void getFrustum(vec_t frustum[6][4]);
  160. /*------------------------------------------------------
  161. * Pre : Frustum is allocated 6x4 vec_t
  162. * Post : Get a copy of the view volume
  163. *
  164. *-- History ------------------------------------------
  165. *
  166. * 2002.12.26:
  167. * Mongoose - Created
  168. ------------------------------------------------------*/
  169. void getPlane(ViewVolumeSide p, vec4_t plane);
  170. /*------------------------------------------------------
  171. * Pre :
  172. * Post : Get a copy of a given plane in view volume
  173. *
  174. *-- History ------------------------------------------
  175. *
  176. * 2002.12.26:
  177. * Mongoose - Created
  178. ------------------------------------------------------*/
  179. ////////////////////////////////////////////////////////////
  180. // Public Mutators
  181. ////////////////////////////////////////////////////////////
  182. void updateFrame(matrix_t proj, matrix_t mdl);
  183. /*------------------------------------------------------
  184. * Pre : Given valid projection and model matrices
  185. * Post : Updates view volume for this frame
  186. *
  187. *-- History ------------------------------------------
  188. *
  189. * 2002.12.15:
  190. * Mongoose - Created
  191. ------------------------------------------------------*/
  192. void updateFrame();
  193. /*------------------------------------------------------
  194. * Pre : Called setModel() and setProjection()
  195. * Post : Updates view volume for this frame
  196. *
  197. *-- History ------------------------------------------
  198. *
  199. * 2002.12.15:
  200. * Mongoose - Created
  201. ------------------------------------------------------*/
  202. void setModel(matrix_t mdl);
  203. /*------------------------------------------------------
  204. * Pre : It's valid model matrix
  205. * Post : Sets this class' model matrix
  206. *
  207. *-- History ------------------------------------------
  208. *
  209. * 2002.12.15:
  210. * Mongoose - Created
  211. ------------------------------------------------------*/
  212. void setProjection(matrix_t proj);
  213. /*------------------------------------------------------
  214. * Pre : It's the valid projection matrix
  215. * Post : Sets this class' projection matrix
  216. *
  217. *-- History ------------------------------------------
  218. *
  219. * 2002.12.15:
  220. * Mongoose - Created
  221. ------------------------------------------------------*/
  222. private:
  223. ////////////////////////////////////////////////////////////
  224. // Private Accessors
  225. ////////////////////////////////////////////////////////////
  226. ////////////////////////////////////////////////////////////
  227. // Private Mutators
  228. ////////////////////////////////////////////////////////////
  229. void updateClip();
  230. /*------------------------------------------------------
  231. * Pre : model and projection matrices are set
  232. * Post : Computes clipping matrix
  233. *
  234. *-- History ------------------------------------------
  235. *
  236. * 2002.12.15:
  237. * Mongoose - Created
  238. ------------------------------------------------------*/
  239. void updateFrustum();
  240. /*------------------------------------------------------
  241. * Pre : model, projection, clip matrices are set
  242. * Post : Computes planes of frustum
  243. *
  244. *-- History ------------------------------------------
  245. *
  246. * 2002.12.15:
  247. * Mongoose - Created
  248. ------------------------------------------------------*/
  249. Matrix mProjection; /* Projection matrix */
  250. Matrix mModel; /* Model matrix */
  251. Matrix mClip; /* Clipping matrix */
  252. vec_t mFrustum[6][4]; /* View volume */
  253. };
  254. #endif