arsa  2.7
CDynamicMeshBuffer.h
Go to the documentation of this file.
1 // Copyright (C) 2008-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 __C_DYNAMIC_MESHBUFFER_H_INCLUDED__
6 #define __C_DYNAMIC_MESHBUFFER_H_INCLUDED__
7 
8 #include "IDynamicMeshBuffer.h"
9 
10 #include "CVertexBuffer.h"
11 #include "CIndexBuffer.h"
12 
13 namespace irr
14 {
15 namespace scene
16 {
17 
19  {
20  public:
24  {
25  VertexBuffer=new CVertexBuffer(vertexType);
26  IndexBuffer=new CIndexBuffer(indexType);
27  }
28 
31  {
32  if (VertexBuffer)
33  VertexBuffer->drop();
34  if (IndexBuffer)
35  IndexBuffer->drop();
36  }
37 
39  {
40  return *VertexBuffer;
41  }
42 
44  {
45  return *IndexBuffer;
46  }
47 
48  virtual void setVertexBuffer(IVertexBuffer *newVertexBuffer) _IRR_OVERRIDE_
49  {
50  if (newVertexBuffer)
51  newVertexBuffer->grab();
52  if (VertexBuffer)
53  VertexBuffer->drop();
54 
55  VertexBuffer=newVertexBuffer;
56  }
57 
58  virtual void setIndexBuffer(IIndexBuffer *newIndexBuffer) _IRR_OVERRIDE_
59  {
60  if (newIndexBuffer)
61  newIndexBuffer->grab();
62  if (IndexBuffer)
63  IndexBuffer->drop();
64 
65  IndexBuffer=newIndexBuffer;
66  }
67 
70  {
71  return Material;
72  }
73 
76  {
77  return Material;
78  }
79 
82  {
83  return BoundingBox;
84  }
85 
87  virtual void setBoundingBox( const core::aabbox3df& box) _IRR_OVERRIDE_
88  {
89  BoundingBox = box;
90  }
91 
94  {
95  if (!getVertexBuffer().size())
96  BoundingBox.reset(0,0,0);
97  else
98  {
100  for (u32 i=1; i<getVertexBuffer().size(); ++i)
102  }
103  }
104 
107  {
109  }
110 
113  {
114  return PrimitiveType;
115  }
116 
121  private:
122  CDynamicMeshBuffer(const CDynamicMeshBuffer&); // = delete in c++11, prevent copying
123 
124  IVertexBuffer *VertexBuffer;
125  IIndexBuffer *IndexBuffer;
126  };
127 
128 
129 } // end namespace scene
130 } // end namespace irr
131 
132 #endif
133 
bool drop() const
Drops the object. Decrements the reference counter by one.
virtual u32 size() const =0
CDynamicMeshBuffer(video::E_VERTEX_TYPE vertexType, video::E_INDEX_TYPE indexType)
constructor
E_PRIMITIVE_TYPE
Enumeration for all primitive types there are.
virtual void setBoundingBox(const core::aabbox3df &box) _IRR_OVERRIDE_
Set bounding box.
E_PRIMITIVE_TYPE PrimitiveType
Primitive type used for rendering (triangles, lines, ...)
Everything in the Irrlicht Engine can be found in this namespace.
Definition: CARSADPad.h:6
GLsizeiptr size
void reset(T x, T y, T z)
Resets the bounding box to a one-point box.
Definition: aabbox3d.h:50
virtual E_PRIMITIVE_TYPE getPrimitiveType() const _IRR_OVERRIDE_
Get the kind of primitive geometry which is used by the meshbuffer.
virtual ~CDynamicMeshBuffer()
destructor
virtual const core::aabbox3d< f32 > & getBoundingBox() const _IRR_OVERRIDE_
Get bounding box.
unsigned int u32
32 bit unsigned variable.
Definition: irrTypes.h:62
Explicitly set all vertices for each triangle.
virtual const video::SMaterial & getMaterial() const _IRR_OVERRIDE_
Get Material of this buffer.
virtual video::SMaterial & getMaterial() _IRR_OVERRIDE_
Get Material of this buffer.
virtual void recalculateBoundingBox() _IRR_OVERRIDE_
Recalculate bounding box.
void addInternalPoint(const vector3d< T > &p)
Adds a point to the bounding box.
Definition: aabbox3d.h:74
#define _IRR_OVERRIDE_
Defines an override macro, to protect virtual functions from typos and other mismatches.
Definition: irrTypes.h:216
core::aabbox3d< f32 > BoundingBox
virtual void setPrimitiveType(E_PRIMITIVE_TYPE type) _IRR_OVERRIDE_
Describe what kind of primitive geometry is used by the meshbuffer.
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 IVertexBuffer & getVertexBuffer() const _IRR_OVERRIDE_
Struct for holding parameters for a material renderer.
Definition: SMaterial.h:304
virtual IIndexBuffer & getIndexBuffer() const _IRR_OVERRIDE_
virtual void setVertexBuffer(IVertexBuffer *newVertexBuffer) _IRR_OVERRIDE_
virtual void setIndexBuffer(IIndexBuffer *newIndexBuffer) _IRR_OVERRIDE_