MeshPart.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #ifndef MESHPART_H_
  2. #define MESHPART_H_
  3. #include "Mesh.h"
  4. namespace gameplay
  5. {
  6. /**
  7. * Defines a part of a mesh describing the way the
  8. * mesh's vertices are connected together.
  9. */
  10. class MeshPart
  11. {
  12. friend class Mesh;
  13. friend class Model;
  14. public:
  15. /**
  16. * Destructor.
  17. */
  18. ~MeshPart();
  19. /**
  20. * Gets the part index in mesh.
  21. *
  22. * @return The part offset index.
  23. */
  24. unsigned int getMeshIndex() const;
  25. /**
  26. * Gets the type of primitive to define how the indices are connected.
  27. *
  28. * @return The type of primitive.
  29. */
  30. Mesh::PrimitiveType getPrimitiveType() const;
  31. /**
  32. * Gets the number of indices in the part.
  33. *
  34. * @return The number of indices in the part.
  35. */
  36. unsigned int getIndexCount() const;
  37. /**
  38. * Returns the format of the part indices.
  39. *
  40. * @return The part index format.
  41. */
  42. Mesh::IndexFormat getIndexFormat() const;
  43. /**
  44. * Returns a handle to the index buffer for the mesh part.
  45. *
  46. * @return The index buffer object handle.
  47. */
  48. IndexBufferHandle getIndexBuffer() const;
  49. /**
  50. * Determines if the indices are dynamic.
  51. *
  52. * @return true if the part is dynamic; false otherwise.
  53. */
  54. bool isDynamic() const;
  55. /**
  56. * Sets the specified index data into the mapped index buffer.
  57. *
  58. * @param indexData The index data to be set.
  59. * @param indexStart The index to start from.
  60. * @param indexCount The number of indices to be set.
  61. */
  62. void setIndexData(void* indexData, unsigned int indexStart, unsigned int indexCount);
  63. private:
  64. /**
  65. * Constructor.
  66. */
  67. MeshPart();
  68. /**
  69. * Constructor.
  70. */
  71. MeshPart(const MeshPart& copy);
  72. /**
  73. * Creates a mesh part for the specified mesh.
  74. *
  75. * @param mesh The mesh that this is part of.
  76. * @param meshIndex The index of the part within the mesh.
  77. * @param primitiveType The primitive type.
  78. * @param indexFormat The index format.
  79. * @param indexCount The number of indices.
  80. * @param dynamic true if the part if dynamic; false otherwise.
  81. */
  82. static MeshPart* create(Mesh* mesh, unsigned int meshIndex, Mesh::PrimitiveType primitiveType, Mesh::IndexFormat indexFormat, unsigned int indexCount, bool dynamic = false);
  83. Mesh* _mesh;
  84. unsigned int _meshIndex;
  85. Mesh::PrimitiveType _primitiveType;
  86. Mesh::IndexFormat _indexFormat;
  87. unsigned int _indexCount;
  88. IndexBufferHandle _indexBuffer;
  89. bool _dynamic;
  90. };
  91. }
  92. #endif