Duckcpp 2.1.0
Duckcpp is a high-performance c++ graphics engine.
Loading...
Searching...
No Matches
IMeshBuffer.hpp
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 duckcpp/duckcpp.hpp
4
5#ifndef DCPP_I_MESH_BUFFER_HPP_INCLUDED
6#define DCPP_I_MESH_BUFFER_HPP_INCLUDED
7
8#include <duckcpp/core/engine/IReferenceCounted.hpp>
9#include <duckcpp/core/engine/SMaterial.hpp>
10#include <duckcpp/core/engine/aabbox3d.hpp>
11#include <duckcpp/core/engine/S3DVertex.hpp>
12#include <duckcpp/core/engine/SVertexIndex.hpp>
13#include <duckcpp/core/engine/EHardwareBufferFlags.hpp>
14#include <duckcpp/core/engine/EPrimitiveTypes.hpp>
15#include <duckcpp/core/engine/EMeshBufferTypes.hpp>
16
17namespace dcpp
18{
19namespace scene
20{
22
40 class IMeshBuffer : public virtual IReferenceCounted
41 {
42 public:
43
45
47
49
50 virtual const dcpp::video::SMaterial& getMaterial() const = 0;
51
53
55
57
59 virtual const void* getVertices() const = 0;
60
62
64 virtual void* getVertices() = 0;
65
67
68 virtual dcpp::uint32_kt getVertexCount() const = 0;
69
71
72 virtual dcpp::video::E_INDEX_TYPE getIndexType() const =0;
73
75
79 virtual const dcpp::uint16_kt* getIndices() const = 0;
80
82
87
89
90 virtual dcpp::uint32_kt getIndexCount() const = 0;
91
93
94 virtual const dcpp::nub::aabbox3df& getBoundingBox() const = 0;
95
97
99 virtual void setBoundingBox(const dcpp::nub::aabbox3df& box) = 0;
100
102 virtual void recalculateBoundingBox() = 0;
103
106
109
111 virtual const dcpp::nub::vector3df& getNormal(dcpp::uint32_kt i) const = 0;
112
115
118
121
124
126 virtual const dcpp::video::SColor& getColor(dcpp::uint32_kt i) const = 0;
127
129
135 virtual void append(const void* const vertices, dcpp::uint32_kt numVertices, const dcpp::uint16_kt* const indices, dcpp::uint32_kt numIndices) = 0;
136
139
141 virtual void append(const IMeshBuffer* const other) = 0;
142
145
148
151
154
156
158
160
162
164
168 virtual void setPrimitiveType(E_PRIMITIVE_TYPE type) = 0;
169
172
175 {
176 const dcpp::uint32_kt indexCount = getIndexCount();
177 switch (getPrimitiveType())
178 {
179 case dcpp::scene::EPT_POINTS: return indexCount;
180 case dcpp::scene::EPT_LINE_STRIP: return indexCount-1;
181 case dcpp::scene::EPT_LINE_LOOP: return indexCount;
182 case dcpp::scene::EPT_LINES: return indexCount/2;
183 case dcpp::scene::EPT_TRIANGLE_STRIP: return (indexCount-2);
184 case dcpp::scene::EPT_TRIANGLE_FAN: return (indexCount-2);
185 case dcpp::scene::EPT_TRIANGLES: return indexCount/3;
186 case dcpp::scene::EPT_QUAD_STRIP: return (indexCount-2)/2;
187 case dcpp::scene::EPT_QUADS: return indexCount/4;
188 case dcpp::scene::EPT_POLYGON: return indexCount; // (not really primitives, that would be 1, works like line_strip)
189 case dcpp::scene::EPT_POINT_SPRITES: return indexCount;
190 }
191 return 0;
192 }
193
195
197 {
198 return EMBT_UNKNOWN;
199 }
200
203 {
204 ECF_VERTICES = 1,
205 ECF_INDICES = 2
206 };
207
209 //\param cloneFlags A combination of ECloneFlags
210 virtual IMeshBuffer* createClone(int cloneFlags=ECF_VERTICES|ECF_INDICES) const = 0;
211 };
212
213} // end namespace scene
214} // end namespace dcpp
215
216#endif
Base class of most objects of the Duckcpp Engine.
Definition IReferenceCounted.hpp:46
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.hpp:22
2d vector template class with lots of operators and methods.
Definition vector2d.hpp:22
3d vector template class with lots of operators and methods.
Definition vector3d.hpp:32
Class for holding a mesh with a single material.
Definition IMeshBuffer.hpp:41
virtual const dcpp::nub::vector3df & getNormal(dcpp::uint32_kt i) const =0
returns normal of vertex i
virtual dcpp::uint32_kt getChangedID_Index() const =0
Get the currently used ID for identification of changes.
virtual const dcpp::nub::vector2df & getTCoords(dcpp::uint32_kt i) const =0
returns texture coord of vertex i
virtual void * getVertices()=0
Get access to vertex data. The data is an array of vertices.
virtual IMeshBuffer * createClone(int cloneFlags=ECF_VERTICES|ECF_INDICES) const =0
Create a new object with a copy of the meshbuffer.
virtual dcpp::uint32_kt getVertexCount() const =0
Get amount of vertices in meshbuffer.
virtual dcpp::video::E_VERTEX_TYPE getVertexType() const =0
Get type of vertex data which is stored in this meshbuffer.
virtual const dcpp::nub::vector3df & getPosition(dcpp::uint32_kt i) const =0
returns position of vertex i
virtual dcpp::nub::vector2df & getTCoords(dcpp::uint32_kt i)=0
returns texture coord of vertex i
virtual dcpp::video::SMaterial & getMaterial()=0
Get the material of this meshbuffer.
virtual dcpp::uint32_kt getPrimitiveCount() const
Calculate how many geometric primitives are used by this meshbuffer.
Definition IMeshBuffer.hpp:174
virtual const dcpp::video::SColor & getColor(dcpp::uint32_kt i) const =0
returns color of vertex i
virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX)=0
flags the meshbuffer as changed, reloads hardware buffers
ECloneFlags
Bitflags with options for cloning.
Definition IMeshBuffer.hpp:203
@ ECF_INDICES
clone the vertices (or copy pointer for SSharedMeshBuffer)
Definition IMeshBuffer.hpp:205
virtual void append(const IMeshBuffer *const other)=0
virtual void setPrimitiveType(E_PRIMITIVE_TYPE type)=0
Describe what kind of primitive geometry is used by the meshbuffer.
virtual const dcpp::video::SMaterial & getMaterial() const =0
Get the material of this meshbuffer.
virtual void setBoundingBox(const dcpp::nub::aabbox3df &box)=0
Set axis aligned bounding box.
virtual dcpp::uint32_kt getChangedID_Vertex() const =0
Get the currently used ID for identification of changes.
virtual dcpp::uint32_kt getIndexCount() const =0
Get amount of indices in this meshbuffer.
virtual dcpp::nub::vector3df & getNormal(dcpp::uint32_kt i)=0
returns normal of vertex i
virtual const dcpp::uint16_kt * getIndices() const =0
Get access to indices.
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const =0
get the current hardware mapping hint
virtual E_PRIMITIVE_TYPE getPrimitiveType() const =0
Get the kind of primitive geometry which is used by the meshbuffer.
virtual void recalculateBoundingBox()=0
Recalculates the bounding box. Should be called if the mesh changed.
virtual EMESH_BUFFER_TYPE getType() const
Returns type of the class implementing the IMeshBuffer.
Definition IMeshBuffer.hpp:196
virtual dcpp::video::E_INDEX_TYPE getIndexType() const =0
Get type of index data which is stored in this meshbuffer.
virtual void append(const void *const vertices, dcpp::uint32_kt numVertices, const dcpp::uint16_kt *const indices, dcpp::uint32_kt numIndices)=0
Append the vertices and indices to the current buffer.
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const =0
get the current hardware mapping hint
virtual const dcpp::nub::aabbox3df & getBoundingBox() const =0
Get the axis aligned bounding box of this meshbuffer.
virtual dcpp::uint16_kt * getIndices()=0
Get access to indices.
virtual dcpp::video::SColor & getColor(dcpp::uint32_kt i)=0
returns color of vertex i
virtual dcpp::nub::vector3df & getPosition(dcpp::uint32_kt i)=0
returns position of vertex i
virtual void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX)=0
set the hardware mapping hint, for driver
virtual const void * getVertices() const =0
Get access to vertex data. The data is an array of vertices.
Class representing a 32 bit ARGB color.
Definition SColor.hpp:317
Class for holding parameters for a material renderer.
Definition SMaterial.hpp:304
E_BUFFER_TYPE
Definition EHardwareBufferFlags.hpp:29
@ EBT_VERTEX_AND_INDEX
Change both vertex and index mapping to the same value.
Definition EHardwareBufferFlags.hpp:37
E_PRIMITIVE_TYPE
Enumeration for all primitive types there are.
Definition EPrimitiveTypes.hpp:15
@ EPT_TRIANGLE_FAN
Definition EPrimitiveTypes.hpp:34
@ EPT_LINE_LOOP
Just as LINE_STRIP, but the last and the first vertex is also connected.
Definition EPrimitiveTypes.hpp:23
@ EPT_POINT_SPRITES
The single vertices are expanded to quad billboards on the GPU.
Definition EPrimitiveTypes.hpp:54
@ EPT_POLYGON
Definition EPrimitiveTypes.hpp:51
@ EPT_POINTS
All vertices are non-connected points.
Definition EPrimitiveTypes.hpp:17
@ EPT_LINES
Every two vertices are connected creating n/2 lines.
Definition EPrimitiveTypes.hpp:26
@ EPT_TRIANGLE_STRIP
Definition EPrimitiveTypes.hpp:30
@ EPT_LINE_STRIP
All vertices form a single connected line.
Definition EPrimitiveTypes.hpp:20
@ EPT_TRIANGLES
Explicitly set all vertices for each triangle.
Definition EPrimitiveTypes.hpp:37
@ EPT_QUAD_STRIP
Definition EPrimitiveTypes.hpp:41
@ EPT_QUADS
Definition EPrimitiveTypes.hpp:46
EMESH_BUFFER_TYPE
An enumeration for all types of built-in mesh buffers.
Definition EMeshBufferTypes.hpp:18
@ EMBT_UNKNOWN
Unknown class type.
Definition EMeshBufferTypes.hpp:38
E_HARDWARE_MAPPING
Definition EHardwareBufferFlags.hpp:14
E_VERTEX_TYPE
Enumeration for all vertex types there are.
Definition S3DVertex.hpp:19
As of Duckcpp 1.6, position2d is a synonym for vector2d.
Definition shared_device.hpp:34
unsigned int uint32_kt
32 bit unsigned variable.
Definition irrTypes.hpp:64
unsigned short uint16_kt
16 bit unsigned variable.
Definition irrTypes.hpp:46

Duckcpp    @cppfx.xyz