![]() |
Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
|
Class ModelRenderer: Abstract base class for all model renders. More...
#include <ModelRenderer.h>

Public Member Functions | |
| ModelRenderer () | |
| virtual | ~ModelRenderer () |
| virtual void | Submit (int cullGroup, CModel *model)=0 |
| Submit: Submit a model for rendering this frame. More... | |
| virtual void | PrepareModels ()=0 |
| PrepareModels: Calculate renderer data for all previously submitted models. More... | |
| virtual void | UploadModels (Renderer::Backend::IDeviceCommandContext *deviceCommandContext)=0 |
| Upload renderer data for all previously submitted models to backend. More... | |
| virtual void | EndFrame ()=0 |
| EndFrame: Remove all models from the list of submitted models. More... | |
| virtual void | Render (Renderer::Backend::IDeviceCommandContext *deviceCommandContext, const RenderModifierPtr &modifier, const CShaderDefines &context, int cullGroup, int flags)=0 |
| Render: Render submitted models, using the given RenderModifier to setup the fragment stage. More... | |
Static Public Member Functions | |
| 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... | |
Class ModelRenderer: Abstract base class for all model renders.
A ModelRenderer manages a per-frame list of models.
It is supposed to be derived in order to create new ways in which the per-frame list of models can be managed (for batching, for transparent rendering, etc.) or potentially for rarely used special effects.
A typical ModelRenderer will delegate vertex transformation/setup to a ModelVertexRenderer. It will delegate fragment stage setup to a RenderModifier.
For most purposes, you should use a BatchModelRenderer with specialized ModelVertexRenderer and RenderModifier implementations.
It is suggested that a derived class implement the provided generic Render function, however in some cases it may be necessary to supply a Render function with a different prototype.
ModelRenderer also contains a number of static helper functions for building vertex arrays.
|
inline |
|
inlinevirtual |
|
static |
BuildColor4ub: Build lighting colors for the given model, based on previously calculated world space normals.
| model | The model that is to be lit. |
| Normal | Array of the model's normal vectors, animated and transformed into world space. |
| Color | Points to the array that will receive the lit vertex color. The array behind the iterator must large enough to hold model->GetModelDef()->GetNumVertices() vertices. |
|
static |
BuildIndices: Create the indices array for the given CModelDef.
| mdef | The model definition object. |
| Indices | The index array, must be able to hold mdef->GetNumFaces()*3 elements. |
|
static |
BuildPositionAndNormals: Build animated vertices and normals, transformed into world space.
| model | The model that is to be transformed. |
| Position | Points to the array that will receive transformed position vectors. The array behind the iterator must be large enough to hold model->GetModelDef()->GetNumVertices() vertices. It must allow 16 bytes to be written to each element (i.e. provide 4 bytes of padding after each CVector3D). |
| Normal | Points to the array that will receive transformed normal vectors. The array behind the iterator must be as large as the Position array. |
|
static |
BuildUV: Copy UV coordinates into the given vertex array.
| mdef | The model def. |
| UV | Points to the array that will receive UV coordinates. The array behind the iterator must large enough to hold mdef->GetNumVertices() vertices. |
|
static |
CopyPositionAndNormals: Copy unanimated object-space vertices and normals into the given vertex array.
| mdef | The underlying CModelDef that contains mesh data. |
| Position | Points to the array that will receive position vectors. The array behind the iterator must be large enough to hold model->GetModelDef()->GetNumVertices() vertices. |
| Normal | Points to the array that will receive normal vectors. The array behind the iterator must be as large as the Position array. |
|
pure virtual |
EndFrame: Remove all models from the list of submitted models.
Implemented in ShaderModelRenderer.
|
static |
GenTangents: Generate tangents for the given CModelDef.
| mdef | The model definition object. |
| newVertices | An out vector of the unindexed vertices with tangents added. The new vertices cannot be used with existing face index and must be welded/reindexed. |
|
static |
Initialise global settings.
Should be called before using the class.
|
pure 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.
Implemented in ShaderModelRenderer.
|
pure virtual |
Render: Render submitted models, using the given RenderModifier to setup the fragment stage.
preconditions : PrepareModels must be called after all models have been submitted and before calling Render.
| modifier | The RenderModifier that specifies the fragment stage. |
| flags | If flags is 0, all submitted models are rendered. If flags is non-zero, only models that contain flags in their CModel::GetFlags() are rendered. |
Implemented in ShaderModelRenderer.
|
pure 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.
| model | The model that will be added to the list of models submitted this frame. |
Implemented in ShaderModelRenderer.
|
pure virtual |
Upload renderer data for all previously submitted models to backend.
Must be called before any rendering calls and after all models for this frame have been prepared.
Implemented in ShaderModelRenderer.