Saga3D API Documentation  1.0-RC4
saga::scene::CMeshBuffer Class Reference

Implementation of the CPU IMeshBuffer interface. More...

#include <CMeshBuffer.h>

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

Public Member Functions

 CMeshBuffer ()
 Default constructor for empty meshbuffer. More...
 
virtual bool isGPUBuffer () const override
 
virtual ~CMeshBuffer ()
 
virtual std::uint64_t getID () const override
 Returns internal ID to identify mesh buffer. More...
 
virtual void buildBuffer (video::IVideoDriver &driver, const video::PipelineHandle pipeline) override
 Generate GPU-compatible data. More...
 
virtual void * getVertices () override
 Get pointer to vertices. More...
 
virtual const void * getData (const video::PipelineHandle pipeline) const override
 Get pointer to GPU staging buffer. More...
 
virtual std::size_t getSize (const video::PipelineHandle pipeline) const override
 Get size of GPU staging buffer. More...
 
virtual std::size_t getVertexCount () const override
 Get number of vertices. More...
 
virtual void setVertexCount (const size_t count) override
 Set number of vertices. More...
 
virtual const std::uint32_t * getIndices () const override
 Get pointer to indices. More...
 
virtual std::uint32_t getIndex (std::size_t offset) const override
 returns vertex index at this offset More...
 
virtual std::uint32_t * getIndices () override
 Get pointer to indices. More...
 
virtual std::uint32_t getIndexCount () const override
 Get number of indices. More...
 
virtual void setIndexCount (const std::uint32_t count) override
 Set number of indices. More...
 
virtual const core::aabbox3d< float > & getBoundingBox () const override
 Get the axis aligned bounding box. More...
 
virtual void setBoundingBox (const core::aabbox3df &box) override
 Set the axis aligned bounding box. More...
 
virtual void recalculateBoundingBox () override
 Recalculate the bounding box. More...
 
virtual const glm::vec3 & getPosition (std::uint32_t i) const override
 returns position of vertex i More...
 
virtual const glm::vec3 & getNormal (std::uint32_t i) const override
 returns normal of vertex i More...
 
virtual const glm::vec2 & getTCoords (std::uint32_t i) const override
 returns texture coord of vertex i More...
 
virtual const glm::vec3 & getTangent (std::uint32_t i) const override
 returns tangent of vertex i More...
 
virtual const glm::vec3 & getBiTangent (std::uint32_t i) const override
 returns bi-tangent of vertex i More...
 
virtual void append (std::vector< S3DVertex > &&vertices, std::vector< uint32_t > &&indices) override
 Append the vertices and indices to the current buffer. More...
 
virtual void appendAttribute (const char *buffer, const size_t size, const size_t stride) override
 Append the custom attribute buffer to the current mesh buffer. More...
 
virtual void append (const IMeshBuffer *const other) override
 Append the meshbuffer to the current buffer. More...
 
- Public Member Functions inherited from saga::scene::IMeshBuffer
virtual ~IMeshBuffer ()
 
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)
 

Public Attributes

const std::uint64_t ID
 
std::vector< glm::vec3 > PositionBuffer
 
std::vector< glm::vec3 > NormalBuffer
 
std::vector< glm::vec4 > ColorBuffer
 
std::vector< glm::vec2 > TCoordBuffer
 
std::vector< glm::vec3 > TangentBuffer
 
std::vector< glm::vec3 > BiTangentBuffer
 
std::vector< glm::vec4 > BoneWeightBuffer
 
std::vector< glm::vec4 > BoneIDBuffer
 
std::vector< std::vector< unsigned char > > AttributeBuffer
 
std::unordered_map< video::PipelineHandle, std::vector< unsigned char > > GPUBuffers
 GPU staging buffer. More...
 
std::vector< std::uint32_t > Indices
 Indices into the vertices of this buffer. More...
 
core::aabbox3d< float > BoundingBox
 Bounding box of this meshbuffer. More...
 

Additional Inherited Members

- Protected Attributes inherited from saga::scene::IMeshBuffer
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 inherited from saga::scene::IMeshBuffer
static MeshBufferID RootID
 To set ID for mesh buffer when created. More...
 

Detailed Description

Implementation of the CPU IMeshBuffer interface.

Definition at line 17 of file CMeshBuffer.h.

Constructor & Destructor Documentation

◆ CMeshBuffer()

saga::scene::CMeshBuffer::CMeshBuffer ( )
inline

Default constructor for empty meshbuffer.

Definition at line 21 of file CMeshBuffer.h.

◆ ~CMeshBuffer()

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

Definition at line 29 of file CMeshBuffer.h.

Member Function Documentation

◆ append() [1/2]

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

Append the meshbuffer to the current buffer.

