1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
\r
2 // This file is part of the "Irrlicht Engine".
\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
\r
5 #ifndef __I_MESH_H_INCLUDED__
\r
6 #define __I_MESH_H_INCLUDED__
\r
8 #include "IReferenceCounted.h"
\r
9 #include "SMaterial.h"
\r
10 #include "EHardwareBufferFlags.h"
\r
16 //! Possible types of meshes.
\r
17 // Note: Was previously only used in IAnimatedMesh so it still has the "animated" in the name.
\r
18 // But can now be used for all mesh-types as we need those casts as well.
\r
19 enum E_ANIMATED_MESH_TYPE
\r
21 //! Unknown animated mesh type.
\r
24 //! Quake 2 MD2 model file
\r
27 //! Quake 3 MD3 model file
\r
30 //! Maya .obj static model
\r
33 //! Quake 3 .bsp static Map
\r
36 //! 3D Studio .3ds file
\r
39 //! My3D Mesh, the file format by Zhuck Dimitry
\r
42 //! Pulsar LMTools .lmts file. This Irrlicht loader was written by Jonas Petersen
\r
45 //! Cartography Shop .csm file. This loader was created by Saurav Mohapatra.
\r
48 //! .oct file for Paul Nette's FSRad or from Murphy McCauley's Blender .oct exporter.
\r
49 /** The oct file format contains 3D geometry and lightmaps and
\r
50 can be loaded directly by Irrlicht */
\r
53 //! Halflife MDL model file
\r
56 //! generic skinned mesh
\r
59 //! generic non-animated mesh
\r
66 //! Class which holds the geometry of an object.
\r
67 /** An IMesh is nothing more than a collection of some mesh buffers
\r
68 (IMeshBuffer). SMesh is a simple implementation of an IMesh.
\r
69 A mesh is usually added to an IMeshSceneNode in order to be rendered.
\r
71 class IMesh : public virtual IReferenceCounted
\r
75 //! Get the amount of mesh buffers.
\r
76 /** \return Amount of mesh buffers (IMeshBuffer) in this mesh. */
\r
77 virtual u32 getMeshBufferCount() const = 0;
\r
79 //! Get pointer to a mesh buffer.
\r
80 /** \param nr: Zero based index of the mesh buffer. The maximum value is
\r
81 getMeshBufferCount() - 1;
\r
82 \return Pointer to the mesh buffer or 0 if there is no such
\r
84 virtual IMeshBuffer* getMeshBuffer(u32 nr) const = 0;
\r
86 //! Get pointer to a mesh buffer which fits a material
\r
87 /** \param material: material to search for
\r
88 \return Pointer to the mesh buffer or 0 if there is no such
\r
90 virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const = 0;
\r
92 //! Get an axis aligned bounding box of the mesh.
\r
93 /** \return Bounding box of this mesh. */
\r
94 virtual const core::aabbox3d<f32>& getBoundingBox() const = 0;
\r
96 //! Set user-defined axis aligned bounding box
\r
97 /** \param box New bounding box to use for the mesh. */
\r
98 virtual void setBoundingBox( const core::aabbox3df& box) = 0;
\r
100 //! Sets a flag of all contained materials to a new value.
\r
101 /** \param flag: Flag to set in all materials.
\r
102 \param newvalue: New value to set in all materials. */
\r
103 virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) = 0;
\r
105 //! Set the hardware mapping hint
\r
106 /** This methods allows to define optimization hints for the
\r
107 hardware. This enables, e.g., the use of hardware buffers on
\r
108 platforms that support this feature. This can lead to noticeable
\r
109 performance gains. */
\r
110 virtual void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) = 0;
\r
112 //! Flag the meshbuffer as changed, reloads hardware buffers
\r
113 /** This method has to be called every time the vertices or
\r
114 indices have changed. Otherwise, changes won't be updated
\r
115 on the GPU in the next render cycle. */
\r
116 virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) = 0;
\r
118 //! Returns the type of the meshes.
\r
119 /** This is useful for making a safe downcast. For example,
\r
120 if getMeshType() returns EAMT_MD2 it's safe to cast the
\r
121 IMesh to IAnimatedMeshMD2.
\r
122 Note: It's no longer just about animated meshes, that name has just historical reasons.
\r
123 \returns Type of the mesh */
\r
124 virtual E_ANIMATED_MESH_TYPE getMeshType() const
\r
126 return EAMT_STATIC;
\r
130 } // end namespace scene
\r
131 } // end namespace irr
\r