Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
3.0 KiB

  1. /**
  2. ** File : sglmesh.h
  3. ** Description: Simple gl mesh definition
  4. **/
  5. #ifndef _sglmesh_h_
  6. #define _sglmesh_h_
  7. #include "global.h"
  8. #include "glstructs.h"
  9. #include "excptn.h"
  10. /*************************************************************************
  11. Typedefs, structs and classes
  12. *************************************************************************/
  13. typedef enum
  14. {
  15. GLPM_SOLID = 0x0001,
  16. GLPM_WIRE = 0x0002,
  17. } RenderType;
  18. class CSimpGlMesh
  19. {
  20. protected:
  21. public:
  22. /*
  23. * Vertex-Array data
  24. */
  25. GLvertex* m_varray; // Vertex Array to store Wedges/Vertices
  26. GLnormal* m_narray; // Normal Array to store Normals
  27. GLtexCoord* m_tarray; // Texture Array
  28. GLface* m_farray; // Face Array
  29. WORD* m_wedgelist; // circular linked lists of wedges sharing the same
  30. // vertex
  31. /*
  32. * Material/Texture related info
  33. */
  34. GLmaterial* m_matArray; // Array of Materials
  35. WORD* m_matcnt; // table of face counts per material
  36. #ifdef __MATPOS_IS_A_PTR
  37. GLface** m_matpos; // pointers to where next face of a given material
  38. // is inserted in the m_farray
  39. #else
  40. WORD* m_matpos; // pointers to where next face of a given material
  41. // is inserted in the m_farray
  42. #endif
  43. /*
  44. * Various counts
  45. */
  46. DWORD m_numFaces;
  47. DWORD m_numWedges;
  48. DWORD m_numVerts;
  49. DWORD m_numMaterials;
  50. DWORD m_numTextures;
  51. /*
  52. * User-defined data
  53. */
  54. DWORD m_userWedgeSize; // Size of user defined wedge-data
  55. LPVOID m_userWedge; // User defined data per wedge
  56. DWORD m_userVertexSize; // Size of user defined vertex-data
  57. LPVOID m_userVertex; // User defined data per vertex
  58. DWORD m_userFaceSize; // Size of user defined face-data
  59. LPVOID m_userFace; // User defined data per face
  60. public:
  61. //Constructor-Destructor
  62. CSimpGlMesh();
  63. virtual ~CSimpGlMesh();
  64. virtual HRESULT Print (ostream& os);
  65. virtual HRESULT RenderMesh (RenderType);
  66. inline DWORD GetMeshNumFaces (void) const {return m_numFaces;}
  67. inline DWORD GetMeshNumWedges (void) const {return m_numWedges;}
  68. inline DWORD GetMeshNumVerts (void) const {return m_numVerts;}
  69. inline DWORD GetMeshNumMaterials (void) const {return m_numMaterials;}
  70. inline DWORD GetMeshNumTextures (void) const {return m_numTextures;}
  71. inline LPGLmaterial GetMeshMaterial (int i) const
  72. {
  73. return &(m_matArray[i]);
  74. }
  75. inline WORD FindVertexIndex(WORD w) const;
  76. inline LPVOID GetMeshUserFaceData (void) const {return m_userFace;}
  77. inline LPVOID GetMeshUserWedgeData (void) const {return m_userWedge;}
  78. inline LPVOID GetMeshUserVertexData (void) const {return m_userVertex;}
  79. };
  80. /*
  81. * Inlines
  82. */
  83. inline WORD CSimpGlMesh::FindVertexIndex(WORD w) const
  84. {
  85. WORD v = USHRT_MAX;
  86. WORD p = w;
  87. do
  88. {
  89. v = min(p,v);
  90. p = m_wedgelist[p];
  91. }
  92. while (p != w);
  93. return v;
  94. }
  95. #endif //_sglmesh_h_