Only works for compatible types, i.e. either the same type or the main buffer is of standard type. Otherwise, behavior is undefined.

Parameters
otherMeshbuffer to be appended to this one.

Implements saga::scene::IMeshBuffer.

Definition at line 333 of file CMeshBuffer.h.

◆ append() [2/2]

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

Append the vertices and indices to the current buffer.

Only works for compatible types, i.e. either the same type or the main buffer is of standard type. Otherwise, behavior is undefined.

Implements saga::scene::IMeshBuffer.

Definition at line 285 of file CMeshBuffer.h.

◆ appendAttribute()

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

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)

Implements saga::scene::IMeshBuffer.

Definition at line 318 of file CMeshBuffer.h.

◆ buildBuffer()

virtual void saga::scene::CMeshBuffer::buildBuffer ( video::IVideoDriver driver,
const video::PipelineHandle  pipeline 
)
inlineoverridevirtual

Generate GPU-compatible data.

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

Implements saga::scene::IMeshBuffer.

Definition at line 33 of file CMeshBuffer.h.

◆ getBiTangent()

virtual const glm::vec3& saga::scene::CMeshBuffer::getBiTangent ( std::uint32_t  i) const
inlineoverridevirtual

returns bi-tangent of vertex i

Implements saga::scene::IMeshBuffer.

Definition at line 275 of file CMeshBuffer.h.

◆ getBoundingBox()

virtual const core::aabbox3d<float>& saga::scene::CMeshBuffer::getBoundingBox ( ) const
inlineoverridevirtual

Get the axis aligned bounding box.

Returns
Axis aligned bounding box of this buffer.

Implements saga::scene::IMeshBuffer.

Definition at line 222 of file CMeshBuffer.h.

◆ getData()

virtual const void* saga::scene::CMeshBuffer::getData ( const video::PipelineHandle  pipeline) const
inlineoverridevirtual

Get pointer to GPU staging buffer.

Returns
Pointer to staging buffer.

Implements saga::scene::IMeshBuffer.

Definition at line 168 of file CMeshBuffer.h.

◆ getID()

virtual std::uint64_t saga::scene::CMeshBuffer::getID ( ) const
inlineoverridevirtual

Returns internal ID to identify mesh buffer.

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

Implements saga::scene::IMeshBuffer.

Definition at line 31 of file CMeshBuffer.h.

◆ getIndex()

virtual std::uint32_t saga::scene::CMeshBuffer::getIndex ( std::size_t  offset) const
inlineoverridevirtual

returns vertex index at this offset

Implements saga::scene::IMeshBuffer.

Definition at line 198 of file CMeshBuffer.h.

◆ getIndexCount()

virtual std::uint32_t saga::scene::CMeshBuffer::getIndexCount ( ) const
inlineoverridevirtual

Get number of indices.

Returns
Number of indices.

Implements saga::scene::IMeshBuffer.

Definition at line 212 of file CMeshBuffer.h.

◆ getIndices() [1/2]

virtual const std::uint32_t* saga::scene::CMeshBuffer::getIndices ( ) const
inlineoverridevirtual

Get pointer to indices.

Returns
Pointer to indices.

Implements saga::scene::IMeshBuffer.

Definition at line 192 of file CMeshBuffer.h.

◆ getIndices() [2/2]

virtual std::uint32_t* saga::scene::CMeshBuffer::getIndices ( )
inlineoverridevirtual

Get pointer to indices.

Returns
Pointer to indices.

Implements saga::scene::IMeshBuffer.

Definition at line 205 of file CMeshBuffer.h.

◆ getNormal()

virtual const glm::vec3& saga::scene::CMeshBuffer::getNormal ( std::uint32_t  i) const
inlineoverridevirtual

returns normal of vertex i

Implements saga::scene::IMeshBuffer.

Definition at line 257 of file CMeshBuffer.h.

◆ getPosition()

virtual const glm::vec3& saga::scene::CMeshBuffer::getPosition ( std::uint32_t  i) const
inlineoverridevirtual

returns position of vertex i

Implements saga::scene::IMeshBuffer.

Definition at line 251 of file CMeshBuffer.h.

◆ getSize()

virtual std::size_t saga::scene::CMeshBuffer::getSize ( const video::PipelineHandle  pipeline) const
inlineoverridevirtual

Get size of GPU staging buffer.

Returns
Size of staging buffer.

Implements saga::scene::IMeshBuffer.

Definition at line 175 of file CMeshBuffer.h.

◆ getTangent()

virtual const glm::vec3& saga::scene::CMeshBuffer::getTangent ( std::uint32_t  i) const
inlineoverridevirtual

returns tangent of vertex i

Implements saga::scene::IMeshBuffer.

Definition at line 269 of file CMeshBuffer.h.

◆ getTCoords()

