// Copyright (C) 2002-2006 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 { //! A mesh buffer able to choose between //! S3DVertex2TCoords, S3DVertex and S3DVertexTangents at runtime struct SSkinMeshBuffer : public IMeshBuffer { SSkinMeshBuffer(video::E_VERTEX_TYPE vt=video::EVT_STANDARD) : VertexType(vt) { #ifdef _DEBUG setDebugName("SSkinMeshBuffer"); #endif } virtual ~SSkinMeshBuffer() {} 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 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& getBoundingBox() const { return BoundingBox; } virtual void setBoundingBox( const core::aabbox3df& box) { BoundingBox = box; } virtual void recalculateBoundingBox() { 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_Tangents; core::array Vertices_2TCoords; core::array Vertices_Standard; core::array Indices; core::aabbox3d BoundingBox; }; } // end namespace scene } // end namespace irr #endif