MIRA
Public Types | Public Member Functions | Protected Attributes | List of all members
DynamicRenderable Class Reference

Abstract base class for renderables based on dynamically growing vertex and index buffers. More...

#include <visualization/3d/DynamicRenderable.h>

Inheritance diagram for DynamicRenderable:
Inheritance graph
[legend]

Public Types

enum  Flags { NONE = 0, INDEX_BUFFER_32BIT = 1 }
 Flags that can be specified in prepareHardwareBuffers(). More...
 

Public Member Functions

 DynamicRenderable ()
 
virtual ~DynamicRenderable ()
 
void initialize (Ogre::RenderOperation::OperationType operationType, const Ogre::VertexDeclaration &vertexDecl, bool useIndices)
 Initializes the dynamic renderable. More...
 
void setOperationType (Ogre::RenderOperation::OperationType operationType)
 Allows to change the operation type after calling initialize. More...
 
void enableIndexBuffer (bool enable=true)
 Allows to enable/disable the index buffer, after initialize() was already called. More...
 
 MIRA_ENUM_TO_FLAGS_INCLASS (Flags)
 
void prepareBuffers (size_t vertexCount, size_t indexCount=0, Flags flags=NONE, Ogre::HardwareBuffer::Usage usage=Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY)
 Prepares the hardware buffers for the requested vertex and index counts. More...
 
void updateVertexCount (size_t vertexCount)
 Update the count of vertices actually filled into the buffer. More...
 
Ogre::HardwareVertexBufferSharedPtr getVertexBuffer (unsigned short index=0)
 Gets the vertex buffer bound to the given source index. More...
 
Ogre::HardwareIndexBufferSharedPtr getIndexBuffer ()
 Gets the index buffer of this renderable (or NULL, if no index buffer was created) More...
 
virtual Ogre::Real getBoundingRadius (void) const
 Implementation of Ogre::SimpleRenderable. More...
 
virtual Ogre::Real getSquaredViewDepth (const Ogre::Camera *cam) const
 Implementation of Ogre::SimpleRenderable. More...
 
virtual void _updateRenderQueue (Ogre::RenderQueue *queue)
 

Protected Attributes

size_t mVertexBufferCapacity
 Maximum capacity of the currently allocated vertex buffer. More...
 
size_t mIndexBufferCapacity
 Maximum capacity of the currently allocated index buffer. More...
 

Detailed Description

Abstract base class for renderables based on dynamically growing vertex and index buffers.

The usage is as follows:

  1. call initialize() once, to create all necessary components and to provide the type of render operations, the layout of the vertex buffer and specify whether to use an index buffer or not.
  2. call prepareBuffers() to specify the size of the vertex and index buffer
  3. fill in the vertex and index buffers, which can be obtained using the getVertexBuffer() and getIndexBuffer() methods.
  4. set the bounding box of the Renderable using the setBoundingBox() method.
  5. continue at 2 or 3, whenever the content needs to be updated.

Member Enumeration Documentation

◆ Flags

enum Flags

Flags that can be specified in prepareHardwareBuffers().

Enumerator
NONE 
INDEX_BUFFER_32BIT 

create a 32bit index buffer instead of 16bit

Constructor & Destructor Documentation

◆ DynamicRenderable()

◆ ~DynamicRenderable()

virtual ~DynamicRenderable ( )
virtual

Member Function Documentation

◆ initialize()

void initialize ( Ogre::RenderOperation::OperationType  operationType,
const Ogre::VertexDeclaration &  vertexDecl,
bool  useIndices 
)

Initializes the dynamic renderable.

This function should only be only called once! It initializes all necessary structures and specifies the operation type (triangle list, fan, etc), the vertex declaration (vertex,normals,texturecoords) and specifies, whether to use an index buffer or not.

Parameters
operationTypeThe type of render operation to perform.
vertexDeclThe vertex declaration describing the content of the vertex buffer
useIndicesSpecifies whether to use an index buffer or not

◆ setOperationType()

void setOperationType ( Ogre::RenderOperation::OperationType  operationType)

Allows to change the operation type after calling initialize.

◆ enableIndexBuffer()

void enableIndexBuffer ( bool  enable = true)

Allows to enable/disable the index buffer, after initialize() was already called.

Note, that you can enable the index buffer only, is the parameter useIndices in the call to initialize() was set true. Otherwise, this method will throw an exception here.

◆ MIRA_ENUM_TO_FLAGS_INCLASS()

MIRA_ENUM_TO_FLAGS_INCLASS ( Flags  )

◆ prepareBuffers()

void prepareBuffers ( size_t  vertexCount,
size_t  indexCount = 0,
Flags  flags = NONE,
Ogre::HardwareBuffer::Usage  usage = Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY 
)

Prepares the hardware buffers for the requested vertex and index counts.

This function must be called at least once before locking the buffers to fill in data. It guarantees that the hardware buffers are large enough to hold at least the requested number of vertices and indices (if using indices). The buffers are possibly reallocated to achieve this. This method can be called more than once to increase the size of the buffers, if necessary.

Parameters
vertexCountThe number of vertices the buffer must hold.
indexCountThe number of indices the buffer must hold. This parameter is ignored if not using indices.

◆ updateVertexCount()

void updateVertexCount ( size_t  vertexCount)

Update the count of vertices actually filled into the buffer.

You should use this if the number of vertices that were eventually filled into the buffer is smaller than the initial count used with prepareBuffers, in order to avoid rendering uninitialized data. Make sure it is not greater than the vertexCount used in the call to prepareBuffers!

◆ getVertexBuffer()

Ogre::HardwareVertexBufferSharedPtr getVertexBuffer ( unsigned short  index = 0)

Gets the vertex buffer bound to the given source index.

◆ getIndexBuffer()

Ogre::HardwareIndexBufferSharedPtr getIndexBuffer ( )

Gets the index buffer of this renderable (or NULL, if no index buffer was created)

◆ getBoundingRadius()

virtual Ogre::Real getBoundingRadius ( void  ) const
virtual

Implementation of Ogre::SimpleRenderable.

◆ getSquaredViewDepth()

virtual Ogre::Real getSquaredViewDepth ( const Ogre::Camera *  cam) const
virtual

Implementation of Ogre::SimpleRenderable.

◆ _updateRenderQueue()

virtual void _updateRenderQueue ( Ogre::RenderQueue *  queue)
inlinevirtual

Member Data Documentation

◆ mVertexBufferCapacity

size_t mVertexBufferCapacity
protected

Maximum capacity of the currently allocated vertex buffer.

◆ mIndexBufferCapacity

size_t mIndexBufferCapacity
protected

Maximum capacity of the currently allocated index buffer.


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