Public Member Functions | Protected Member Functions | Protected Attributes | Friends

sp::video::MaterialStates Class Reference

MaterialStates class used to store and handle material attributes. More...

#include <spMaterialStates.hpp>

List of all members.

Public Member Functions

 MaterialStates ()
 MaterialStates (const MaterialStates *Other)
virtual ~MaterialStates ()
virtual void copy (const MaterialStates *Other)
 Copies all attributes.
virtual bool compare (const MaterialStates *Other) const
 Returns true if the settings are equal with the other one. Otherwise false.
virtual void update ()
void setWireframe (const EWireframeTypes Type)
 Sets the wireframe only for this MaterialNode.
void setWireframe (const EWireframeTypes TypeFront, const EWireframeTypes TypeBack)
EWireframeTypes getWireframeFront () const
 Returns the wireframe mode for the front side of polygons.
EWireframeTypes getWireframeBack () const
 Returns the wireframe mode for the back side of polygons.
void setRenderFace (const EFaceTypes Face)
EFaceTypes getRenderFace () const
void setShininess (f32 Intensity)
f32 getShininess () const
 Returns shininess factor.
void setShininessFactor (f32 Factor)
 Sets the real renderer shininess factor in the range [0.0, 128.0].
f32 getShininessFactor () const
 Returns the real renderer shininess factor in the range [0.0, 128.0].
void setColorMaterial (bool isColorMaterial)
bool getColorMaterial () const
 Returns status of color material.
void setLighting (bool isLighting)
 Enables or disables lighting computations.
bool getLighting () const
 Returns status of lighting computations.
void setDepthBuffer (bool isDepthBuffer)
 Enabled or disables depth buffering.
bool getDepthBuffer () const
 Returns status of depth buffering.
void setBlending (bool isBlending)
 Enabled or disables alpha blending.
bool getBlending () const
 Returns status of alpha blending.
void setFog (bool isFog)
 Enables or disables fog effect.
bool getFog () const
 Returns status of fog effect.
void setPolygonOffset (bool isPolygonOffset)
 Enables or disables polygon offset without changing factor or units.
bool getPolygonOffset () const
 Returns status of polygon offset.
void setColors (const color &Diffuse, const color &Ambient, const color &Specular, const color &Emission)
void setDiffuseColor (const color &Color)
 Sets the diffuse color. This is the main color for coloring objects.
color getDiffuseColor () const
 Returns diffuse color.
colorgetDiffuseColor ()
 Returns diffuse color reference.
void setAmbientColor (const color &Color)
 Sets the ambient color. This is the color for the areas where no light is.
color getAmbientColor () const
 Returns ambient color.
colorgetAmbientColor ()
 Returns ambient color reference.
void setSpecularColor (const color &Color)
 Sets the specular color. Use "setShininess" to set the specular's intensity.
color getSpecularColor () const
 Returns specular color.
colorgetSpecularColor ()
 Returns specular color reference.
void setEmissionColor (const color &Color)
color getEmissionColor () const
 Returns emission color.
colorgetEmissionColor ()
 Returns emission color reference.
void setDiffuseAlpha (f32 Alpha)
 Only sets the diffuse's alpha channel with a floating-point.
void setShading (const EShadingTypes Type)
EShadingTypes getShading () const
 Returns the shading type.
void setPolygonOffset (bool isPolygonOffset, f32 OffsetFactor, f32 OffsetUnits=0.0f)
void setPolygonOffsetFactor (f32 Factor)
 Sets the polygon offset factor. By defautl 0.0.
f32 getPolygonOffsetFactor () const
 Returns the polygon offset factor. By default 0.0.
void setPolygonOffsetUnits (f32 Units)
 Sets the polygon offset units. By default 0.0.
f32 getPolygonOffsetUnits () const
 Returns the polygon offset units. By default 0.0.
void setBlendingMode (const EDefaultBlendingTypes Mode)
void setBlendingMode (const EBlendingTypes BlendSource, const EBlendingTypes BlendTarget)
void setBlendSource (const EBlendingTypes BlendSource)
 Sets the blending source.
EBlendingTypes getBlendSource () const
 Returns the blending source.
