2019-12-12 17:32:41 +01:00
|
|
|
// Copyright (C) 2008-2012 Nikolaus Gebhardt
|
|
|
|
// This file is part of the "Irrlicht Engine".
|
|
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
|
|
|
2021-08-27 17:03:34 +02:00
|
|
|
#ifndef IRR_I_DYNAMIC_MESH_BUFFER_H_INCLUDED
|
|
|
|
#define IRR_I_DYNAMIC_MESH_BUFFER_H_INCLUDED
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
#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;
|
|
|
|
|
|
|
|
|
2022-04-22 16:22:41 +02:00
|
|
|
// ------------------- Old interface ------------------- //
|
|
|
|
// That stuff could also be in CDynamicMeshBuffer
|
|
|
|
// I suppose it was put here to show that the information
|
|
|
|
// is now basically handled by the vertex/index buffers instead
|
|
|
|
// of the meshbuffer itself.
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
//! get the current hardware mapping hint
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const IRR_OVERRIDE
|
2019-12-12 17:32:41 +01:00
|
|
|
{
|
|
|
|
return getVertexBuffer().getHardwareMappingHint();
|
|
|
|
}
|
|
|
|
|
|
|
|
//! get the current hardware mapping hint
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const IRR_OVERRIDE
|
2019-12-12 17:32:41 +01:00
|
|
|
{
|
|
|
|
return getIndexBuffer().getHardwareMappingHint();
|
|
|
|
}
|
|
|
|
|
|
|
|
//! set the hardware mapping hint, for driver
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX ) IRR_OVERRIDE
|
2019-12-12 17:32:41 +01:00
|
|
|
{
|
|
|
|
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
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setDirty(E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX) IRR_OVERRIDE
|
2019-12-12 17:32:41 +01:00
|
|
|
{
|
|
|
|
if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_VERTEX)
|
|
|
|
getVertexBuffer().setDirty();
|
|
|
|
if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_INDEX)
|
|
|
|
getIndexBuffer().setDirty();
|
|
|
|
}
|
|
|
|
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual u32 getChangedID_Vertex() const IRR_OVERRIDE
|
2019-12-12 17:32:41 +01:00
|
|
|
{
|
|
|
|
return getVertexBuffer().getChangedID();
|
|
|
|
}
|
|
|
|
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual u32 getChangedID_Index() const IRR_OVERRIDE
|
2019-12-12 17:32:41 +01:00
|
|
|
{
|
|
|
|
return getIndexBuffer().getChangedID();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//! Get type of vertex data which is stored in this meshbuffer.
|
|
|
|
/** \return Vertex type of this buffer. */
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual video::E_VERTEX_TYPE getVertexType() const IRR_OVERRIDE
|
2019-12-12 17:32:41 +01:00
|
|
|
{
|
|
|
|
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. */
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual const void* getVertices() const IRR_OVERRIDE
|
2019-12-12 17:32:41 +01:00
|
|
|
{
|
|
|
|
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. */
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void* getVertices() IRR_OVERRIDE
|
2019-12-12 17:32:41 +01:00
|
|
|
{
|
|
|
|
return getVertexBuffer().getData();
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Get amount of vertices in meshbuffer.
|
|
|
|
/** \return Number of vertices in this buffer. */
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual u32 getVertexCount() const IRR_OVERRIDE
|
2019-12-12 17:32:41 +01:00
|
|
|
{
|
|
|
|
return getVertexBuffer().size();
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Get type of index data which is stored in this meshbuffer.
|
|
|
|
/** \return Index type of this buffer. */
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual video::E_INDEX_TYPE getIndexType() const IRR_OVERRIDE
|
2019-12-12 17:32:41 +01:00
|
|
|
{
|
|
|
|
return getIndexBuffer().getType();
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Get access to indices.
|
|
|
|
/** \return Pointer to indices array. */
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual const u16* getIndices() const IRR_OVERRIDE
|
2019-12-12 17:32:41 +01:00
|
|
|
{
|
|
|
|
return (u16*)getIndexBuffer().getData();
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Get access to indices.
|
|
|
|
/** \return Pointer to indices array. */
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual u16* getIndices() IRR_OVERRIDE
|
2019-12-12 17:32:41 +01:00
|
|
|
{
|
|
|
|
return (u16*)getIndexBuffer().getData();
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Get amount of indices in this meshbuffer.
|
|
|
|
/** \return Number of indices in this buffer. */
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual u32 getIndexCount() const IRR_OVERRIDE
|
2019-12-12 17:32:41 +01:00
|
|
|
{
|
|
|
|
return getIndexBuffer().size();
|
|
|
|
}
|
|
|
|
|
|
|
|
//! returns position of vertex i
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual const core::vector3df& getPosition(u32 i) const IRR_OVERRIDE
|
2019-12-12 17:32:41 +01:00
|
|
|
{
|
|
|
|
return getVertexBuffer()[i].Pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! returns position of vertex i
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual core::vector3df& getPosition(u32 i) IRR_OVERRIDE
|
2019-12-12 17:32:41 +01:00
|
|
|
{
|
|
|
|
return getVertexBuffer()[i].Pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! returns texture coords of vertex i
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual const core::vector2df& getTCoords(u32 i) const IRR_OVERRIDE
|
2019-12-12 17:32:41 +01:00
|
|
|
{
|
|
|
|
return getVertexBuffer()[i].TCoords;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! returns texture coords of vertex i
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual core::vector2df& getTCoords(u32 i) IRR_OVERRIDE
|
2019-12-12 17:32:41 +01:00
|
|
|
{
|
|
|
|
return getVertexBuffer()[i].TCoords;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! returns normal of vertex i
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual const core::vector3df& getNormal(u32 i) const IRR_OVERRIDE
|
2019-12-12 17:32:41 +01:00
|
|
|
{
|
|
|
|
return getVertexBuffer()[i].Normal;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! returns normal of vertex i
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual core::vector3df& getNormal(u32 i) IRR_OVERRIDE
|
2019-12-12 17:32:41 +01:00
|
|
|
{
|
|
|
|
return getVertexBuffer()[i].Normal;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // end namespace scene
|
|
|
|
} // end namespace irr
|
|
|
|
|
|
|
|
#endif
|