Skylicht Engine
Loading...
Searching...
No Matches
IMeshBuffer.h
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 "IVertexDescriptor.h"
13#include "CVertexBuffer.h"
14#include "CIndexBuffer.h"
15#include "EHardwareBufferFlags.h"
16#include "EPrimitiveTypes.h"
17
18namespace irr
19{
20namespace scene
21{
23
41 class IMeshBuffer : public virtual IReferenceCounted
42 {
43 public:
44 IMeshBuffer(video::IVertexDescriptor* vertexDescriptor) : VertexDescriptor(vertexDescriptor), VertexBufferCompatible(true),
45 IndexBuffer(0), PrimitiveType(EPT_TRIANGLES), BoundingBoxNeedsRecalculated(true), UseForHardwareInstancing(false)
46 {
47 }
48
49 virtual ~IMeshBuffer() {}
50
51 virtual video::IVertexDescriptor* getVertexDescriptor() const = 0;
52
53 virtual bool setVertexDescriptor(video::IVertexDescriptor* vertexDescriptor) = 0;
54
55 virtual bool addVertexBuffer(IVertexBuffer* vertexBuffer) = 0;
56
57 virtual IVertexBuffer* getVertexBuffer(u32 id = 0) const = 0;
58
59 virtual u32 getVertexBufferCount() const = 0;
60
61 virtual void removeVertexBuffer(u32 id) = 0;
62
63 virtual bool setVertexBuffer(IVertexBuffer* vertexBuffer, u32 id = 0) = 0;
64
67 {
68 return VertexBufferCompatible;
69 }
70
71 virtual IIndexBuffer* getIndexBuffer() const = 0;
72
73 virtual bool setIndexBuffer(IIndexBuffer* indexBuffer) = 0;
74
77 {
78 u32 primitiveCount = 0;
79
80 switch (PrimitiveType)
81 {
82 case EPT_POINTS:
84 primitiveCount = IndexBuffer->getIndexCount();
85 break;
87 primitiveCount = IndexBuffer->getIndexCount() - 1;
88 break;
90 primitiveCount = IndexBuffer->getIndexCount();
91 break;
93 primitiveCount = IndexBuffer->getIndexCount() / 2;
94 break;
96 primitiveCount = IndexBuffer->getIndexCount() - 2;
97 break;
99 primitiveCount = IndexBuffer->getIndexCount() - 2;
100 break;
102 primitiveCount = IndexBuffer->getIndexCount() / 3;
103 break;
104 }
105
106 return primitiveCount;
107 }
108
111 {
112 return PrimitiveType;
113 }
114
117 {
118 PrimitiveType = primitiveType;
119 }
120
121 virtual video::E_VERTEX_TYPE getVertexType() const = 0;
122
124
126
128
129 virtual const video::SMaterial& getMaterial() const = 0;
130
132
133 virtual const core::aabbox3df& getBoundingBox() const = 0;
134
136
138
141
143 virtual void recalculateBoundingBox() = 0;
144
145 virtual void append(IVertexBuffer* vertexBuffer, u32 vertexBufferID, IIndexBuffer* indexBuffer) = 0;
146
148
150 virtual void append(IMeshBuffer* meshBuffer) = 0;
151
154
157
160
162 virtual void setDirty(E_BUFFER_TYPE type = EBT_VERTEX_AND_INDEX, u32 id = 0) = 0;
163
165
166 virtual u32 getChangedID_Vertex(u32 id = 0) const = 0;
167
169
170 virtual u32 getChangedID_Index() const = 0;
171
172 virtual core::matrix4& getTransformation() = 0;
173
174 virtual void setUseForHardwareInstancing(bool b) = 0;
175
176 virtual bool useForHardwareInstancing() = 0;
177
178 protected:
181
182 // Inform if mesh buffers store compatible vertex buffers and vertex descriptor.
183 bool VertexBufferCompatible;
184
187
190
191 // Primitive type.
192 E_PRIMITIVE_TYPE PrimitiveType;
193
196
197 // Inform if bounding box need recalculation.
198 bool BoundingBoxNeedsRecalculated;
199
202
203 // Transformation.
204 core::matrix4 Transformation;
205
206 // UseForHardwareInstancing
207 bool UseForHardwareInstancing;
208 };
209
210} // end namespace scene
211} // end namespace irr
212
213#endif
214
215
IReferenceCounted()
Constructor.
Definition IReferenceCounted.h:50
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.h:22
Self reallocating template array (like stl vector) with additional features.
Definition irrArray.h:23
Definition IIndexBuffer.h:25
virtual void recalculateBoundingBox()=0
Recalculates the bounding box. Should be called if the mesh changed.
core::array< scene::IVertexBuffer * > VertexBuffer
Vertex buffer array.
Definition IMeshBuffer.h:186
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const =0
get the current hardware mapping hint
E_PRIMITIVE_TYPE getPrimitiveType() const
Get primitive type.
Definition IMeshBuffer.h:110
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex(u32 id=0) const =0
get the current hardware mapping hint
video::IVertexDescriptor * VertexDescriptor
Vertex descriptor.
Definition IMeshBuffer.h:180
core::aabbox3d< f32 > BoundingBox
Bounding box.
Definition IMeshBuffer.h:201
virtual u32 getChangedID_Vertex(u32 id=0) const =0
Get the currently used ID for identification of changes.
virtual void setHardwareMappingHint(E_HARDWARE_MAPPING pMappingHint, E_BUFFER_TYPE type=EBT_VERTEX_AND_INDEX, u32 id=0)=0
set the hardware mapping hint, for driver
virtual void append(IMeshBuffer *meshBuffer)=0
Append the meshbuffer to the current buffer.
bool isVertexBufferCompatible() const
Inform if stored vertex buffers have the same vertex descriptors.
Definition IMeshBuffer.h:66
virtual void setDirty(E_BUFFER_TYPE type=EBT_VERTEX_AND_INDEX, u32 id=0)=0
flags the meshbuffer as changed, reloads hardware buffers
u32 getPrimitiveCount() const
Get primitive count.
Definition IMeshBuffer.h:76
virtual core::aabbox3df & getBoundingBox()=0
Get the axis aligned bounding box of this meshbuffer.
void setPrimitiveType(E_PRIMITIVE_TYPE primitiveType)
Set primitive type.
Definition IMeshBuffer.h:116
virtual video::SMaterial & getMaterial()=0
Get the material of this meshbuffer.
scene::IIndexBuffer * IndexBuffer
Index buffer.
Definition IMeshBuffer.h:189
virtual void boundingBoxNeedsRecalculated()=0
Call this after changing the positions of any vertex.
virtual const core::aabbox3df & getBoundingBox() const =0
Get the axis aligned bounding box of this meshbuffer.
video::SMaterial Material
Material.
Definition IMeshBuffer.h:195
virtual u32 getChangedID_Index() const =0
Get the currently used ID for identification of changes.
virtual const video::SMaterial & getMaterial() const =0
Get the material of this meshbuffer.
Definition IVertexBuffer.h:17
Definition IVertexDescriptor.h:154
Struct for holding parameters for a material renderer.
Definition SMaterial.h:255
CMatrix4< f32 > matrix4
Typedef for f32 matrix.
Definition matrix4.h:2241
aabbox3d< f32 > aabbox3df
Typedef for a f32 3d bounding box.
Definition aabbox3d.h:351
All scene management can be found in this namespace: Mesh loading, special scene nodes like octrees a...
Definition CIndexBuffer.h:13
E_PRIMITIVE_TYPE
Enumeration for all primitive types there are.
Definition EPrimitiveTypes.h:15
@ EPT_LINES
Every two vertices are connected creating n/2 lines.
Definition EPrimitiveTypes.h:26
@ EPT_POINTS
All vertices are non-connected points.
Definition EPrimitiveTypes.h:17
@ EPT_TRIANGLES
Explicitly set all vertices for each triangle.
Definition EPrimitiveTypes.h:37
@ EPT_LINE_STRIP
All vertices form a single connected line.
Definition EPrimitiveTypes.h:20
@ EPT_TRIANGLE_FAN
Definition EPrimitiveTypes.h:34
@ EPT_TRIANGLE_STRIP
Definition EPrimitiveTypes.h:30
@ EPT_POINT_SPRITES
The single vertices are expanded to quad billboards on the GPU.
Definition EPrimitiveTypes.h:40
@ EPT_LINE_LOOP
Just as LINE_STRIP, but the last and the first vertex is also connected.
Definition EPrimitiveTypes.h:23
E_BUFFER_TYPE
Definition EHardwareBufferFlags.h:29
@ EBT_VERTEX_AND_INDEX
Change both vertex and index mapping to the same value.
Definition EHardwareBufferFlags.h:37
E_HARDWARE_MAPPING
Definition EHardwareBufferFlags.h:14
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 Skylicht.h:33
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.h:58