aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/irrlicht-1.8.1/include/SSharedMeshBuffer.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/others/irrlicht-1.8.1/include/SSharedMeshBuffer.h')
-rw-r--r--src/others/irrlicht-1.8.1/include/SSharedMeshBuffer.h242
1 files changed, 242 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/include/SSharedMeshBuffer.h b/src/others/irrlicht-1.8.1/include/SSharedMeshBuffer.h
new file mode 100644
index 0000000..b9ee07a
--- /dev/null
+++ b/src/others/irrlicht-1.8.1/include/SSharedMeshBuffer.h
@@ -0,0 +1,242 @@
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 __S_SHARED_MESH_BUFFER_H_INCLUDED__
6#define __S_SHARED_MESH_BUFFER_H_INCLUDED__
7
8#include "irrArray.h"
9#include "IMeshBuffer.h"
10
11namespace irr
12{
13namespace scene
14{
15 //! Implementation of the IMeshBuffer interface with shared vertex list
16 struct SSharedMeshBuffer : public IMeshBuffer
17 {
18 //! constructor
19 SSharedMeshBuffer() : IMeshBuffer(), Vertices(0), ChangedID_Vertex(1), ChangedID_Index(1), MappingHintVertex(EHM_NEVER), MappingHintIndex(EHM_NEVER)
20 {
21 #ifdef _DEBUG
22 setDebugName("SSharedMeshBuffer");
23 #endif
24 }
25
26 //! constructor
27 SSharedMeshBuffer(core::array<video::S3DVertex> *vertices) : IMeshBuffer(), Vertices(vertices)
28 {
29 #ifdef _DEBUG
30 setDebugName("SSharedMeshBuffer");
31 #endif
32 }
33
34 //! returns the material of this meshbuffer
35 virtual const video::SMaterial& getMaterial() const
36 {
37 return Material;
38 }
39
40 //! returns the material of this meshbuffer
41 virtual video::SMaterial& getMaterial()
42 {
43 return Material;
44 }
45
46 //! returns pointer to vertices
47 virtual const void* getVertices() const
48 {
49 if (Vertices)
50 return Vertices->const_pointer();
51 else
52 return 0;
53 }
54
55 //! returns pointer to vertices
56 virtual void* getVertices()
57 {
58 if (Vertices)
59 return Vertices->pointer();
60 else
61 return 0;
62 }
63
64 //! returns amount of vertices
65 virtual u32 getVertexCount() const
66 {
67 if (Vertices)
68 return Vertices->size();
69 else
70 return 0;
71 }
72
73 //! returns pointer to Indices
74 virtual const u16* getIndices() const
75 {
76 return Indices.const_pointer();
77 }
78
79 //! returns pointer to Indices
80 virtual u16* getIndices()
81 {
82 return Indices.pointer();
83 }
84
85 //! returns amount of indices
86 virtual u32 getIndexCount() const
87 {
88 return Indices.size();
89 }
90
91 //! Get type of index data which is stored in this meshbuffer.
92 virtual video::E_INDEX_TYPE getIndexType() const
93 {
94 return video::EIT_16BIT;
95 }
96
97 //! returns an axis aligned bounding box
98 virtual const core::aabbox3d<f32>& getBoundingBox() const
99 {
100 return BoundingBox;
101 }
102
103 //! set user axis aligned bounding box
104 virtual void setBoundingBox( const core::aabbox3df& box)
105 {
106 BoundingBox = box;
107 }
108
109 //! returns which type of vertex data is stored.
110 virtual video::E_VERTEX_TYPE getVertexType() const
111 {
112 return video::EVT_STANDARD;
113 }
114
115 //! recalculates the bounding box. should be called if the mesh changed.
116 virtual void recalculateBoundingBox()
117 {
118 if (!Vertices || Vertices->empty() || Indices.empty())
119 BoundingBox.reset(0,0,0);
120 else
121 {
122 BoundingBox.reset((*Vertices)[Indices[0]].Pos);
123 for (u32 i=1; i<Indices.size(); ++i)
124 BoundingBox.addInternalPoint((*Vertices)[Indices[i]].Pos);
125 }
126 }
127
128 //! returns position of vertex i
129 virtual const core::vector3df& getPosition(u32 i) const
130 {
131 _IRR_DEBUG_BREAK_IF(!Vertices);
132 return (*Vertices)[Indices[i]].Pos;
133 }
134
135 //! returns position of vertex i
136 virtual core::vector3df& getPosition(u32 i)
137 {
138 _IRR_DEBUG_BREAK_IF(!Vertices);
139 return (*Vertices)[Indices[i]].Pos;
140 }
141
142 //! returns normal of vertex i
143 virtual const core::vector3df& getNormal(u32 i) const
144 {
145 _IRR_DEBUG_BREAK_IF(!Vertices);
146 return (*Vertices)[Indices[i]].Normal;
147 }
148
149 //! returns normal of vertex i
150 virtual core::vector3df& getNormal(u32 i)
151 {
152 _IRR_DEBUG_BREAK_IF(!Vertices);
153 return (*Vertices)[Indices[i]].Normal;
154 }
155
156 //! returns texture coord of vertex i
157 virtual const core::vector2df& getTCoords(u32 i) const
158 {
159 _IRR_DEBUG_BREAK_IF(!Vertices);
160 return (*Vertices)[Indices[i]].TCoords;
161 }
162
163 //! returns texture coord of vertex i
164 virtual core::vector2df& getTCoords(u32 i)
165 {
166 _IRR_DEBUG_BREAK_IF(!Vertices);
167 return (*Vertices)[Indices[i]].TCoords;
168 }
169
170 //! append the vertices and indices to the current buffer
171 virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) {}
172
173 //! append the meshbuffer to the current buffer
174 virtual void append(const IMeshBuffer* const other) {}
175
176 //! get the current hardware mapping hint
177 virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const
178 {
179 return MappingHintVertex;
180 }
181
182 //! get the current hardware mapping hint
183 virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const
184 {
185 return MappingHintIndex;
186 }
187
188 //! set the hardware mapping hint, for driver
189 virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX )
190 {
191 if (buffer==EBT_VERTEX_AND_INDEX || buffer==EBT_VERTEX)
192 MappingHintVertex=NewMappingHint;
193 if (buffer==EBT_VERTEX_AND_INDEX || buffer==EBT_INDEX)
194 MappingHintIndex=NewMappingHint;
195 }
196
197 //! flags the mesh as changed, reloads hardware buffers
198 virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX)
199 {
200 if (buffer==EBT_VERTEX_AND_INDEX || buffer==EBT_VERTEX)
201 ++ChangedID_Vertex;
202 if (buffer==EBT_VERTEX_AND_INDEX || buffer==EBT_INDEX)
203 ++ChangedID_Index;
204 }
205
206 //! Get the currently used ID for identification of changes.
207 /** This shouldn't be used for anything outside the VideoDriver. */
208 virtual u32 getChangedID_Vertex() const {return ChangedID_Vertex;}
209
210 //! Get the currently used ID for identification of changes.
211 /** This shouldn't be used for anything outside the VideoDriver. */
212 virtual u32 getChangedID_Index() const {return ChangedID_Index;}
213
214 //! Material of this meshBuffer
215 video::SMaterial Material;
216
217 //! Shared Array of vertices
218 core::array<video::S3DVertex> *Vertices;
219
220 //! Array of Indices
221 core::array<u16> Indices;
222
223 //! ID used for hardware buffer management
224 u32 ChangedID_Vertex;
225
226 //! ID used for hardware buffer management
227 u32 ChangedID_Index;
228
229 //! Bounding box
230 core::aabbox3df BoundingBox;
231
232 //! hardware mapping hint
233 E_HARDWARE_MAPPING MappingHintVertex;
234 E_HARDWARE_MAPPING MappingHintIndex;
235 };
236
237
238} // end namespace scene
239} // end namespace irr
240
241#endif
242