MeshPart.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. * @script{ignore}
  62. */
  63. void setIndexData(const void* indexData, unsigned int indexStart, unsigned int indexCount);
  64. private:
  65. /**
  66. * Constructor.
  67. */
  68. MeshPart();
  69. /**
  70. * Constructor.
  71. */
  72. MeshPart(const MeshPart& copy);
  73. /**
  74. * Creates a mesh part for the specified mesh.
  75. *
  76. * @param mesh The mesh that this is part of.
  77. * @param meshIndex The index of the part within the mesh.
  78. * @param primitiveType The primitive type.
  79. * @param indexFormat The index format.
  80. * @param indexCount The number of indices.
  81. * @param dynamic true if the part if dynamic; false otherwise.
  82. */
  83. static MeshPart* create(Mesh* mesh, unsigned int meshIndex, Mesh::PrimitiveType primitiveType, Mesh::IndexFormat indexFormat, unsigned int indexCount, bool dynamic = false);
  84. Mesh* _mesh;
  85. unsigned int _meshIndex;
  86. Mesh::PrimitiveType _primitiveType;
  87. Mesh::IndexFormat _indexFormat;
  88. unsigned int _indexCount;
  89. IndexBufferHandle _indexBuffer;
  90. bool _dynamic;
  91. };
  92. }
  93. #endif