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
5 #ifndef __I_DYNAMIC_MESH_BUFFER_H_INCLUDED__
\r
6 #define __I_DYNAMIC_MESH_BUFFER_H_INCLUDED__
\r
8 #include "IMeshBuffer.h"
\r
9 #include "IVertexBuffer.h"
\r
10 #include "IIndexBuffer.h"
\r
17 /** a dynamic meshBuffer */
\r
18 class IDynamicMeshBuffer : public IMeshBuffer
\r
21 virtual IVertexBuffer &getVertexBuffer() const =0;
\r
22 virtual IIndexBuffer &getIndexBuffer() const =0;
\r
24 virtual void setVertexBuffer(IVertexBuffer *vertexBuffer) =0;
\r
25 virtual void setIndexBuffer(IIndexBuffer *indexBuffer) =0;
\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
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
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
39 //! Set axis aligned bounding box
\r
40 /** \param box User defined axis aligned bounding box to use
\r
42 virtual void setBoundingBox(const core::aabbox3df& box) _IRR_OVERRIDE_ =0;
\r
44 //! Recalculates the bounding box. Should be called if the mesh changed.
\r
45 virtual void recalculateBoundingBox() _IRR_OVERRIDE_ =0;
\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
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
66 // ------------------- To be removed? ------------------- //
\r
68 //! get the current hardware mapping hint
\r
69 virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const _IRR_OVERRIDE_
\r
71 return getVertexBuffer().getHardwareMappingHint();
\r
74 //! get the current hardware mapping hint
\r
75 virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const _IRR_OVERRIDE_
\r
77 return getIndexBuffer().getHardwareMappingHint();
\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
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
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
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
98 virtual u32 getChangedID_Vertex() const _IRR_OVERRIDE_
\r
100 return getVertexBuffer().getChangedID();
\r
103 virtual u32 getChangedID_Index() const _IRR_OVERRIDE_
\r
105 return getIndexBuffer().getChangedID();
\r
108 // ------------------- Old interface ------------------- //
\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
114 return getVertexBuffer().getType();
\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
122 return getVertexBuffer().getData();
\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
130 return getVertexBuffer().getData();
\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
137 return getVertexBuffer().size();
\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
144 return getIndexBuffer().getType();
\r
147 //! Get access to indices.
\r
148 /** \return Pointer to indices array. */
\r
149 virtual const u16* getIndices() const _IRR_OVERRIDE_
\r
151 return (u16*)getIndexBuffer().getData();
\r
154 //! Get access to indices.
\r
155 /** \return Pointer to indices array. */
\r
156 virtual u16* getIndices() _IRR_OVERRIDE_
\r
158 return (u16*)getIndexBuffer().getData();
\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
165 return getIndexBuffer().size();
\r
168 //! returns position of vertex i
\r
169 virtual const core::vector3df& getPosition(u32 i) const _IRR_OVERRIDE_
\r
171 return getVertexBuffer()[i].Pos;
\r
174 //! returns position of vertex i
\r
175 virtual core::vector3df& getPosition(u32 i) _IRR_OVERRIDE_
\r
177 return getVertexBuffer()[i].Pos;
\r
180 //! returns texture coords of vertex i
\r
181 virtual const core::vector2df& getTCoords(u32 i) const _IRR_OVERRIDE_
\r
183 return getVertexBuffer()[i].TCoords;
\r
186 //! returns texture coords of vertex i
\r
187 virtual core::vector2df& getTCoords(u32 i) _IRR_OVERRIDE_
\r
189 return getVertexBuffer()[i].TCoords;
\r
192 //! returns normal of vertex i
\r
193 virtual const core::vector3df& getNormal(u32 i) const _IRR_OVERRIDE_
\r
195 return getVertexBuffer()[i].Normal;
\r
198 //! returns normal of vertex i
\r
199 virtual core::vector3df& getNormal(u32 i) _IRR_OVERRIDE_
\r
201 return getVertexBuffer()[i].Normal;
\r
206 } // end namespace scene
\r
207 } // end namespace irr
\r