Saga3D API Documentation  1.0-RC4
saga::scene::IMeshBuffer Class Referenceabstract

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

#include <IMeshBuffer.h>

Inheritance diagram for saga::scene::IMeshBuffer:
saga::scene::CGPUMeshBuffer saga::scene::CMeshBuffer

Public Member Functions

virtual ~IMeshBuffer ()
 
virtual bool isGPUBuffer () const =0
 
virtual std::uint64_t getID () const =0
 Returns internal ID to identify mesh buffer. More...
 
virtual void buildBuffer (video::IVideoDriver &driver, const video::PipelineHandle pipeline)=0
 Generate GPU-compatible data. More...
 
virtual const void * getData (const video::PipelineHandle pipeline) const =0
 Get pointer to GPU staging buffer. More...
 
virtual std::size_t getSize (const video::PipelineHandle pipeline) const =0
 Get size of GPU staging buffer. More...
 
virtual void * getVertices ()=0
 Get access to vertex data. The data is an array of vertices. More...
 
virtual void setVertexCount (const size_t count)=0
 Set number of vertices. More...
 
virtual std::size_t getVertexCount () const =0
 Get amount of vertices in meshbuffer. More...
 
virtual const std::uint32_t * getIndices () const =0
 Get access to indices. More...
 
virtual std::uint32_t * getIndices ()=0
 Get access to indices. More...
 
virtual std::uint32_t getIndexCount () const =0
 Get amount of indices in this meshbuffer. More...
 
virtual void setIndexCount (const std::uint32_t count)=0
 Set number of indices. More...
 
virtual const core::aabbox3dfgetBoundingBox () const =0
 Get the axis aligned bounding box of this meshbuffer. More...
 
virtual void setBoundingBox (const core::aabbox3df &box)=0
 Set axis aligned bounding box. More...
 
virtual void recalculateBoundingBox ()=0
 Recalculates the bounding box. Should be called if the mesh changed. More...
 
virtual const glm::vec3 & getPosition (std::uint32_t i) const =0
 returns position of vertex i More...
 
virtual const glm::vec3 & getNormal (std::uint32_t i) const =0
 returns normal of vertex i More...
 
virtual const glm::vec2 & getTCoords (std::uint32_t i) const =0
 returns texture coord of vertex i More...
 
virtual const glm::vec3 & getTangent (std::uint32_t i) const =0
 returns tangent of vertex i More...
 
virtual const glm::vec3 & getBiTangent (std::uint32_t i) const =0
 returns bi-tangent of vertex i More...
 
virtual std::uint32_t getIndex (std::size_t offset) const =0
 returns vertex index at this offset More...
 
virtual void append (std::vector< S3DVertex > &&vertices, std::vector< uint32_t > &&indices)=0
 Append the vertices and indices to the current buffer. More...
 
virtual void append (const IMeshBuffer *const other)=0
 Append the meshbuffer to the current buffer. More...
 
virtual void appendAttribute (const char *buffer, const size_t size, const size_t stride)=0
 Append the custom attribute buffer to the current mesh buffer. More...
 
void setPrimitiveType (scene::E_PRIMITIVE_TYPE type)
 Describe what kind of primitive geometry is used by the meshbuffer. More...
 
scene::E_PRIMITIVE_TYPE getPrimitiveType () const
 Get the kind of primitive geometry which is used by the meshbuffer. More...
 
E_INDEX_TYPE getIndexType () const
 Get index type. More...
 
void setIndexType (const E_INDEX_TYPE type)
 Set index type. More...
 
void setInstanceCount (const size_t count)
 Set buffer binding location. More...
 
std::size_t getInstanceCount () const
 Get buffer binding location. More...
 
void setBindingLocation (const int binding)
 Set buffer binding location. More...
 
int getBindingLocation () const
 Get buffer binding location. More...
 
void isNull (const bool null)
 
bool isNull () const
 
virtual std::uint32_t getPrimitiveCount () const
 Calculate how many geometric primitives are used by this meshbuffer. More...
 
bool useIndirectDraw () const
 
auto indirectDrawBuffer () const
 
void setIndirectDrawBuffer (const video::IndirectBufferHandle buffer)
 
bool useIndexedIndirectDraw () const
 
auto indexedIndirectDrawBuffer () const
 
void setIndexedIndirectDrawBuffer (const video::IndexedIndirectBufferHandle buffer)
 

Protected Attributes