virtual const glm::vec2& saga::scene::CMeshBuffer::getTCoords ( std::uint32_t  i) const
inlineoverridevirtual

returns texture coord of vertex i

Implements saga::scene::IMeshBuffer.

Definition at line 263 of file CMeshBuffer.h.

◆ getVertexCount()

virtual std::size_t saga::scene::CMeshBuffer::getVertexCount ( ) const
inlineoverridevirtual

Get number of vertices.

Returns
Number of vertices.

Implements saga::scene::IMeshBuffer.

Definition at line 182 of file CMeshBuffer.h.

◆ getVertices()

virtual void* saga::scene::CMeshBuffer::getVertices ( )
inlineoverridevirtual

Get pointer to vertices.

Returns
Pointer to vertices.

Implements saga::scene::IMeshBuffer.

Definition at line 161 of file CMeshBuffer.h.

◆ isGPUBuffer()

virtual bool saga::scene::CMeshBuffer::isGPUBuffer ( ) const
inlineoverridevirtual

Implements saga::scene::IMeshBuffer.

Definition at line 27 of file CMeshBuffer.h.

◆ recalculateBoundingBox()

virtual void saga::scene::CMeshBuffer::recalculateBoundingBox ( )
inlineoverridevirtual

Recalculate the bounding box.

should be called if the mesh changed.

Implements saga::scene::IMeshBuffer.

Definition at line 237 of file CMeshBuffer.h.

◆ setBoundingBox()

virtual void saga::scene::CMeshBuffer::setBoundingBox ( const core::aabbox3df box)
inlineoverridevirtual

Set the axis aligned bounding box.

Parameters
boxNew axis aligned bounding box for this buffer. set user axis aligned bounding box

Implements saga::scene::IMeshBuffer.

Definition at line 230 of file CMeshBuffer.h.

◆ setIndexCount()

virtual void saga::scene::CMeshBuffer::setIndexCount ( const std::uint32_t  count)
inlineoverridevirtual

Set number of indices.

Implements saga::scene::IMeshBuffer.

Definition at line 218 of file CMeshBuffer.h.

◆ setVertexCount()

virtual void saga::scene::CMeshBuffer::setVertexCount ( const size_t  count)
inlineoverridevirtual

Set number of vertices.

Implements saga::scene::IMeshBuffer.

Definition at line 188 of file CMeshBuffer.h.

Member Data Documentation

◆ AttributeBuffer

std::vector<std::vector<unsigned char> > saga::scene::CMeshBuffer::AttributeBuffer

Definition at line 367 of file CMeshBuffer.h.

◆ BiTangentBuffer

std::vector<glm::vec3> saga::scene::CMeshBuffer::BiTangentBuffer

Definition at line 364 of file CMeshBuffer.h.

◆ BoneIDBuffer

std::vector<glm::vec4> saga::scene::CMeshBuffer::BoneIDBuffer

Definition at line 366 of file CMeshBuffer.h.

◆ BoneWeightBuffer

std::vector<glm::vec4> saga::scene::CMeshBuffer::BoneWeightBuffer

Definition at line 365 of file CMeshBuffer.h.

◆ BoundingBox

core::aabbox3d<float> saga::scene::CMeshBuffer::BoundingBox

Bounding box of this meshbuffer.

Definition at line 374 of file CMeshBuffer.h.

◆ ColorBuffer

std::vector<glm::vec4> saga::scene::CMeshBuffer::ColorBuffer

Definition at line 361 of file CMeshBuffer.h.

◆ GPUBuffers

std::unordered_map<video::PipelineHandle, std::vector<unsigned char> > saga::scene::CMeshBuffer::GPUBuffers

GPU staging buffer.

Definition at line 370 of file CMeshBuffer.h.

◆ ID

const std::uint64_t saga::scene::CMeshBuffer::ID

Definition at line 357 of file CMeshBuffer.h.

◆ Indices

std::vector<std::uint32_t> saga::scene::CMeshBuffer::Indices

Indices into the vertices of this buffer.

Definition at line 372 of file CMeshBuffer.h.

◆ NormalBuffer

std::vector<glm::vec3> saga::scene::CMeshBuffer::NormalBuffer

Definition at line 360 of file CMeshBuffer.h.

◆ PositionBuffer

std::vector<glm::vec3> saga::scene::CMeshBuffer::PositionBuffer

Definition at line 359 of file CMeshBuffer.h.

◆ TangentBuffer

std::vector<glm::vec3> saga::scene::CMeshBuffer::TangentBuffer

Definition at line 363 of file CMeshBuffer.h.

◆ TCoordBuffer

std::vector<glm::vec2> saga::scene::CMeshBuffer::TCoordBuffer

Definition at line 362 of file CMeshBuffer.h.


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