ModelRenderer.h
Go to the documentation of this file.
1 #ifndef B_MODEL_RENDERER_H
2 #define B_MODEL_RENDERER_H
3 
4 /* bRenderer includes */
5 #include "Logger.h"
6 #include "ObjectManager.h"
7 #include "RenderQueue.h"
8 
9 /* vmmlib includes */
10 #include "vmmlib/util.hpp"
11 #include "vmmlib/frustum_culler.hpp"
12 
13 
18 {
19 public:
20 
21  /* Functions */
22 
25  ModelRenderer();
26 
31 
34  virtual ~ModelRenderer(){}
35 
39 
44 
48 
57  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);
58 
68  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);
69 
83  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);
84 
99  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);
100 
108  virtual void drawText(const std::string &textSpriteName, const std::string &cameraName, const vmml::Matrix4f &modelMatrix, const std::vector<std::string> &lightNames, bool doFrustumCulling = false);
109 
121  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);
122 
126  void drawQueue(GLenum mode = GL_TRIANGLES);
127 
130  void clearQueue();
131 
136  vmml::Visibility viewFrustumCulling(const vmml::AABBf &aabbObjectSpace, const vmml::Matrix4f &modelViewProjectionMatrix);
137 
138 private:
139 
140  /* Variables */
141 
142  ObjectManagerPtr _objectManager = nullptr;
143  RenderQueuePtr _renderQueue = nullptr;
144 };
145 
146 typedef std::shared_ptr< ModelRenderer > ModelRendererPtr;
147 
148 #endif /* defined(B_MODEL_RENDERER_H) */
RenderQueuePtr getRenderQueue()
Returns a pointer to the render queue.
Definition: ModelRenderer.cpp:27
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.
Definition: ModelRenderer.cpp:32
A helper class to efficiently draw and queue models with one function call.
Definition: ModelRenderer.h:17
std::shared_ptr< ModelRenderer > ModelRendererPtr
Definition: ModelRenderer.h:146
ObjectManagerPtr getObjectManager()
Returns a pointer to the object manager used to get the models, cameras and lights from...
Definition: ModelRenderer.cpp:17
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.
Definition: ModelRenderer.cpp:110
virtual ~ModelRenderer()
Virtual destructor.
Definition: ModelRenderer.h:34
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.
Definition: ModelRenderer.cpp:201
void setObjectManager(ObjectManagerPtr o)
Set the object manager to get the models, cameras and lights from.
Definition: ModelRenderer.cpp:22
vmml::Visibility viewFrustumCulling(const vmml::AABBf &aabbObjectSpace, const vmml::Matrix4f &modelViewProjectionMatrix)
Tests an axis-aligned bounding box against the view frustum.
Definition: ModelRenderer.cpp:221
ModelRenderer()
Constructor.
Definition: ModelRenderer.cpp:6
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.
Definition: ModelRenderer.cpp:206
void clearQueue()
Clears the render queue.
Definition: ModelRenderer.cpp:216
std::shared_ptr< ObjectManager > ObjectManagerPtr
Definition: ObjectManager.h:690
void drawQueue(GLenum mode=GL_TRIANGLES)
Draws the render queue into the current framebuffer.
Definition: ModelRenderer.cpp:211
std::shared_ptr< RenderQueue > RenderQueuePtr
Definition: RenderQueue.h:80
std::shared_ptr< Model > ModelPtr
Definition: Model.h:188