Duckcpp 2.1.0
Duckcpp is a high-performance c++ graphics engine.
Loading...
Searching...
No Matches
dcpp::scene::IMeshBuffer Class Referenceabstract

Class for holding a mesh with a single material. More...

#include <duckcpp/core/engine/IMeshBuffer.hpp>

Inheritance diagram for dcpp::scene::IMeshBuffer:
Inheritance graph
Collaboration diagram for dcpp::scene::IMeshBuffer:
Collaboration graph

Public Types

enum  ECloneFlags { ECF_VERTICES = 1 , ECF_INDICES = 2 }
 Bitflags with options for cloning. More...
 

Public Member Functions

virtual dcpp::video::SMaterialgetMaterial ()=0
 Get the material of this meshbuffer.
 
virtual const dcpp::video::SMaterialgetMaterial () const =0
 Get the material of this meshbuffer.
 
virtual dcpp::video::E_VERTEX_TYPE getVertexType () const =0
 Get type of vertex data which is stored in this meshbuffer.
 
virtual const void * getVertices () const =0
 Get access to vertex data. The data is an array of vertices.
 
virtual void * getVertices ()=0
 Get access to vertex data. The data is an array of vertices.
 
virtual dcpp::uint32_kt getVertexCount () const =0
 Get amount of vertices in meshbuffer.
 
virtual dcpp::video::E_INDEX_TYPE getIndexType () const =0
 Get type of index data which is stored in this meshbuffer.
 
virtual const dcpp::uint16_ktgetIndices () const =0
 Get access to indices.
 
virtual dcpp::uint16_ktgetIndices ()=0
 Get access to indices.
 
virtual dcpp::uint32_kt getIndexCount () const =0
 Get amount of indices in this meshbuffer.
 
virtual const dcpp::nub::aabbox3dfgetBoundingBox () const =0
 Get the axis aligned bounding box of this meshbuffer.
 
virtual void setBoundingBox (const dcpp::nub::aabbox3df &box)=0
 Set axis aligned bounding box.
 
virtual void recalculateBoundingBox ()=0
 Recalculates the bounding box. Should be called if the mesh changed.
 
virtual const dcpp::nub::vector3dfgetPosition (dcpp::uint32_kt i) const =0
 returns position of vertex i
 
virtual dcpp::nub::vector3dfgetPosition (dcpp::uint32_kt i)=0
 returns position of vertex i
 
virtual const dcpp::nub::vector3dfgetNormal (dcpp::uint32_kt i) const =0
 returns normal of vertex i
 
virtual dcpp::nub::vector3dfgetNormal (dcpp::uint32_kt i)=0
 returns normal of vertex i
 
virtual const dcpp::nub::vector2dfgetTCoords (dcpp::uint32_kt i) const =0
 returns texture coord of vertex i
 
virtual dcpp::nub::vector2dfgetTCoords (dcpp::uint32_kt i)=0
 returns texture coord of vertex i
 
virtual dcpp::video::SColorgetColor (dcpp::uint32_kt i)=0
 returns color of vertex i
 
virtual const dcpp::video::SColorgetColor (dcpp::uint32_kt i) const =0
 returns color of vertex i
 
virtual void append (const void *const vertices, dcpp::uint32_kt numVertices, const dcpp::uint16_kt *const indices, dcpp::uint32_kt numIndices)=0
 Append the vertices and indices to the current buffer.
 
virtual void append (const IMeshBuffer *const other)=0
 
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex () const =0
 get the current hardware mapping hint
 
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index () const =0
 get the current hardware mapping hint
 
virtual void setHardwareMappingHint (E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX)=0
 set the hardware mapping hint, for driver
 
virtual void setDirty (E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX)=0
 flags the meshbuffer as changed, reloads hardware buffers
 
virtual dcpp::uint32_kt getChangedID_Vertex () const =0
 Get the currently used ID for identification of changes.
 
virtual dcpp::uint32_kt getChangedID_Index () const =0
 Get the currently used ID for identification of changes.
 
