arsa  2.7
IMeshBuffer.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 __I_MESH_BUFFER_H_INCLUDED__
6 #define __I_MESH_BUFFER_H_INCLUDED__
7 
8 #include "IReferenceCounted.h"
9 #include "SMaterial.h"
10 #include "aabbox3d.h"
11 #include "S3DVertex.h"
12 #include "SVertexIndex.h"
13 #include "EHardwareBufferFlags.h"
14 #include "EPrimitiveTypes.h"
15 
16 namespace irr
17 {
18 namespace scene
19 {
21 
39  class IMeshBuffer : public virtual IReferenceCounted
40  {
41  public:
42 
44 
45  virtual video::SMaterial& getMaterial() = 0;
46 
48 
49  virtual const video::SMaterial& getMaterial() const = 0;
50 
52 
53  virtual video::E_VERTEX_TYPE getVertexType() const = 0;
54 
56 
58  virtual const void* getVertices() const = 0;
59 
61 
63  virtual void* getVertices() = 0;
64 
66 
67  virtual u32 getVertexCount() const = 0;
68 
70 
71  virtual video::E_INDEX_TYPE getIndexType() const =0;
72 
74 
75  virtual const u16* getIndices() const = 0;
76 
78 
79  virtual u16* getIndices() = 0;
80 
82 
83  virtual u32 getIndexCount() const = 0;
84 
86 
87  virtual const core::aabbox3df& getBoundingBox() const = 0;
88 
90 
92  virtual void setBoundingBox(const core::aabbox3df& box) = 0;
93 
95  virtual void recalculateBoundingBox() = 0;
96 
98  virtual const core::vector3df& getPosition(u32 i) const = 0;
99 
101  virtual core::vector3df& getPosition(u32 i) = 0;
102 
104  virtual const core::vector3df& getNormal(u32 i) const = 0;
105 
107  virtual core::vector3df& getNormal(u32 i) = 0;
108 
110  virtual const core::vector2df& getTCoords(u32 i) const = 0;
111 
113  virtual core::vector2df& getTCoords(u32 i) = 0;
114 
116 
121  virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) = 0;
122 
124 
126  virtual void append(const IMeshBuffer* const other) = 0;
127 
130 
133 
136 
139 
141 
142  virtual u32 getChangedID_Vertex() const = 0;
143 
145 
146  virtual u32 getChangedID_Index() const = 0;
147 
149 
153  virtual void setPrimitiveType(E_PRIMITIVE_TYPE type) = 0;
154 
156  virtual E_PRIMITIVE_TYPE getPrimitiveType() const = 0;
157 
159  virtual u32 getPrimitiveCount() const
160  {
161  const u32 indexCount = getIndexCount();
162  switch (getPrimitiveType())
163  {
164  case scene::EPT_POINTS: return indexCount;
165  case scene::EPT_LINE_STRIP: return indexCount-1;
166  case scene::EPT_LINE_LOOP: return indexCount;
167  case scene::EPT_LINES: return indexCount/2;
168  case scene::EPT_TRIANGLE_STRIP: return (indexCount-2);
169  case scene::EPT_TRIANGLE_FAN: return (indexCount-2);
170  case scene::EPT_TRIANGLES: return indexCount/3;
171  case scene::EPT_QUAD_STRIP: return (indexCount-2)/2;
172  case scene::EPT_QUADS: return indexCount/4;
173  case scene::EPT_POLYGON: return indexCount; // (not really primitives, that would be 1, works like line_strip)
174  case scene::EPT_POINT_SPRITES: return indexCount;
175  }
176  return 0;
177  }
178 
179  };
180 
181 } // end namespace scene
182 } // end namespace irr
183 
184 #endif
virtual void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX)=0
set the hardware mapping hint, for driver
virtual void recalculateBoundingBox()=0
Recalculates the bounding box. Should be called if the mesh changed.
virtual u32 getChangedID_Index() const =0
Get the currently used ID for identification of changes.
All vertices are non-connected points.
E_PRIMITIVE_TYPE
Enumeration for all primitive types there are.
virtual u32 getIndexCount() const =0
Get amount of indices in this meshbuffer.
virtual const core::aabbox3df & getBoundingBox() const =0
Get the axis aligned bounding box of this meshbuffer.
virtual void setBoundingBox(const core::aabbox3df &box)=0
Set axis aligned bounding box.
virtual const core::vector2df & getTCoords(u32 i) const =0
returns texture coord of vertex i
GLuint GLuint GLsizei GLenum const GLvoid * indices
Definition: SDL_opengl.h:1571
virtual const core::vector3df & getPosition(u32 i) const =0
returns position of vertex i
virtual void append(const void *const vertices, u32 numVertices, const u16 *const indices, u32 numIndices)=0
Append the vertices and indices to the current buffer.
Everything in the Irrlicht Engine can be found in this namespace.
Definition: CARSADPad.h:6
virtual const core::vector3df & getNormal(u32 i) const =0
returns normal of vertex i
virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX)=0
flags the meshbuffer as changed, reloads hardware buffers
unsigned short u16
16 bit unsigned variable.
Definition: irrTypes.h:44
virtual u32 getChangedID_Vertex() const =0
Get the currently used ID for identification of changes.
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const =0
get the current hardware mapping hint
Every two vertices are connected creating n/2 lines.
Struct for holding a mesh with a single material.
Definition: IMeshBuffer.h:39
virtual E_PRIMITIVE_TYPE getPrimitiveType() const =0
Get the kind of primitive geometry which is used by the meshbuffer.
unsigned int u32
32 bit unsigned variable.
Definition: irrTypes.h:62
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const =0
get the current hardware mapping hint
Explicitly set all vertices for each triangle.
Change both vertex and index mapping to the same value.
virtual u32 getPrimitiveCount() const
Calculate how many geometric primitives are used by this meshbuffer.
Definition: IMeshBuffer.h:159
virtual u32 getVertexCount() const =0
Get amount of vertices in meshbuffer.
virtual video::E_INDEX_TYPE getIndexType() const =0
Get type of index data which is stored in this meshbuffer.
virtual const u16 * getIndices() const =0
Get access to indices.
virtual video::SMaterial & getMaterial()=0
Get the material of this meshbuffer.
The single vertices are expanded to quad billboards on the GPU.
virtual void setPrimitiveType(E_PRIMITIVE_TYPE type)=0
Describe what kind of primitive geometry is used by the meshbuffer.
GLuint buffer
Base class of most objects of the Irrlicht Engine.
virtual const void * getVertices() const =0
Get access to vertex data. The data is an array of vertices.
GLuint GLuint GLsizei GLenum type
Definition: SDL_opengl.h:1571
E_VERTEX_TYPE
Enumeration for all vertex types there are.
Definition: S3DVertex.h:18
Struct for holding parameters for a material renderer.
Definition: SMaterial.h:304
virtual video::E_VERTEX_TYPE getVertexType() const =0
Get type of vertex data which is stored in this meshbuffer.
All vertices form a single connected line.
Just as LINE_STRIP, but the last and the first vertex is also connected.