ModelRenderer Class Reference

A helper class to efficiently draw and queue models with one function call. More...

#include <ModelRenderer.h>

Public Member Functions

 ModelRenderer ()
 Constructor. More...
 
 ModelRenderer (ObjectManagerPtr o)
 Constructor. More...
 
virtual ~ModelRenderer ()
 Virtual destructor. More...
 
ObjectManagerPtr getObjectManager ()
 Returns a pointer to the object manager used to get the models, cameras and lights from. More...
 
void setObjectManager (ObjectManagerPtr o)
 Set the object manager to get the models, cameras and lights from. More...
 
RenderQueuePtr getRenderQueue ()
 Returns a pointer to the render queue. More...
 
virtual void drawModel (const std::string &modelName, const std::string &cameraName, const vmml::Matrix4f &modelMatrix, const std::vector< std::string > &lightNames, bool doFrustumCulling=true, bool cullIndividualGeometry=false)
 Draw specified model into the current framebuffer. More...
 
virtual void drawModel (ModelPtr model, const vmml::Matrix4f &modelMatrix, const vmml::Matrix4f &viewMatrix, const vmml::Matrix4f &projectionMatrix, const std::vector< std::string > &lightNames, bool doFrustumCulling=true, bool cullIndividualGeometry=false)
 Draw specified model into the current framebuffer. More...
 
virtual void queueModelInstance (const std::string &modelName, const std::string &instanceName, const std::string &cameraName, const vmml::Matrix4f &modelMatrix, const std::vector< std::string > &lightNames, bool doFrustumCulling=true, bool cullIndividualGeometry=false, bool isTransparent=false, GLenum blendSfactor=GL_SRC_ALPHA, GLenum blendDfactor=GL_ONE_MINUS_SRC_ALPHA, GLfloat customDistance=10000.0f)
 Queue specified model into the render queue. More...
 
virtual void queueModelInstance (ModelPtr model, const std::string &instanceName, const vmml::Matrix4f &modelMatrix, const vmml::Matrix4f &viewMatrix, const vmml::Matrix4f &projectionMatrix, const std::vector< std::string > &lightNames, bool doFrustumCulling=true, bool cullIndividualGeometry=false, bool isTransparent=false, GLenum blendSfactor=GL_SRC_ALPHA, GLenum blendDfactor=GL_ONE_MINUS_SRC_ALPHA, GLfloat customDistance=10000.0f)
 Queue specified model into the render queue. More...
 
virtual void drawText (const std::string &textSpriteName, const std::string &cameraName, const vmml::Matrix4f &modelMatrix, const std::vector< std::string > &lightNames, bool doFrustumCulling=false)
 Draw specified text sprite into the current framebuffer. More...
 
virtual void queueTextInstance (const std::string &textSpriteName, const std::string &instanceName, const std::string &cameraName, const vmml::Matrix4f &modelMatrix, const std::vector< std::string > &lightNames, bool doFrustumCulling=true, GLenum blendSfactor=GL_SRC_ALPHA, GLenum blendDfactor=GL_ONE_MINUS_SRC_ALPHA, GLfloat customDistance=10000.0f)
 Queue specified text sprite into the render queue. More...
 
void drawQueue (GLenum mode=GL_TRIANGLES)
 Draws the render queue into the current framebuffer. More...
 
void clearQueue ()
 Clears the render queue. More...
 
vmml::Visibility viewFrustumCulling (const vmml::AABBf &aabbObjectSpace, const vmml::Matrix4f &modelViewProjectionMatrix)
 Tests an axis-aligned bounding box against the view frustum. More...
 

Detailed Description

A helper class to efficiently draw and queue models with one function call.

Author
Benjamin Buergisser

Constructor & Destructor Documentation

ModelRenderer::ModelRenderer ( )

Constructor.

ModelRenderer::ModelRenderer ( ObjectManagerPtr  o)

Constructor.

Parameters
[in]oPointer to the object manager
virtual ModelRenderer::~ModelRenderer ( )
inlinevirtual

Virtual destructor.

Member Function Documentation

void ModelRenderer::clearQueue ( )

Clears the render queue.

void ModelRenderer::drawModel ( const std::string &  modelName,
const std::string &  cameraName,
const vmml::Matrix4f &  modelMatrix,
const std::vector< std::string > &  lightNames,
bool  doFrustumCulling = true,
bool  cullIndividualGeometry = false 
)
virtual

Draw specified model into the current framebuffer.

Parameters
[in]modelNameName of the model
[in]cameraNameName of the camera
[in]modelMatrix
[in]lightNamesNames of the lights in a vector
[in]doFrustumCullingSet true if the model should be tested against the view frustum (optional)
[in]cullIndividualGeometrySet true if all the geometry should be tested against the view frustum (optional)
void ModelRenderer::drawModel ( ModelPtr  model,
const vmml::Matrix4f &  modelMatrix,
const vmml::Matrix4f &  viewMatrix,
const vmml::Matrix4f &  projectionMatrix,
const std::vector< std::string > &  lightNames,
bool  doFrustumCulling = true,
bool  cullIndividualGeometry = false 
)
virtual

Draw specified model into the current framebuffer.

Parameters
[in]modelThe model to be drawn
[in]modelMatrix
[in]viewMatrix
[in]projectionMatrix
[in]lightNamesNames of the lights in a vector
[in]doFrustumCullingSet true if the model should be tested against the view frustum (optional)
[in]cullIndividualGeometrySet true if all the geometry should be tested against the view frustum (optional)
void ModelRenderer::drawQueue ( GLenum  mode = GL_TRIANGLES)

