]> git.lizzy.rs Git - irrlicht.git/blob - include/IDynamicMeshBuffer.h
Add a unified cross platform OpenGL core profile binding (#52)
[irrlicht.git] / include / IDynamicMeshBuffer.h
1 // Copyright (C) 2008-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_DYNAMIC_MESH_BUFFER_H_INCLUDED__\r
6 #define __I_DYNAMIC_MESH_BUFFER_H_INCLUDED__\r
7 \r
8 #include "IMeshBuffer.h"\r
9 #include "IVertexBuffer.h"\r
10 #include "IIndexBuffer.h"\r
11 \r
12 namespace irr\r
13 {\r
14 namespace scene\r
15 {\r
16 \r
17         /** a dynamic meshBuffer */\r
18         class IDynamicMeshBuffer : public IMeshBuffer\r
19         {\r
20         public:\r
21                 virtual IVertexBuffer &getVertexBuffer() const =0;\r
22                 virtual IIndexBuffer &getIndexBuffer() const =0;\r
23 \r
24                 virtual void setVertexBuffer(IVertexBuffer *vertexBuffer) =0;\r
25                 virtual void setIndexBuffer(IIndexBuffer *indexBuffer) =0;\r
26 \r
27                 //! Get the material of this meshbuffer\r
28                 /** \return Material of this buffer. */\r
29                 virtual video::SMaterial& getMaterial() _IRR_OVERRIDE_ =0;\r
30 \r
31                 //! Get the material of this meshbuffer\r
32                 /** \return Material of this buffer. */\r
33                 virtual const video::SMaterial& getMaterial() const _IRR_OVERRIDE_ =0;\r
34 \r
35                 //! Get the axis aligned bounding box of this meshbuffer.\r
36                 /** \return Axis aligned bounding box of this buffer. */\r
37                 virtual const core::aabbox3df& getBoundingBox() const _IRR_OVERRIDE_ =0;\r
38 \r
39                 //! Set axis aligned bounding box\r
40                 /** \param box User defined axis aligned bounding box to use\r
41                 for this buffer. */\r
42                 virtual void setBoundingBox(const core::aabbox3df& box) _IRR_OVERRIDE_ =0;\r
43 \r
44                 //! Recalculates the bounding box. Should be called if the mesh changed.\r
45                 virtual void recalculateBoundingBox() _IRR_OVERRIDE_ =0;\r
46 \r
47                 //! Append the vertices and indices to the current buffer\r
48                 /** Only works for compatible vertex types.\r
49                 \param vertices Pointer to a vertex array.\r
50                 \param numVertices Number of vertices in the array.\r
51                 \param indices Pointer to index array.\r
52                 \param numIndices Number of indices in array. */\r
53                 virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) _IRR_OVERRIDE_\r
54                 {\r
55 \r
56                 }\r
57 \r
58                 //! Append the meshbuffer to the current buffer\r
59                 /** Only works for compatible vertex types\r
60                 \param other Buffer to append to this one. */\r
61                 virtual void append(const IMeshBuffer* const other) _IRR_OVERRIDE_\r
62                 {\r
63 \r
64                 }\r
65 \r
66                 // ------------------- To be removed? -------------------  //\r
67 \r
68                 //! get the current hardware mapping hint\r
69                 virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const _IRR_OVERRIDE_\r
70                 {\r
71                         return getVertexBuffer().getHardwareMappingHint();\r
72                 }\r
73 \r
74                 //! get the current hardware mapping hint\r
75                 virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const _IRR_OVERRIDE_\r
76                 {\r
77                         return getIndexBuffer().getHardwareMappingHint();\r
78                 }\r
79 \r
80                 //! set the hardware mapping hint, for driver\r
81                 virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX ) _IRR_OVERRIDE_\r
82                 {\r
83                         if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_VERTEX)\r
84                                 getVertexBuffer().setHardwareMappingHint(NewMappingHint);\r
85                         if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_INDEX)\r
86                                 getIndexBuffer().setHardwareMappingHint(NewMappingHint);\r
87                 }\r
88 \r
89                 //! flags the mesh as changed, reloads hardware buffers\r
90                 virtual void setDirty(E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX) _IRR_OVERRIDE_\r
91                 {\r
92                         if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_VERTEX)\r
93                                 getVertexBuffer().setDirty();\r
94                         if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_INDEX)\r
95                                 getIndexBuffer().setDirty();\r
96                 }\r
97 \r
98                 virtual u32 getChangedID_Vertex() const _IRR_OVERRIDE_\r
99                 {\r
100                         return getVertexBuffer().getChangedID();\r
101                 }\r
102 \r
103                 virtual u32 getChangedID_Index() const _IRR_OVERRIDE_\r
104                 {\r
105                         return getIndexBuffer().getChangedID();\r
106                 }\r
107 \r
108                 // ------------------- Old interface -------------------  //\r
109 \r
110                 //! Get type of vertex data which is stored in this meshbuffer.\r
111                 /** \return Vertex type of this buffer. */\r
112                 virtual video::E_VERTEX_TYPE getVertexType() const _IRR_OVERRIDE_\r
113                 {\r
114                         return getVertexBuffer().getType();\r
115                 }\r
116 \r
117                 //! Get access to vertex data. The data is an array of vertices.\r
118                 /** Which vertex type is used can be determined by getVertexType().\r
119                 \return Pointer to array of vertices. */\r
120                 virtual const void* getVertices() const _IRR_OVERRIDE_\r
121                 {\r
122                         return getVertexBuffer().getData();\r
123                 }\r
124 \r
125                 //! Get access to vertex data. The data is an array of vertices.\r
126                 /** Which vertex type is used can be determined by getVertexType().\r
127                 \return Pointer to array of vertices. */\r
128                 virtual void* getVertices() _IRR_OVERRIDE_\r
129                 {\r
130                         return getVertexBuffer().getData();\r
131                 }\r
132 \r
133                 //! Get amount of vertices in meshbuffer.\r
134                 /** \return Number of vertices in this buffer. */\r
135                 virtual u32 getVertexCount() const _IRR_OVERRIDE_\r
136                 {\r
137                         return getVertexBuffer().size();\r
138                 }\r
139 \r
140                 //! Get type of index data which is stored in this meshbuffer.\r
141                 /** \return Index type of this buffer. */\r
142                 virtual video::E_INDEX_TYPE getIndexType() const _IRR_OVERRIDE_\r
143                 {\r
144                         return getIndexBuffer().getType();\r
145                 }\r
146 \r
147                 //! Get access to indices.\r
148                 /** \return Pointer to indices array. */\r
149                 virtual const u16* getIndices() const _IRR_OVERRIDE_\r
150                 {\r
151                         return (u16*)getIndexBuffer().getData();\r
152                 }\r
153 \r
154                 //! Get access to indices.\r
155                 /** \return Pointer to indices array. */\r
156                 virtual u16* getIndices() _IRR_OVERRIDE_\r
157                 {\r
158                         return (u16*)getIndexBuffer().getData();\r
159                 }\r
160 \r
161                 //! Get amount of indices in this meshbuffer.\r
162                 /** \return Number of indices in this buffer. */\r
163                 virtual u32 getIndexCount() const _IRR_OVERRIDE_\r
164                 { \r
165                         return getIndexBuffer().size();\r
166                 }\r
167 \r
168                 //! returns position of vertex i\r
169                 virtual const core::vector3df& getPosition(u32 i) const _IRR_OVERRIDE_\r
170                 {\r
171                         return getVertexBuffer()[i].Pos;\r
172                 }\r
173 \r
174                 //! returns position of vertex i\r
175                 virtual core::vector3df& getPosition(u32 i) _IRR_OVERRIDE_\r
176                 {\r
177                         return getVertexBuffer()[i].Pos;\r
178                 }\r
179 \r
180                 //! returns texture coords of vertex i\r
181                 virtual const core::vector2df& getTCoords(u32 i) const _IRR_OVERRIDE_\r
182                 {\r
183                         return getVertexBuffer()[i].TCoords;\r
184                 }\r
185 \r
186                 //! returns texture coords of vertex i\r
187                 virtual core::vector2df& getTCoords(u32 i) _IRR_OVERRIDE_\r
188                 {\r
189                         return getVertexBuffer()[i].TCoords;\r
190                 }\r
191 \r
192                 //! returns normal of vertex i\r
193                 virtual const core::vector3df& getNormal(u32 i) const _IRR_OVERRIDE_\r
194                 {\r
195                         return getVertexBuffer()[i].Normal;\r
196                 }\r
197 \r
198                 //! returns normal of vertex i\r
199                 virtual core::vector3df& getNormal(u32 i) _IRR_OVERRIDE_\r
200                 {\r
201                         return getVertexBuffer()[i].Normal;\r
202                 }\r
203         };\r
204 \r
205 \r
206 } // end namespace scene\r
207 } // end namespace irr\r
208 \r
209 #endif\r
210 \r
211 \r