Irrlicht 3D Engine
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 
38  virtual IVertexBuffer& getVertexBuffer() const
39  {
40  return *VertexBuffer;
41  }
42 
43  virtual IIndexBuffer& getIndexBuffer() const
44  {
45  return *IndexBuffer;
46  }
47 
48  virtual void setVertexBuffer(IVertexBuffer *newVertexBuffer)
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)
59  {
60  if (newIndexBuffer)
61  newIndexBuffer->grab();
62  if (IndexBuffer)
63  IndexBuffer->drop();
64 
65  IndexBuffer=newIndexBuffer;
66  }
67 
69  virtual const video::SMaterial& getMaterial() const
70  {
71  return Material;
72  }
73 
76  {
77  return Material;
78  }
79 
81  virtual const core::aabbox3d<f32>& getBoundingBox() const
82  {
83  return BoundingBox;
84  }
85 
87  virtual void setBoundingBox( const core::aabbox3df& box)
88  {
89  BoundingBox = box;
90  }
91 
93  virtual void recalculateBoundingBox()
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  {
108  PrimitiveType = type;
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 IIndexBuffer & getIndexBuffer() const
E_PRIMITIVE_TYPE PrimitiveType
Primitive type used for rendering (triangles, lines, ...)
virtual E_PRIMITIVE_TYPE getPrimitiveType() const
Get the kind of primitive geometry which is used by the meshbuffer.
virtual void setIndexBuffer(IIndexBuffer *newIndexBuffer)
Everything in the Irrlicht Engine can be found in this namespace.
Definition: aabbox3d.h:12
void reset(T x, T y, T z)
Resets the bounding box to a one-point box.
Definition: aabbox3d.h:50
virtual ~CDynamicMeshBuffer()
destructor
virtual void setVertexBuffer(IVertexBuffer *newVertexBuffer)
unsigned int u32
32 bit unsigned variable.
Definition: irrTypes.h:62
Explicitly set all vertices for each triangle.
virtual const core::aabbox3d< f32 > & getBoundingBox() const
Get bounding box.
virtual IVertexBuffer & getVertexBuffer() const
virtual void setBoundingBox(const core::aabbox3df &box)
Set bounding box.
virtual video::SMaterial & getMaterial()
Get Material of this buffer.
void addInternalPoint(const vector3d< T > &p)
Adds a point to the bounding box.
Definition: aabbox3d.h:74
void grab() const
Grabs the object. Increments the reference counter by one.
core::aabbox3d< f32 > BoundingBox
virtual const video::SMaterial & getMaterial() const
Get Material of this buffer.
E_VERTEX_TYPE
Enumeration for all vertex types there are.
Definition: S3DVertex.h:18
virtual void setPrimitiveType(E_PRIMITIVE_TYPE type)
Describe what kind of primitive geometry is used by the meshbuffer.
virtual void recalculateBoundingBox()
Recalculate bounding box.
Struct for holding parameters for a material renderer.
Definition: SMaterial.h:286