arsa  2.7
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  : IMeshBuffer()
24  {
25  #ifdef _DEBUG
26  setDebugName("SSharedMeshBuffer");
27  #endif
28  }
29 
32  {
33  #ifdef _DEBUG
34  setDebugName("SSharedMeshBuffer");
35  #endif
36  }
37 
40  {
41  return Material;
42  }
43 
46  {
47  return Material;
48  }
49 
51  virtual const void* getVertices() const _IRR_OVERRIDE_
52  {
53  if (Vertices)
54  return Vertices->const_pointer();
55  else
56  return 0;
57  }
58 
60  virtual void* getVertices() _IRR_OVERRIDE_
61  {
62  if (Vertices)
63  return Vertices->pointer();
64  else
65  return 0;
66  }
67 
70  {
71  if (Vertices)
72  return Vertices->size();
73  else
74  return 0;
75  }
76 
79  {
80  return Indices.const_pointer();
81  }
82 
85  {
86  return Indices.pointer();
87  }
88 
91  {
92  return Indices.size();
93  }
94 
97  {
98  return video::EIT_16BIT;
99  }
100 
103  {
104  return BoundingBox;
105  }
106 
109  {
110  BoundingBox = box;
111  }
112 
115  {
116  return video::EVT_STANDARD;
117  }
118 
121  {
122  if (!Vertices || Vertices->empty() || Indices.empty())
123  BoundingBox.reset(0,0,0);
124  else
125  {
126  BoundingBox.reset((*Vertices)[Indices[0]].Pos);
127  for (u32 i=1; i<Indices.size(); ++i)
129  }
130  }
131 
134  {
136  return (*Vertices)[Indices[i]].Pos;
137  }
138 
141  {
143  return (*Vertices)[Indices[i]].Pos;
144  }
145 
147  virtual const core::vector3df& getNormal(u32 i) const _IRR_OVERRIDE_
148  {
150  return (*Vertices)[Indices[i]].Normal;
151  }
152 
155  {
157  return (*Vertices)[Indices[i]].Normal;
158  }
159 
162  {
164  return (*Vertices)[Indices[i]].TCoords;
165  }
166 
169  {
171  return (*Vertices)[Indices[i]].TCoords;
172  }
173 
175  virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) _IRR_OVERRIDE_ {}
177  virtual void append(const IMeshBuffer* const other) _IRR_OVERRIDE_ {}
178 
181  {
182  return MappingHintVertex;
183  }
184 
187  {
188  return MappingHintIndex;
189  }
190 
193  {
195  MappingHintVertex=NewMappingHint;
197  MappingHintIndex=NewMappingHint;
198  }
199 
202  {
204  }
205 
208  {
209  return PrimitiveType;
210  }
211 
214  {
218  ++ChangedID_Index;
219  }
220 
222 
224 
226 
228 
231 
234 
237 
240 
243 
246 
250 
253  };
254 
255 
256 } // end namespace scene
257 } // end namespace irr
258 
259 #endif
260 
Change the vertex mapping.
virtual core::vector3df & getNormal(u32 i) _IRR_OVERRIDE_
returns normal of vertex i
virtual const core::vector2df & getTCoords(u32 i) const _IRR_OVERRIDE_
returns texture coord of vertex i
virtual void recalculateBoundingBox() _IRR_OVERRIDE_
recalculates the bounding box. should be called if the mesh changed.
E_PRIMITIVE_TYPE
Enumeration for all primitive types there are.
virtual void append(const IMeshBuffer *const other) _IRR_OVERRIDE_
append the meshbuffer to the current buffer
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const _IRR_OVERRIDE_
get the current hardware mapping hint
virtual u16 * getIndices() _IRR_OVERRIDE_
returns pointer to indices
virtual void setBoundingBox(const core::aabbox3df &box) _IRR_OVERRIDE_
set user axis aligned bounding box
virtual const core::aabbox3d< f32 > & getBoundingBox() const _IRR_OVERRIDE_
returns an axis aligned bounding box
GLuint GLuint GLsizei GLenum const GLvoid * indices
Definition: SDL_opengl.h:1571
const T * const_pointer() const
Gets a const pointer to the array.
Definition: irrArray.h:356
core::array< video::S3DVertex > * Vertices
Shared Array of vertices.
virtual const video::SMaterial & getMaterial() const _IRR_OVERRIDE_
returns the material of this meshbuffer
video::SMaterial Material
Material of this meshBuffer.
virtual const void * getVertices() const _IRR_OVERRIDE_
returns pointer to vertices
virtual void setPrimitiveType(E_PRIMITIVE_TYPE type) _IRR_OVERRIDE_
Describe what kind of primitive geometry is used by the meshbuffer.
Everything in the Irrlicht Engine can be found in this namespace.
Definition: CARSADPad.h:6
Don't store on the hardware.
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
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const _IRR_OVERRIDE_
get the current hardware mapping hint
virtual video::SMaterial & getMaterial() _IRR_OVERRIDE_
returns the material of this meshbuffer
bool empty() const
Check if array is empty.
Definition: irrArray.h:381
unsigned short u16
16 bit unsigned variable.
Definition: irrTypes.h:44
core::aabbox3df BoundingBox
Bounding box.
virtual core::vector3df & getPosition(u32 i) _IRR_OVERRIDE_
returns position of vertex i
virtual core::vector2df & getTCoords(u32 i) _IRR_OVERRIDE_
returns texture coord of vertex i
Struct for holding a mesh with a single material.
Definition: IMeshBuffer.h:39
SSharedMeshBuffer(core::array< video::S3DVertex > *vertices)
constructor
unsigned int u32
32 bit unsigned variable.
Definition: irrTypes.h:62
Standard vertex type used by the Irrlicht engine, video::S3DVertex.
Definition: S3DVertex.h:21
Explicitly set all vertices for each triangle.
Change both vertex and index mapping to the same value.
u32 size() const
Get number of occupied elements of the array.
Definition: irrArray.h:364
virtual void setHardwareMappingHint(E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) _IRR_OVERRIDE_
set the hardware mapping hint, for driver
#define _IRR_DEBUG_BREAK_IF(_CONDITION_)
define a break macro for debugging.
Definition: irrTypes.h:185
virtual const core::vector3df & getNormal(u32 i) const _IRR_OVERRIDE_
returns normal of vertex i
virtual E_PRIMITIVE_TYPE getPrimitiveType() const _IRR_OVERRIDE_
Get the kind of primitive geometry which is used by the meshbuffer.
virtual u32 getChangedID_Vertex() const _IRR_OVERRIDE_
Get the currently used ID for identification of changes.
virtual const u16 * getIndices() const _IRR_OVERRIDE_
returns pointer to indices
Change the index mapping.
void addInternalPoint(const vector3d< T > &p)
Adds a point to the bounding box.
Definition: aabbox3d.h:74
Self reallocating template array (like stl vector) with additional features.
Definition: irrArray.h:22
#define _IRR_OVERRIDE_
Defines an override macro, to protect virtual functions from typos and other mismatches.
Definition: irrTypes.h:216
E_PRIMITIVE_TYPE PrimitiveType
Primitive type used for rendering (triangles, lines, ...)
Implementation of the IMeshBuffer interface with shared vertex list.
virtual video::E_VERTEX_TYPE getVertexType() const _IRR_OVERRIDE_
returns which type of vertex data is stored.
virtual u32 getVertexCount() const _IRR_OVERRIDE_
returns amount of vertices
void setDebugName(const c8 *newName)
Sets the debug name of the object.
GLuint buffer
virtual const core::vector3df & getPosition(u32 i) const _IRR_OVERRIDE_
returns position of vertex i
GLuint GLuint GLsizei GLenum type
Definition: SDL_opengl.h:1571
E_VERTEX_TYPE
Enumeration for all vertex types there are.
Definition: S3DVertex.h:18
#define const
Definition: zconf.h:217
virtual u32 getIndexCount() const _IRR_OVERRIDE_
returns amount of indices
virtual void * getVertices() _IRR_OVERRIDE_
returns pointer to vertices
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:304
T * pointer()
Gets a pointer to the array.
Definition: irrArray.h:348
u32 ChangedID_Vertex
ID used for hardware buffer management.
virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) _IRR_OVERRIDE_
flags the mesh as changed, reloads hardware buffers
virtual u32 getChangedID_Index() const _IRR_OVERRIDE_
Get the currently used ID for identification of changes.
E_HARDWARE_MAPPING MappingHintIndex
virtual void append(const void *const vertices, u32 numVertices, const u16 *const indices, u32 numIndices) _IRR_OVERRIDE_
append the vertices and indices to the current buffer
virtual video::E_INDEX_TYPE getIndexType() const _IRR_OVERRIDE_
Get type of index data which is stored in this meshbuffer.