MODEL.H
Upload User: nthssl
Upload Date: 2022-04-05
Package Size: 25357k
Code Size: 2k
Category:

OpenCV

Development Platform:

Visual C++

  1. // Model.h: interface for the Model class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_MODEL_H__85D1D432_6220_4EB9_B6A2_12ECFC2B0E5D__INCLUDED_)
  5. #define AFX_MODEL_H__85D1D432_6220_4EB9_B6A2_12ECFC2B0E5D__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. #include "Texture.h"
  10. class Model  
  11. {
  12. public:
  13. // Mesh
  14. struct Mesh
  15. {
  16. int m_materialIndex;
  17. int m_numTriangles;
  18. int *m_pTriangleIndices;
  19. };
  20. // Material properties
  21. struct Material
  22. {
  23. GLfloat m_ambient[4], m_diffuse[4], m_specular[4], m_emissive[4];
  24. GLfloat m_shininess;
  25. GLuint m_texture;
  26. char *m_pTextureFilename;
  27. };
  28. // Triangle structure
  29. struct Triangle
  30. {
  31. GLfloat m_vertexNormals[3][3];
  32. GLfloat m_s[3], m_t[3];
  33. int m_vertexIndices[3];
  34. };
  35. // Vertex structure
  36. struct Vertex
  37. {
  38. char m_boneID; // for skeletal animation
  39. GLfloat m_location[3];
  40. };
  41. Texture m_texture;
  42. public:
  43. Model();
  44. virtual ~Model();
  45. /*
  46. Load the model data into the private variables. 
  47. filename Model filename
  48. */
  49. virtual bool loadModelData( const char *filename ) = 0;
  50. /*
  51. Draw the model.
  52. */
  53. void draw();
  54. /*
  55.     Make a display list from the model
  56.         */
  57. GLuint makeDisplayList();
  58. /*
  59. Called if OpenGL context was lost and we need to reload textures, display lists, etc.
  60. */
  61. void reloadTextures();
  62. protected:
  63. // Meshes used
  64. int m_numMeshes;
  65. Mesh *m_pMeshes;
  66. // Materials used
  67. int m_numMaterials;
  68. Material *m_pMaterials;
  69. // Triangles used
  70. int m_numTriangles;
  71. Triangle *m_pTriangles;
  72. // Vertices Used
  73. int m_numVertices;
  74. Vertex *m_pVertices;
  75. };
  76. #endif // !defined(AFX_MODEL_H__85D1D432_6220_4EB9_B6A2_12ECFC2B0E5D__INCLUDED_)