Irrlicht 3D Engine
SSharedMeshBuffer.h
Go to the documentation of this file.
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 
11 namespace irr
12 {
13 namespace scene
14 {
17  {
20  {
21  #ifdef _DEBUG
22  setDebugName("SSharedMeshBuffer");
23  #endif
24  }
25 
28  {
29  #ifdef _DEBUG
30  setDebugName("SSharedMeshBuffer");
31  #endif
32  }
33 
35  virtual const video::SMaterial& getMaterial() const
36  {
37  return Material;
38  }
39 
42  {
43  return Material;
44  }
45 
47  virtual const void* getVertices() const
48  {
49  if (Vertices)
50  return Vertices->const_pointer();
51  else
52  return 0;
53  }
54 
56  virtual void* getVertices()
57  {
58  if (Vertices)
59  return Vertices->pointer();
60  else
61  return 0;
62  }
63 
65  virtual u32 getVertexCount() const
66  {
67  if (Vertices)
68  return Vertices->size();
69  else
70  return 0;
71  }
72 
74  virtual const u16* getIndices() const
75  {
76  return Indices.const_pointer();
77  }
78 
80  virtual u16* getIndices()
81  {
82  return Indices.pointer();
83  }
84 
86  virtual u32 getIndexCount() const
87  {
88  return Indices.size();
89  }
90 
93  {
94  return video::EIT_16BIT;
95  }
96 
98  virtual const core::aabbox3d<f32>& getBoundingBox() const
99  {
100  return BoundingBox;
101  }
102 
104  virtual void setBoundingBox( const core::aabbox3df& box)
105  {
106  BoundingBox = box;
107  }
108 
111  {
112  return video::EVT_STANDARD;
113  }
114 
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)
125  }
126  }
127 
129  virtual const core::vector3df& getPosition(u32 i) const
130  {
132  return (*Vertices)[Indices[i]].Pos;
133  }
134 
137  {
139  return (*Vertices)[Indices[i]].Pos;
140  }
141 
143  virtual const core::vector3df& getNormal(u32 i) const
144  {
146  return (*Vertices)[Indices[i]].Normal;
147  }
148 
151  {
153  return (*Vertices)[Indices[i]].Normal;
154  }
155 
157  virtual const core::vector2df& getTCoords(u32 i) const
158  {
160  return (*Vertices)[Indices[i]].TCoords;
161  }
162 
165  {
167  return (*Vertices)[Indices[i]].TCoords;
168  }
169 
171  virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) {}
172 
174  virtual void append(const IMeshBuffer* const other) {}
175 
178  {
179  return MappingHintVertex;
180  }
181 
184  {
185  return MappingHintIndex;
186  }
187 
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 
199  {
200  if (buffer==EBT_VERTEX_AND_INDEX || buffer==EBT_VERTEX)
202  if (buffer==EBT_VERTEX_AND_INDEX || buffer==EBT_INDEX)
203  ++ChangedID_Index;
204  }
205 
207 
208  virtual u32 getChangedID_Vertex() const {return ChangedID_Vertex;}
209 
211 
212  virtual u32 getChangedID_Index() const {return ChangedID_Index;}
213 
216 
219 
222 
225 
228 
231 
235  };
236 
237 
238 } // end namespace scene
239 } // end namespace irr
240 
241 #endif
242 
Change the vertex mapping.
virtual void recalculateBoundingBox()
recalculates the bounding box. should be called if the mesh changed.
virtual core::vector2df & getTCoords(u32 i)
returns texture coord of vertex i
virtual const core::vector3df & getPosition(u32 i) const
returns position of vertex i
virtual const void * getVertices() const
returns pointer to vertices
virtual video::SMaterial & getMaterial()
returns the material of this meshbuffer
virtual void * getVertices()
returns pointer to vertices
virtual video::E_VERTEX_TYPE getVertexType() const
returns which type of vertex data is stored.
const T * const_pointer() const
Gets a const pointer to the array.
Definition: irrArray.h:360
virtual void setHardwareMappingHint(E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX)
set the hardware mapping hint, for driver
virtual core::vector3df & getPosition(u32 i)
returns position of vertex i
core::array< video::S3DVertex > * Vertices
Shared Array of vertices.
video::SMaterial Material
Material of this meshBuffer.
Everything in the Irrlicht Engine can be found in this namespace.
Definition: aabbox3d.h:12
Don&#39;t store on the hardware.
virtual const core::aabbox3d< f32 > & getBoundingBox() const
returns an axis aligned bounding box
core::array< u16 > Indices
Array of Indices.
void reset(T x, T y, T z)
Resets the bounding box to a one-point box.
Definition: aabbox3d.h:50
bool empty() const
Check if array is empty.
Definition: irrArray.h:385
unsigned short u16
16 bit unsigned variable.
Definition: irrTypes.h:40
core::aabbox3df BoundingBox
Bounding box.
virtual void setBoundingBox(const core::aabbox3df &box)
set user axis aligned bounding box
virtual u16 * getIndices()
returns pointer to Indices
Struct for holding a mesh with a single material.
Definition: IMeshBuffer.h:39
virtual u32 getIndexCount() const
returns amount of indices
SSharedMeshBuffer(core::array< video::S3DVertex > *vertices)
constructor
unsigned int u32
32 bit unsigned variable.
Definition: irrTypes.h:58
Standard vertex type used by the Irrlicht engine, video::S3DVertex.
Definition: S3DVertex.h:21
Change both vertex and index mapping to the same value.
u32 size() const
Get number of occupied elements of the array.
Definition: irrArray.h:368
#define _IRR_DEBUG_BREAK_IF(_CONDITION_)
define a break macro for debugging.
Definition: irrTypes.h:178
virtual void append(const IMeshBuffer *const other)
append the meshbuffer to the current buffer
virtual const video::SMaterial & getMaterial() const
returns the material of this meshbuffer
virtual u32 getVertexCount() const
returns amount of vertices
virtual core::vector3df & getNormal(u32 i)
returns normal of vertex i
virtual const u16 * getIndices() const
returns pointer to Indices
virtual const core::vector2df & getTCoords(u32 i) const
returns texture coord of vertex i
virtual void append(const void *const vertices, u32 numVertices, const u16 *const indices, u32 numIndices)
append the vertices and indices to the current buffer
Change the index mapping.
void addInternalPoint(const vector3d< T > &p)
Adds a point to the bounding box.
Definition: aabbox3d.h:74
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const
get the current hardware mapping hint
virtual u32 getChangedID_Index() const
Get the currently used ID for identification of changes.
virtual u32 getChangedID_Vertex() const
Get the currently used ID for identification of changes.
Implementation of the IMeshBuffer interface with shared vertex list.
void setDebugName(const c8 *newName)
Sets the debug name of the object.
virtual video::E_INDEX_TYPE getIndexType() const
Get type of index data which is stored in this meshbuffer.
E_VERTEX_TYPE
Enumeration for all vertex types there are.
Definition: S3DVertex.h:18
u32 ChangedID_Index
ID used for hardware buffer management.
E_HARDWARE_MAPPING MappingHintVertex
hardware mapping hint
Struct for holding parameters for a material renderer.
Definition: SMaterial.h:226
T * pointer()
Gets a pointer to the array.
Definition: irrArray.h:352
virtual const core::vector3df & getNormal(u32 i) const
returns normal of vertex i
virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX)
flags the mesh as changed, reloads hardware buffers
u32 ChangedID_Vertex
ID used for hardware buffer management.
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const
get the current hardware mapping hint
E_HARDWARE_MAPPING MappingHintIndex