5#ifndef S_SKIN_MESH_BUFFER_HPP_INCLUDED
6#define S_SKIN_MESH_BUFFER_HPP_INCLUDED
8#include <duckcpp/core/engine/IMeshBuffer.hpp>
9#include <duckcpp/core/engine/S3DVertex.hpp>
24 ChangedID_Vertex(1), ChangedID_Index(1), VertexType(vt),
27 BoundingBoxNeedsRecalculated(true)
56 return &Vertices_Standard[index];
80 return Vertices_2TCoords.
pointer();
82 return Vertices_Tangents.
pointer();
84 return Vertices_Standard.
pointer();
94 return Vertices_2TCoords.
size();
96 return Vertices_Tangents.
size();
98 return Vertices_Standard.
size();
106 return dcpp::video::EIT_16BIT;
124 return Indices.
size();
142 if(!BoundingBoxNeedsRecalculated)
145 BoundingBoxNeedsRecalculated =
false;
151 if (Vertices_Standard.
empty())
152 BoundingBox.
reset(0,0,0);
155 BoundingBox.
reset(Vertices_Standard[0].Pos);
163 if (Vertices_2TCoords.
empty())
164 BoundingBox.
reset(0,0,0);
167 BoundingBox.
reset(Vertices_2TCoords[0].Pos);
175 if (Vertices_Tangents.
empty())
176 BoundingBox.
reset(0,0,0);
179 BoundingBox.
reset(Vertices_Tangents[0].Pos);
202 Vertex.
Color=Vertices_Standard[n].Color;
203 Vertex.
Pos=Vertices_Standard[n].Pos;
204 Vertex.
Normal=Vertices_Standard[n].Normal;
205 Vertex.
TCoords=Vertices_Standard[n].TCoords;
208 Vertices_Standard.
clear();
221 Vertex.
Color=Vertices_Standard[n].Color;
222 Vertex.
Pos=Vertices_Standard[n].Pos;
223 Vertex.
Normal=Vertices_Standard[n].Normal;
224 Vertex.
TCoords=Vertices_Standard[n].TCoords;
227 Vertices_Standard.
clear();
235 Vertex.
Color=Vertices_2TCoords[n].Color;
236 Vertex.
Pos=Vertices_2TCoords[n].Pos;
237 Vertex.
Normal=Vertices_2TCoords[n].Normal;
238 Vertex.
TCoords=Vertices_2TCoords[n].TCoords;
241 Vertices_2TCoords.
clear();
252 return Vertices_2TCoords[i].Pos;
254 return Vertices_Tangents[i].Pos;
256 return Vertices_Standard[i].Pos;
266 return Vertices_2TCoords[i].Pos;
268 return Vertices_Tangents[i].Pos;
270 return Vertices_Standard[i].Pos;
280 return Vertices_2TCoords[i].Normal;
282 return Vertices_Tangents[i].Normal;
284 return Vertices_Standard[i].Normal;
294 return Vertices_2TCoords[i].Normal;
296 return Vertices_Tangents[i].Normal;
298 return Vertices_Standard[i].Normal;
308 return Vertices_2TCoords[i].TCoords;
310 return Vertices_Tangents[i].TCoords;
312 return Vertices_Standard[i].TCoords;
322 return Vertices_2TCoords[i].TCoords;
324 return Vertices_Tangents[i].TCoords;
326 return Vertices_Standard[i].TCoords;
336 return Vertices_2TCoords[i].Color;
338 return Vertices_Tangents[i].Color;
340 return Vertices_Standard[i].Color;
350 return Vertices_2TCoords[i].Color;
352 return Vertices_Tangents[i].Color;
354 return Vertices_Standard[i].Color;
367 return MappingHint_Vertex;
373 return MappingHint_Index;
380 MappingHint_Vertex=NewMappingHint;
382 MappingHint_Index=NewMappingHint;
385 MappingHint_Vertex=NewMappingHint;
386 MappingHint_Index=NewMappingHint;
426 if (cloneFlags & ECF_VERTICES)
428 clone->Vertices_Tangents = Vertices_Tangents;
429 clone->Vertices_2TCoords = Vertices_2TCoords;
430 clone->Vertices_Standard = Vertices_Standard;
432 clone->BoundingBox = BoundingBox;
433 clone->BoundingBoxNeedsRecalculated = BoundingBoxNeedsRecalculated;
438 clone->Indices = Indices;
441 clone->Transformation = Transformation;
444 clone->MappingHint_Vertex = MappingHint_Vertex;
445 clone->MappingHint_Index = MappingHint_Index;
476 bool BoundingBoxNeedsRecalculated:1;
void setDebugName(const dcpp::char_kt *newName)
Sets the debug name of the object.
Definition IReferenceCounted.hpp:163
4x4 matrix. Mostly used as transformation matrix for 3d calculations.
Definition matrix4.hpp:49
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.hpp:22
void reset(T x, T y, T z)
Resets the bounding box to a one-point box.
Definition aabbox3d.hpp:50
void addInternalPoint(const vector3d< T > &p)
Adds a point to the bounding box.
Definition aabbox3d.hpp:74
T * pointer()
Gets a pointer to the array.
Definition irrArray.hpp:381
dcpp::uint32_kt size() const
Get number of occupied elements of the array.
Definition irrArray.hpp:397
const T * const_pointer() const
Gets a const pointer to the array.
Definition irrArray.hpp:389
bool empty() const
Check if array is empty.
Definition irrArray.hpp:414
void clear()
Clears the array and deletes all allocated memory.
Definition irrArray.hpp:199
void push_back(const T &element)
Adds an element at back of array.
Definition irrArray.hpp:111
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
@ ECF_INDICES
clone the vertices (or copy pointer for SSharedMeshBuffer)
Definition IMeshBuffer.hpp:205
A mesh buffer able to choose between S3DVertex2TCoords, S3DVertex and S3DVertexTangents at runtime.
Definition SSkinMeshBuffer.hpp:20
virtual void setDirty(E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX) override
flags the mesh as changed, reloads hardware buffers
Definition SSkinMeshBuffer.hpp:403
void convertToTangents()
Convert to tangents vertex type.
Definition SSkinMeshBuffer.hpp:214
void boundingBoxNeedsRecalculated(void)
Call this after changing the positions of any vertex.
Definition SSkinMeshBuffer.hpp:451
E_PRIMITIVE_TYPE PrimitiveType
Primitive type used for rendering (triangles, lines, ...)
Definition SSkinMeshBuffer.hpp:470
virtual dcpp::video::SMaterial & getMaterial() override
Get Material of this buffer.
Definition SSkinMeshBuffer.hpp:41
virtual dcpp::video::E_INDEX_TYPE getIndexType() const override
Get type of index data which is stored in this meshbuffer.
Definition SSkinMeshBuffer.hpp:104
virtual IMeshBuffer * createClone(int cloneFlags) const override
Create copy of the meshbuffer.
Definition SSkinMeshBuffer.hpp:422
virtual const dcpp::nub::vector3df & getNormal(dcpp::uint32_kt i) const override
returns normal of vertex i
Definition SSkinMeshBuffer.hpp:275
virtual dcpp::video::S3DVertex * getVertex(dcpp::uint32_kt index)
Get standard vertex at given index.
Definition SSkinMeshBuffer.hpp:47
virtual const dcpp::video::SMaterial & getMaterial() const override
Get Material of this buffer.
Definition SSkinMeshBuffer.hpp:35
virtual const dcpp::nub::vector2df & getTCoords(dcpp::uint32_kt i) const override
returns texture coords of vertex i
Definition SSkinMeshBuffer.hpp:303
virtual const dcpp::video::SColor & getColor(dcpp::uint32_kt i) const override
returns color of vertex i
Definition SSkinMeshBuffer.hpp:345
virtual E_PRIMITIVE_TYPE getPrimitiveType() const override
Get the kind of primitive geometry which is used by the meshbuffer.
Definition SSkinMeshBuffer.hpp:397
virtual void recalculateBoundingBox() override
Recalculate bounding box.
Definition SSkinMeshBuffer.hpp:140
virtual const dcpp::nub::vector3df & getPosition(dcpp::uint32_kt i) const override
returns position of vertex i
Definition SSkinMeshBuffer.hpp:247
virtual dcpp::nub::vector2df & getTCoords(dcpp::uint32_kt i) override
returns texture coords of vertex i
Definition SSkinMeshBuffer.hpp:317
virtual dcpp::uint32_kt getChangedID_Index() const override
Get the currently used ID for identification of changes.
Definition SSkinMeshBuffer.hpp:413
virtual dcpp::video::SColor & getColor(dcpp::uint32_kt i) override
returns color of vertex i
Definition SSkinMeshBuffer.hpp:331
virtual dcpp::uint32_kt getChangedID_Vertex() const override
Get the currently used ID for identification of changes.
Definition SSkinMeshBuffer.hpp:411
SSkinMeshBuffer(dcpp::video::E_VERTEX_TYPE vt=dcpp::video::EVT_STANDARD)
Default constructor.
Definition SSkinMeshBuffer.hpp:23
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const override
get the current hardware mapping hint for index buffers
Definition SSkinMeshBuffer.hpp:371
virtual dcpp::uint16_kt * getIndices() override
Get pointer to index array.
Definition SSkinMeshBuffer.hpp:116
virtual EMESH_BUFFER_TYPE getType() const override
Returns type of the class implementing the IMeshBuffer.
Definition SSkinMeshBuffer.hpp:416
virtual const dcpp::nub::aabbox3df & getBoundingBox() const override
Get bounding box.
Definition SSkinMeshBuffer.hpp:128
void convertTo2TCoords()
Convert to 2tcoords vertex type.
Definition SSkinMeshBuffer.hpp:195
virtual void setBoundingBox(const dcpp::nub::aabbox3df &box) override
Set bounding box.
Definition SSkinMeshBuffer.hpp:134
virtual void setPrimitiveType(E_PRIMITIVE_TYPE type) override
Describe what kind of primitive geometry is used by the meshbuffer.
Definition SSkinMeshBuffer.hpp:391
virtual void * getVertices() override
Get pointer to vertex array.
Definition SSkinMeshBuffer.hpp:75
virtual const dcpp::uint16_kt * getIndices() const override
Get pointer to index array.
Definition SSkinMeshBuffer.hpp:110
virtual void append(const void *const vertices, dcpp::uint32_kt numVertices, const dcpp::uint16_kt *const indices, dcpp::uint32_kt numIndices) override
append the vertices and indices to the current buffer
Definition SSkinMeshBuffer.hpp:359
virtual dcpp::nub::vector3df & getNormal(dcpp::uint32_kt i) override
returns normal of vertex i
Definition SSkinMeshBuffer.hpp:289
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const override
get the current hardware mapping hint for vertex buffers
Definition SSkinMeshBuffer.hpp:365
virtual dcpp::nub::vector3df & getPosition(dcpp::uint32_kt i) override
returns position of vertex i
Definition SSkinMeshBuffer.hpp:261
virtual dcpp::uint32_kt getIndexCount() const override
Get index count.
Definition SSkinMeshBuffer.hpp:122
virtual void append(const IMeshBuffer *const other) override
append the meshbuffer to the current buffer
Definition SSkinMeshBuffer.hpp:362
virtual const void * getVertices() const override
Get pointer to vertex array.
Definition SSkinMeshBuffer.hpp:61
virtual void setHardwareMappingHint(E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX) override
set the hardware mapping hint, for driver
Definition SSkinMeshBuffer.hpp:377
virtual dcpp::video::E_VERTEX_TYPE getVertexType() const override
Get vertex type.
Definition SSkinMeshBuffer.hpp:189
virtual dcpp::uint32_kt getVertexCount() const override
Get vertex count.
Definition SSkinMeshBuffer.hpp:89
Vertex with two texture coordinates.
Definition S3DVertex.hpp:116
Vertex with a tangent and binormal vector.
Definition S3DVertex.hpp:199
standard vertex used by the Duckcpp engine.
Definition S3DVertex.hpp:45
dcpp::nub::vector3df Normal
Normal vector.
Definition S3DVertex.hpp:64
dcpp::nub::vector2df TCoords
Texture coordinates.
Definition S3DVertex.hpp:70
dcpp::nub::vector3df Pos
Position.
Definition S3DVertex.hpp:61
SColor Color
Color.
Definition S3DVertex.hpp:67
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_INDEX
Change the index mapping.
Definition EHardwareBufferFlags.hpp:35
@ EBT_VERTEX_AND_INDEX
Change both vertex and index mapping to the same value.
Definition EHardwareBufferFlags.hpp:37
@ EBT_VERTEX
Change the vertex mapping.
Definition EHardwareBufferFlags.hpp:33
E_PRIMITIVE_TYPE
Enumeration for all primitive types there are.
Definition EPrimitiveTypes.hpp:15
@ EPT_TRIANGLES
Explicitly set all vertices for each triangle.
Definition EPrimitiveTypes.hpp:37
EMESH_BUFFER_TYPE
An enumeration for all types of built-in mesh buffers.
Definition EMeshBufferTypes.hpp:18
E_HARDWARE_MAPPING
Definition EHardwareBufferFlags.hpp:14
@ EHM_NEVER
Don't store on the hardware.
Definition EHardwareBufferFlags.hpp:16
E_VERTEX_TYPE
Enumeration for all vertex types there are.
Definition S3DVertex.hpp:19
@ EVT_2TCOORDS
Vertex with two texture coordinates, dcpp::video::S3DVertex2TCoords.
Definition S3DVertex.hpp:25
@ EVT_TANGENTS
Vertex with a tangent and binormal vector, dcpp::video::S3DVertexTangents.
Definition S3DVertex.hpp:31
@ EVT_STANDARD
Standard vertex type used by the Duckcpp engine, dcpp::video::S3DVertex.
Definition S3DVertex.hpp:21
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