virtual void setPrimitiveType (E_PRIMITIVE_TYPE type)=0
 Describe what kind of primitive geometry is used by the meshbuffer.
 
virtual E_PRIMITIVE_TYPE getPrimitiveType () const =0
 Get the kind of primitive geometry which is used by the meshbuffer.
 
virtual dcpp::uint32_kt getPrimitiveCount () const
 Calculate how many geometric primitives are used by this meshbuffer.
 
virtual EMESH_BUFFER_TYPE getType () const
 Returns type of the class implementing the IMeshBuffer.
 
virtual IMeshBuffercreateClone (int cloneFlags=ECF_VERTICES|ECF_INDICES) const =0
 Create a new object with a copy of the meshbuffer.
 
- Public Member Functions inherited from dcpp::IReferenceCounted
 IReferenceCounted ()
 Constructor.
 
virtual ~IReferenceCounted ()
 Destructor.
 
void grab () const
 Grabs the object. Increments the reference counter by one.
 
bool drop () const
 Drops the object. Decrements the reference counter by one.
 
dcpp::int32_kt getReferenceCount () const
 Get the reference count.
 
const dcpp::char_ktgetDebugName () const
 Returns the debug name of the object.
 

Additional Inherited Members

- Protected Member Functions inherited from dcpp::IReferenceCounted
void setDebugName (const dcpp::char_kt *newName)
 Sets the debug name of the object.
 

Detailed Description

Class for holding a mesh with a single material.

A part of an IMesh which has the same material on each face of that group. Logical groups of an IMesh need not be put into separate mesh buffers, but can be. Separately animated parts of the mesh must be put into separate mesh buffers. Some mesh buffer implementations have limitations on the number of vertices the buffer can hold. In that case, logical grouping can help. Moreover, the number of vertices should be optimized for the GPU upload, which often depends on the type of gfx card. Typical figures are 1000-10000 vertices per buffer. SMeshBuffer is a simple implementation of a MeshBuffer, which supports up to 65535 vertices.

Since meshbuffers are used for drawing, and hence will be exposed to the driver, chances are high that they are grab()'ed from somewhere. It's therefore required to dynamically allocate meshbuffers which are passed to a video driver and only drop the buffer once it's not used in the current code block anymore.

Member Enumeration Documentation

◆ ECloneFlags

Bitflags with options for cloning.

Enumerator
ECF_INDICES 

clone the vertices (or copy pointer for SSharedMeshBuffer)

Member Function Documentation

◆ append() [1/2]

virtual void dcpp::scene::IMeshBuffer::append ( const IMeshBuffer *const  other)
pure virtual

Not supported right now by any meshbuffer In theory: Append the meshbuffer to the current buffer Only works for compatible vertex types

Parameters
otherBuffer to append to this one.

Implemented in dcpp::scene::PDynamicMeshBuffer, dcpp::scene::PMeshBuffer< T >, dcpp::scene::SSharedMeshBuffer, and dcpp::scene::SSkinMeshBuffer.

◆ append() [2/2]

virtual void dcpp::scene::IMeshBuffer::append ( const void *const  vertices,
dcpp::uint32_kt  numVertices,
const dcpp::uint16_kt *const  indices,
dcpp::uint32_kt  numIndices 
)
pure virtual

Append the vertices and indices to the current buffer.

Only works for compatible vertex types and not implemented for most buffers for now.

Parameters
verticesPointer to a vertex array.
numVerticesNumber of vertices in the array.
indicesPointer to index array.
numIndicesNumber of indices in array.

Implemented in dcpp::scene::PDynamicMeshBuffer, dcpp::scene::PMeshBuffer< T >, dcpp::scene::SSharedMeshBuffer, and dcpp::scene::SSkinMeshBuffer.

◆ createClone()

virtual IMeshBuffer * dcpp::scene::IMeshBuffer::createClone ( int  cloneFlags = ECF_VERTICES|ECF_INDICES) const
pure virtual

Create a new object with a copy of the meshbuffer.

