Mesh.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. bool hasNormals() const;
  47. bool hasVertexColors() const;
  48. void computeBounds();
  49. Model* model;
  50. std::vector<Vertex> vertices;
  51. std::vector<MeshPart*> parts;
  52. BoundingVolume bounds;
  53. std::map<Vertex, unsigned int> vertexLookupTable;
  54. private:
  55. std::vector<VertexElement> _vertexFormat;
  56. };
  57. }
  58. #endif