void setBlendTarget (const EBlendingTypes BlendTarget)
 Sets the blending target.
EBlendingTypes getBlendTarget () const
 Returns the blending target.
void setDepthMethod (const ESizeComparisionTypes Method)
ESizeComparisionTypes getDepthMethod () const
 Returns the depth-test function.
virtual void setAlphaMethod (const ESizeComparisionTypes Method, f32 AlphaReference)
void setAlphaMethod (const ESizeComparisionTypes Method)
 Sets the alpha-test method without changing the alpha reference value.
ESizeComparisionTypes getAlphaMethod () const
 Returns the alpha-test method.
void setAlphaReference (f32 AlphaReference)
 Sets the alpha-test reference value.
f32 getAlphaReference () const
 Returns the alpha-test reference value.
void setMaterialCallback (const UserMaterialCallback &MaterialCallback)
UserMaterialCallback getMaterialCallback () const
 Returns the material callback.

Protected Member Functions

virtual void setDefaultBlending (const video::EDefaultBlendingTypes Mode, video::EBlendingTypes &SrcBlend, video::EBlendingTypes &DestBlend)

Protected Attributes

color ColorDiffuse_
 Diffuse material color which represents the main object's color (by default 255, 255, 255, 255).
color ColorAmbient_
 Ambient material color (by default 50, 50, 50, 255).
color ColorSpecular_
 Specular material color (by default 255, 255, 255, 255).
color ColorEmission_
 Emission material color (by default 0, 0, 0, 255).
f32 Shininess_
 Shininess factor (must be in a range of 0.0 to 1.0).
f32 AlphaReference_
 Reference value for the alpha test method (must be in a range of 0.0 to 1.0).
f32 OffsetFactor_
 Polygon offset factor. If polygon offset is enabled each pixel's depth value will be modified by this factor.
f32 OffsetUnits_
 Polygon offset units. If polygon offset is enabled each pixel's depth value will be moved by this value.
EShadingTypes Shading_
 Shading mode (flat, gouraud, phong or per-pixel).
ESizeComparisionTypes DepthMethod_
 Depth test method.
ESizeComparisionTypes AlphaMethod_
 Alpha test method.
EBlendingTypes BlendSource_
 Source blend type for alpha-blending.
EBlendingTypes BlendTarget_
 Target blend type for alpha-blending.
EWireframeTypes RenderModeFront_
 Specifies the wireframe mode for the front side of each triangle.
EWireframeTypes RenderModeBack_
 Specifies the wireframe mode for the back side of each triangle.
EFaceTypes RenderFace_
 Specifies which face's sides are used (front, back or both).
bool isColorMaterial_
 Option for per-vertex coloring if enabled (by default enabled).
bool isLighting_
 Option for lighting (by default enabled; global lighting needs to be enabled).
bool isBlending_
 Option for alpha-blending (by default enabled).
bool isZBuffer_
 Option for depth-buffering (by default enabled).
bool isFog_
 Option for fog effect (by default enabled; global fog effect needs to be enabled).
bool isPolygonOffset_
 Option for polygon offset which manipulates each pixel depth value which is to be written (by default disabled).
UserMaterialCallback UserMaterialProc_

Friends

class Direct3D9RenderSystem
class Direct3D11RenderSystem

Detailed Description

MaterialStates class used to store and handle material attributes.


Constructor & Destructor Documentation

sp::video::MaterialStates::MaterialStates (  ) 
sp::video::MaterialStates::MaterialStates ( const MaterialStates Other  ) 
sp::video::MaterialStates::~MaterialStates (  )  [virtual]

Member Function Documentation

bool sp::video::MaterialStates::compare ( const MaterialStates Other  )  const [virtual]

Returns true if the settings are equal with the other one. Otherwise false.

void sp::video::MaterialStates::copy ( const MaterialStates Other  )  [virtual]

Copies all attributes.

ESizeComparisionTypes sp::video::MaterialStates::getAlphaMethod (  )  const [inline]

Returns the alpha-test method.

f32 sp::video::MaterialStates::getAlphaReference (  )  const [inline]