Implemented in dcpp::scene::PDynamicMeshBuffer, dcpp::scene::PMeshBuffer< T >, dcpp::scene::SSharedMeshBuffer, and dcpp::scene::SSkinMeshBuffer.

◆ getBoundingBox()

virtual const dcpp::nub::aabbox3df & dcpp::scene::IMeshBuffer::getBoundingBox ( ) const
pure virtual

Get the axis aligned bounding box of this meshbuffer.

Returns
Axis aligned bounding box of this buffer.

Implemented in dcpp::scene::PDynamicMeshBuffer, dcpp::scene::PMeshBuffer< T >, dcpp::scene::SSharedMeshBuffer, and dcpp::scene::SSkinMeshBuffer.

◆ getChangedID_Index()

virtual dcpp::uint32_kt dcpp::scene::IMeshBuffer::getChangedID_Index ( ) const
pure virtual

Get the currently used ID for identification of changes.

This shouldn't be used for anything outside the VideoDriver.

Implemented in dcpp::scene::IDynamicMeshBuffer, dcpp::scene::PMeshBuffer< T >, dcpp::scene::SSharedMeshBuffer, and dcpp::scene::SSkinMeshBuffer.

◆ getChangedID_Vertex()

virtual dcpp::uint32_kt dcpp::scene::IMeshBuffer::getChangedID_Vertex ( ) const
pure virtual

Get the currently used ID for identification of changes.

This shouldn't be used for anything outside the VideoDriver.

Implemented in dcpp::scene::IDynamicMeshBuffer, dcpp::scene::PMeshBuffer< T >, dcpp::scene::SSharedMeshBuffer, and dcpp::scene::SSkinMeshBuffer.

◆ getColor() [1/2]

virtual const dcpp::video::SColor & dcpp::scene::IMeshBuffer::getColor ( dcpp::uint32_kt  i) const
pure virtual

◆ getColor() [2/2]

virtual dcpp::video::SColor & dcpp::scene::IMeshBuffer::getColor ( dcpp::uint32_kt  i)
pure virtual

◆ getHardwareMappingHint_Index()

virtual E_HARDWARE_MAPPING dcpp::scene::IMeshBuffer::getHardwareMappingHint_Index ( ) const
pure virtual

◆ getHardwareMappingHint_Vertex()

virtual E_HARDWARE_MAPPING dcpp::scene::IMeshBuffer::getHardwareMappingHint_Vertex ( ) const
pure virtual

◆ getIndexCount()

virtual dcpp::uint32_kt dcpp::scene::IMeshBuffer::getIndexCount ( ) const
pure virtual

Get amount of indices in this meshbuffer.

Returns
Number of indices in this buffer.

Implemented in dcpp::scene::IDynamicMeshBuffer, dcpp::scene::PMeshBuffer< T >, dcpp::scene::SSharedMeshBuffer, and dcpp::scene::SSkinMeshBuffer.

◆ getIndexType()

virtual dcpp::video::E_INDEX_TYPE dcpp::scene::IMeshBuffer::getIndexType ( ) const
pure virtual

Get type of index data which is stored in this meshbuffer.

Returns
Index type of this buffer.

Implemented in dcpp::scene::IDynamicMeshBuffer, dcpp::scene::PMeshBuffer< T >, dcpp::scene::SSharedMeshBuffer, and dcpp::scene::SSkinMeshBuffer.

◆ getIndices() [1/2]

virtual const dcpp::uint16_kt * dcpp::scene::IMeshBuffer::getIndices ( ) const
pure virtual

Get access to indices.

Note: For historical reasons data pointer is of type dcpp::uint16_kt*, but for an index type of EIT_32BIT the index data is using an dcpp::uint32_kt array and therefore needs a cast to dcpp::uint32_kt*.

Returns
Pointer to indices array.

Implemented in dcpp::scene::IDynamicMeshBuffer, dcpp::scene::PMeshBuffer< T >, dcpp::scene::SSharedMeshBuffer, and dcpp::scene::SSkinMeshBuffer.

