Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
ModelRenderer Class Reference

ModelRenderer renders a per-frame list of models. More...

#include <ModelRenderer.h>

Public Member Functions

void Render (Renderer::Backend::IDeviceCommandContext *deviceCommandContext, ModelVertexRenderer &modelVertexRenderer, RenderModifier &modifier, const CShaderDefines &context, int cullGroup, int flags, const ERenderMode renderMode, std::span< CModel * > submissions)
 Render: Render submitted models, using the given RenderModifier to setup the fragment stage. More...
 

Static Public Member Functions

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 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< std::uint16_t > &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

ModelRenderer renders a per-frame list of models.

It loads the appropriate shaders for rendering each model, and that batches by shader technique (and by mesh and texture).

ModelRenderer delegates vertex transformation/setup to a ModelVertexRenderer. It delegates fragment stage setup to a RenderModifier.

ModelRenderer also contains a number of static helper functions for building vertex arrays.

Member Function Documentation

◆ BuildIndices()

void ModelRenderer::BuildIndices ( const CModelDefPtr &  mdef,
const VertexArrayIterator< std::uint16_t > &  Indices 
)
static

BuildIndices: Create the indices array for the given CModelDef.

Parameters
mdefThe model definition object.
IndicesThe index array, must be able to hold mdef->GetNumFaces()*3 elements.

◆ BuildPositionAndNormals()

void ModelRenderer::BuildPositionAndNormals ( CModel *  model,
const VertexArrayIterator< CVector3D > &  Position,
const VertexArrayIterator< CVector3D > &  Normal 
)
static

BuildPositionAndNormals: Build animated vertices and normals, transformed into world space.

Parameters
modelThe model that is to be transformed.
PositionPoints 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).
NormalPoints to the array that will receive transformed normal vectors. The array behind the iterator must be as large as the Position array.

◆ BuildUV()

void ModelRenderer::BuildUV ( const CModelDefPtr &  mdef,
const VertexArrayIterator< float[2]> &  UV,
int  UVset 
)
static

BuildUV: Copy UV coordinates into the given vertex array.

Parameters
mdefThe model def.
UVPoints to the array that will receive UV coordinates. The array behind the iterator must large enough to hold mdef->GetNumVertices() vertices.

◆ CopyPositionAndNormals()

void ModelRenderer::CopyPositionAndNormals ( const CModelDefPtr &  mdef,
const VertexArrayIterator< CVector3D > &  Position,
const VertexArrayIterator< CVector3D > &  Normal 
)
static

CopyPositionAndNormals: Copy unanimated object-space vertices and normals into the given vertex array.

Parameters
mdefThe underlying CModelDef that contains mesh data.
PositionPoints to the array that will receive position vectors. The array behind the iterator must be large enough to hold model->GetModelDef()->GetNumVertices() vertices.
NormalPoints to the array that will receive normal vectors. The array behind the iterator must be as large as the Position array.

◆ GenTangents()

void ModelRenderer::GenTangents ( const CModelDefPtr &  mdef,
std::vector< float > &  newVertices,
bool  gpuSkinning 
)
static

GenTangents: Generate tangents for the given CModelDef.

Parameters
mdefThe model definition object.
newVerticesAn out vector of the unindexed vertices with tangents added. The new vertices cannot be used with existing face index and must be welded/reindexed.

◆ Render()

void ModelRenderer::Render ( Renderer::Backend::IDeviceCommandContext *  deviceCommandContext,
ModelVertexRenderer &  modelVertexRenderer,
RenderModifier &  modifier,
const CShaderDefines &  context,
int  cullGroup,
int  flags,
const ERenderMode  renderMode,
std::span< CModel * >  submissions 
)

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.

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.

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