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