scene::E_PRIMITIVE_TYPE PrimitiveType = E_PRIMITIVE_TYPE::TRIANGLES
 Primitive type used for rendering (triangles, lines, ...) More...
 
std::size_t InstanceCount = 1
 Instance count for rendering multiple objects with this buffer. More...
 
int Binding = 0
 Binding location. More...
 
bool IsNull = false
 Is a null buffer? More...
 
video::IndirectBufferHandle IndirectDrawBuffer = video::NULL_GPU_RESOURCE_HANDLE
 Indirect draw command buffer for this mesh buffer. More...
 
video::IndexedIndirectBufferHandle IndexedIndirectDrawBuffer = video::NULL_GPU_RESOURCE_HANDLE
 Indexed indirect draw command buffer for this mesh buffer. More...
 
E_INDEX_TYPE IndexType = E_INDEX_TYPE::UINT32
 

Static Protected Attributes

static MeshBufferID RootID
 To set ID for mesh buffer when created. More...
 

Detailed Description

Struct 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.

Definition at line 43 of file IMeshBuffer.h.

Constructor & Destructor Documentation

◆ ~IMeshBuffer()

virtual saga::scene::IMeshBuffer::~IMeshBuffer ( )
inlinevirtual

Definition at line 46 of file IMeshBuffer.h.

Member Function Documentation

◆ append() [1/2]

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

Append the meshbuffer to the current buffer.

Only works for compatible vertex types

Parameters
otherBuffer to append to this one.

Implemented in saga::scene::CMeshBuffer, and saga::scene::CGPUMeshBuffer.

◆ append() [2/2]

virtual void saga::scene::IMeshBuffer::append ( std::vector< S3DVertex > &&  vertices,
std::vector< uint32_t > &&  indices 
)
pure virtual

Append the vertices and indices to the current buffer.

Only works for compatible vertex types.

Parameters
verticesvertex vector.
indicesindex vector.

Implemented in saga::scene::CMeshBuffer, and saga::scene::CGPUMeshBuffer.

◆ appendAttribute()

virtual void saga::scene::IMeshBuffer::appendAttribute ( const char *  buffer,
const size_t  size,
const size_t  stride 
)
pure virtual

Append the custom attribute buffer to the current mesh buffer.

Parameters
bufferPointer to the buffer containing data
sizeTotal size of buffer (bytes)
strideThe custom data size of each vertex (bytes)

Implemented in saga::scene::CMeshBuffer, and saga::scene::CGPUMeshBuffer.

◆ buildBuffer()

virtual void saga::scene::IMeshBuffer::buildBuffer ( video::IVideoDriver driver,
const video::PipelineHandle  pipeline 
)
pure virtual

Generate GPU-compatible data.

Depending on render pass's pipeline layout, this function generates vertex data for that pass

Implemented in saga::scene::CMeshBuffer, and saga::scene::CGPUMeshBuffer.

◆ getBindingLocation()

int saga::scene::IMeshBuffer::getBindingLocation ( ) const
inline

Get buffer binding location.

Definition at line 188 of file IMeshBuffer.h.

◆ getBiTangent()

virtual const glm::vec3& saga::scene::IMeshBuffer::getBiTangent ( std::uint32_t  i) const
pure virtual

returns bi-tangent of vertex i

Implemented in saga::scene::CMeshBuffer, and saga::scene::CGPUMeshBuffer.

◆ getBoundingBox()

virtual const core::aabbox3df& saga::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 saga::scene::CMeshBuffer, and saga::scene::CGPUMeshBuffer.

◆ getData()

virtual const void* saga::scene::IMeshBuffer::getData ( const video::PipelineHandle  pipeline) const
pure virtual

Get pointer to GPU staging buffer.

Returns
Pointer to staging buffer.

Implemented in saga::scene::CMeshBuffer, and saga::scene::CGPUMeshBuffer.

◆ getID()

virtual std::uint64_t saga::scene::IMeshBuffer::getID ( ) const
pure virtual

Returns internal ID to identify mesh buffer.

Each mesh buffer will be assigned an unique ID in its creation

Implemented in saga::scene::CMeshBuffer, and saga::scene::CGPUMeshBuffer.

◆ getIndex()

virtual std::uint32_t saga::scene::IMeshBuffer::getIndex ( std::size_t  offset) const
pure virtual

returns vertex index at this offset

Implemented in saga::scene::CMeshBuffer, and saga::scene::CGPUMeshBuffer.

◆ getIndexCount()

virtual std::uint32_t saga::scene::IMeshBuffer::getIndexCount ( ) const
pure virtual

