ProcessedMaterial Class Reference

#include <processedMaterial.h>

Inheritance diagram for ProcessedMaterial:

Inheritance graph
[legend]
List of all members.

Detailed Description

This is an abstract base class which provides the external interface all subclasses must implement.

This interface primarily consists of setting state. Pass creation is implementation specific, and internal, thus it is not in this base class.


Public Member Functions

 ProcessedMaterial ()
virtual ~ProcessedMaterial ()
virtual void init (const GFXMaterialFeatureData::FeatureListHandle &features, GFXVertexFlags vertFlags)=0
 Initializes us (eg. loads textures, creates passes, generates shaders).
virtual bool setupPass (SceneState *, const SceneGraphData &sgData, U32 pass)=0
 Sets up the given pass.
virtual MaterialParametersallocMaterialParameters ()=0
virtual MaterialParametersgetDefaultMaterialParameters ()=0
virtual void setMaterialParameters (MaterialParameters *param, S32 pass)
virtual MaterialParametersgetMaterialParameters ()
virtual MaterialParameterHandlegetMaterialParameterHandle (const String &name)=0
virtual void cleanup (U32 pass)
 Cleans up the state and resources set by the given pass.
RenderPassDatagetPass (U32 pass)
 Returns the pass data for the given pass.
const RenderPassDatagetPass (U32 pass) const
 Returns the pass data for the given pass (const version).
virtual U32 getNumStages ()=0
 Returns the number of stages we're rendering (not to be confused with the number of passes).
U32 getNumPasses ()
 Returns the number of passes we are rendering (not to be confused with the number of stages).
bool hasGlow ()
 Returns true if any pass glows.
U32 getStageFromPass (U32 pass) const
 Gets the stage number for a pass.
virtual void dumpMaterialInfo ()
 Dump shader info, or FF texture info?
State setting functions
virtual void addStateBlockDesc (const GFXStateBlockDesc &sb)
virtual void setTextureStages (SceneState *, const SceneGraphData &sgData, U32 pass)=0
 Sets the textures needed for rendering the current pass.
virtual void setTransforms (const MatrixF &world, const MatrixF &view, const MatrixF &projection, const U32 pass)=0
 Sets the transformation matrix, i.e. Model * View * Projection.
virtual void setLightInfo (SceneState *, const SceneGraphData &sgData, U32 pass)=0
 Sets the light info for the given pass.
virtual void setEyePosition (MatrixF objTrans, Point3F position, U32 pass)=0
 Sets the eye position so we can do view dependent effects such as specular lighting.
virtual void setBuffers (GFXVertexBufferHandleBase *vertBuffer, GFXPrimitiveBufferHandle *primBuffer)
 Sets the given vertex and primitive buffers so we can render geometry.

Protected Member Functions

void _setBlendState (Material::BlendOp blendOp, GFXStateBlockDesc &desc)
 Sets the blend state for rendering.
GFXTexHandle _createTexture (const char *filename, GFXTextureProfile *profile)
 Loads the texture located at filename and gives it the specified profile.
State blocks
virtual void _initStateBlockTemplates (GFXStateBlockDesc &stateTranslucent, GFXStateBlockDesc &stateGlow, GFXStateBlockDesc &stateReflect)
 Creates the default state block templates, used by initStateBlocks.
virtual void _initPassStateBlock (const Material::BlendOp blendOp, U32 numTex, const U32 texFlags[Material::MAX_TEX_PER_PASS], GFXStateBlockDesc &result)
 Does the base render state block setting, normally per pass.
virtual void _initRenderStateStateBlocks (const Material::BlendOp blendOp, U32 numTex, const U32 texFlags[Material::MAX_TEX_PER_PASS], GFXStateBlockRef renderStates[RenderPassData::STATE_MAX])
 Creates the default state blocks for a list of render states.
virtual void _initRenderPassDataStateBlocks ()
 Creates the default state blocks for each RenderPassData item.
virtual U32 _getRenderStateIndex (const SceneGraphData &sgData)
 This returns the index into the renderState array based on the sgData passed in.
virtual void _setRenderState (const SceneGraphData &sgData, const U32 pass)
 Activates the correct mPasses[currPass].renderState based on scene graph info.

Protected Attributes

Vector< RenderPassData * > mPasses
 Our passes.
MaterialmMaterial
 The material which we are processing.
MaterialParametersmCurrentParams
Material::StageData mStages [Material::MAX_STAGES]
 Material::StageData is used here because the shader generator throws a fit if it's passed anything else.
bool mHasSetStageData
 If we've already loaded the stage data.
bool mHasGlow
 If we glow.
U32 mMaxStages
 Number of stages (not to be confused with number of passes).
GFXVertexFlags mVertFlags
 Vertex flags.
GFXStateBlockDesc mUserDefined


Constructor & Destructor Documentation

ProcessedMaterial::ProcessedMaterial (  ) 

virtual ProcessedMaterial::~ProcessedMaterial (  )  [virtual]


Member Function Documentation

virtual void ProcessedMaterial::addStateBlockDesc ( const GFXStateBlockDesc sb  )  [virtual]

virtual void ProcessedMaterial::setTextureStages ( SceneState ,
const SceneGraphData sgData,
U32  pass 
) [pure virtual]

Sets the textures needed for rendering the current pass.

Implemented in ProcessedCustomMaterial, ProcessedFFMaterial, and ProcessedShaderMaterial.

virtual void ProcessedMaterial::setTransforms ( const MatrixF world,
const MatrixF view,
const MatrixF projection,
const U32  pass 
) [pure virtual]

Sets the transformation matrix, i.e. Model * View * Projection.

Implemented in ProcessedFFMaterial, and ProcessedShaderMaterial.

