Mesh.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. namespace gameplay
  8. {
  9. class Mesh : public Object
  10. {
  11. public:
  12. /**
  13. * Constructor.
  14. */
  15. Mesh(void);
  16. /**
  17. * Destructor.
  18. */
  19. virtual ~Mesh(void);
  20. virtual unsigned int getTypeId(void) const;
  21. virtual const char* getElementName(void) const;
  22. virtual void writeBinary(FILE* file);
  23. void writeBinaryVertices(FILE* file);
  24. virtual void writeText(FILE* file);
  25. void writeText(FILE* file, const Vertex& vertex);
  26. void writeText(FILE* file, const Vector3& v);
  27. void addMeshPart(MeshPart* part);
  28. void addMeshPart(Vertex* vertex);
  29. void addVetexAttribute(unsigned int usage, unsigned int count);
  30. size_t getVertexCount() const;
  31. /**
  32. * Returns true if this MeshPart contains the given Vertex.
  33. */
  34. bool contains(const Vertex& vertex) const;
  35. /**
  36. * Adds a vertex to this MeshPart and returns the index.
  37. */
  38. unsigned int addVertex(const Vertex& vertex);
  39. unsigned int getVertexIndex(const Vertex& vertex);
  40. std::vector<Vertex> vertices;
  41. std::vector<MeshPart*> parts;
  42. struct
  43. {
  44. Vector3 min;
  45. Vector3 max;
  46. Vector3 center;
  47. float radius;
  48. } bounds;
  49. std::map<Vertex, unsigned int> vertexLookupTable;
  50. private:
  51. void computeBounds();
  52. private:
  53. std::vector<VertexElement> _vertexFormats;
  54. };
  55. }
  56. #endif