Mesh.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #ifndef MESH_H_
  2. #define MESH_H_
  3. #include "Base.h"
  4. #include "Object.h"
  5. #include "MeshPart.h"
  6. #include "VertexElement.h"
  7. #include "BoundingVolume.h"
  8. namespace gameplay
  9. {
  10. class Model;
  11. class Mesh : public Object
  12. {
  13. friend class Model;
  14. public:
  15. /**
  16. * Constructor.
  17. */
  18. Mesh(void);
  19. /**
  20. * Destructor.
  21. */
  22. virtual ~Mesh(void);
  23. virtual unsigned int getTypeId(void) const;
  24. virtual const char* getElementName(void) const;
  25. virtual void writeBinary(FILE* file);
  26. void writeBinaryVertices(FILE* file);
  27. virtual void writeText(FILE* file);
  28. void writeText(FILE* file, const Vertex& vertex);
  29. void writeText(FILE* file, const Vector3& v);
  30. void addMeshPart(MeshPart* part);
  31. void addMeshPart(Vertex* vertex);
  32. void addVetexAttribute(unsigned int usage, unsigned int count);
  33. size_t getVertexCount() const;
  34. const Vertex& getVertex(unsigned int index) const;
  35. size_t getVertexElementCount() const;
  36. const VertexElement& getVertexElement(unsigned int index) const;
  37. /**
  38. * Returns true if this MeshPart contains the given Vertex.
  39. */
  40. bool contains(const Vertex& vertex) const;
  41. /**
  42. * Adds a vertex to this MeshPart and returns the index.
  43. */
  44. unsigned int addVertex(const Vertex& vertex);
  45. unsigned int getVertexIndex(const Vertex& vertex);
  46. /**
  47. * Generates a heightmap with the given filename for this mesh.
  48. */
  49. void generateHeightmap(const char* filename);
  50. Model* model;
  51. std::vector<Vertex> vertices;
  52. std::vector<MeshPart*> parts;
  53. BoundingVolume bounds;
  54. std::map<Vertex, unsigned int> vertexLookupTable;
  55. private:
  56. void computeBounds();
  57. private:
  58. std::vector<VertexElement> _vertexFormat;
  59. };
  60. }
  61. #endif