◆ getIndices() [2/2]

virtual dcpp::uint16_kt * dcpp::scene::IMeshBuffer::getIndices ( )
pure virtual

Get access to indices.

Note: For historical reasons data pointer is of type dcpp::uint16_kt*, but for an index type of EIT_32BIT the index data is using an dcpp::uint32_kt array and therefore needs a cast to dcpp::uint32_kt*.

Returns
Pointer to indices array.

Implemented in dcpp::scene::IDynamicMeshBuffer, dcpp::scene::PMeshBuffer< T >, dcpp::scene::SSharedMeshBuffer, and dcpp::scene::SSkinMeshBuffer.

◆ getMaterial() [1/2]

virtual const dcpp::video::SMaterial & dcpp::scene::IMeshBuffer::getMaterial ( ) const
pure virtual

Get the material of this meshbuffer.

Returns
Material of this buffer.

Implemented in dcpp::scene::PDynamicMeshBuffer, dcpp::scene::PMeshBuffer< T >, dcpp::scene::SSharedMeshBuffer, and dcpp::scene::SSkinMeshBuffer.

◆ getMaterial() [2/2]

virtual dcpp::video::SMaterial & dcpp::scene::IMeshBuffer::getMaterial ( )
pure virtual

Get the material of this meshbuffer.

Returns
Material of this buffer.

Implemented in dcpp::scene::PDynamicMeshBuffer, dcpp::scene::PMeshBuffer< T >, dcpp::scene::SSharedMeshBuffer, and dcpp::scene::SSkinMeshBuffer.

◆ getNormal() [1/2]

virtual const dcpp::nub::vector3df & dcpp::scene::IMeshBuffer::getNormal ( dcpp::uint32_kt  i) const
pure virtual

◆ getNormal() [2/2]

virtual dcpp::nub::vector3df & dcpp::scene::IMeshBuffer::getNormal ( dcpp::uint32_kt  i)
pure virtual

◆ getPosition() [1/2]

virtual const dcpp::nub::vector3df & dcpp::scene::IMeshBuffer::getPosition ( dcpp::uint32_kt  i) const
pure virtual

◆ getPosition() [2/2]

virtual dcpp::nub::vector3df & dcpp::scene::IMeshBuffer::getPosition ( dcpp::uint32_kt  i)
pure virtual

◆ getPrimitiveType()

virtual E_PRIMITIVE_TYPE dcpp::scene::IMeshBuffer::getPrimitiveType ( ) const
pure virtual

Get the kind of primitive geometry which is used by the meshbuffer.

Implemented in dcpp::scene::PDynamicMeshBuffer, dcpp::scene::PMeshBuffer< T >, dcpp::scene::SSharedMeshBuffer, and dcpp::scene::SSkinMeshBuffer.

◆ getTCoords() [1/2]

virtual const dcpp::nub::vector2df & dcpp::scene::IMeshBuffer::getTCoords ( dcpp::uint32_kt  i) const
pure virtual

◆ getTCoords() [2/2]

virtual dcpp::nub::vector2df & dcpp::scene::IMeshBuffer::getTCoords ( dcpp::uint32_kt  i)
pure virtual

◆ getType()

virtual EMESH_BUFFER_TYPE dcpp::scene::IMeshBuffer::getType ( ) const
inlinevirtual

Returns type of the class implementing the IMeshBuffer.

Returns
The class type of this meshbuffer.

Reimplemented in dcpp::scene::PDynamicMeshBuffer, dcpp::scene::PMeshBuffer< T >, dcpp::scene::SSharedMeshBuffer, and dcpp::scene::SSkinMeshBuffer.

◆ getVertexCount()

virtual dcpp::uint32_kt dcpp::scene::IMeshBuffer::getVertexCount ( ) const
pure virtual

Get amount of vertices in meshbuffer.

Returns
Number of vertices in this buffer.

Implemented in dcpp::scene::IDynamicMeshBuffer, dcpp::scene::PMeshBuffer< T >, dcpp::scene::SSharedMeshBuffer, and dcpp::scene::SSkinMeshBuffer.

