Irrlicht 3D Engine
 
Loading...
Searching...
No Matches
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
9
10#include "CVertexBuffer.h"
11#include "CIndexBuffer.h"
12
13namespace irr
14{
15namespace scene
16{
17
19 {
20 public:
23 {
24 VertexBuffer=new CVertexBuffer(vertexType);
25 IndexBuffer=new CIndexBuffer(indexType);
26 }
27
30 {
31 if (VertexBuffer)
32 VertexBuffer->drop();
33 if (IndexBuffer)
34 IndexBuffer->drop();
35 }
36
38 {
39 return *VertexBuffer;
40 }
41
43 {
44 return *IndexBuffer;
45 }
46
47 virtual void setVertexBuffer(IVertexBuffer *newVertexBuffer)
48 {
49 if (newVertexBuffer)
50 newVertexBuffer->grab();
51 if (VertexBuffer)
52 VertexBuffer->drop();
53
54 VertexBuffer=newVertexBuffer;
55 }
56
57 virtual void setIndexBuffer(IIndexBuffer *newIndexBuffer)
58 {
59 if (newIndexBuffer)
60 newIndexBuffer->grab();
61 if (IndexBuffer)
62 IndexBuffer->drop();
63
64 IndexBuffer=newIndexBuffer;
65 }
66
68 virtual const video::SMaterial& getMaterial() const
69 {
70 return Material;
71 }
72
75 {
76 return Material;
77 }
78
80 virtual const core::aabbox3d<f32>& getBoundingBox() const
81 {
82 return BoundingBox;
83 }
84
86 virtual void setBoundingBox( const core::aabbox3df& box)
87 {
88 BoundingBox = box;
89 }
90
93 {
94 if (!getVertexBuffer().size())
95 BoundingBox.reset(0,0,0);
96 else
97 {
99 for (u32 i=1; i<getVertexBuffer().size(); ++i)
101 }
102 }
103
106 private:
107 IVertexBuffer *VertexBuffer;
108 IIndexBuffer *IndexBuffer;
109 };
110
111
112} // end namespace scene
113} // end namespace irr
114
115#endif
116
bool drop() const
Drops the object. Decrements the reference counter by one.
void grab() const
Grabs the object. Increments the reference counter by one.
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.h:22
void addInternalPoint(const vector3d< T > &p)
Adds a point to the bounding box.
Definition aabbox3d.h:74
void reset(T x, T y, T z)
Resets the bounding box to a one-point box.
Definition aabbox3d.h:50
virtual IVertexBuffer & getVertexBuffer() const
virtual const video::SMaterial & getMaterial() const
Get Material of this buffer.
virtual ~CDynamicMeshBuffer()
destructor
virtual void recalculateBoundingBox()
Recalculate bounding box.
virtual void setVertexBuffer(IVertexBuffer *newVertexBuffer)
virtual IIndexBuffer & getIndexBuffer() const
virtual video::SMaterial & getMaterial()
Get Material of this buffer.
virtual void setBoundingBox(const core::aabbox3df &box)
Set bounding box.
virtual void setIndexBuffer(IIndexBuffer *newIndexBuffer)
virtual const core::aabbox3d< f32 > & getBoundingBox() const
Get bounding box.
CDynamicMeshBuffer(video::E_VERTEX_TYPE vertexType, video::E_INDEX_TYPE indexType)
constructor
virtual u32 size() const =0
Struct for holding parameters for a material renderer.
Definition SMaterial.h:227
E_VERTEX_TYPE
Enumeration for all vertex types there are.
Definition S3DVertex.h:19
Everything in the Irrlicht Engine can be found in this namespace.
Definition aabbox3d.h:13
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.h:58