Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Attributes | Friends | List of all members
ShaderModelRenderer Class Reference

Implementation of ModelRenderer that loads the appropriate shaders for rendering each model, and that batches by shader (and by mesh and texture). More...

#include <ModelRenderer.h>

Inheritance diagram for ShaderModelRenderer:
ModelRenderer

Public Member Functions

 ShaderModelRenderer (ModelVertexRendererPtr vertexrender)
 
virtual ~ShaderModelRenderer ()
 
virtual void Submit (CModel *model)
 Submit: Submit a model for rendering this frame. More...
 
virtual void PrepareModels ()
 PrepareModels: Calculate renderer data for all previously submitted models. More...
 
virtual void EndFrame ()
 EndFrame: Remove all models from the list of submitted models. More...
 
virtual void Render (const RenderModifierPtr &modifier, const CShaderDefines &context, int flags)
 Render: Render submitted models, using the given RenderModifier to setup the fragment stage. More...
 
virtual void Filter (CModelFilter &filter, int passed, int flags)
 Filter: Filter submitted models, setting the passed flags on any models that pass the filter, and clearing them from models that fail. More...
 
- Public Member Functions inherited from ModelRenderer
 ModelRenderer ()
 
virtual ~ModelRenderer ()
 

Private Attributes

ShaderModelRendererInternalsm
 

Friends

struct ShaderModelRendererInternals
 

Additional Inherited Members

- Static Public Member Functions inherited from ModelRenderer
static void Init ()
 Initialise global settings. More...
 
static void CopyPositionAndNormals (const CModelDefPtr &mdef, const VertexArrayIterator< CVector3D > &Position, const VertexArrayIterator< CVector3D > &Normal)
 CopyPositionAndNormals: Copy unanimated object-space vertices and normals into the given vertex array. More...
 
static void BuildPositionAndNormals (CModel *model, const VertexArrayIterator< CVector3D > &Position, const VertexArrayIterator< CVector3D > &Normal)
 BuildPositionAndNormals: Build animated vertices and normals, transformed into world space. More...
 
static void BuildColor4ub (CModel *model, const VertexArrayIterator< CVector3D > &Normal, const VertexArrayIterator< SColor4ub > &Color)
 BuildColor4ub: Build lighting colors for the given model, based on previously calculated world space normals. More...
 
static void BuildUV (const CModelDefPtr &mdef, const VertexArrayIterator< float[2]> &UV, int UVset)
 BuildUV: Copy UV coordinates into the given vertex array. More...
 
static void BuildIndices (const CModelDefPtr &mdef, const VertexArrayIterator< u16 > &Indices)
 BuildIndices: Create the indices array for the given CModelDef. More...
 
static void GenTangents (const CModelDefPtr &mdef, std::vector< float > &newVertices, bool gpuSkinning)
 GenTangents: Generate tangents for the given CModelDef. More...
 

Detailed Description

Implementation of ModelRenderer that loads the appropriate shaders for rendering each model, and that batches by shader (and by mesh and texture).

Note that the term "Shader" is somewhat misleading, as this handled fixed-function rendering using the same API as real GLSL/ARB shaders.

Definition at line 278 of file ModelRenderer.h.

Constructor & Destructor Documentation

ShaderModelRenderer::ShaderModelRenderer ( ModelVertexRendererPtr  vertexrender)

Definition at line 223 of file ModelRenderer.cpp.

ShaderModelRenderer::~ShaderModelRenderer ( )
virtual

Definition at line 229 of file ModelRenderer.cpp.

Member Function Documentation

void ShaderModelRenderer::EndFrame ( )
virtual

EndFrame: Remove all models from the list of submitted models.

Implements ModelRenderer.

Definition at line 270 of file ModelRenderer.cpp.

void ShaderModelRenderer::Filter ( CModelFilter filter,
int  passed,
int  flags 
)
virtual

Filter: Filter submitted models, setting the passed flags on any models that pass the filter, and clearing them from models that fail.

Parameters
filterFilter to select a subset of models.
passedFlags to be set/cleared.
flagsIf non-zero, only models that contain flags have the filter test applied.

Implements ModelRenderer.

Definition at line 766 of file ModelRenderer.cpp.

void ShaderModelRenderer::PrepareModels ( )
virtual

PrepareModels: Calculate renderer data for all previously submitted models.

Must be called before any rendering calls and after all models for this frame have been submitted.

Implements ModelRenderer.

Definition at line 254 of file ModelRenderer.cpp.

void ShaderModelRenderer::Render ( const RenderModifierPtr modifier,
const CShaderDefines context,
int  flags 
)
virtual

Render: Render submitted models, using the given RenderModifier to setup the fragment stage.

Note
It is suggested that derived model renderers implement and use this Render functions. However, a highly specialized model renderer may need to "disable" this function and provide its own Render function with a different prototype.

preconditions : PrepareModels must be called after all models have been submitted and before calling Render.

Parameters
modifierThe RenderModifier that specifies the fragment stage.
flagsIf flags is 0, all submitted models are rendered. If flags is non-zero, only models that contain flags in their CModel::GetFlags() are rendered.

Implements ModelRenderer.

Definition at line 361 of file ModelRenderer.cpp.

void ShaderModelRenderer::Submit ( CModel model)
virtual

Submit: Submit a model for rendering this frame.

preconditions : The model must not have been submitted to any ModelRenderer in this frame. Submit may only be called after EndFrame and before PrepareModels.

Parameters
modelThe model that will be added to the list of models submitted this frame.

Implements ModelRenderer.

Definition at line 235 of file ModelRenderer.cpp.

Friends And Related Function Documentation

friend struct ShaderModelRendererInternals
friend

Definition at line 280 of file ModelRenderer.h.

Member Data Documentation

ShaderModelRendererInternals* ShaderModelRenderer::m
private

Definition at line 294 of file ModelRenderer.h.


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