Get amount of indices in this meshbuffer.

Returns
Number of indices in this buffer.

Implemented in saga::scene::CMeshBuffer, and saga::scene::CGPUMeshBuffer.

◆ getIndexType()

E_INDEX_TYPE saga::scene::IMeshBuffer::getIndexType ( ) const
inline

Get index type.

Definition at line 158 of file IMeshBuffer.h.

◆ getIndices() [1/2]

virtual const std::uint32_t* saga::scene::IMeshBuffer::getIndices ( ) const
pure virtual

Get access to indices.

Returns
Pointer to indices array.

Implemented in saga::scene::CMeshBuffer, and saga::scene::CGPUMeshBuffer.

◆ getIndices() [2/2]

virtual std::uint32_t* saga::scene::IMeshBuffer::getIndices ( )
pure virtual

Get access to indices.

Returns
Pointer to indices array.

Implemented in saga::scene::CMeshBuffer, and saga::scene::CGPUMeshBuffer.

◆ getInstanceCount()

std::size_t saga::scene::IMeshBuffer::getInstanceCount ( ) const
inline

Get buffer binding location.

Definition at line 176 of file IMeshBuffer.h.

◆ getNormal()

virtual const glm::vec3& saga::scene::IMeshBuffer::getNormal ( std::uint32_t  i) const
pure virtual

returns normal of vertex i

Implemented in saga::scene::CMeshBuffer, and saga::scene::CGPUMeshBuffer.

◆ getPosition()

virtual const glm::vec3& saga::scene::IMeshBuffer::getPosition ( std::uint32_t  i) const
pure virtual

returns position of vertex i

Implemented in saga::scene::CMeshBuffer, and saga::scene::CGPUMeshBuffer.

◆ getPrimitiveCount()

virtual std::uint32_t saga::scene::IMeshBuffer::getPrimitiveCount ( ) const
inlinevirtual

Calculate how many geometric primitives are used by this meshbuffer.

Definition at line 204 of file IMeshBuffer.h.

◆ getPrimitiveType()

scene::E_PRIMITIVE_TYPE saga::scene::IMeshBuffer::getPrimitiveType ( ) const
inline

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

Definition at line 152 of file IMeshBuffer.h.

◆ getSize()

virtual std::size_t saga::scene::IMeshBuffer::getSize ( const video::PipelineHandle  pipeline) const
pure virtual

Get size of GPU staging buffer.

Returns
Size of staging buffer.

Implemented in saga::scene::CMeshBuffer, and saga::scene::CGPUMeshBuffer.

◆ getTangent()

virtual const glm::vec3& saga::scene::IMeshBuffer::getTangent ( std::uint32_t  i) const
pure virtual

returns tangent of vertex i

Implemented in saga::scene::CMeshBuffer, and saga::scene::CGPUMeshBuffer.

◆ getTCoords()

virtual const glm::vec2& saga::scene::IMeshBuffer::getTCoords ( std::uint32_t  i) const
pure virtual

returns texture coord of vertex i

Implemented in saga::scene::CMeshBuffer, and saga::scene::CGPUMeshBuffer.

◆ getVertexCount()

virtual std::size_t saga::scene::IMeshBuffer::getVertexCount ( ) const
pure virtual

Get amount of vertices in meshbuffer.

Returns
Number of vertices in this buffer.

Implemented in saga::scene::CMeshBuffer, and saga::scene::CGPUMeshBuffer.

◆ getVertices()

virtual void* saga::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 saga::scene::CMeshBuffer, and saga::scene::CGPUMeshBuffer.

◆ indexedIndirectDrawBuffer()

auto saga::scene::IMeshBuffer::indexedIndirectDrawBuffer ( ) const
inline

Definition at line 244 of file IMeshBuffer.h.

◆ indirectDrawBuffer()

auto saga::scene::IMeshBuffer::indirectDrawBuffer ( ) const
inline

Definition at line 229 of file IMeshBuffer.h.

◆ isGPUBuffer()

virtual bool saga::scene::IMeshBuffer::isGPUBuffer ( ) const
pure virtual

◆ isNull() [1/2]

bool saga::scene::IMeshBuffer::isNull ( ) const
inline

Definition at line 198 of file IMeshBuffer.h.

◆ isNull() [2/2]

void saga::scene::IMeshBuffer::isNull ( const bool  null)
inline

Definition at line 193 of file IMeshBuffer.h.

◆ recalculateBoundingBox()

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

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

