Loading...
Searching...
No Matches
SSkinMeshBuffer.h
Go to the documentation of this file.
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_SKIN_MESH_BUFFER_H_INCLUDED__
#define __I_SKIN_MESH_BUFFER_H_INCLUDED__
#include "IMeshBuffer.h"
#include "S3DVertex.h"
namespace irr
{
namespace scene
{
struct SSkinMeshBuffer : public IMeshBuffer
{
SSkinMeshBuffer(video::E_VERTEX_TYPE vt=video::EVT_STANDARD) :
ChangedID_Vertex(1), ChangedID_Index(1), VertexType(vt),
MappingHint_Vertex(EHM_NEVER), MappingHint_Index(EHM_NEVER),
BoundingBoxNeedsRecalculated(true)
{
#ifdef _DEBUG
setDebugName("SSkinMeshBuffer");
#endif
}
virtual const video::SMaterial& getMaterial() const
{
return Material;
}
virtual video::SMaterial& getMaterial()
{
return Material;
}
virtual video::S3DVertex *getVertex(u32 index)
{
switch (VertexType)
{
case video::EVT_2TCOORDS:
return (video::S3DVertex*)&Vertices_2TCoords[index];
case video::EVT_TANGENTS:
return (video::S3DVertex*)&Vertices_Tangents[index];
default:
return &Vertices_Standard[index];
}
}
virtual const void* getVertices() const
{
switch (VertexType)
{
case video::EVT_2TCOORDS:
return Vertices_2TCoords.const_pointer();
case video::EVT_TANGENTS:
return Vertices_Tangents.const_pointer();
default:
return Vertices_Standard.const_pointer();
}
}
virtual void* getVertices()
{
switch (VertexType)
{
case video::EVT_2TCOORDS:
return Vertices_2TCoords.pointer();
case video::EVT_TANGENTS:
return Vertices_Tangents.pointer();
default:
return Vertices_Standard.pointer();
}
}
virtual u32 getVertexCount() const
{
switch (VertexType)
{
case video::EVT_2TCOORDS:
return Vertices_2TCoords.size();
case video::EVT_TANGENTS:
return Vertices_Tangents.size();
default:
return Vertices_Standard.size();
}
}
virtual video::E_INDEX_TYPE getIndexType() const
{
return video::EIT_16BIT;
}
virtual const u16* getIndices() const
{
return Indices.const_pointer();
}
virtual u16* getIndices()
{
return Indices.pointer();
}
virtual u32 getIndexCount() const
{
return Indices.size();
}
virtual const core::aabbox3d<f32>& getBoundingBox() const
{
return BoundingBox;
}
virtual void setBoundingBox( const core::aabbox3df& box)
{
BoundingBox = box;
}
virtual void recalculateBoundingBox()
{
if(!BoundingBoxNeedsRecalculated)
return;
BoundingBoxNeedsRecalculated = false;
switch (VertexType)
{
case video::EVT_STANDARD:
{
if (Vertices_Standard.empty())
BoundingBox.reset(0,0,0);
else
{
BoundingBox.reset(Vertices_Standard[0].Pos);
for (u32 i=1; i<Vertices_Standard.size(); ++i)
BoundingBox.addInternalPoint(Vertices_Standard[i].Pos);
}
break;
}
case video::EVT_2TCOORDS:
{
if (Vertices_2TCoords.empty())
BoundingBox.reset(0,0,0);
else
{
BoundingBox.reset(Vertices_2TCoords[0].Pos);
for (u32 i=1; i<Vertices_2TCoords.size(); ++i)
BoundingBox.addInternalPoint(Vertices_2TCoords[i].Pos);
}
break;
}
case video::EVT_TANGENTS:
{
if (Vertices_Tangents.empty())
BoundingBox.reset(0,0,0);
else
{
BoundingBox.reset(Vertices_Tangents[0].Pos);
for (u32 i=1; i<Vertices_Tangents.size(); ++i)
BoundingBox.addInternalPoint(Vertices_Tangents[i].Pos);
}
break;
}
}
}
virtual video::E_VERTEX_TYPE getVertexType() const
{
return VertexType;
}
virtual void convertTo2TCoords()
{
if (VertexType==video::EVT_STANDARD)
{
for(u32 n=0;n<Vertices_Standard.size();++n)
{
video::S3DVertex2TCoords Vertex;
Vertex.Color=Vertices_Standard[n].Color;
Vertex.Pos=Vertices_Standard[n].Pos;
Vertex.Normal=Vertices_Standard[n].Normal;
Vertex.TCoords=Vertices_Standard[n].TCoords;
Vertices_2TCoords.push_back(Vertex);
}
Vertices_Standard.clear();
VertexType=video::EVT_2TCOORDS;
}
}
virtual void convertToTangents()
{
if (VertexType==video::EVT_STANDARD)
{
for(u32 n=0;n<Vertices_Standard.size();++n)
{
video::S3DVertexTangents Vertex;
Vertex.Color=Vertices_Standard[n].Color;
Vertex.Pos=Vertices_Standard[n].Pos;
Vertex.Normal=Vertices_Standard[n].Normal;
Vertex.TCoords=Vertices_Standard[n].TCoords;
Vertices_Tangents.push_back(Vertex);
}
Vertices_Standard.clear();
VertexType=video::EVT_TANGENTS;
}
else if (VertexType==video::EVT_2TCOORDS)
{
for(u32 n=0;n<Vertices_2TCoords.size();++n)
{
video::S3DVertexTangents Vertex;
Vertex.Color=Vertices_2TCoords[n].Color;
Vertex.Pos=Vertices_2TCoords[n].Pos;
Vertex.Normal=Vertices_2TCoords[n].Normal;
Vertex.TCoords=Vertices_2TCoords[n].TCoords;
Vertices_Tangents.push_back(Vertex);
}
Vertices_2TCoords.clear();
VertexType=video::EVT_TANGENTS;
}
}
virtual const core::vector3df& getPosition(u32 i) const
{
switch (VertexType)
{
case video::EVT_2TCOORDS:
return Vertices_2TCoords[i].Pos;
case video::EVT_TANGENTS:
return Vertices_Tangents[i].Pos;
default:
return Vertices_Standard[i].Pos;
}
}
virtual core::vector3df& getPosition(u32 i)
{
switch (VertexType)
{
case video::EVT_2TCOORDS:
return Vertices_2TCoords[i].Pos;
case video::EVT_TANGENTS:
return Vertices_Tangents[i].Pos;
default:
return Vertices_Standard[i].Pos;
}
}
virtual const core::vector3df& getNormal(u32 i) const
{
switch (VertexType)
{
case video::EVT_2TCOORDS:
return Vertices_2TCoords[i].Normal;
case video::EVT_TANGENTS:
return Vertices_Tangents[i].Normal;
default:
return Vertices_Standard[i].Normal;
}
}
virtual core::vector3df& getNormal(u32 i)
{
switch (VertexType)
{
case video::EVT_2TCOORDS:
return Vertices_2TCoords[i].Normal;
case video::EVT_TANGENTS:
return Vertices_Tangents[i].Normal;
default:
return Vertices_Standard[i].Normal;
}
}
virtual const core::vector2df& getTCoords(u32 i) const
{
switch (VertexType)
{
case video::EVT_2TCOORDS:
return Vertices_2TCoords[i].TCoords;
case video::EVT_TANGENTS:
return Vertices_Tangents[i].TCoords;
default:
return Vertices_Standard[i].TCoords;
}
}
virtual core::vector2df& getTCoords(u32 i)
{
switch (VertexType)
{
case video::EVT_2TCOORDS:
return Vertices_2TCoords[i].TCoords;
case video::EVT_TANGENTS:
return Vertices_Tangents[i].TCoords;
default:
return Vertices_Standard[i].TCoords;
}
}
virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) {}
virtual void append(const IMeshBuffer* const other) {}
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const
{
return MappingHint_Vertex;
}
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const
{
return MappingHint_Index;
}
virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX )
{
if (Buffer==EBT_VERTEX)
MappingHint_Vertex=NewMappingHint;
else if (Buffer==EBT_INDEX)
MappingHint_Index=NewMappingHint;
else if (Buffer==EBT_VERTEX_AND_INDEX)
{
MappingHint_Vertex=NewMappingHint;
MappingHint_Index=NewMappingHint;
}
}
virtual void setDirty(E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX)
{
if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_VERTEX)
++ChangedID_Vertex;
if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_INDEX)
++ChangedID_Index;
}
virtual u32 getChangedID_Vertex() const {return ChangedID_Vertex;}
virtual u32 getChangedID_Index() const {return ChangedID_Index;}
void boundingBoxNeedsRecalculated(void) { BoundingBoxNeedsRecalculated = true; }
core::array<video::S3DVertexTangents> Vertices_Tangents;
core::array<video::S3DVertex2TCoords> Vertices_2TCoords;
core::array<video::S3DVertex> Vertices_Standard;
core::array<u16> Indices;
u32 ChangedID_Vertex;
u32 ChangedID_Index;
//ISkinnedMesh::SJoint *AttachedJoint;
core::matrix4 Transformation;
video::SMaterial Material;
video::E_VERTEX_TYPE VertexType;
core::aabbox3d<f32> BoundingBox;
// hardware mapping hint
E_HARDWARE_MAPPING MappingHint_Vertex:3;
E_HARDWARE_MAPPING MappingHint_Index:3;
bool BoundingBoxNeedsRecalculated:1;
};
} // end namespace scene
} // end namespace irr
#endif
IMeshBuffer.h
S3DVertex.h
irr::IReferenceCounted::setDebugName
void setDebugName(const c8 *newName)
Sets the debug name of the object.
Definition IReferenceCounted.h:153
irr::core::aabbox3d
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.h:22
irr::core::array
Self reallocating template array (like stl vector) with additional features.
Definition irrArray.h:23
irr::scene::IMeshBuffer
Struct for holding a mesh with a single material.
Definition IMeshBuffer.h:40
irr::video::SMaterial
Struct for holding parameters for a material renderer.
Definition SMaterial.h:227
irr::core::vector3df
vector3d< f32 > vector3df
Typedef for a f32 3d vector.
Definition vector3d.h:445
irr::core::vector2df
vector2d< f32 > vector2df
Typedef for f32 2d vector.
Definition vector2d.h:323
irr::core::matrix4
CMatrix4< f32 > matrix4
Typedef for f32 matrix.
Definition matrix4.h:2235
irr::core::aabbox3df
aabbox3d< f32 > aabbox3df
Typedef for a f32 3d bounding box.
Definition aabbox3d.h:324
irr::scene
All scene management can be found in this namespace: Mesh loading, special scene nodes like octrees a...
Definition CDynamicMeshBuffer.h:16
irr::scene::E_BUFFER_TYPE
E_BUFFER_TYPE
Definition EHardwareBufferFlags.h:29
irr::scene::EBT_VERTEX_AND_INDEX
@ EBT_VERTEX_AND_INDEX
Change both vertex and index mapping to the same value.
Definition EHardwareBufferFlags.h:37
irr::scene::EBT_INDEX
@ EBT_INDEX
Change the index mapping.
Definition EHardwareBufferFlags.h:35
irr::scene::EBT_VERTEX
@ EBT_VERTEX
Change the vertex mapping.
Definition EHardwareBufferFlags.h:33
irr::scene::E_HARDWARE_MAPPING
E_HARDWARE_MAPPING
Definition EHardwareBufferFlags.h:14
irr::scene::EHM_NEVER
@ EHM_NEVER
Don't store on the hardware.
Definition EHardwareBufferFlags.h:16
irr::video::E_VERTEX_TYPE
E_VERTEX_TYPE
Enumeration for all vertex types there are.
Definition S3DVertex.h:19
irr::video::EVT_2TCOORDS
@ EVT_2TCOORDS
Vertex with two texture coordinates, video::S3DVertex2TCoords.
Definition S3DVertex.h:25
irr::video::EVT_TANGENTS
@ EVT_TANGENTS
Vertex with a tangent and binormal vector, video::S3DVertexTangents.
Definition S3DVertex.h:29
irr::video::EVT_STANDARD
@ EVT_STANDARD
Standard vertex type used by the Irrlicht engine, video::S3DVertex.
Definition S3DVertex.h:21
irr::video::E_INDEX_TYPE
E_INDEX_TYPE
Definition SVertexIndex.h:16
irr::video::EIT_16BIT
@ EIT_16BIT
Definition SVertexIndex.h:17
irr
Everything in the Irrlicht Engine can be found in this namespace.
Definition aabbox3d.h:13
irr::u32
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.h:58
irr::u16
unsigned short u16
16 bit unsigned variable.
Definition irrTypes.h:40
irr::scene::SSkinMeshBuffer::getVertexCount
virtual u32 getVertexCount() const
Get vertex count.
Definition SSkinMeshBuffer.h:87
irr::scene::SSkinMeshBuffer::getIndexType
virtual video::E_INDEX_TYPE getIndexType() const
Get type of index data which is stored in this meshbuffer.
Definition SSkinMeshBuffer.h:102
irr::scene::SSkinMeshBuffer::BoundingBoxNeedsRecalculated
bool BoundingBoxNeedsRecalculated
Definition SSkinMeshBuffer.h:396
irr::scene::SSkinMeshBuffer::BoundingBox
core::aabbox3d< f32 > BoundingBox
Definition SSkinMeshBuffer.h:390
irr::scene::SSkinMeshBuffer::getHardwareMappingHint_Vertex
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const
get the current hardware mapping hint for vertex buffers
Definition SSkinMeshBuffer.h:335
irr::scene::SSkinMeshBuffer::Material
video::SMaterial Material
Definition SSkinMeshBuffer.h:387
irr::scene::SSkinMeshBuffer::Vertices_Standard
core::array< video::S3DVertex > Vertices_Standard
Definition SSkinMeshBuffer.h:378
irr::scene::SSkinMeshBuffer::getIndices
virtual u16 * getIndices()
Get pointer to index array.
Definition SSkinMeshBuffer.h:114
irr::scene::SSkinMeshBuffer::Vertices_2TCoords
core::array< video::S3DVertex2TCoords > Vertices_2TCoords
Definition SSkinMeshBuffer.h:377
irr::scene::SSkinMeshBuffer::getTCoords
virtual const core::vector2df & getTCoords(u32 i) const
returns texture coords of vertex i
Definition SSkinMeshBuffer.h:301
irr::scene::SSkinMeshBuffer::MappingHint_Index
E_HARDWARE_MAPPING MappingHint_Index
Definition SSkinMeshBuffer.h:394
irr::scene::SSkinMeshBuffer::convertTo2TCoords
virtual void convertTo2TCoords()
Convert to 2tcoords vertex type.
Definition SSkinMeshBuffer.h:193
irr::scene::SSkinMeshBuffer::getHardwareMappingHint_Index
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const
get the current hardware mapping hint for index buffers
Definition SSkinMeshBuffer.h:341
irr::scene::SSkinMeshBuffer::VertexType
video::E_VERTEX_TYPE VertexType
Definition SSkinMeshBuffer.h:388
irr::scene::SSkinMeshBuffer::append
virtual void append(const IMeshBuffer *const other)
append the meshbuffer to the current buffer
Definition SSkinMeshBuffer.h:332
irr::scene::SSkinMeshBuffer::getChangedID_Index
virtual u32 getChangedID_Index() const
Get the currently used ID for identification of changes.
Definition SSkinMeshBuffer.h:371
irr::scene::SSkinMeshBuffer::Indices
core::array< u16 > Indices
Definition SSkinMeshBuffer.h:379
irr::scene::SSkinMeshBuffer::getVertices
virtual const void * getVertices() const
Get pointer to vertex array.
Definition SSkinMeshBuffer.h:59
irr::scene::SSkinMeshBuffer::getPosition
virtual const core::vector3df & getPosition(u32 i) const
returns position of vertex i
Definition SSkinMeshBuffer.h:245
irr::scene::SSkinMeshBuffer::getNormal
virtual core::vector3df & getNormal(u32 i)
returns normal of vertex i
Definition SSkinMeshBuffer.h:287
irr::scene::SSkinMeshBuffer::getTCoords
virtual core::vector2df & getTCoords(u32 i)
returns texture coords of vertex i
Definition SSkinMeshBuffer.h:315
irr::scene::SSkinMeshBuffer::getVertexType
virtual video::E_VERTEX_TYPE getVertexType() const
Get vertex type.
Definition SSkinMeshBuffer.h:187
irr::scene::SSkinMeshBuffer::getVertices
virtual void * getVertices()
Get pointer to vertex array.
Definition SSkinMeshBuffer.h:73
irr::scene::SSkinMeshBuffer::getBoundingBox
virtual const core::aabbox3d< f32 > & getBoundingBox() const
Get bounding box.
Definition SSkinMeshBuffer.h:126
irr::scene::SSkinMeshBuffer::getChangedID_Vertex
virtual u32 getChangedID_Vertex() const
Get the currently used ID for identification of changes.
Definition SSkinMeshBuffer.h:369
irr::scene::SSkinMeshBuffer::convertToTangents
virtual void convertToTangents()
Convert to tangents vertex type.
Definition SSkinMeshBuffer.h:212
irr::scene::SSkinMeshBuffer::Vertices_Tangents
core::array< video::S3DVertexTangents > Vertices_Tangents
Definition SSkinMeshBuffer.h:376
irr::scene::SSkinMeshBuffer::SSkinMeshBuffer
SSkinMeshBuffer(video::E_VERTEX_TYPE vt=video::EVT_STANDARD)
Default constructor.
Definition SSkinMeshBuffer.h:22
irr::scene::SSkinMeshBuffer::MappingHint_Vertex
E_HARDWARE_MAPPING MappingHint_Vertex
Definition SSkinMeshBuffer.h:393
irr::scene::SSkinMeshBuffer::setBoundingBox
virtual void setBoundingBox(const core::aabbox3df &box)
Set bounding box.
Definition SSkinMeshBuffer.h:132
irr::scene::SSkinMeshBuffer::setHardwareMappingHint
virtual void setHardwareMappingHint(E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX)
set the hardware mapping hint, for driver
Definition SSkinMeshBuffer.h:347
irr::scene::SSkinMeshBuffer::getPosition
virtual core::vector3df & getPosition(u32 i)
returns position of vertex i
Definition SSkinMeshBuffer.h:259
irr::scene::SSkinMeshBuffer::getVertex
virtual video::S3DVertex * getVertex(u32 index)
Get standard vertex at given index.
Definition SSkinMeshBuffer.h:45
irr::scene::SSkinMeshBuffer::getMaterial
virtual video::SMaterial & getMaterial()
Get Material of this buffer.
Definition SSkinMeshBuffer.h:39
irr::scene::SSkinMeshBuffer::getMaterial
virtual const video::SMaterial & getMaterial() const
Get Material of this buffer.
Definition SSkinMeshBuffer.h:33
irr::scene::SSkinMeshBuffer::getIndexCount
virtual u32 getIndexCount() const
Get index count.
Definition SSkinMeshBuffer.h:120
irr::scene::SSkinMeshBuffer::Transformation
core::matrix4 Transformation
Definition SSkinMeshBuffer.h:385
irr::scene::SSkinMeshBuffer::getNormal
virtual const core::vector3df & getNormal(u32 i) const
returns normal of vertex i
Definition SSkinMeshBuffer.h:273
irr::scene::SSkinMeshBuffer::append
virtual void append(const void *const vertices, u32 numVertices, const u16 *const indices, u32 numIndices)
append the vertices and indices to the current buffer
Definition SSkinMeshBuffer.h:329
irr::scene::SSkinMeshBuffer::setDirty
virtual void setDirty(E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX)
flags the mesh as changed, reloads hardware buffers
Definition SSkinMeshBuffer.h:361
irr::scene::SSkinMeshBuffer::boundingBoxNeedsRecalculated
void boundingBoxNeedsRecalculated(void)
Call this after changing the positions of any vertex.
Definition SSkinMeshBuffer.h:374
irr::scene::SSkinMeshBuffer::getIndices
virtual const u16 * getIndices() const
Get pointer to index array.
Definition SSkinMeshBuffer.h:108
irr::scene::SSkinMeshBuffer::recalculateBoundingBox
virtual void recalculateBoundingBox()
Recalculate bounding box.
Definition SSkinMeshBuffer.h:138
irr::scene::SSkinMeshBuffer::ChangedID_Vertex
u32 ChangedID_Vertex
Definition SSkinMeshBuffer.h:381
irr::scene::SSkinMeshBuffer::ChangedID_Index
u32 ChangedID_Index
Definition SSkinMeshBuffer.h:382
irr::video::S3DVertex2TCoords
Vertex with two texture coordinates.
Definition S3DVertex.h:110
irr::video::S3DVertex
standard vertex used by the Irrlicht engine.
Definition S3DVertex.h:43
irr::video::S3DVertex::TCoords
core::vector2d< f32 > TCoords
Texture coordinates.
Definition S3DVertex.h:66
irr::video::S3DVertex::Normal
core::vector3df Normal
Normal vector.
Definition S3DVertex.h:60
irr::video::S3DVertex::Color
SColor Color
Color.
Definition S3DVertex.h:63
irr::video::S3DVertex::Pos
core::vector3df Pos
Position.
Definition S3DVertex.h:57
irr::video::S3DVertexTangents
Vertex with a tangent and binormal vector.
Definition S3DVertex.h:188
- Irrlicht Engine Documentation © 2003-2012 by Nikolaus Gebhardt. Generated on for Irrlicht 3D Engine by Doxygen 1.15.0