Some header files for a new meshbuffer, not being used yet, till I commit the changes to irrlicht.
new meshbuffer has split vertex and index buffers and supports switching between different vertex and index(16/32bit) types at runtime. some parts like CSpecific(Vertex/Index)List may need to be optimized. may change to use plain switches, having options (like 32bit) able to be undefined. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1444 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
878c280ccb
commit
bea9e087fd
|
@ -0,0 +1,120 @@
|
|||
// Copyright (C) 2002-2008 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __C_DYNAMIC_MESHBUFFER_H_INCLUDED__
|
||||
#define __C_DYNAMIC_MESHBUFFER_H_INCLUDED__
|
||||
|
||||
#include "IDynamicMeshBuffer.h"
|
||||
|
||||
#include "CVertexBuffer.h"
|
||||
#include "CIndexBuffer.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
|
||||
|
||||
class CDynamicMeshBuffer: public IDynamicMeshBuffer
|
||||
{
|
||||
|
||||
IVertexBuffer *VertexBuffer;
|
||||
IIndexBuffer *IndexBuffer;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
CDynamicMeshBuffer(video::E_VERTEX_TYPE vertexType, video::E_INDEX_TYPE indexType)
|
||||
{
|
||||
VertexBuffer=new CVertexBuffer(vertexType);
|
||||
IndexBuffer=new CIndexBuffer(indexType);
|
||||
|
||||
}
|
||||
|
||||
~CDynamicMeshBuffer()
|
||||
{
|
||||
if (VertexBuffer) VertexBuffer->drop();
|
||||
if (IndexBuffer) IndexBuffer->drop();
|
||||
}
|
||||
|
||||
|
||||
virtual IVertexBuffer &getVertexBuffer() const
|
||||
{
|
||||
return *VertexBuffer;
|
||||
}
|
||||
virtual IIndexBuffer &getIndexBuffer() const
|
||||
{
|
||||
return *IndexBuffer;
|
||||
}
|
||||
|
||||
virtual void setVertexBuffer(IVertexBuffer *newVertexBuffer)
|
||||
{
|
||||
if (newVertexBuffer) newVertexBuffer->grab();
|
||||
if (VertexBuffer) VertexBuffer->drop();
|
||||
|
||||
VertexBuffer=newVertexBuffer;
|
||||
}
|
||||
|
||||
virtual void setIndexBuffer(IIndexBuffer *newIndexBuffer)
|
||||
{
|
||||
if (newIndexBuffer) newIndexBuffer->grab();
|
||||
if (IndexBuffer) IndexBuffer->drop();
|
||||
|
||||
IndexBuffer=newIndexBuffer;
|
||||
}
|
||||
|
||||
|
||||
//! Get Material of this buffer.
|
||||
virtual const video::SMaterial& getMaterial() const
|
||||
{
|
||||
return Material;
|
||||
}
|
||||
|
||||
//! Get Material of this buffer.
|
||||
virtual video::SMaterial& getMaterial()
|
||||
{
|
||||
return Material;
|
||||
}
|
||||
|
||||
//! Get bounding box
|
||||
virtual const core::aabbox3d<f32>& getBoundingBox() const
|
||||
{
|
||||
return BoundingBox;
|
||||
}
|
||||
|
||||
//! Set bounding box
|
||||
virtual void setBoundingBox( const core::aabbox3df& box)
|
||||
{
|
||||
BoundingBox = box;
|
||||
}
|
||||
|
||||
//! Recalculate bounding box
|
||||
virtual void recalculateBoundingBox()
|
||||
{
|
||||
|
||||
if (!getVertexBuffer().size())
|
||||
BoundingBox.reset(0,0,0);
|
||||
else
|
||||
{
|
||||
BoundingBox.reset(getVertexBuffer()[0].Pos);
|
||||
for (u32 i=1; i<getVertexBuffer().size(); ++i)
|
||||
BoundingBox.addInternalPoint(getVertexBuffer()[i].Pos);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
video::SMaterial Material;
|
||||
core::aabbox3d<f32> BoundingBox;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,220 @@
|
|||
// Copyright (C) 2002-2008 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __C_INDEX_BUFFER_H_INCLUDED__
|
||||
#define __C_INDEX_BUFFER_H_INCLUDED__
|
||||
|
||||
#include "IIndexBuffer.h"
|
||||
|
||||
|
||||
namespace irr
|
||||
{
|
||||
|
||||
|
||||
namespace scene
|
||||
{
|
||||
|
||||
|
||||
class CIndexBuffer : public IIndexBuffer
|
||||
{
|
||||
|
||||
class IIndexList
|
||||
{
|
||||
public:
|
||||
virtual u32 stride() const =0;
|
||||
virtual u32 size() const=0;
|
||||
virtual void push_back (const u32 &element) =0;
|
||||
virtual const u32 operator [](u32 index) const=0;
|
||||
virtual const u32 getLast() =0;
|
||||
virtual void setValue(u32 index, u32 value) =0;
|
||||
virtual void set_used(u32 usedNow) =0;
|
||||
virtual void reallocate(u32 new_size)=0;
|
||||
virtual u32 allocated_size() const=0;
|
||||
virtual void* pointer() =0;
|
||||
virtual video::E_INDEX_TYPE getType()=0;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class CSpecificIndexList : public IIndexList
|
||||
{
|
||||
public:
|
||||
core::array<T> Indices;
|
||||
|
||||
virtual u32 stride() const {return sizeof(T);}
|
||||
|
||||
virtual u32 size() const
|
||||
{return Indices.size();}
|
||||
|
||||
virtual void push_back (const u32 &element)
|
||||
{Indices.push_back((T&)element);}
|
||||
|
||||
virtual const u32 operator [](u32 index) const
|
||||
{return (u32) (Indices[index]);}
|
||||
|
||||
virtual const u32 getLast()
|
||||
{return (u32)Indices.getLast();}
|
||||
|
||||
virtual void setValue(u32 index, u32 value)
|
||||
{
|
||||
Indices[index]=(T)value;
|
||||
}
|
||||
|
||||
|
||||
virtual void set_used(u32 usedNow)
|
||||
{Indices.set_used(usedNow);}
|
||||
|
||||
virtual void reallocate(u32 new_size)
|
||||
{Indices.reallocate(new_size);}
|
||||
|
||||
virtual u32 allocated_size() const
|
||||
{
|
||||
return Indices.allocated_size();
|
||||
}
|
||||
|
||||
virtual void* pointer() {return Indices.pointer();}
|
||||
|
||||
virtual video::E_INDEX_TYPE getType()
|
||||
{
|
||||
if (sizeof(T)==sizeof(u16)) return video::EIT_16BIT;
|
||||
return video::EIT_32BIT;
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
IIndexList *Indices;
|
||||
|
||||
CIndexBuffer(video::E_INDEX_TYPE IndexType) :Indices(0), MappingHint(EHM_NEVER), ChangedID(1)
|
||||
{
|
||||
setType(IndexType);
|
||||
}
|
||||
|
||||
~CIndexBuffer()
|
||||
{
|
||||
if (Indices)
|
||||
delete Indices;
|
||||
}
|
||||
|
||||
//virtual void setType(video::E_INDEX_TYPE IndexType);
|
||||
virtual void setType(video::E_INDEX_TYPE IndexType)
|
||||
{
|
||||
|
||||
IIndexList *NewIndices=0;
|
||||
|
||||
switch (IndexType)
|
||||
{
|
||||
case video::EIT_16BIT:
|
||||
{
|
||||
NewIndices=new CSpecificIndexList<u16>;
|
||||
break;
|
||||
}
|
||||
case video::EIT_32BIT:
|
||||
{
|
||||
NewIndices=new CSpecificIndexList<u32>;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Indices)
|
||||
{
|
||||
NewIndices->reallocate( Indices->size() );
|
||||
|
||||
for(u32 n=0;n<Indices->size();++n)
|
||||
NewIndices->push_back((*Indices)[n]);
|
||||
|
||||
delete Indices;
|
||||
}
|
||||
|
||||
Indices=NewIndices;
|
||||
}
|
||||
|
||||
|
||||
|
||||
virtual void* getData() {return Indices->pointer();}
|
||||
virtual video::E_INDEX_TYPE getType(){return Indices->getType();}
|
||||
|
||||
virtual u32 stride() const {return Indices->stride();}
|
||||
|
||||
virtual u32 size() const
|
||||
{
|
||||
return Indices->size();
|
||||
}
|
||||
|
||||
virtual void push_back (const u32 &element)
|
||||
{
|
||||
Indices->push_back(element);
|
||||
}
|
||||
|
||||
virtual const u32 operator [](u32 index) const
|
||||
{
|
||||
return (*Indices)[index];
|
||||
}
|
||||
|
||||
virtual const u32 getLast()
|
||||
{
|
||||
return Indices->getLast();
|
||||
}
|
||||
|
||||
virtual void setValue(u32 index, u32 value)
|
||||
{
|
||||
Indices->setValue(index, value);
|
||||
}
|
||||
|
||||
|
||||
virtual void set_used(u32 usedNow)
|
||||
{
|
||||
Indices->set_used(usedNow);
|
||||
}
|
||||
|
||||
virtual void reallocate(u32 new_size)
|
||||
{
|
||||
Indices->reallocate(new_size);
|
||||
}
|
||||
|
||||
virtual u32 allocated_size() const
|
||||
{
|
||||
return Indices->allocated_size();
|
||||
}
|
||||
|
||||
virtual void* pointer()
|
||||
{
|
||||
return Indices->pointer();
|
||||
}
|
||||
|
||||
//! get the current hardware mapping hint
|
||||
virtual const E_HARDWARE_MAPPING getHardwareMappingHint() const
|
||||
{
|
||||
return MappingHint;
|
||||
}
|
||||
|
||||
//! set the hardware mapping hint, for driver
|
||||
virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint )
|
||||
{
|
||||
MappingHint=NewMappingHint;
|
||||
}
|
||||
|
||||
//! flags the mesh as changed, reloads hardware buffers
|
||||
virtual void setDirty()
|
||||
{
|
||||
++ChangedID;
|
||||
}
|
||||
|
||||
//! Get the currently used ID for identification of changes.
|
||||
/** This shouldn't be used for anything outside the VideoDriver. */
|
||||
virtual const u32 getChangedID() const {return ChangedID;}
|
||||
|
||||
E_HARDWARE_MAPPING MappingHint;
|
||||
u32 ChangedID;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,208 @@
|
|||
// Copyright (C) 2002-2008 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __C_VERTEX_BUFFER_H_INCLUDED__
|
||||
#define __C_VERTEX_BUFFER_H_INCLUDED__
|
||||
|
||||
#include "IVertexBuffer.h"
|
||||
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
|
||||
|
||||
class CVertexBuffer : public IVertexBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
class IVertexList
|
||||
{
|
||||
public:
|
||||
virtual u32 stride() const =0;
|
||||
|
||||
virtual u32 size() const=0;
|
||||
virtual void push_back (const video::S3DVertex &element) =0;
|
||||
virtual video::S3DVertex& operator [](const u32 index) const=0;
|
||||
virtual video::S3DVertex& getLast() =0;
|
||||
virtual void set_used(u32 usedNow) =0;
|
||||
virtual void reallocate(u32 new_size)=0;
|
||||
virtual u32 allocated_size() const =0;
|
||||
virtual video::S3DVertex* pointer() =0;
|
||||
virtual video::E_VERTEX_TYPE getType()=0;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class CSpecificVertexList : public IVertexList
|
||||
{
|
||||
public:
|
||||
core::array<T> Vertices;
|
||||
|
||||
virtual u32 stride() const {return sizeof(T);}
|
||||
|
||||
virtual u32 size() const
|
||||
{return Vertices.size();}
|
||||
|
||||
virtual void push_back (const video::S3DVertex &element)
|
||||
{Vertices.push_back((T&)element);}
|
||||
|
||||
virtual video::S3DVertex& operator [](const u32 index) const
|
||||
{return (video::S3DVertex&)Vertices[index];}
|
||||
|
||||
virtual video::S3DVertex& getLast()
|
||||
{return (video::S3DVertex&)Vertices.getLast();}
|
||||
|
||||
virtual void set_used(u32 usedNow)
|
||||
{Vertices.set_used(usedNow);}
|
||||
|
||||
virtual void reallocate(u32 new_size)
|
||||
{Vertices.reallocate(new_size);}
|
||||
|
||||
virtual u32 allocated_size() const
|
||||
{
|
||||
return Vertices.allocated_size();
|
||||
}
|
||||
|
||||
virtual video::S3DVertex* pointer() {return Vertices.pointer();}
|
||||
|
||||
virtual video::E_VERTEX_TYPE getType(){return T().getType();}
|
||||
};
|
||||
|
||||
public:
|
||||
IVertexList *Vertices;
|
||||
|
||||
CVertexBuffer(video::E_VERTEX_TYPE vertexType) :Vertices(0), MappingHint(EHM_NEVER), ChangedID(1)
|
||||
{
|
||||
setType(vertexType);
|
||||
}
|
||||
|
||||
~CVertexBuffer()
|
||||
{
|
||||
if (Vertices)
|
||||
delete Vertices;
|
||||
}
|
||||
|
||||
|
||||
//virtual void setType(video::E_VERTEX_TYPE vertexType);
|
||||
|
||||
virtual void setType(video::E_VERTEX_TYPE vertexType)
|
||||
{
|
||||
|
||||
IVertexList *NewVertices=0;
|
||||
|
||||
switch (vertexType)
|
||||
{
|
||||
case video::EVT_STANDARD:
|
||||
{
|
||||
NewVertices=new CSpecificVertexList<video::S3DVertex>;
|
||||
break;
|
||||
}
|
||||
case video::EVT_2TCOORDS:
|
||||
{
|
||||
NewVertices=new CSpecificVertexList<video::S3DVertex2TCoords>;
|
||||
break;
|
||||
}
|
||||
case video::EVT_TANGENTS:
|
||||
{
|
||||
NewVertices=new CSpecificVertexList<video::S3DVertexTangents>;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (Vertices)
|
||||
{
|
||||
NewVertices->reallocate( Vertices->size() );
|
||||
|
||||
for(u32 n=0;n<Vertices->size();++n)
|
||||
NewVertices->push_back((*Vertices)[n]);
|
||||
|
||||
delete Vertices;
|
||||
}
|
||||
|
||||
Vertices=NewVertices;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
virtual void* getData() {return Vertices->pointer();}
|
||||
virtual video::E_VERTEX_TYPE getType(){return Vertices->getType();}
|
||||
|
||||
virtual u32 stride() const {return Vertices->stride();}
|
||||
|
||||
virtual u32 size() const
|
||||
{
|
||||
return Vertices->size();
|
||||
}
|
||||
|
||||
virtual void push_back (const video::S3DVertex &element)
|
||||
{
|
||||
Vertices->push_back(element);
|
||||
}
|
||||
|
||||
virtual video::S3DVertex& operator [](const u32 index) const
|
||||
{
|
||||
return (*Vertices)[index];
|
||||
}
|
||||
|
||||
virtual video::S3DVertex& getLast()
|
||||
{
|
||||
return Vertices->getLast();
|
||||
}
|
||||
|
||||
virtual void set_used(u32 usedNow)
|
||||
{
|
||||
Vertices->set_used(usedNow);
|
||||
}
|
||||
|
||||
virtual void reallocate(u32 new_size)
|
||||
{
|
||||
Vertices->reallocate(new_size);
|
||||
}
|
||||
|
||||
virtual u32 allocated_size() const
|
||||
{
|
||||
return Vertices->allocated_size();
|
||||
}
|
||||
|
||||
virtual video::S3DVertex* pointer()
|
||||
{
|
||||
return Vertices->pointer();
|
||||
}
|
||||
|
||||
//! get the current hardware mapping hint
|
||||
virtual const E_HARDWARE_MAPPING getHardwareMappingHint() const
|
||||
{
|
||||
return MappingHint;
|
||||
}
|
||||
|
||||
//! set the hardware mapping hint, for driver
|
||||
virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint )
|
||||
{
|
||||
MappingHint=NewMappingHint;
|
||||
}
|
||||
|
||||
//! flags the mesh as changed, reloads hardware buffers
|
||||
virtual void setDirty()
|
||||
{
|
||||
++ChangedID;
|
||||
}
|
||||
|
||||
//! Get the currently used ID for identification of changes.
|
||||
/** This shouldn't be used for anything outside the VideoDriver. */
|
||||
virtual const u32 getChangedID() const {return ChangedID;}
|
||||
|
||||
E_HARDWARE_MAPPING MappingHint;
|
||||
u32 ChangedID;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,209 @@
|
|||
// Copyright (C) 2002-2008 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __I_DYNAMIC_MESH_BUFFER_H_INCLUDED__
|
||||
#define __I_DYNAMIC_MESH_BUFFER_H_INCLUDED__
|
||||
|
||||
#include "IMeshBuffer.h"
|
||||
|
||||
|
||||
#include "IVertexBuffer.h"
|
||||
#include "IIndexBuffer.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
|
||||
/** a dynamic meshBuffer */
|
||||
class IDynamicMeshBuffer : public IMeshBuffer
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
virtual IVertexBuffer &getVertexBuffer() const =0;
|
||||
virtual IIndexBuffer &getIndexBuffer() const =0;
|
||||
|
||||
virtual void setVertexBuffer(IVertexBuffer *vertexBuffer) =0;
|
||||
virtual void setIndexBuffer(IIndexBuffer *indexBuffer) =0;
|
||||
|
||||
|
||||
//! Get the material of this meshbuffer
|
||||
/** \return Material of this buffer. */
|
||||
virtual video::SMaterial& getMaterial() = 0;
|
||||
|
||||
//! Get the material of this meshbuffer
|
||||
/** \return Material of this buffer. */
|
||||
virtual const video::SMaterial& getMaterial() const = 0;
|
||||
|
||||
|
||||
//! Get the axis aligned bounding box of this meshbuffer.
|
||||
/** \return Axis aligned bounding box of this buffer. */
|
||||
virtual const core::aabbox3df& getBoundingBox() const = 0;
|
||||
|
||||
//! Set axis aligned bounding box
|
||||
/** \param box User defined axis aligned bounding box to use
|
||||
for this buffer. */
|
||||
virtual void setBoundingBox(const core::aabbox3df& box) = 0;
|
||||
|
||||
//! Recalculates the bounding box. Should be called if the mesh changed.
|
||||
virtual void recalculateBoundingBox() = 0;
|
||||
|
||||
|
||||
|
||||
//! Append the vertices and indices to the current buffer
|
||||
/** Only works for compatible vertex types.
|
||||
\param vertices Pointer to a vertex array.
|
||||
\param numVertices Number of vertices in the array.
|
||||
\param indices Pointer to index array.
|
||||
\param numIndices Number of indices in array. */
|
||||
virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//! Append the meshbuffer to the current buffer
|
||||
/** Only works for compatible vertex types
|
||||
\param other Buffer to append to this one. */
|
||||
virtual void append(const IMeshBuffer* const other)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
// ------------------- To be removed? ------------------- //
|
||||
|
||||
|
||||
//! get the current hardware mapping hint
|
||||
virtual const E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const
|
||||
{
|
||||
return getVertexBuffer().getHardwareMappingHint();
|
||||
}
|
||||
|
||||
//! get the current hardware mapping hint
|
||||
virtual const E_HARDWARE_MAPPING getHardwareMappingHint_Index() const
|
||||
{
|
||||
return getIndexBuffer().getHardwareMappingHint();
|
||||
}
|
||||
|
||||
//! set the hardware mapping hint, for driver
|
||||
virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX )
|
||||
{
|
||||
if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_VERTEX)
|
||||
getVertexBuffer().setHardwareMappingHint(NewMappingHint);
|
||||
if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_INDEX)
|
||||
getIndexBuffer().setHardwareMappingHint(NewMappingHint);
|
||||
}
|
||||
|
||||
//! flags the mesh as changed, reloads hardware buffers
|
||||
virtual void setDirty(E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX)
|
||||
{
|
||||
if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_VERTEX)
|
||||
getVertexBuffer().setDirty();
|
||||
if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_INDEX)
|
||||
getIndexBuffer().setDirty();
|
||||
}
|
||||
|
||||
virtual const u32 getChangedID_Vertex() const
|
||||
{
|
||||
return getVertexBuffer().getChangedID();
|
||||
}
|
||||
|
||||
virtual const u32 getChangedID_Index() const
|
||||
{
|
||||
return getIndexBuffer().getChangedID();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ------------------- Old interface ------------------- //
|
||||
|
||||
//! Get type of vertex data which is stored in this meshbuffer.
|
||||
/** \return Vertex type of this buffer. */
|
||||
virtual video::E_VERTEX_TYPE getVertexType() const
|
||||
{
|
||||
return getVertexBuffer().getType();
|
||||
}
|
||||
|
||||
//! Get access to vertex data. The data is an array of vertices.
|
||||
/** Which vertex type is used can be determined by getVertexType().
|
||||
\return Pointer to array of vertices. */
|
||||
virtual const void* getVertices() const
|
||||
{
|
||||
return getVertexBuffer().getData();
|
||||
}
|
||||
|
||||
//! Get access to vertex data. The data is an array of vertices.
|
||||
/** Which vertex type is used can be determined by getVertexType().
|
||||
\return Pointer to array of vertices. */
|
||||
virtual void* getVertices()
|
||||
{
|
||||
return getVertexBuffer().getData();
|
||||
}
|
||||
|
||||
//! Get amount of vertices in meshbuffer.
|
||||
/** \return Number of vertices in this buffer. */
|
||||
virtual u32 getVertexCount() const
|
||||
{
|
||||
return getVertexBuffer().size();
|
||||
}
|
||||
|
||||
//! Get type of index data which is stored in this meshbuffer.
|
||||
/** \return Index type of this buffer. */
|
||||
virtual video::E_INDEX_TYPE getIndexType() const
|
||||
{
|
||||
return getIndexBuffer().getType();
|
||||
}
|
||||
|
||||
//! Get access to Indices.
|
||||
/** \return Pointer to indices array. */
|
||||
virtual const u16* getIndices() const
|
||||
{
|
||||
return (u16*)getIndexBuffer().getData();
|
||||
}
|
||||
|
||||
//! Get access to Indices.
|
||||
/** \return Pointer to indices array. */
|
||||
virtual u16* getIndices()
|
||||
{
|
||||
return (u16*)getIndexBuffer().getData();
|
||||
}
|
||||
|
||||
//! Get amount of indices in this meshbuffer.
|
||||
/** \return Number of indices in this buffer. */
|
||||
virtual u32 getIndexCount() const
|
||||
{
|
||||
return getIndexBuffer().size();
|
||||
}
|
||||
|
||||
//! returns position of vertex i
|
||||
virtual const core::vector3df& getPosition(u32 i) const
|
||||
{
|
||||
return getVertexBuffer()[i].Pos;
|
||||
}
|
||||
|
||||
//! returns position of vertex i
|
||||
virtual core::vector3df& getPosition(u32 i)
|
||||
{
|
||||
return getVertexBuffer()[i].Pos;
|
||||
}
|
||||
//! returns normal of vertex i
|
||||
virtual const core::vector3df& getNormal(u32 i) const
|
||||
{
|
||||
return getVertexBuffer()[i].Normal;
|
||||
}
|
||||
//! returns normal of vertex i
|
||||
virtual core::vector3df& getNormal(u32 i)
|
||||
{
|
||||
return getVertexBuffer()[i].Normal;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
// Copyright (C) 2002-2008 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __I_INDEX_BUFFER_H_INCLUDED__
|
||||
#define __I_INDEX_BUFFER_H_INCLUDED__
|
||||
|
||||
#include "IReferenceCounted.h"
|
||||
#include "irrArray.h"
|
||||
|
||||
#include "SVertexIndex.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
|
||||
namespace video
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
namespace scene
|
||||
{
|
||||
|
||||
class IIndexBuffer : public virtual IReferenceCounted
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void* getData()=0;
|
||||
|
||||
virtual video::E_INDEX_TYPE getType() =0;
|
||||
virtual void setType(video::E_INDEX_TYPE IndexType) =0;
|
||||
|
||||
|
||||
virtual u32 stride() const =0;
|
||||
|
||||
|
||||
|
||||
virtual u32 size() const=0;
|
||||
virtual void push_back (const u32 &element) =0;
|
||||
virtual const u32 operator [](u32 index) const=0;
|
||||
virtual const u32 getLast() =0;
|
||||
virtual void setValue(u32 index, u32 value) =0;
|
||||
virtual void set_used(u32 usedNow) =0;
|
||||
virtual void reallocate(u32 new_size)=0;
|
||||
virtual u32 allocated_size() const=0;
|
||||
|
||||
|
||||
|
||||
virtual void* pointer() =0;
|
||||
|
||||
|
||||
//! get the current hardware mapping hint
|
||||
virtual const E_HARDWARE_MAPPING getHardwareMappingHint() const = 0;
|
||||
|
||||
//! set the hardware mapping hint, for driver
|
||||
virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint ) = 0;
|
||||
|
||||
//! flags the meshbuffer as changed, reloads hardware buffers
|
||||
virtual void setDirty() = 0;
|
||||
|
||||
//! Get the currently used ID for identification of changes.
|
||||
/** This shouldn't be used for anything outside the VideoDriver. */
|
||||
virtual const u32 getChangedID() const = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
// Copyright (C) 2002-2008 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __I_VERTEX_BUFFER_H_INCLUDED__
|
||||
#define __I_VERTEX_BUFFER_H_INCLUDED__
|
||||
|
||||
#include "IReferenceCounted.h"
|
||||
#include "irrArray.h"
|
||||
#include "S3DVertex.h"
|
||||
|
||||
|
||||
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
|
||||
class IVertexBuffer : public virtual IReferenceCounted
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void* getData()=0;
|
||||
virtual video::E_VERTEX_TYPE getType() =0;
|
||||
virtual void setType(video::E_VERTEX_TYPE vertexType)=0;
|
||||
virtual u32 stride() const =0;
|
||||
virtual u32 size() const=0;
|
||||
virtual void push_back (const video::S3DVertex &element) =0;
|
||||
virtual video::S3DVertex& operator [](const u32 index) const=0;
|
||||
virtual video::S3DVertex& getLast() =0;
|
||||
virtual void set_used(u32 usedNow) =0;
|
||||
virtual void reallocate(u32 new_size)=0;
|
||||
virtual u32 allocated_size() const=0;
|
||||
virtual video::S3DVertex* pointer() =0;
|
||||
|
||||
//! get the current hardware mapping hint
|
||||
virtual const E_HARDWARE_MAPPING getHardwareMappingHint() const = 0;
|
||||
|
||||
//! set the hardware mapping hint, for driver
|
||||
virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint ) = 0;
|
||||
|
||||
//! flags the meshbuffer as changed, reloads hardware buffers
|
||||
virtual void setDirty() = 0;
|
||||
|
||||
//! Get the currently used ID for identification of changes.
|
||||
/** This shouldn't be used for anything outside the VideoDriver. */
|
||||
virtual const u32 getChangedID() const = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
// Copyright (C) 2002-2008 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __S_VERTEX_INDEX_H_INCLUDED__
|
||||
#define __S_VERTEX_INDEX_H_INCLUDED__
|
||||
|
||||
#include "irrTypes.h"
|
||||
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
enum E_INDEX_TYPE
|
||||
{
|
||||
EIT_16BIT = 0,
|
||||
EIT_32BIT
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
//! vertex index used by the Irrlicht engine.
|
||||
template <class T>
|
||||
struct SSpecificVertexIndex
|
||||
{
|
||||
T Index;
|
||||
|
||||
|
||||
//! default constructor
|
||||
SSpecificVertexIndex() {}
|
||||
|
||||
//! constructor
|
||||
SSpecificVertexIndex(u32 _index) :Index(_index) {}
|
||||
|
||||
|
||||
bool operator==(const SSpecificVertexIndex& other) const
|
||||
{
|
||||
return (Index == other.Index);
|
||||
}
|
||||
|
||||
bool operator!=(const SSpecificVertexIndex& other) const
|
||||
{
|
||||
return (Index != other.Index);
|
||||
}
|
||||
|
||||
bool operator<(const SSpecificVertexIndex& other) const
|
||||
{
|
||||
return (Index < other.Index);
|
||||
}
|
||||
|
||||
|
||||
|
||||
SSpecificVertexIndex operator+(const u32& other) const
|
||||
{
|
||||
return SSpecificVertexIndex(Index + other);
|
||||
}
|
||||
|
||||
operator const u32() const
|
||||
{
|
||||
return (const u32)Index;
|
||||
}
|
||||
|
||||
E_INDEX_TYPE getType() const
|
||||
{
|
||||
if (sizeof(T)==sizeof(u16)) return video::EIT_16BIT;
|
||||
return video::EIT_32BIT;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//typedef SSpecificVertexIndex<u16> SVertexIndex;
|
||||
|
||||
|
||||
typedef u32 SVertexIndex;
|
||||
*/
|
||||
|
||||
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue