Overview   Project   Class   Tree   Deprecated   Index 
0 A.D.
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD

renderer
Class ModelRenderer

   in ModelRenderer.h
   in ModelRenderer.cpp
Direct Known Subclasses:
BatchModelRenderer, RenderModifierRenderer, SortModelRenderer

class ModelRenderer

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.


Constructor Summary
ModelRenderer()
          
virtual ~ModelRenderer()
          
 
Method Summary
 static void BuildColor4ub( CModel* model, VertexArrayIterator< CVector3D > Normal, VertexArrayIterator< SColor4ub > Color, bool onlyDiffuse )
          BuildColor4ub: Build lighting colors for the given model, based on previously calculated world space normals.
 static void BuildIndices( CModelDefPtr mdef, u16* Indices )
          BatchModelRenderer implementation
 static void BuildPositionAndNormals( CModel* model, VertexArrayIterator< CVector3D > Position, VertexArrayIterator< CVector3D > Normal )
          BuildPositionAndNormals: Build animated vertices and normals, transformed into world space.
 static void BuildUV( CModelDefPtr mdef, VertexArrayIterator< float[ 2] > UV )
          BuildUV: Copy UV coordinates into the given vertex array.
 static void CopyPositionAndNormals( CModelDefPtr mdef, VertexArrayIterator< CVector3D > Position, VertexArrayIterator< CVector3D > Normal )
          CopyPositionAndNormals: Copy unanimated object-space vertices and normals into the given vertex array.
 virtual void EndFrame()= 0
          EndFrame: Remove all models from the list of submitted models.
 virtual bool HaveSubmissions()= 0
          HaveSubmissions: Return whether any models have been submitted this frame.
 virtual void PrepareModels()= 0
          PrepareModels: Calculate renderer data for all previously submitted models.
 virtual void Render( RenderModifierPtr modifier, u32 flags )= 0
          Render: Render submitted models, using the given RenderModifier to setup the fragment stage.
 virtual void Submit( CModel* model )= 0
          Submit: Submit a model for rendering this frame.
 

Constructor Detail

ModelRenderer

public ModelRenderer();

~ModelRenderer

public virtual ~ModelRenderer();


Method Detail

BuildColor4ub

public static void BuildColor4ub( CModel* model, VertexArrayIterator< CVector3D > Normal, VertexArrayIterator< SColor4ub > Color, bool onlyDiffuse );
BuildColor4ub: Build lighting colors for the given model, based on previously calculated world space normals.
Parameters:
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.
onlyDiffuse - if true, color will only contain the diffuse term (instead of both ambient and diffuse)

BuildIndices

public static void BuildIndices( CModelDefPtr mdef, u16* Indices );
BatchModelRenderer implementation

BuildPositionAndNormals

public static void BuildPositionAndNormals( CModel* model, VertexArrayIterator< CVector3D > Position, VertexArrayIterator< CVector3D > Normal );
BuildPositionAndNormals: Build animated vertices and normals, transformed into world space.
Parameters:
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.
Normal - Points to the array that will receive transformed normal vectors. The array behind the iterator must be as large as the Position array.

BuildUV

public static void BuildUV( CModelDefPtr mdef, VertexArrayIterator< float[ 2] > UV );
BuildUV: Copy UV coordinates into the given vertex array.
Parameters:
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.

CopyPositionAndNormals

public static void CopyPositionAndNormals( CModelDefPtr mdef, VertexArrayIterator< CVector3D > Position, VertexArrayIterator< CVector3D > Normal );
CopyPositionAndNormals: Copy unanimated object-space vertices and normals into the given vertex array.
Parameters:
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.

EndFrame

public virtual void EndFrame()= 0;
EndFrame: Remove all models from the list of submitted models.

HaveSubmissions

public virtual bool HaveSubmissions()= 0;
HaveSubmissions: Return whether any models have been submitted this frame.
Returns:
true if models have been submitted, false otherwise.

PrepareModels

public virtual void PrepareModels()= 0;
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.

Render

public virtual void Render( RenderModifierPtr modifier, u32 flags )= 0;
Render: Render submitted models, using the given RenderModifier to setup the fragment stage.
Parameters:
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.

Submit

public virtual void Submit( CModel* model )= 0;
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:
model - The model that will be added to the list of models submitted this frame.

 Overview   Project   Class   Tree   Deprecated   Index 
0 A.D.
Generated on September 04, 2007 at 18:14
CppDoc v2.4.0
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD