Open Source Tomb Raider Engine
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

OpenGLMesh.h 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
  2. /*================================================================
  3. *
  4. * Project : OpenRaider
  5. * Author : Terry 'Mongoose' Hendrix II
  6. * Website : http://www.westga.edu/~stu7440/
  7. * Email : stu7440@westga.edu
  8. * Object : OpenGLMesh
  9. * License : No use w/o permission (C) 2002 Mongoose
  10. * Comments:
  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_OPENGLMESH - Builds OpenGLMesh class as a console unit test
  19. *
  20. *-- History ------------------------------------------------
  21. *
  22. * 2002.08.23:
  23. * Mongoose - Created
  24. ================================================================*/
  25. #ifndef GUARD__OPENRAIDER_MONGOOSE_OPENGLMESH_H_
  26. #define GUARD__OPENRAIDER_MONGOOSE_OPENGLMESH_H_
  27. #include "hel/math.h"
  28. // TODO: Unify the parallel systems here, arrays and the allocate/set
  29. typedef enum
  30. {
  31. OpenGLMeshModeSolid = 0,
  32. OpenGLMeshModeWireframe = 1,
  33. OpenGLMeshModeTexture = 2,
  34. OpenGLMeshModeMultiTexture = 3
  35. } OpenGLMeshMode;
  36. enum OpenGLMeshFlags
  37. {
  38. fOpenGLMesh_Transparent = 1,
  39. fOpenGLMesh_BumpMap = 2,
  40. fOpenGLMesh_UseVertexArray = 4
  41. };
  42. typedef struct tris_s
  43. {
  44. int texture;
  45. #ifdef MULTITEXTURE
  46. int bumpmap;
  47. #endif
  48. unsigned int cnum_triangles;
  49. unsigned int cnum_alpha_triangles;
  50. unsigned int num_texcoors;
  51. vec2_t *texcoors;
  52. unsigned int num_texcoors2;
  53. vec2_t *texcoors2;
  54. // Arrays of triangle indices sorted by texture
  55. unsigned int num_triangles;
  56. unsigned int *triangles; // ABCABCABC...
  57. // Arrays of alpha triangle indices sorted by texture
  58. unsigned int num_alpha_triangles;
  59. unsigned int *alpha_triangles; // ABCABCABC...
  60. } tris_t;
  61. typedef struct rect_s
  62. {
  63. int texture;
  64. #ifdef MULTITEXTURE
  65. int bumpmap;
  66. #endif
  67. unsigned int cnum_quads;
  68. unsigned int cnum_alpha_quads;
  69. unsigned int num_texcoors;
  70. vec2_t *texcoors;
  71. unsigned int num_texcoors2;
  72. vec2_t *texcoors2;
  73. // Arrays of rectangle indices sorted by texture
  74. unsigned int num_quads;
  75. unsigned int *quads; // ABCDABCDABCD...
  76. // Arrays of alpha rectangle indices sorted by texture
  77. unsigned int num_alpha_quads;
  78. unsigned int *alpha_quads; // ABCDABCDABCD...
  79. } rect_t;
  80. class OpenGLMesh
  81. {
  82. public:
  83. ////////////////////////////////////////////////////////////
  84. // Constructors
  85. ////////////////////////////////////////////////////////////
  86. OpenGLMesh();
  87. /*------------------------------------------------------
  88. * Pre :
  89. * Post : Constructs an object of OpenGLMesh
  90. *
  91. *-- History ------------------------------------------
  92. *
  93. * 2002.08.23:
  94. * Mongoose - Created
  95. ------------------------------------------------------*/
  96. ~OpenGLMesh();
  97. /*------------------------------------------------------
  98. * Pre : OpenGLMesh object is allocated
  99. * Post : Deconstructs an object of OpenGLMesh
  100. *
  101. *-- History ------------------------------------------
  102. *
  103. * 2002.08.23:
  104. * Mongoose - Created
  105. ------------------------------------------------------*/
  106. ////////////////////////////////////////////////////////////
  107. // Public Accessors
  108. ////////////////////////////////////////////////////////////
  109. void drawAlpha();
  110. /*------------------------------------------------------
  111. * Pre :
  112. * Post : Render alpha polygons
  113. *
  114. *-- History ------------------------------------------
  115. *
  116. * 2002.08.23:
  117. * Mongoose - Created
  118. ------------------------------------------------------*/
  119. void drawSolid();
  120. /*------------------------------------------------------
  121. * Pre :
  122. * Post : Render solid polygons
  123. *
  124. *-- History ------------------------------------------
  125. *
  126. * 2002.08.23:
  127. * Mongoose - Created
  128. ------------------------------------------------------*/
  129. ////////////////////////////////////////////////////////////
  130. // Public Mutators
  131. ////////////////////////////////////////////////////////////
  132. void allocateColors(unsigned int n);
  133. /*------------------------------------------------------
  134. * Pre :
  135. * Post :
  136. *
  137. *-- History ------------------------------------------
  138. *
  139. * 2002.08.23:
  140. * Mongoose - Created
  141. ------------------------------------------------------*/
  142. void allocateNormals(unsigned int n);
  143. /*------------------------------------------------------
  144. * Pre :
  145. * Post :
  146. *
  147. *-- History ------------------------------------------
  148. *
  149. * 2002.08.23:
  150. * Mongoose - Created
  151. ------------------------------------------------------*/
  152. void allocateRectangles(unsigned int n);
  153. /*------------------------------------------------------
  154. * Pre :
  155. * Post :
  156. *
  157. *-- History ------------------------------------------
  158. *
  159. * 2002.08.23:
  160. * Mongoose - Created
  161. ------------------------------------------------------*/
  162. void allocateTriangles(unsigned int n);
  163. /*------------------------------------------------------
  164. * Pre :
  165. * Post :
  166. *
  167. *-- History ------------------------------------------
  168. *
  169. * 2002.08.23:
  170. * Mongoose - Created
  171. ------------------------------------------------------*/
  172. void allocateVertices(unsigned int n);
  173. /*------------------------------------------------------
  174. * Pre :
  175. * Post :
  176. *
  177. *-- History ------------------------------------------
  178. *
  179. * 2002.08.23:
  180. * Mongoose - Created
  181. ------------------------------------------------------*/
  182. void bufferColorArray(unsigned int colorCount, vec_t *colors,
  183. unsigned int colorWidth);
  184. /*------------------------------------------------------
  185. * Pre :
  186. * Post :
  187. *
  188. *-- History ------------------------------------------
  189. *
  190. * 2003.05.20:
  191. * Mongoose - Created
  192. ------------------------------------------------------*/
  193. void bufferNormalArray(unsigned int normalCount, vec_t *normals);
  194. /*------------------------------------------------------
  195. * Pre :
  196. * Post :
  197. *
  198. *-- History ------------------------------------------
  199. *
  200. * 2003.05.20:
  201. * Mongoose - Created
  202. ------------------------------------------------------*/
  203. void bufferTriangles(unsigned int count,
  204. unsigned int *indices, vec_t *texCoords,
  205. int *textures, unsigned int *flags);
  206. /*------------------------------------------------------
  207. * Pre :
  208. * Post :
  209. *
  210. *-- History ------------------------------------------
  211. *
  212. * 2003.05.26:
  213. * Mongoose - Created
  214. ------------------------------------------------------*/
  215. void bufferVertexArray(unsigned int vertexCount, vec_t *vertices);
  216. /*------------------------------------------------------
  217. * Pre :
  218. * Post :
  219. *
  220. *-- History ------------------------------------------
  221. *
  222. * 2003.05.20:
  223. * Mongoose - Created
  224. ------------------------------------------------------*/
  225. void setColor(unsigned int index, float r, float g, float b, float a);
  226. /*------------------------------------------------------
  227. * Pre :
  228. * Post :
  229. *
  230. *-- History ------------------------------------------
  231. *
  232. * 2002.08.23:
  233. * Mongoose - Created
  234. ------------------------------------------------------*/
  235. void setColor(unsigned int index, float rgba[4]);
  236. /*------------------------------------------------------
  237. * Pre :
  238. * Post :
  239. *
  240. *-- History ------------------------------------------
  241. *
  242. * 2002.08.23:
  243. * Mongoose - Created
  244. ------------------------------------------------------*/
  245. void setNormal(unsigned int index, float i, float j, float k);
  246. /*------------------------------------------------------
  247. * Pre :
  248. * Post :
  249. *
  250. *-- History ------------------------------------------
  251. *
  252. * 2002.08.23:
  253. * Mongoose - Created
  254. ------------------------------------------------------*/
  255. void setVertex(unsigned int index, float x, float y, float z);
  256. /*------------------------------------------------------
  257. * Pre :
  258. * Post :
  259. *
  260. *-- History ------------------------------------------
  261. *
  262. * 2002.08.23:
  263. * Mongoose - Created
  264. ------------------------------------------------------*/
  265. #ifdef NOT_IMPLEMENTED
  266. void sortFacesByTexture();
  267. /*------------------------------------------------------
  268. * Pre :
  269. * Post :
  270. *
  271. *-- History ------------------------------------------
  272. *
  273. * 2003.05.26:
  274. * Mongoose - Created
  275. ------------------------------------------------------*/
  276. void addFace(int textureIndex, int textureIndexB, unsigned int flags,
  277. unsigned int vertexIndexCount, vec_t *vertexIndices);
  278. /*------------------------------------------------------
  279. * Pre :
  280. * Post :
  281. *
  282. *-- History ------------------------------------------
  283. *
  284. * 2003.05.26:
  285. * Mongoose - Created
  286. ------------------------------------------------------*/
  287. void addTexTiledFace(int textureIndex, int textureIndexB,
  288. unsigned int flags, unsigned int indexCount,
  289. vec_t *vertexIndices, vec_t *texcoords);
  290. /*------------------------------------------------------
  291. * Pre :
  292. * Post :
  293. *
  294. *-- History ------------------------------------------
  295. *
  296. * 2003.05.26:
  297. * Mongoose - Created
  298. ------------------------------------------------------*/
  299. void bufferTexcoords(unsigned int texcoordCount, vec_t *texcoords);
  300. /*------------------------------------------------------
  301. * Pre :
  302. * Post :
  303. *
  304. *-- History ------------------------------------------
  305. *
  306. * 2003.05.26:
  307. * Mongoose - Created
  308. ------------------------------------------------------*/
  309. void duplicateArraysForTexTiledTexcoords();
  310. /*------------------------------------------------------
  311. * Pre :
  312. * Post :
  313. *
  314. *-- History ------------------------------------------
  315. *
  316. * 2003.05.26:
  317. * Mongoose - Created
  318. ------------------------------------------------------*/
  319. #endif
  320. unsigned int mFlags;
  321. OpenGLMeshMode mMode;
  322. unsigned int mNumVertices;
  323. vec3_t *mVertices; // <XYZ>
  324. unsigned int mNumNormals;
  325. vec3_t *mNormals; // <IJK>
  326. unsigned int mNumColors;
  327. vec4_t *mColors; // <RGBA>
  328. unsigned int mNumTris;
  329. tris_t *mTris;
  330. unsigned int mNumQuads;
  331. rect_t *mQuads;
  332. unsigned int mTriangleCount;
  333. int *mTriangleTextures;
  334. unsigned int *mTriangleIndices;
  335. unsigned int *mTriangleFlags;
  336. vec_t *mTriangleTexCoordArray;
  337. vec_t *mVertexArray;
  338. vec_t *mNormalArray;
  339. vec_t *mColorArray;
  340. private:
  341. ////////////////////////////////////////////////////////////
  342. // Private Accessors
  343. ////////////////////////////////////////////////////////////
  344. ////////////////////////////////////////////////////////////
  345. // Private Mutators
  346. ////////////////////////////////////////////////////////////
  347. /* */
  348. };
  349. #endif