IMesh.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. // Copyright (C) 2002-2012 Nikolaus Gebhardt
  2. // This file is part of the "Irrlicht Engine".
  3. // For conditions of distribution and use, see copyright notice in irrlicht.h
  4. #pragma once
  5. #include "IReferenceCounted.h"
  6. #include "SMaterial.h"
  7. #include "EHardwareBufferFlags.h"
  8. namespace irr
  9. {
  10. namespace scene
  11. {
  12. //! Possible types of meshes.
  13. // Note: Was previously only used in IAnimatedMesh so it still has the "animated" in the name.
  14. // But can now be used for all mesh-types as we need those casts as well.
  15. enum E_ANIMATED_MESH_TYPE
  16. {
  17. //! Unknown animated mesh type.
  18. EAMT_UNKNOWN = 0,
  19. //! Quake 2 MD2 model file
  20. EAMT_MD2,
  21. //! Quake 3 MD3 model file
  22. EAMT_MD3,
  23. //! Maya .obj static model
  24. EAMT_OBJ,
  25. //! Quake 3 .bsp static Map
  26. EAMT_BSP,
  27. //! 3D Studio .3ds file
  28. EAMT_3DS,
  29. //! My3D Mesh, the file format by Zhuck Dimitry
  30. EAMT_MY3D,
  31. //! Pulsar LMTools .lmts file. This Irrlicht loader was written by Jonas Petersen
  32. EAMT_LMTS,
  33. //! Cartography Shop .csm file. This loader was created by Saurav Mohapatra.
  34. EAMT_CSM,
  35. //! .oct file for Paul Nette's FSRad or from Murphy McCauley's Blender .oct exporter.
  36. /** The oct file format contains 3D geometry and lightmaps and
  37. can be loaded directly by Irrlicht */
  38. EAMT_OCT,
  39. //! Halflife MDL model file
  40. EAMT_MDL_HALFLIFE,
  41. //! generic skinned mesh
  42. EAMT_SKINNED,
  43. //! generic non-animated mesh
  44. EAMT_STATIC
  45. };
  46. class IMeshBuffer;
  47. //! Class which holds the geometry of an object.
  48. /** An IMesh is nothing more than a collection of some mesh buffers
  49. (IMeshBuffer). SMesh is a simple implementation of an IMesh.
  50. A mesh is usually added to an IMeshSceneNode in order to be rendered.
  51. */
  52. class IMesh : public virtual IReferenceCounted
  53. {
  54. public:
  55. //! Get the amount of mesh buffers.
  56. /** \return Amount of mesh buffers (IMeshBuffer) in this mesh. */
  57. virtual u32 getMeshBufferCount() const = 0;
  58. //! Get pointer to a mesh buffer.
  59. /** \param nr: Zero based index of the mesh buffer. The maximum value is
  60. getMeshBufferCount() - 1;
  61. \return Pointer to the mesh buffer or 0 if there is no such
  62. mesh buffer. */
  63. virtual IMeshBuffer *getMeshBuffer(u32 nr) const = 0;
  64. //! Get pointer to a mesh buffer which fits a material
  65. /** \param material: material to search for
  66. \return Pointer to the mesh buffer or 0 if there is no such
  67. mesh buffer. */
  68. virtual IMeshBuffer *getMeshBuffer(const video::SMaterial &material) const = 0;
  69. //! Minetest binds textures (node tiles, object textures) to models.
  70. // glTF allows multiple primitives (mesh buffers) to reference the same texture.
  71. // This is reflected here: This function gets the texture slot for a mesh buffer.
  72. /** \param meshbufNr: Zero based index of the mesh buffer. The maximum value is
  73. getMeshBufferCount() - 1;
  74. \return number of texture slot to bind to the given mesh buffer */
  75. virtual u32 getTextureSlot(u32 meshbufNr) const
  76. {
  77. return meshbufNr;
  78. }
  79. //! Get an axis aligned bounding box of the mesh.
  80. /** \return Bounding box of this mesh. */
  81. virtual const core::aabbox3d<f32> &getBoundingBox() const = 0;
  82. //! Set user-defined axis aligned bounding box
  83. /** \param box New bounding box to use for the mesh. */
  84. virtual void setBoundingBox(const core::aabbox3df &box) = 0;
  85. //! Set the hardware mapping hint
  86. /** This methods allows to define optimization hints for the
  87. hardware. This enables, e.g., the use of hardware buffers on
  88. platforms that support this feature. This can lead to noticeable
  89. performance gains. */
  90. virtual void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer = EBT_VERTEX_AND_INDEX) = 0;
  91. //! Flag the meshbuffer as changed, reloads hardware buffers
  92. /** This method has to be called every time the vertices or
  93. indices have changed. Otherwise, changes won't be updated
  94. on the GPU in the next render cycle. */
  95. virtual void setDirty(E_BUFFER_TYPE buffer = EBT_VERTEX_AND_INDEX) = 0;
  96. //! Returns the type of the meshes.
  97. /** This is useful for making a safe downcast. For example,
  98. if getMeshType() returns EAMT_MD2 it's safe to cast the
  99. IMesh to IAnimatedMeshMD2.
  100. Note: It's no longer just about animated meshes, that name has just historical reasons.
  101. \returns Type of the mesh */
  102. virtual E_ANIMATED_MESH_TYPE getMeshType() const
  103. {
  104. return EAMT_STATIC;
  105. }
  106. };
  107. } // end namespace scene
  108. } // end namespace irr