Returns the alpha-test reference value.

color& sp::video::MaterialStates::getAmbientColor (  )  [inline]

Returns ambient color reference.

color sp::video::MaterialStates::getAmbientColor (  )  const [inline]

Returns ambient color.

bool sp::video::MaterialStates::getBlending (  )  const [inline]

Returns status of alpha blending.

EBlendingTypes sp::video::MaterialStates::getBlendSource (  )  const [inline]

Returns the blending source.

EBlendingTypes sp::video::MaterialStates::getBlendTarget (  )  const [inline]

Returns the blending target.

bool sp::video::MaterialStates::getColorMaterial (  )  const [inline]

Returns status of color material.

bool sp::video::MaterialStates::getDepthBuffer (  )  const [inline]

Returns status of depth buffering.

ESizeComparisionTypes sp::video::MaterialStates::getDepthMethod (  )  const [inline]

Returns the depth-test function.

color& sp::video::MaterialStates::getDiffuseColor (  )  [inline]

Returns diffuse color reference.

color sp::video::MaterialStates::getDiffuseColor (  )  const [inline]

Returns diffuse color.

color sp::video::MaterialStates::getEmissionColor (  )  const [inline]

Returns emission color.

color& sp::video::MaterialStates::getEmissionColor (  )  [inline]

Returns emission color reference.

bool sp::video::MaterialStates::getFog (  )  const [inline]

Returns status of fog effect.

bool sp::video::MaterialStates::getLighting (  )  const [inline]

Returns status of lighting computations.

UserMaterialCallback sp::video::MaterialStates::getMaterialCallback (  )  const [inline]

Returns the material callback.

bool sp::video::MaterialStates::getPolygonOffset (  )  const [inline]

Returns status of polygon offset.

f32 sp::video::MaterialStates::getPolygonOffsetFactor (  )  const [inline]

Returns the polygon offset factor. By default 0.0.

f32 sp::video::MaterialStates::getPolygonOffsetUnits (  )  const [inline]

Returns the polygon offset units. By default 0.0.

EFaceTypes sp::video::MaterialStates::getRenderFace (  )  const [inline]
EShadingTypes sp::video::MaterialStates::getShading (  )  const [inline]

Returns the shading type.

f32 sp::video::MaterialStates::getShininess (  )  const [inline]

Returns shininess factor.

f32 sp::video::MaterialStates::getShininessFactor (  )  const [inline]

Returns the real renderer shininess factor in the range [0.0, 128.0].

color sp::video::MaterialStates::getSpecularColor (  )  const [inline]

Returns specular color.

color& sp::video::MaterialStates::getSpecularColor (  )  [inline]

Returns specular color reference.

EWireframeTypes sp::video::MaterialStates::getWireframeBack (  )  const [inline]

Returns the wireframe mode for the back side of polygons.

EWireframeTypes sp::video::MaterialStates::getWireframeFront (  )  const [inline]

Returns the wireframe mode for the front side of polygons.

void sp::video::MaterialStates::setAlphaMethod ( const ESizeComparisionTypes  Method,
f32  AlphaReference 
) [virtual]

Sets the alpha-test function. By default "CMPSIZE_ALWAYS".

Parameters:
Method,: Alpha-test function which is proceeded before a pixel is rendered. In many games this test-function is used to avoid that pixels are rendered which are anyway not visible because of their alpha-channel. But the depth is normally also rendered into the depth-buffer which affects that sometimes problems can occur when using transparency 3D models. e.g. a mesh wire fence (good example are some maps from Counter-Strike 1). In this case you can set the alpha-test function to "CMPSIZE_GREATER" and "AlphaReference" to 0.5 and disable blending (using "isBlending = false" which is a member of MaterialStates). Then pixels with an alpha-channel lower than 0.5 are not rendered.
void sp::video::MaterialStates::setAlphaMethod ( const ESizeComparisionTypes  Method  )  [inline]

Sets the alpha-test method without changing the alpha reference value.

void sp::video::MaterialStates::setAlphaReference ( f32  AlphaReference  )  [inline]

Sets the alpha-test reference value.

void sp::video::MaterialStates::setAmbientColor ( const color Color  )  [inline]