Implemented in saga::scene::CMeshBuffer, and saga::scene::CGPUMeshBuffer.

◆ setBindingLocation()

void saga::scene::IMeshBuffer::setBindingLocation ( const int  binding)
inline

Set buffer binding location.

Definition at line 182 of file IMeshBuffer.h.

◆ setBoundingBox()

virtual void saga::scene::IMeshBuffer::setBoundingBox ( const core::aabbox3df box)
pure virtual

Set axis aligned bounding box.

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

Implemented in saga::scene::CMeshBuffer, and saga::scene::CGPUMeshBuffer.

◆ setIndexCount()

virtual void saga::scene::IMeshBuffer::setIndexCount ( const std::uint32_t  count)
pure virtual

Set number of indices.

Implemented in saga::scene::CMeshBuffer, and saga::scene::CGPUMeshBuffer.

◆ setIndexedIndirectDrawBuffer()

void saga::scene::IMeshBuffer::setIndexedIndirectDrawBuffer ( const video::IndexedIndirectBufferHandle  buffer)
inline

Definition at line 249 of file IMeshBuffer.h.

◆ setIndexType()

void saga::scene::IMeshBuffer::setIndexType ( const E_INDEX_TYPE  type)
inline

Set index type.

Definition at line 164 of file IMeshBuffer.h.

◆ setIndirectDrawBuffer()

void saga::scene::IMeshBuffer::setIndirectDrawBuffer ( const video::IndirectBufferHandle  buffer)
inline

Definition at line 234 of file IMeshBuffer.h.

◆ setInstanceCount()

void saga::scene::IMeshBuffer::setInstanceCount ( const size_t  count)
inline

Set buffer binding location.

Definition at line 170 of file IMeshBuffer.h.

◆ setPrimitiveType()

void saga::scene::IMeshBuffer::setPrimitiveType ( scene::E_PRIMITIVE_TYPE  type)
inline

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

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

Definition at line 146 of file IMeshBuffer.h.

◆ setVertexCount()

virtual void saga::scene::IMeshBuffer::setVertexCount ( const size_t  count)
pure virtual

Set number of vertices.

Implemented in saga::scene::CMeshBuffer, and saga::scene::CGPUMeshBuffer.

◆ useIndexedIndirectDraw()

bool saga::scene::IMeshBuffer::useIndexedIndirectDraw ( ) const
inline

Definition at line 239 of file IMeshBuffer.h.

◆ useIndirectDraw()

bool saga::scene::IMeshBuffer::useIndirectDraw ( ) const
inline

Definition at line 224 of file IMeshBuffer.h.

Member Data Documentation

◆ Binding

int saga::scene::IMeshBuffer::Binding = 0
protected

Binding location.

Definition at line 265 of file IMeshBuffer.h.

◆ IndexedIndirectDrawBuffer

video::IndexedIndirectBufferHandle saga::scene::IMeshBuffer::IndexedIndirectDrawBuffer = video::NULL_GPU_RESOURCE_HANDLE
protected

Indexed indirect draw command buffer for this mesh buffer.

Definition at line 274 of file IMeshBuffer.h.

◆ IndexType

E_INDEX_TYPE saga::scene::IMeshBuffer::IndexType = E_INDEX_TYPE::UINT32
protected

Definition at line 276 of file IMeshBuffer.h.

◆ IndirectDrawBuffer

video::IndirectBufferHandle saga::scene::IMeshBuffer::IndirectDrawBuffer = video::NULL_GPU_RESOURCE_HANDLE
protected

Indirect draw command buffer for this mesh buffer.

Definition at line 271 of file IMeshBuffer.h.

◆ InstanceCount

std::size_t saga::scene::IMeshBuffer::InstanceCount = 1
protected

Instance count for rendering multiple objects with this buffer.

Definition at line 262 of file IMeshBuffer.h.

◆ IsNull

bool saga::scene::IMeshBuffer::IsNull = false
protected

Is a null buffer?

Definition at line 268 of file IMeshBuffer.h.

◆ PrimitiveType

scene::E_PRIMITIVE_TYPE saga::scene::IMeshBuffer::PrimitiveType = E_PRIMITIVE_TYPE::TRIANGLES
protected

Primitive type used for rendering (triangles, lines, ...)

Definition at line 259 of file IMeshBuffer.h.

◆ RootID

MeshBufferID saga::scene::IMeshBuffer::RootID
staticprotected

To set ID for mesh buffer when created.

Definition at line 256 of file IMeshBuffer.h.


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