Draws the render queue into the current framebuffer.

Parameters
[in]mode
void ModelRenderer::drawText ( const std::string &  textSpriteName,
const std::string &  cameraName,
const vmml::Matrix4f &  modelMatrix,
const std::vector< std::string > &  lightNames,
bool  doFrustumCulling = false 
)
virtual

Draw specified text sprite into the current framebuffer.

Parameters
[in]textSpriteNameName of the text sprite
[in]cameraNameName of the camera
[in]modelMatrix
[in]lightNamesNames of the lights in a vector
[in]doFrustumCullingSet true if the text sprite should be tested against the view frustum (optional)
ObjectManagerPtr ModelRenderer::getObjectManager ( )

Returns a pointer to the object manager used to get the models, cameras and lights from.

RenderQueuePtr ModelRenderer::getRenderQueue ( )

Returns a pointer to the render queue.

void ModelRenderer::queueModelInstance ( const std::string &  modelName,
const std::string &  instanceName,
const std::string &  cameraName,
const vmml::Matrix4f &  modelMatrix,
const std::vector< std::string > &  lightNames,
bool  doFrustumCulling = true,
bool  cullIndividualGeometry = false,
bool  isTransparent = false,
GLenum  blendSfactor = GL_SRC_ALPHA,
GLenum  blendDfactor = GL_ONE_MINUS_SRC_ALPHA,
GLfloat  customDistance = 10000.0f 
)
virtual

Queue specified model into the render queue.

Parameters
[in]modelNameName of the model
[in]instanceNameThe name of the model instance to be queued (instance is created automatically if not present)
[in]cameraNameName of the camera
[in]modelMatrix
[in]lightNamesNames of the lights in a vector
[in]doFrustumCullingSet true if the model should be tested against the view frustum (optional)
[in]cullIndividualGeometrySet true if all the geometry should be tested against the view frustum (optional)
[in]isTransparentSet true if the model is (partially) transparent and sorting according to distance should occur (optional)
[in]blendSfactorSpecifies how the red, green, blue, and alpha source blending factors are computed (optional)
[in]blendDfactorSpecifies how the red, green, blue, and alpha destination blending factors are computed (optional)
[in]customDistanceIf the function should not determine the distance to the camera a custom distance can be set (optional)
void ModelRenderer::queueModelInstance ( ModelPtr  model,
const std::string &  instanceName,
const vmml::Matrix4f &  modelMatrix,
const vmml::Matrix4f &  viewMatrix,
const vmml::Matrix4f &  projectionMatrix,
const std::vector< std::string > &  lightNames,
bool  doFrustumCulling = true,
bool  cullIndividualGeometry = false,
bool  isTransparent = false,
GLenum  blendSfactor = GL_SRC_ALPHA,
GLenum  blendDfactor = GL_ONE_MINUS_SRC_ALPHA,
GLfloat  customDistance = 10000.0f 
)
virtual

Queue specified model into the render queue.

Parameters
[in]modelThe model to be drawn
[in]instanceNameThe name of the model instance to be queued (instance is created automatically if not present)
[in]modelMatrix
[in]viewMatrix
[in]projectionMatrix
[in]lightNamesNames of the lights in a vector
[in]doFrustumCullingSet true if the model should be tested against the view frustum (optional)
[in]cullIndividualGeometrySet true if all the geometry should be tested against the view frustum (optional)
[in]isTransparentSet true if the model is (partially) transparent and sorting according to distance should occur (optional)
[in]blendSfactorSpecifies how the red, green, blue, and alpha source blending factors are computed (optional)
[in]blendDfactorSpecifies how the red, green, blue, and alpha destination blending factors are computed (optional)
[in]customDistanceIf the function should not determine the distance to the camera a custom distance can be set (optional)
void ModelRenderer::queueTextInstance ( const std::string &  textSpriteName,
const std::string &  instanceName,
const std::string &  cameraName,
const vmml::Matrix4f &  modelMatrix,
const std::vector< std::string > &  lightNames,
bool  doFrustumCulling = true,
GLenum  blendSfactor = GL_SRC_ALPHA,
GLenum  blendDfactor = GL_ONE_MINUS_SRC_ALPHA,
GLfloat  customDistance = 10000.0f 
)
virtual

Queue specified text sprite into the render queue.

Parameters
[in]textSpriteNameName of the text sprite
[in]instanceNameThe name of the text sprite instance to be queued (instance is created automatically if not present)
[in]cameraNameName of the camera
[in]modelMatrix
[in]lightNamesNames of the lights in a vector
[in]doFrustumCullingSet true if the text sprite should be tested against the view frustum (optional)
[in]blendSfactorSpecifies how the red, green, blue, and alpha source blending factors are computed (optional)
[in]blendDfactorSpecifies how the red, green, blue, and alpha destination blending factors are computed (optional)
[in]customDistanceIf the function should not determine the distance to the camera a custom distance can be set (optional)
void ModelRenderer::setObjectManager ( ObjectManagerPtr  o)

Set the object manager to get the models, cameras and lights from.

Parameters
[in]oPointer to the object manager
vmml::Visibility ModelRenderer::viewFrustumCulling ( const vmml::AABBf &  aabbObjectSpace,
const vmml::Matrix4f &  modelViewProjectionMatrix 
)

Tests an axis-aligned bounding box against the view frustum.

Parameters
[in]aabbObjectSpaceThe axis-aligned bounding box in object space
[in]modelViewProjectionMatrixThe model view projection matrix (projection * view * model)