Sets the ambient color. This is the color for the areas where no light is.

void sp::video::MaterialStates::setBlending ( bool  isBlending  )  [inline]

Enabled or disables alpha blending.

void sp::video::MaterialStates::setBlendingMode ( const EDefaultBlendingTypes  Mode  )  [inline]

Sets the blending mode.

Parameters:
Mode,: Sets the blending bright, dark or normal.
void sp::video::MaterialStates::setBlendingMode ( const EBlendingTypes  BlendSource,
const EBlendingTypes  BlendTarget 
) [inline]

Sets the blending source and target. Blending is particularly used for Billboards which represents a lense flare or kind of these things but can also be used for Mesh or Terrain objects.

Parameters:
BlendSource,: Source blending method.
BlendTarget,: Target/ destination blending method.
void sp::video::MaterialStates::setBlendSource ( const EBlendingTypes  BlendSource  )  [inline]

Sets the blending source.

void sp::video::MaterialStates::setBlendTarget ( const EBlendingTypes  BlendTarget  )  [inline]

Sets the blending target.

void sp::video::MaterialStates::setColorMaterial ( bool  isColorMaterial  )  [inline]

Enables or disables the color material. By default it is enabled. When disabling the color material the vertices' color will not be used but the "ColorDiffuse" front the material. This can be used when only one color for the whole Mesh/ Terrain shall be used and has to be changed very fast for large 3D models.

void sp::video::MaterialStates::setColors ( const color Diffuse,
const color Ambient,
const color Specular,
const color Emission 
) [inline]

Sets all colors.

Parameters:
Diffuse,: Diffuse (or rather basic) color.
Ambient,: Ambient color (where no light is).
Specular,: Specular color (Color for shininess).
Emission,: Emission color (Self lighting color).
void sp::video::MaterialStates::setDefaultBlending ( const video::EDefaultBlendingTypes  Mode,
video::EBlendingTypes SrcBlend,
video::EBlendingTypes DestBlend 
) [protected, virtual]
void sp::video::MaterialStates::setDepthBuffer ( bool  isDepthBuffer  )  [inline]

Enabled or disables depth buffering.

void sp::video::MaterialStates::setDepthMethod ( const ESizeComparisionTypes  Method  )  [inline]

Sets the depth-test function. By default "CMPSIZE_LESSEQUAL".

Parameters:
Method,: Detph-test function which is proceeded before a pixel is rendered.
void sp::video::MaterialStates::setDiffuseAlpha ( f32  Alpha  )  [inline]

Only sets the diffuse's alpha channel with a floating-point.

void sp::video::MaterialStates::setDiffuseColor ( const color Color  )  [inline]

Sets the diffuse color. This is the main color for coloring objects.

void sp::video::MaterialStates::setEmissionColor ( const color Color  )  [inline]

Sets the emission color. This color is normally used only for shaders. It specifies the reflection color (or rather reflection intensity).

void sp::video::MaterialStates::setFog ( bool  isFog  )  [inline]

Enables or disables fog effect.

void sp::video::MaterialStates::setLighting ( bool  isLighting  )  [inline]

Enables or disables lighting computations.

void sp::video::MaterialStates::setMaterialCallback ( const UserMaterialCallback MaterialCallback  )  [inline]

Sets the material callback. Use this to make extended configurations on a geometry object. If set, this function will be called twice. First times you can enable your extended options and second times you can disable it.

void sp::video::MaterialStates::setPolygonOffset ( bool  isPolygonOffset,
f32  OffsetFactor,
f32  OffsetUnits = 0.0f 
) [inline]

Sets polygon offset. With polygon offset you can manipulate the pixel depht values. Use this when you have polygons which lie direct onto other polygons to avoid "Z-fighting".

Parameters:
isPolygonOffset,: Enables or disables polygon offset.
OffsetFactor,: Factor whereby the pixel depth is multiplied.
OffsetUnits,: Units which are added to the pixel depth.
void sp::video::MaterialStates::setPolygonOffset ( bool  isPolygonOffset  )  [inline]

Enables or disables polygon offset without changing factor or units.

