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 5 #ifndef __I_MESH_H_INCLUDED__ 6 #define __I_MESH_H_INCLUDED__ 7 8 #include "IReferenceCounted.h" 9 #include "SMaterial.h" 10 #include "EHardwareBufferFlags.h" 11 12 namespace irr 13 { 14 namespace scene 15 { 16 class IMeshBuffer; 17 18 //! Class which holds the geometry of an object. 19 /** An IMesh is nothing more than a collection of some mesh buffers 20 (IMeshBuffer). SMesh is a simple implementation of an IMesh. 21 A mesh is usually added to an IMeshSceneNode in order to be rendered. 22 */ 23 class IMesh : public virtual IReferenceCounted 24 { 25 public: 26 27 //! Get the amount of mesh buffers. 28 /** \return Amount of mesh buffers (IMeshBuffer) in this mesh. */ 29 virtual u32 getMeshBufferCount() const = 0; 30 31 //! Get pointer to a mesh buffer. 32 /** \param nr: Zero based index of the mesh buffer. The maximum value is 33 getMeshBufferCount() - 1; 34 \return Pointer to the mesh buffer or 0 if there is no such 35 mesh buffer. */ 36 virtual IMeshBuffer* getMeshBuffer(u32 nr) const = 0; 37 38 //! Get pointer to a mesh buffer which fits a material 39 /** \param material: material to search for 40 \return Pointer to the mesh buffer or 0 if there is no such 41 mesh buffer. */ 42 virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const = 0; 43 44 //! Get an axis aligned bounding box of the mesh. 45 /** \return Bounding box of this mesh. */ 46 virtual const core::aabbox3d<f32>& getBoundingBox() const = 0; 47 48 //! Set user-defined axis aligned bounding box 49 /** \param box New bounding box to use for the mesh. */ 50 virtual void setBoundingBox( const core::aabbox3df& box) = 0; 51 52 //! Sets a flag of all contained materials to a new value. 53 /** \param flag: Flag to set in all materials. 54 \param newvalue: New value to set in all materials. */ 55 virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) = 0; 56 57 //! Set the hardware mapping hint 58 /** This methods allows to define optimization hints for the 59 hardware. This enables, e.g., the use of hardware buffers on 60 pltforms that support this feature. This can lead to noticeable 61 performance gains. */ 62 virtual void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) = 0; 63 64 //! Flag the meshbuffer as changed, reloads hardware buffers 65 /** This method has to be called every time the vertices or 66 indices have changed. Otherwise, changes won't be updated 67 on the GPU in the next render cycle. */ 68 virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) = 0; 69 70 /** This is used in server without graphics to free all mesh vertex buffer if 71 possible, for example: kart, attachment and power model (because they are not used in physics). */ freeMeshVertexBuffer()72 virtual void freeMeshVertexBuffer() {} 73 }; 74 75 } // end namespace scene 76 } // end namespace irr 77 78 #endif 79 80