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.

131 lines
3.3 KiB

  1. /**
  2. ** File : glmesh.h
  3. ** Description: Mesh definition
  4. **/
  5. #ifndef _glmesh_h_
  6. #define _glmesh_h_
  7. #include <objidl.h>
  8. #include <fstream.h>
  9. #include <limits.h>
  10. #include "glstructs.h"
  11. #include "excptn.h"
  12. /*************************************************************************
  13. Defines
  14. *************************************************************************/
  15. #define UNDEF USHRT_MAX
  16. /*************************************************************************
  17. Typedefs, structs and classes
  18. *************************************************************************/
  19. typedef enum {
  20. GLPM_SOLID=0x0001,
  21. GLPM_WIRE=0x0002,
  22. } RenderType;
  23. struct hashentry
  24. {
  25. WORD v2;
  26. WORD f, m; // face and it's matid
  27. hashentry* next;
  28. };
  29. typedef hashentry* PHASHENTRY;
  30. class CGlMesh
  31. {
  32. friend class CPMesh;
  33. private:
  34. public:
  35. GLmaterial* m_matArray; // Array of Materials
  36. /*
  37. * Vertex-Array data
  38. */
  39. GLvertex* m_varray; // Vertex Array to store Wedges/Vertices
  40. GLnormal* m_narray; // Normal Array to store Normals
  41. GLtexCoord* m_tarray; // Texture Array
  42. GLface* m_farray; // Face Array
  43. WORD* m_facemap; // Array remapping the face numbers
  44. WORD* m_wedgelist; // circular linked lists of wedges sharing the same
  45. // vertex
  46. WORD (*m_fnei)[3]; // face neightbour information table
  47. WORD* m_matcnt; // table of face counts per material
  48. #ifdef __MATPOS_IS_A_PTR
  49. GLface** m_matpos; // pointers to where next face of a given material
  50. // is inserted in the m_farray
  51. #else
  52. WORD* m_matpos; // pointers to where next face of a given material
  53. // is inserted in the m_farray
  54. #endif
  55. DWORD m_numFaces;
  56. DWORD m_numWedges;
  57. DWORD m_numVerts;
  58. DWORD m_numMaterials;
  59. DWORD m_numTextures;
  60. public:
  61. //Constructor-Destructor
  62. CGlMesh();
  63. ~CGlMesh();
  64. STDMETHODIMP Print (ostream& os);
  65. STDMETHODIMP Render (RenderType);
  66. #if 0
  67. STDMETHODIMP AddWedge (WORD vertex_id, GLnormal& n, GLtexCoord& t,
  68. DWORD* const wedge_id);
  69. STDMETHODIMP AddWedge (WORD vertex_id, WORD old_wedge_id,
  70. DWORD* const wedge_id);
  71. STDMETHODIMP AddFace (WORD matid, GLface& f);
  72. #endif
  73. inline DWORD GetNumFaces (void) const {return m_numFaces;};
  74. inline DWORD GetNumWedges (void) const {return m_numWedges;};
  75. inline DWORD GetNumVerts (void) const {return m_numVerts;};
  76. void ComputeAdjacency(void);
  77. //inline LPGLMaterial GetMaterial (int i) {return &(m_matArray[i]);}
  78. inline WORD FindVertexIndex(WORD w) const;
  79. private:
  80. #ifdef __MATPOS_IS_A_PTR
  81. inline WORD GetFaceIndex(int m, int f) const;
  82. #endif
  83. void HashAdd(WORD va, WORD vb, WORD f);
  84. WORD HashFind(WORD va, WORD vb);
  85. };
  86. /*************************************************************************
  87. Inlines
  88. *************************************************************************/
  89. inline WORD CGlMesh::FindVertexIndex(WORD w) const
  90. {
  91. WORD v = USHRT_MAX;
  92. WORD p = w;
  93. do
  94. {
  95. v = min(p,v);
  96. p = m_wedgelist[p];
  97. }
  98. while (p != w);
  99. return v;
  100. }
  101. #ifdef __MATPOS_IS_A_PTR
  102. inline WORD CGlMesh::GetFaceIndex(int m, int f) const
  103. {
  104. return (WORD) (&(m_matpos[m][f].w[0]) -
  105. &(m_matpos[0][0].w[0]))/(sizeof(GLface));
  106. }
  107. #endif
  108. #endif //_glmesh_h_