virtual void ProcessedMaterial::setLightInfo ( SceneState ,
const SceneGraphData sgData,
U32  pass 
) [pure virtual]

Sets the light info for the given pass.

Implemented in ProcessedFFMaterial, and ProcessedShaderMaterial.

virtual void ProcessedMaterial::setEyePosition ( MatrixF  objTrans,
Point3F  position,
U32  pass 
) [pure virtual]

Sets the eye position so we can do view dependent effects such as specular lighting.

Implemented in ProcessedFFMaterial, and ProcessedShaderMaterial.

virtual void ProcessedMaterial::setBuffers ( GFXVertexBufferHandleBase vertBuffer,
GFXPrimitiveBufferHandle primBuffer 
) [virtual]

Sets the given vertex and primitive buffers so we can render geometry.

virtual void ProcessedMaterial::init ( const GFXMaterialFeatureData::FeatureListHandle features,
GFXVertexFlags  vertFlags 
) [pure virtual]

Initializes us (eg. loads textures, creates passes, generates shaders).

Implemented in ProcessedCustomMaterial, ProcessedFFMaterial, and ProcessedShaderMaterial.

virtual bool ProcessedMaterial::setupPass ( SceneState ,
const SceneGraphData sgData,
U32  pass 
) [pure virtual]

Sets up the given pass.

Returns true if the pass was set up, false if there was an error or if the specified pass is out of bounds.

Implemented in ProcessedCustomMaterial, ProcessedFFMaterial, and ProcessedShaderMaterial.

virtual MaterialParameters* ProcessedMaterial::allocMaterialParameters (  )  [pure virtual]

virtual MaterialParameters* ProcessedMaterial::getDefaultMaterialParameters (  )  [pure virtual]

virtual void ProcessedMaterial::setMaterialParameters ( MaterialParameters param,
S32  pass 
) [inline, virtual]

virtual MaterialParameters* ProcessedMaterial::getMaterialParameters (  )  [inline, virtual]

virtual MaterialParameterHandle* ProcessedMaterial::getMaterialParameterHandle ( const String name  )  [pure virtual]

virtual void ProcessedMaterial::cleanup ( U32  pass  )  [virtual]

Cleans up the state and resources set by the given pass.

Reimplemented in ProcessedCustomMaterial, ProcessedFFMaterial, and ProcessedShaderMaterial.

RenderPassData* ProcessedMaterial::getPass ( U32  pass  )  [inline]

Returns the pass data for the given pass.

const RenderPassData* ProcessedMaterial::getPass ( U32  pass  )  const [inline]

Returns the pass data for the given pass (const version).

virtual U32 ProcessedMaterial::getNumStages (  )  [pure virtual]

Returns the number of stages we're rendering (not to be confused with the number of passes).

Implemented in ProcessedFFMaterial, and ProcessedShaderMaterial.

U32 ProcessedMaterial::getNumPasses (  )  [inline]

Returns the number of passes we are rendering (not to be confused with the number of stages).

bool ProcessedMaterial::hasGlow (  )  [inline]

Returns true if any pass glows.

U32 ProcessedMaterial::getStageFromPass ( U32  pass  )  const [inline]

Gets the stage number for a pass.

virtual void ProcessedMaterial::dumpMaterialInfo (  )  [inline, virtual]

Dump shader info, or FF texture info?

Reimplemented in ProcessedShaderMaterial.

void ProcessedMaterial::_setBlendState ( Material::BlendOp  blendOp,
GFXStateBlockDesc desc 
) [protected]

Sets the blend state for rendering.

GFXTexHandle ProcessedMaterial::_createTexture ( const char *  filename,
GFXTextureProfile profile 
) [protected]

Loads the texture located at filename and gives it the specified profile.

virtual void ProcessedMaterial::_initStateBlockTemplates ( GFXStateBlockDesc stateTranslucent,
GFXStateBlockDesc stateGlow,
GFXStateBlockDesc stateReflect 
) [protected, virtual]

Creates the default state block templates, used by initStateBlocks.

virtual void ProcessedMaterial::_initPassStateBlock ( const Material::BlendOp  blendOp,
U32  numTex,
const U32  texFlags[Material::MAX_TEX_PER_PASS],
GFXStateBlockDesc result 
) [protected, virtual]

Does the base render state block setting, normally per pass.

Reimplemented in ProcessedDynamicLightMaterial, ProcessedCustomMaterial, and ProcessedFFMaterial.

virtual void ProcessedMaterial::_initRenderStateStateBlocks ( const Material::BlendOp  blendOp,
U32  numTex,
const U32  texFlags[Material::MAX_TEX_PER_PASS],
GFXStateBlockRef  renderStates[RenderPassData::STATE_MAX] 
) [protected, virtual]

Creates the default state blocks for a list of render states.

virtual void ProcessedMaterial::_initRenderPassDataStateBlocks (  )  [protected, virtual]

Creates the default state blocks for each RenderPassData item.

virtual U32 ProcessedMaterial::_getRenderStateIndex ( const SceneGraphData sgData  )  [protected, virtual]

This returns the index into the renderState array based on the sgData passed in.

virtual void ProcessedMaterial::_setRenderState ( const SceneGraphData sgData,
const U32  pass 
) [protected, virtual]

Activates the correct mPasses[currPass].renderState based on scene graph info.


Member Data Documentation

The material which we are processing.

Material::StageData ProcessedMaterial::mStages[Material::MAX_STAGES] [protected]

Material::StageData is used here because the shader generator throws a fit if it's passed anything else.

If we've already loaded the stage data.

If we glow.

Number of stages (not to be confused with number of passes).

Vertex flags.