IMesh.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. //! Get an axis aligned bounding box of the mesh.
  70. /** \return Bounding box of this mesh. */
  71. virtual const core::aabbox3d<f32> &getBoundingBox() const = 0;
  72. //! Set user-defined axis aligned bounding box
  73. /** \param box New bounding box to use for the mesh. */
  74. virtual void setBoundingBox(const core::aabbox3df &box) = 0;
  75. //! Set the hardware mapping hint
  76. /** This methods allows to define optimization hints for the
  77. hardware. This enables, e.g., the use of hardware buffers on
  78. platforms that support this feature. This can lead to noticeable
  79. performance gains. */
  80. virtual void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer = EBT_VERTEX_AND_INDEX) = 0;
  81. //! Flag the meshbuffer as changed, reloads hardware buffers
  82. /** This method has to be called every time the vertices or
  83. indices have changed. Otherwise, changes won't be updated
  84. on the GPU in the next render cycle. */
  85. virtual void setDirty(E_BUFFER_TYPE buffer = EBT_VERTEX_AND_INDEX) = 0;
  86. //! Returns the type of the meshes.
  87. /** This is useful for making a safe downcast. For example,
  88. if getMeshType() returns EAMT_MD2 it's safe to cast the
  89. IMesh to IAnimatedMeshMD2.
  90. Note: It's no longer just about animated meshes, that name has just historical reasons.
  91. \returns Type of the mesh */
  92. virtual E_ANIMATED_MESH_TYPE getMeshType() const
  93. {
  94. return EAMT_STATIC;
  95. }
  96. };
  97. } // end namespace scene
  98. } // end namespace irr