5#ifndef S_SKIN_MESH_BUFFER_HPP_INCLUDED
6#define S_SKIN_MESH_BUFFER_HPP_INCLUDED
8#include <nirtcpp/core/engine/IMeshBuffer.hpp>
9#include <nirtcpp/core/engine/S3DVertex.hpp>
24 ChangedID_Vertex(1), ChangedID_Index(1), VertexType(vt),
27 BoundingBoxNeedsRecalculated(true)
56 return &Vertices_Standard[index];
66 return Vertices_2TCoords.const_pointer();
68 return Vertices_Tangents.const_pointer();
70 return Vertices_Standard.const_pointer();
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 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);
156 for (
u32 i=1; i<Vertices_Standard.size(); ++i)
163 if (Vertices_2TCoords.empty())
164 BoundingBox.
reset(0,0,0);
167 BoundingBox.
reset(Vertices_2TCoords[0].Pos);
168 for (
u32 i=1; i<Vertices_2TCoords.size(); ++i)
175 if (Vertices_Tangents.empty())
176 BoundingBox.
reset(0,0,0);
179 BoundingBox.
reset(Vertices_Tangents[0].Pos);
180 for (
u32 i=1; i<Vertices_Tangents.size(); ++i)
199 for(
u32 n=0;n<Vertices_Standard.size();++n)
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;
206 Vertices_2TCoords.push_back(Vertex);
208 Vertices_Standard.clear();
218 for(
u32 n=0;n<Vertices_Standard.size();++n)
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;
225 Vertices_Tangents.push_back(Vertex);
227 Vertices_Standard.clear();
232 for(
u32 n=0;n<Vertices_2TCoords.size();++n)
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;
239 Vertices_Tangents.push_back(Vertex);
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;
359 virtual void append(
const void*
const vertices,
u32 numVertices,
const u16*
const indices,
u32 numIndices)
override {}
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;
458 u32 ChangedID_Vertex;
476 bool BoundingBoxNeedsRecalculated:1;
void setDebugName(const c8 *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 addInternalPoint(const vector3d< T > &p)
Adds a point to the bounding box.
Definition aabbox3d.hpp:74
void reset(T x, T y, T z)
Resets the bounding box to a one-point box.
Definition aabbox3d.hpp:50
u32 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
T * pointer()
Gets a pointer to the array.
Definition irrArray.hpp:381
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 video::E_INDEX_TYPE getIndexType() const override
Get type of index data which is stored in this meshbuffer.
Definition SSkinMeshBuffer.hpp:104
virtual const core::vector2df & getTCoords(u32 i) const override
returns texture coords of vertex i
Definition SSkinMeshBuffer.hpp:303
SSkinMeshBuffer(video::E_VERTEX_TYPE vt=video::EVT_STANDARD)
Default constructor.
Definition SSkinMeshBuffer.hpp:23
virtual u16 * getIndices() override
Get pointer to index array.
Definition SSkinMeshBuffer.hpp:116
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 video::SColor & getColor(u32 i) override
returns color of vertex i
Definition SSkinMeshBuffer.hpp:331
void convertToTangents()
Convert to tangents vertex type.
Definition SSkinMeshBuffer.hpp:214
virtual u32 getIndexCount() const override
Get index count.
Definition SSkinMeshBuffer.hpp:122
virtual EMESH_BUFFER_TYPE getType() const override
Returns type of the class implementing the IMeshBuffer.
Definition SSkinMeshBuffer.hpp:416
virtual void append(const IMeshBuffer *const other) override
append the meshbuffer to the current buffer
Definition SSkinMeshBuffer.hpp:362
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 void recalculateBoundingBox() override
Recalculate bounding box.
Definition SSkinMeshBuffer.hpp:140
virtual u32 getChangedID_Vertex() const override
Get the currently used ID for identification of changes.
Definition SSkinMeshBuffer.hpp:411
virtual u32 getChangedID_Index() const override
Get the currently used ID for identification of changes.
Definition SSkinMeshBuffer.hpp:413
virtual IMeshBuffer * createClone(int cloneFlags) const override
Create copy of the meshbuffer.
Definition SSkinMeshBuffer.hpp:422
virtual void append(const void *const vertices, u32 numVertices, const u16 *const indices, u32 numIndices) override
append the vertices and indices to the current buffer
Definition SSkinMeshBuffer.hpp:359
virtual void setBoundingBox(const core::aabbox3df &box) override
Set bounding box.
Definition SSkinMeshBuffer.hpp:134
virtual core::vector3df & getNormal(u32 i) override
returns normal of vertex i
Definition SSkinMeshBuffer.hpp:289
virtual u32 getVertexCount() const override
Get vertex count.
Definition SSkinMeshBuffer.hpp:89
virtual void * getVertices() override
Get pointer to vertex array.
Definition SSkinMeshBuffer.hpp:75
virtual const core::vector3df & getNormal(u32 i) const override
returns normal of vertex i
Definition SSkinMeshBuffer.hpp:275
virtual const video::SMaterial & getMaterial() const override
Get Material of this buffer.
Definition SSkinMeshBuffer.hpp:35
void convertTo2TCoords()
Convert to 2tcoords vertex type.
Definition SSkinMeshBuffer.hpp:195
virtual const core::aabbox3d< f32 > & getBoundingBox() const override
Get bounding box.
Definition SSkinMeshBuffer.hpp:128
virtual const video::SColor & getColor(u32 i) const override
returns color of vertex i
Definition SSkinMeshBuffer.hpp:345
virtual core::vector3df & getPosition(u32 i) override
returns position of vertex i
Definition SSkinMeshBuffer.hpp:261
virtual video::S3DVertex * getVertex(u32 index)
Get standard vertex at given index.
Definition SSkinMeshBuffer.hpp:47
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const override
get the current hardware mapping hint for vertex buffers
Definition SSkinMeshBuffer.hpp:365
virtual E_PRIMITIVE_TYPE getPrimitiveType() const override
Get the kind of primitive geometry which is used by the meshbuffer.
Definition SSkinMeshBuffer.hpp:397
virtual const core::vector3df & getPosition(u32 i) const override
returns position of vertex i
Definition SSkinMeshBuffer.hpp:247
virtual video::SMaterial & getMaterial() override
Get Material of this buffer.
Definition SSkinMeshBuffer.hpp:41
virtual const u16 * getIndices() const override
Get pointer to index array.
Definition SSkinMeshBuffer.hpp:110
virtual const void * getVertices() const override
Get pointer to vertex array.
Definition SSkinMeshBuffer.hpp:61
virtual video::E_VERTEX_TYPE getVertexType() const override
Get vertex type.
Definition SSkinMeshBuffer.hpp:189
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const override
get the current hardware mapping hint for index buffers
Definition SSkinMeshBuffer.hpp:371
virtual core::vector2df & getTCoords(u32 i) override
returns texture coords of vertex i
Definition SSkinMeshBuffer.hpp:317
virtual void setDirty(E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX) override
flags the mesh as changed, reloads hardware buffers
Definition SSkinMeshBuffer.hpp:403
virtual void setPrimitiveType(E_PRIMITIVE_TYPE type) override
Describe what kind of primitive geometry is used by the meshbuffer.
Definition SSkinMeshBuffer.hpp:391
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 Nirtcpp engine.
Definition S3DVertex.hpp:45
core::vector3df Normal
Normal vector.
Definition S3DVertex.hpp:64
SColor Color
Color.
Definition S3DVertex.hpp:67
core::vector2d< f32 > TCoords
Texture coordinates.
Definition S3DVertex.hpp:70
core::vector3df Pos
Position.
Definition S3DVertex.hpp:61
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
@ EBT_INDEX
Change the index mapping.
Definition EHardwareBufferFlags.hpp:35
@ 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
E_HARDWARE_MAPPING
Definition EHardwareBufferFlags.hpp:14
@ EHM_NEVER
Don't store on the hardware.
Definition EHardwareBufferFlags.hpp:16
EMESH_BUFFER_TYPE
An enumeration for all types of built-in mesh buffers.
Definition EMeshBufferTypes.hpp:18
E_VERTEX_TYPE
Enumeration for all vertex types there are.
Definition S3DVertex.hpp:19
@ EVT_2TCOORDS
Vertex with two texture coordinates, video::S3DVertex2TCoords.
Definition S3DVertex.hpp:25
@ EVT_STANDARD
Standard vertex type used by the Nirtcpp engine, video::S3DVertex.
Definition S3DVertex.hpp:21
@ EVT_TANGENTS
Vertex with a tangent and binormal vector, video::S3DVertexTangents.
Definition S3DVertex.hpp:31
As of Nirtcpp 1.6, position2d is a synonym for vector2d.
Definition vector3d.hpp:11
unsigned short u16
16 bit unsigned variable.
Definition irrTypes.hpp:46
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.hpp:64