void sp::video::MaterialStates::setPolygonOffsetFactor ( f32  Factor  )  [inline]

Sets the polygon offset factor. By defautl 0.0.

void sp::video::MaterialStates::setPolygonOffsetUnits ( f32  Units  )  [inline]

Sets the polygon offset units. By default 0.0.

void sp::video::MaterialStates::setRenderFace ( const EFaceTypes  Face  )  [inline]

Sets the render face type.

Parameters:
Face,: Face type. Three types are supported: Front, Back, Both. This type specifies which side of each triangle is visible. This feature is also called "cullmode".
void sp::video::MaterialStates::setShading ( const EShadingTypes  Type  )  [inline]

Sets the shading type. By default "SHADING_GOURAUD" is used for a smooth lighting. When changing the shading type you have to call "updateNormals". Two methods are supported yet: Flat- and grouaud shading. There is also Phong shading but not supported yet, it will switch to Gouraud shading.

Parameters:
Type,: Type of shading (flat, gouraud, phong, per-pixel).
void sp::video::MaterialStates::setShininess ( f32  Intensity  )  [inline]

Sets the shininess.

Parameters:
Intensity,: Shininess factor (must be in a range of [0.0, 1.0]).
void sp::video::MaterialStates::setShininessFactor ( f32  Factor  )  [inline]

Sets the real renderer shininess factor in the range [0.0, 128.0].

void sp::video::MaterialStates::setSpecularColor ( const color Color  )  [inline]

Sets the specular color. Use "setShininess" to set the specular's intensity.

void sp::video::MaterialStates::setWireframe ( const EWireframeTypes  TypeFront,
const EWireframeTypes  TypeBack 
) [inline]

Sets the wireframe only for this mesh for the front- and the back side. By default only the front side is visible. You can set front, back or both by using the "setRenderFace" function.

void sp::video::MaterialStates::setWireframe ( const EWireframeTypes  Type  )  [inline]

Sets the wireframe only for this MaterialNode.

void sp::video::MaterialStates::update (  )  [virtual]

Updates the material states. Call this after changing material states manual. This is normally only used for the Direct3D11 video driver but as a good programming style always call it after changing a rasterizer-, depth-stencil- or blend state. This shall not include: colors (diffuse, ambient etc.), shininess, shading, color material and lighting.


Friends And Related Function Documentation

friend class Direct3D11RenderSystem [friend]
friend class Direct3D9RenderSystem [friend]

Member Data Documentation

Alpha test method.

Reference value for the alpha test method (must be in a range of 0.0 to 1.0).

Source blend type for alpha-blending.

Target blend type for alpha-blending.

Ambient material color (by default 50, 50, 50, 255).

Diffuse material color which represents the main object's color (by default 255, 255, 255, 255).

Emission material color (by default 0, 0, 0, 255).

Specular material color (by default 255, 255, 255, 255).

Depth test method.

Option for alpha-blending (by default enabled).

Option for per-vertex coloring if enabled (by default enabled).

Option for fog effect (by default enabled; global fog effect needs to be enabled).

Option for lighting (by default enabled; global lighting needs to be enabled).

Option for polygon offset which manipulates each pixel depth value which is to be written (by default disabled).

Option for depth-buffering (by default enabled).

Polygon offset factor. If polygon offset is enabled each pixel's depth value will be modified by this factor.

Polygon offset units. If polygon offset is enabled each pixel's depth value will be moved by this value.

Specifies which face's sides are used (front, back or both).

Specifies the wireframe mode for the back side of each triangle.

Specifies the wireframe mode for the front side of each triangle.

Shading mode (flat, gouraud, phong or per-pixel).

Shininess factor (must be in a range of 0.0 to 1.0).

User material callback function. If this function is set it will be called in the "render" function of the Mesh class before the material is set and the object is rendered where the given parameter "isBegin" is true. A second time it will be called after the object is rendered where the given parameter is 'false'. This function can be used to extend the functionallity of material settings. e.g. the material does not have a parameter to change the fog type for each object individual. In your own callback function you can change it when "isBegin" is true and reset it when it is false. In this way your options are immense.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines