]> git.lizzy.rs Git - irrlicht.git/blob - include/IMesh.h
Support both OpenGL3 and GLES2 on SDL2
[irrlicht.git] / include / IMesh.h
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
4 \r
5 #ifndef __I_MESH_H_INCLUDED__\r
6 #define __I_MESH_H_INCLUDED__\r
7 \r
8 #include "IReferenceCounted.h"\r
9 #include "SMaterial.h"\r
10 #include "EHardwareBufferFlags.h"\r
11 \r
12 namespace irr\r
13 {\r
14 namespace scene\r
15 {\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
20         {\r
21                 //! Unknown animated mesh type.\r
22                 EAMT_UNKNOWN = 0,\r
23 \r
24                 //! Quake 2 MD2 model file\r
25                 EAMT_MD2,\r
26 \r
27                 //! Quake 3 MD3 model file\r
28                 EAMT_MD3,\r
29 \r
30                 //! Maya .obj static model\r
31                 EAMT_OBJ,\r
32 \r
33                 //! Quake 3 .bsp static Map\r
34                 EAMT_BSP,\r
35 \r
36                 //! 3D Studio .3ds file\r
37                 EAMT_3DS,\r
38 \r
39                 //! My3D Mesh, the file format by Zhuck Dimitry\r
40                 EAMT_MY3D,\r
41 \r
42                 //! Pulsar LMTools .lmts file. This Irrlicht loader was written by Jonas Petersen\r
43                 EAMT_LMTS,\r
44 \r
45                 //! Cartography Shop .csm file. This loader was created by Saurav Mohapatra.\r
46                 EAMT_CSM,\r
47 \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
51                 EAMT_OCT,\r
52 \r
53                 //! Halflife MDL model file\r
54                 EAMT_MDL_HALFLIFE,\r
55 \r
56                 //! generic skinned mesh\r
57                 EAMT_SKINNED,\r
58 \r
59                 //! generic non-animated mesh\r
60                 EAMT_STATIC\r
61         };\r
62 \r
63 \r
64         class IMeshBuffer;\r
65 \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
70         */\r
71         class IMesh : public virtual IReferenceCounted\r
72         {\r
73         public:\r
74 \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
78 \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
83                 mesh buffer. */\r
84                 virtual IMeshBuffer* getMeshBuffer(u32 nr) const = 0;\r
85 \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
89                 mesh buffer. */\r
90                 virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const = 0;\r
91 \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
95 \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
99 \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
104 \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
111 \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
117 \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
125                 {\r
126                         return EAMT_STATIC;\r
127                 }\r
128         };\r
129 \r
130 } // end namespace scene\r
131 } // end namespace irr\r
132 \r
133 #endif\r
134 \r