◆ getVertexType()

virtual dcpp::video::E_VERTEX_TYPE dcpp::scene::IMeshBuffer::getVertexType ( ) const
pure virtual

Get type of vertex data which is stored in this meshbuffer.

Returns
Vertex type of this buffer.

Implemented in dcpp::scene::IDynamicMeshBuffer, dcpp::scene::PMeshBuffer< T >, dcpp::scene::SSharedMeshBuffer, and dcpp::scene::SSkinMeshBuffer.

◆ getVertices() [1/2]

virtual const void * dcpp::scene::IMeshBuffer::getVertices ( ) const
pure virtual

Get access to vertex data. The data is an array of vertices.

Which vertex type is used can be determined by getVertexType().

Returns
Pointer to array of vertices.

Implemented in dcpp::scene::IDynamicMeshBuffer, dcpp::scene::PMeshBuffer< T >, dcpp::scene::SSharedMeshBuffer, and dcpp::scene::SSkinMeshBuffer.

◆ getVertices() [2/2]

virtual void * dcpp::scene::IMeshBuffer::getVertices ( )
pure virtual

Get access to vertex data. The data is an array of vertices.

Which vertex type is used can be determined by getVertexType().

Returns
Pointer to array of vertices.

Implemented in dcpp::scene::IDynamicMeshBuffer, dcpp::scene::PMeshBuffer< T >, dcpp::scene::SSharedMeshBuffer, and dcpp::scene::SSkinMeshBuffer.

◆ recalculateBoundingBox()

virtual void dcpp::scene::IMeshBuffer::recalculateBoundingBox ( )
pure virtual

Recalculates the bounding box. Should be called if the mesh changed.

Implemented in dcpp::scene::PDynamicMeshBuffer, dcpp::scene::PMeshBuffer< T >, dcpp::scene::SSharedMeshBuffer, and dcpp::scene::SSkinMeshBuffer.

◆ setBoundingBox()

virtual void dcpp::scene::IMeshBuffer::setBoundingBox ( const dcpp::nub::aabbox3df box)
pure virtual

Set axis aligned bounding box.

Parameters
boxUser defined axis aligned bounding box to use for this buffer.

Implemented in dcpp::scene::PDynamicMeshBuffer, dcpp::scene::PMeshBuffer< T >, dcpp::scene::SSharedMeshBuffer, and dcpp::scene::SSkinMeshBuffer.

◆ setDirty()

virtual void dcpp::scene::IMeshBuffer::setDirty ( E_BUFFER_TYPE  buffer = EBT_VERTEX_AND_INDEX)
pure virtual

flags the meshbuffer as changed, reloads hardware buffers

Implemented in dcpp::scene::IDynamicMeshBuffer, dcpp::scene::PMeshBuffer< T >, dcpp::scene::SSharedMeshBuffer, and dcpp::scene::SSkinMeshBuffer.

◆ setHardwareMappingHint()

virtual void dcpp::scene::IMeshBuffer::setHardwareMappingHint ( E_HARDWARE_MAPPING  newMappingHint,
E_BUFFER_TYPE  buffer = EBT_VERTEX_AND_INDEX 
)
pure virtual

◆ setPrimitiveType()

virtual void dcpp::scene::IMeshBuffer::setPrimitiveType ( E_PRIMITIVE_TYPE  type)
pure virtual

Describe what kind of primitive geometry is used by the meshbuffer.

Note: Default is EPT_TRIANGLES. Using other types is fine for rendering. But meshbuffer manipulation functions might expect type EPT_TRIANGLES to work correctly. Also mesh writers will generally fail (badly!) with other types than EPT_TRIANGLES.

Implemented in dcpp::scene::PDynamicMeshBuffer, dcpp::scene::PMeshBuffer< T >, dcpp::scene::SSharedMeshBuffer, and dcpp::scene::SSkinMeshBuffer.


The documentation for this class was generated from the following file:

Duckcpp    @cppfx.xyz