NL3D::CMaterial Class Reference

A material represent ALL the states relatives to the aspect of a primitive. More...

#include <material.h>

Inherits NLMISC::CRefCount.

List of all members.

Classes

struct  CLightMap
struct  CTexEnv
struct  CUserTexMat

Public Types

enum  ZFunc {
  always = 0, never, equal, notequal,
  less, lessequal, greater, greaterequal,
  zfuncCount
}
enum  TBlend {
  one = 0, zero, srcalpha, invsrcalpha,
  srccolor, invsrccolor, blendConstantColor, blendConstantInvColor,
  blendConstantAlpha, blendConstantInvAlpha, blendCount
}
 

Blend enums.

More...
enum  TShader {
  Normal = 0, Bump, UserColor, LightMap,
  Specular, Caustics, PerPixelLighting, PerPixelLightingNoSpec,
  Cloud, Water, shaderCount
}
 

Normal shader:

  • use simple multitexturing.
More...
enum  TTexCoordGenMode { TexCoordGenReflect = 0, TexCoordGenObjectSpace, TexCoordGenEyeSpace, numTexCoordGenMode }
 

TexGen Mode.

More...
typedef std::vector< CLightMapTTexturePtrs
Texture Env Modes.



enum  TTexOperator {
  Replace = 0, Modulate, Add, AddSigned,
  InterpolateTexture, InterpolatePrevious, InterpolateDiffuse, InterpolateConstant,
  EMBM, Mad, TexOperatorCount
}
 

Environements operators: Replace: out= arg0 Modulate: out= arg0 * arg1 Add: out= arg0 + arg1 AddSigned: out= arg0 + arg1 -0.5 Interpolate*: out= arg0*As + arg1*(1-As), where As is taken from the SrcAlpha of Texture/Previous/Diffuse/Constant, respectively if operator is InterpolateTexture/InterpolatePrevious/InterpolateDiffuse/InterpolateConstant.

More...
enum  TTexSource {
  Texture = 0, Previous, Diffuse, Constant,
  TexSourceCount
}
 

Source argument.

More...
enum  TTexOperand {
  SrcColor = 0, InvSrcColor, SrcAlpha, InvSrcAlpha,
  TexOperandCount
}
 

Operand for the argument.

More...
Texture Addressing Modes. They are valid only with the normal texture shader.

All modes are not supported everywhere, so you should check for it in the driver.

The modes are similar to those introduced with DirectX 8.0 Pixel Shaders and OpenGL TEXTURE_SHADERS_NV



enum  TTexAddressingMode {
  TextureOff = 0, FetchTexture, PassThrough, CullFragment,
  OffsetTexture, OffsetTextureScale, DependentARTexture, DependentGBTexture,
  DP3, DP3Texture2D, DP3CubeMap, DP3ReflectCubeMap,
  DP3ConstEyeReflectCubeMap, DP3DiffuseCubeMap, DP3DepthReplace, TexAddrCount
}

Public Member Functions

void setShader (TShader val)
 Set the shader for this material.
TShader getShader () const
 get the current material shadertype.
bool getStainedGlassWindow ()
void setStainedGlassWindow (bool val)
void flushTextures (IDriver &driver, uint selectedTexture)
 Flush textures. Force texture generation.
void serial (NLMISC::IStream &f)
bool isSupportedByDriver (IDriver &drv, bool forceBaseCaps) const
 test if material a driver supports rendering of that material
uint32 getFlags () const
uint32 getTouched (void) const
void clearTouched (uint32 flag)
Object.



 CMaterial ()
 ctor.
 CMaterial (const CMaterial &mat)
 see operator=.
 ~CMaterial ()
 dtor.
CMaterialoperator= (const CMaterial &mat)
 Do not copy DrvInfos, copy all infos and set IDRV_TOUCHED_ALL.
Texture.



void setTexture (uint8 stage, ITexture *ptex)
 set a texture for a special stage.
ITexturegetTexture (uint8 stage) const
bool texturePresent (uint8 stage) const
uint getNumUsedTextureStages () const
Blending.



void setBlend (bool active)
void setBlendFunc (TBlend src, TBlend dst)
void setSrcBlend (TBlend val)
void setDstBlend (TBlend val)
bool getBlend () const
TBlend getSrcBlend (void) const
TBlend getDstBlend (void) const
Texture Addressing Mode Method



void enableTexAddrMode (bool enable=true)
 enable / disable the use of special texture addressing modes When enabled, all texture addressing modes are set to 'None'
bool texAddrEnabled () const
 test whether texture addressing mode are enabled
void setTexAddressingMode (uint8 stage, TTexAddressingMode mode)
 Set a texture addressing mode for the given stage.
TTexAddressingMode getTexAddressingMode (uint8 stage)
 Get the texture addressing mode for the given stage.
Double sided.



void setDoubleSided (bool active)
bool getDoubleSided () const
Alpha Test



void setAlphaTest (bool active)
bool getAlphaTest () const
void setAlphaTestThreshold (float thre)
 change the threshold against alpha is tested.
float getAlphaTestThreshold () const
ZBuffer.



void setZFunc (ZFunc val)
void setZWrite (bool active)
void setZBias (float val)
 The z bias is a z dispacement of the object to solve z precision problem.
ZFunc getZFunc (void) const
bool getZWrite (void) const
float getZBias (void) const
Color/Lighting..



void setColor (CRGBA rgba)
 The Color is used only if lighting is disabled. Also, color is replaced by per vertex color (if any).
void setLighting (bool active, CRGBA emissive=CRGBA(0, 0, 0), CRGBA ambient=CRGBA(0, 0, 0), CRGBA diffuse=CRGBA(0, 0, 0), CRGBA specular=CRGBA(0, 0, 0), float shininess=10)
 Batch setup lighting. Opacity is in diffuse.A.
void setEmissive (CRGBA emissive=CRGBA(0, 0, 0))
 Set the emissive part ot material. Useful only if setLighting(true) has been done.
void setAmbient (CRGBA ambient=CRGBA(0, 0, 0))
 Set the Ambient part ot material. Useful only if setLighting(true) has been done.
void setDiffuse (CRGBA diffuse=CRGBA(0, 0, 0))
 Set the Diffuse part ot material. Useful only if setLighting(true) has been done. NB: opacity is NOT copied from diffuse.A.
void setOpacity (uint8 opa)
 Set the Opacity part ot material. Useful only if setLighting(true) has been done.
void setSpecular (CRGBA specular=CRGBA(0, 0, 0))
 Set the specular part ot material. Useful only if setLighting(true) has been done.
void setShininess (float shininess)
 Set the shininess part ot material. Useful only if setLighting(true) has been done.
void setLightedVertexColor (bool useLightedVertexColor)
 Set the color material flag. Used when the material is lighted. True to use the diffuse color of the material when lighted, false to use the color vertex.
bool getLightedVertexColor () const
 Get the lighted vertex color flag.
bool isLighted () const
bool isLightedVertexColor () const
 Return true if this material uses color material as diffuse when lighted, else return false if it uses color vertex.
CRGBA getColor (void) const
CRGBA getEmissive () const
CRGBA getAmbient () const
CRGBA getDiffuse () const
 return diffuse part. NB: A==opacity.
uint8 getOpacity () const
CRGBA getSpecular () const
float getShininess () const
Texture environnement. Normal shader only.



void texEnvOpRGB (uint stage, TTexOperator ope)
 This part is valid for Normal shaders (nlassert).
void texEnvArg0RGB (uint stage, TTexSource src, TTexOperand oper)
void texEnvArg1RGB (uint stage, TTexSource src, TTexOperand oper)
void texEnvArg2RGB (uint stage, TTexSource src, TTexOperand oper)
void texEnvOpAlpha (uint stage, TTexOperator ope)
void texEnvArg0Alpha (uint stage, TTexSource src, TTexOperand oper)
void texEnvArg1Alpha (uint stage, TTexSource src, TTexOperand oper)
void texEnvArg2Alpha (uint stage, TTexSource src, TTexOperand oper)
void texConstantColor (uint stage, CRGBA color)
 Setup the constant color for a stage. Used for the TTexSource:Constant.
uint32 getTexEnvMode (uint stage)
 For push/pop only, get the packed version of the environnment mode.
void setTexEnvMode (uint stage, uint32 packed)
 For push/pop only, set the packed version of the environnment mode.
CRGBA getTexConstantColor (uint stage)
TTexOperator getTexEnvOpRGB (uint stage) const
TTexOperator getTexEnvOpAlpha (uint stage) const
void setTexCoordGen (uint stage, bool generate)
bool getTexCoordGen (uint stage) const
void setTexCoordGenMode (uint stage, TTexCoordGenMode mode)
TTexCoordGenMode getTexCoordGenMode (uint stage) const
void enableUserTexMat (uint stage, bool enabled=true)
bool isUserTexMatEnabled (uint stage) const
void setUserTexMat (uint stage, const NLMISC::CMatrix &m)
 Set a new texture matrix for the given stage.
const NLMISC::CMatrixgetUserTexMat (uint stage) const
 Get a const ref.
void decompUserTexMat (uint stage, float &uTrans, float &vTrans, float &wRot, float &uScale, float &vScale)
 Decompose a user texture matrix, We assume that this is only a matrix for 2d texture.
Texture UserColor. UserColor shader only.



void setUserColor (CRGBA userColor)
 This part is valid for Normal shaders (nlassert).
CRGBA getUserColor () const
LightMap. LightMap shader only.



void setLightMap (uint lmapId, ITexture *lmap)
 This part is valid for LightMap shaders (nlassert).
ITexturegetLightMap (uint lmapId) const
 Get the ith lightmap. (NULL if none).
void setLightMapFactor (uint lmapId, CRGBA factor)
 Set the lightmap intensity. (def : White).
void setLightMapMulx2 (bool val)
 Set the multiply x 2 mode to burn colors (used with lightmaps 8 bits) (def: false).
void setLMCColors (uint lmapId, CRGBA ambColor, CRGBA diffColor)
 Used for LightMap Compression (LMC). Set the LMC color terms. default to black/white (no compression).
Tools..



void initUnlit ()
 Init the material as unlit.
void initLighted ()
 Init the material as default white lighted material.



void selectTextureSet (uint index)
 Select one texture set for all the textures of this material.

Public Attributes

CSmartPtr< ITexture_Textures [IDRV_MAT_MAXTEXTURES]
uint8 _TexAddrMode [IDRV_MAT_MAXTEXTURES]
CTexEnv _TexEnvs [IDRV_MAT_MAXTEXTURES]
CRefPtr< IMaterialDrvInfos_MatDrvInfo
TTexturePtrs _LightMaps
bool _LightMapsMulx2

Private Attributes

TShader _ShaderType
uint32 _Flags
TBlend _SrcBlend
TBlend _DstBlend
ZFunc _ZFunction
float _ZBias
CRGBA _Color
CRGBA _Emissive
CRGBA _Ambient
CRGBA _Diffuse
CRGBA _Specular
float _Shininess
float _AlphaTestThreshold
uint32 _Touched
bool _StainedGlassWindow
uint16 _TexCoordGenMode
std::auto_ptr< CUserTexMat_TexUserMat

Detailed Description

A material represent ALL the states relatives to the aspect of a primitive.

Definition at line 141 of file material.h.


Member Typedef Documentation

Definition at line 728 of file material.h.


Member Enumeration Documentation

Blend enums.

see setSrcBlend()/setDstBlend()/setBlendFunc(). blendConstant* enums are only valid if driver->supportBlendConstantColor().

See also:
IDriver::supportBlendConstantColor()
Enumerator:
one 
zero 
srcalpha 
invsrcalpha 
srccolor 
invsrccolor 
blendConstantColor 
blendConstantInvColor 
blendConstantAlpha 
blendConstantInvAlpha 
blendCount 

Definition at line 151 of file material.h.

Normal shader:

  • use simple multitexturing.

see texEnv*() methods. Bump:

  • not implemented yet. UserColor:
  • UserColor (see setUserColor()) is blended with precomputed texture/textureAlpha.
  • Alpha Blending ignore Alpha of texture (of course :) ), but use Alpha diffuse (vertex/material color). LightMap:
  • Texture of stage 0 is blended with sum of lightmaps (see setLightmap()). Vertex Color (or color, or lighting) doesn't affect the final result (neither diffuse part nor specular part). Blending is special. If enabled, Lightmap shader apply a standard transparency srcalpha/invsrcalpha.
  • NB: if no texture in stage 0, undefined result.
  • UV0 is the UV for decal Texture. UV1 is the UVs for all the lightmaps. Specular:

Texture of stage 0 is added to the multiplication of Texture Alpha of stage 0 and Texture of stage 1

  • This is done in 2 passes PerPixelLighting :
  • When not supported by the driver, this is equivalent to the normal shader. This can be querried from the driver
  • When supported by the driver, the strongest light is rendered using per pixel lighting. The last tex coordinate must be the S vector of the tangent space basis (oriented in the direction where the s texture coords grows). Other lights are rendered using gouraud shaing. The light setup is done in the driver. PerPixelLighting : The same as PerPixelLighting but with no specular Caustics: NOT IMPLEMENTED Cloud :

Alpha of texture in stage 0 is blended with alpha of texture in stage 1. Blend done with the alpha color of each stage and the whole is multiplied by the alpha in color vertex [AT0*ADiffuseCol+AT1*(1-ADiffuseCol)]*AStage

  • RGB still unchanged
Enumerator:
Normal 
Bump 
UserColor 
LightMap 
Specular 
Caustics 
PerPixelLighting 
PerPixelLightingNoSpec 
Cloud 
Water 
shaderCount 

Definition at line 183 of file material.h.

Enumerator:
TextureOff 
FetchTexture 
PassThrough 
CullFragment 
OffsetTexture 
OffsetTextureScale 
DependentARTexture 
DependentGBTexture 
DP3 
DP3Texture2D 
DP3CubeMap 
DP3ReflectCubeMap 
DP3ConstEyeReflectCubeMap 
DP3DiffuseCubeMap 
DP3DepthReplace 
TexAddrCount 

Definition at line 236 of file material.h.

TexGen Mode.

TexCoordGenReflect: For Cube or Spherical EnvMapping. TexCoordGenObjectSpace: The UVW are generated from the XYZ defined in ObjectSpace (before transformation) TexCoordGenEyeSpace: The UVW are generated from the XYZ defined in EyeSpace (after ModelViewMatrix transformation) NB: use the TextureMatrix for more control on the wanted effect (eg: shadowMap projection etc...)

Enumerator:
TexCoordGenReflect 
TexCoordGenObjectSpace 
TexCoordGenEyeSpace 
numTexCoordGenMode 

Definition at line 254 of file material.h.

Operand for the argument.

For Alpha arguments, only SrcAlpha and InvSrcAlpha are Valid!!
SrcColor: arg= ColorSource. InvSrcColor: arg= 1-ColorSource. SrcAlpha: arg= AlphaSource. InvSrcAlpha: arg= 1-AlphaSource.

Enumerator:
SrcColor 
InvSrcColor 
SrcAlpha 
InvSrcAlpha 
TexOperandCount 

Definition at line 227 of file material.h.

Environements operators: Replace: out= arg0 Modulate: out= arg0 * arg1 Add: out= arg0 + arg1 AddSigned: out= arg0 + arg1 -0.5 Interpolate*: out= arg0*As + arg1*(1-As), where As is taken from the SrcAlpha of Texture/Previous/Diffuse/Constant, respectively if operator is InterpolateTexture/InterpolatePrevious/InterpolateDiffuse/InterpolateConstant.

Multiply-Add (Mad) out= arg0 * arg1 + arg2. Must be supported by driver (see IDriver::supportMADOperator) EMBM : apply to both color and alpha : the current texture, whose format is DSDT, is used to offset the texture in the next stage, unless the EMBM unit is at the last stage, in which case it operates on texture at first stage NB : for EMBM, this must be supported by driver.

Enumerator:
Replace 
Modulate 
Add 
AddSigned 
InterpolateTexture 
InterpolatePrevious 
InterpolateDiffuse 
InterpolateConstant 
EMBM 
Mad 
TexOperatorCount 

Definition at line 209 of file material.h.

Source argument.

Texture: the arg is taken from the current texture of the stage. Previous: the arg is taken from the previous enabled stage. If stage 0, Previous==Diffuse. Diffuse: the arg is taken from the primary color vertex. Constant: the arg is taken from the constant color setuped for this texture stage.

Enumerator:
Texture 
Previous 
Diffuse 
Constant 
TexSourceCount 

Definition at line 218 of file material.h.

Enumerator:
always 
never 
equal 
notequal 
less 
lessequal 
greater 
greaterequal 
zfuncCount 

Definition at line 145 of file material.h.


Constructor & Destructor Documentation

NL3D::CMaterial::CMaterial (  ) 

ctor.

By default, shader is normal, SrcBlend is srcalpha, dstblend is invsrcalpha, ZFunction is lessequal, ZBias is 0, Color is White: (255,255,255,255), not double sided.

Definition at line 39 of file material.cpp.

References _AlphaTestThreshold, _Color, _DstBlend, _Flags, _LightMapsMulx2, _ShaderType, _SrcBlend, _StainedGlassWindow, _TexCoordGenMode, _Touched, _ZBias, _ZFunction, NL3D::IDRV_MAT_ZWRITE, invsrcalpha, lessequal, Normal, NLMISC::CRGBA::set(), and srcalpha.

NL3D::CMaterial::CMaterial ( const CMaterial mat  )  [inline]

see operator=.

Definition at line 270 of file material.h.

References _Flags, _Touched, and operator=().

NL3D::CMaterial::~CMaterial (  ) 

dtor.

Definition at line 135 of file material.cpp.

References _MatDrvInfo, and NLMISC::CRefPtr< T >::kill().


Member Function Documentation

void NL3D::CMaterial::clearTouched ( uint32  flag  )  [inline]

Definition at line 735 of file material.h.

References _Touched.

Referenced by NL3D::CDriverGL::setupMaterial(), and NL3D::CDriverD3D::setupMaterial().

void NL3D::CMaterial::decompUserTexMat ( uint  stage,
float uTrans,
float vTrans,
float wRot,
float uScale,
float vScale 
)
void NL3D::CMaterial::enableTexAddrMode ( bool  enable = true  ) 

enable / disable the use of special texture addressing modes When enabled, all texture addressing modes are set to 'None'

Definition at line 477 of file material.cpp.

References _Flags, _TexAddrMode, NL3D::IDRV_MAT_MAXTEXTURES, NL3D::IDRV_MAT_TEX_ADDR, and TextureOff.

Referenced by NL3D::CPSMultiTexturedParticle::setupMultiTexEnv().

void NL3D::CMaterial::enableUserTexMat ( uint  stage,
bool  enabled = true 
) [inline]
void NL3D::CMaterial::flushTextures ( IDriver driver,
uint  selectedTexture 
)

Flush textures. Force texture generation.

Definition at line 370 of file material.cpp.

References _LightMaps, _ShaderType, _Textures, NL3D::IDRV_MAT_MAXTEXTURES, LightMap, and NL3D::IDriver::setupTexture().

Referenced by NL3D::CSegRemanenceShape::flushTextures().

bool NL3D::CMaterial::getAlphaTest (  )  const [inline]
float NL3D::CMaterial::getAlphaTestThreshold (  )  const [inline]
CRGBA NL3D::CMaterial::getAmbient (  )  const [inline]
bool NL3D::CMaterial::getBlend (  )  const [inline]
CRGBA NL3D::CMaterial::getColor ( void   )  const [inline]
CRGBA NL3D::CMaterial::getDiffuse (  )  const [inline]
bool NL3D::CMaterial::getDoubleSided (  )  const [inline]

Definition at line 338 of file material.h.

References _Flags, and NL3D::IDRV_MAT_DOUBLE_SIDED.

Referenced by NL3D::CZoneLighter::getTexture().

TBlend NL3D::CMaterial::getDstBlend ( void   )  const [inline]
CRGBA NL3D::CMaterial::getEmissive (  )  const [inline]
uint32 NL3D::CMaterial::getFlags (  )  const [inline]
bool NL3D::CMaterial::getLightedVertexColor (  )  const [inline]

Get the lighted vertex color flag.

Definition at line 199 of file driver_material_inline.h.

References _Flags, and NL3D::IDRV_MAT_LIGHTED_VERTEX_COLOR.

Referenced by NL3D::CDriverD3D::setupMaterial(), and NL3D::CPSConstraintMesh::setupRenderPasses().

ITexture * NL3D::CMaterial::getLightMap ( uint  lmapId  )  const

Get the ith lightmap. (NULL if none).

Definition at line 416 of file material.cpp.

References _LightMaps, _ShaderType, LightMap, and nlassert.

Referenced by NL3D::CShapeBank::processWaitingShapes(), and NL3D::CAsyncFileManager3D::CMeshLoad::run().

uint NL3D::CMaterial::getNumUsedTextureStages (  )  const

Definition at line 573 of file material.cpp.

References _Textures, and NL3D::IDRV_MAT_MAXTEXTURES.

Referenced by isSupportedByDriver().

uint8 NL3D::CMaterial::getOpacity (  )  const [inline]
TShader NL3D::CMaterial::getShader (  )  const [inline]
float NL3D::CMaterial::getShininess (  )  const [inline]
CRGBA NL3D::CMaterial::getSpecular (  )  const [inline]
TBlend NL3D::CMaterial::getSrcBlend ( void   )  const [inline]
bool NL3D::CMaterial::getStainedGlassWindow (  )  [inline]

Definition at line 516 of file material.h.

References _StainedGlassWindow.

CMaterial::TTexAddressingMode NL3D::CMaterial::getTexAddressingMode ( uint8  stage  ) 

Get the texture addressing mode for the given stage.

Definition at line 513 of file material.cpp.

References _Flags, _TexAddrMode, NL3D::IDRV_MAT_MAXTEXTURES, NL3D::IDRV_MAT_TEX_ADDR, and nlassert.

CRGBA NL3D::CMaterial::getTexConstantColor ( uint  stage  )  [inline]
bool NL3D::CMaterial::getTexCoordGen ( uint  stage  )  const [inline]
TTexCoordGenMode NL3D::CMaterial::getTexCoordGenMode ( uint  stage  )  const [inline]
uint32 NL3D::CMaterial::getTexEnvMode ( uint  stage  )  [inline]
CMaterial::TTexOperator NL3D::CMaterial::getTexEnvOpAlpha ( uint  stage  )  const [inline]
CMaterial::TTexOperator NL3D::CMaterial::getTexEnvOpRGB ( uint  stage  )  const [inline]
ITexture * NL3D::CMaterial::getTexture ( uint8  stage  )  const [inline]

Definition at line 44 of file driver_material_inline.h.

References _Textures, NL3D::IDRV_MAT_MAXTEXTURES, and nlassert.

Referenced by NL3D::CDriverGL::beginSpecularMultiPass(), NL3D::CCoarseMeshBuild::buildBitmap(), NL3D::CDriverD3D::computeRelevantTexEnv(), NL3D::CFontManager::computeString(), NL3D::CFontManager::computeStringInfo(), NL3D::CPSMaterial::forceModulateConstantColor(), NL3D::CPSMaterial::forceTexturedMaterialStages(), NL3D::UInstanceMaterial::getLastTextureStage(), NL3D::CZoneLighter::getTexture(), NL3D::UInstanceMaterial::getTextureFileName(), NL3D::UInstanceMaterial::getWrapS(), NL3D::UInstanceMaterial::getWrapT(), isSupportedByDriver(), NL3D::UInstanceMaterial::isTextureFile(), NL3D::CDriverD3D::needsConstantForDiffuse(), NL3D::CDriverD3D::needsConstants(), NL3D::CShapeBank::processWaitingShapes(), NL3D::CCoarseMeshBuild::remapCoordinates(), NL3D::CSegRemanence::render(), NL3D::CMeshMRMSkinnedGeom::renderSkinGroupPrimitives(), NL3D::CMeshMRMGeom::renderSkinGroupPrimitives(), NL3D::CAsyncFileManager3D::CMeshLoad::run(), NL3D::CMeshBaseInstance::selectTextureSet(), NL3D::CDriverGL::setTextureEnvFunction(), NL3D::UInstanceMaterial::setTextureFileName(), NL3D::CDriverGL::setupLightMapPass(), NL3D::CSegRemanenceShape::setupMaterial(), NL3D::CDriverGL::setupMaterial(), NL3D::CDriverD3D::setupMaterial(), NL3D::CDriverGL::setupPPLNoSpecPass(), NL3D::CDriverGL::setupPPLPass(), NL3D::CPSConstraintMesh::setupRenderPasses(), NL3D::CDriverGL::setupSpecularPass(), NL3D::CDriverGL::setupWaterPassARB(), NL3D::CDriverGL::setupWaterPassNV20(), NL3D::CDriverGL::setupWaterPassR200(), NL3D::UInstanceMaterial::setWrapS(), and NL3D::UInstanceMaterial::setWrapT().

uint32 NL3D::CMaterial::getTouched ( void   )  const [inline]

Definition at line 734 of file material.h.

References _Touched.

Referenced by NL3D::CDriverGL::setupMaterial(), and NL3D::CDriverD3D::setupMaterial().

CRGBA NL3D::CMaterial::getUserColor (  )  const [inline]
const NLMISC::CMatrix & NL3D::CMaterial::getUserTexMat ( uint  stage  )  const [inline]

Get a const ref.

on the texture matrix of the n-th stage. User texture matrix must be enabled for that stage, otherwise an assertion is raised.

Definition at line 418 of file driver_material_inline.h.

References _TexUserMat, isUserTexMatEnabled(), and nlassert.

Referenced by NL3D::UInstanceMaterial::getUserTexMat(), NL3D::CDriverD3D::setupMaterial(), and NL3D::CDriverGL::setupUserTextureMatrix().

float NL3D::CMaterial::getZBias ( void   )  const [inline]
ZFunc NL3D::CMaterial::getZFunc ( void   )  const [inline]
bool NL3D::CMaterial::getZWrite ( void   )  const [inline]
void NL3D::CMaterial::initLighted (  ) 

Init the material as default white lighted material.

normal shader, lighting .... Default to: normal shader, full black lighting, no texture, ZBias=0, ZFunc= lessequal, ZWrite==true, no blend. All other states are undefined (such as blend function, since blend is disabled).

Definition at line 77 of file material.cpp.

References initUnlit(), and setLighting().

void NL3D::CMaterial::initUnlit (  ) 
bool NL3D::CMaterial::isLighted (  )  const [inline]
bool NL3D::CMaterial::isLightedVertexColor (  )  const [inline]

Return true if this material uses color material as diffuse when lighted, else return false if it uses color vertex.

Definition at line 404 of file material.h.

References _Flags, and NL3D::IDRV_MAT_LIGHTED_VERTEX_COLOR.

Referenced by NL3D::CDriverGL::setupMaterial(), and NL3D::CDriverD3D::setupMaterial().

bool NL3D::CMaterial::isSupportedByDriver ( IDriver drv,
bool  forceBaseCaps 
) const

test if material a driver supports rendering of that material

Parameters:
forceBaseCaps When true, the driver is considered to have the most basic required caps (2 stages hardwares, no pixelShader, support for constant color blend & multiply-add texture operator), so that any fancy material will fail the test.

Definition at line 583 of file material.cpp.

References Bump, Caustics, Cloud, EMBM, NL3D::IDriver::getNbTextureStages(), getNumUsedTextureStages(), getShader(), getTexEnvOpAlpha(), getTexEnvOpRGB(), getTexture(), NL3D::IDRV_MAT_MAXTEXTURES, InterpolateConstant, NL3D::IDriver::isEMBMSupportedAtStage(), LightMap, Mad, min, nlassert, Normal, PerPixelLighting, PerPixelLightingNoSpec, Specular, NL3D::IDriver::supportBlendConstantColor(), NL3D::IDriver::supportEMBM(), NL3D::IDriver::supportMADOperator(), NL3D::IDriver::supportPerPixelLighting(), UserColor, and Water.

Referenced by NL3D::UInstance::supportMaterialRendering().

bool NL3D::CMaterial::isUserTexMatEnabled ( uint  stage  )  const [inline]
CMaterial & NL3D::CMaterial::operator= ( const CMaterial mat  ) 
void NL3D::CMaterial::selectTextureSet ( uint  index  ) 

Select one texture set for all the textures of this material.

This is useful only if textures of this material support selection of course (such as CTextureMultiFile)

Definition at line 556 of file material.cpp.

References _Textures, and NL3D::IDRV_MAT_MAXTEXTURES.

void NL3D::CMaterial::serial ( NLMISC::IStream f  ) 
void NL3D::CMaterial::setAlphaTest ( bool  active  )  [inline]
void NL3D::CMaterial::setAlphaTestThreshold ( float  thre  )  [inline]
void NL3D::CMaterial::setAmbient ( CRGBA  ambient = CRGBA(0,0,0)  )  [inline]

Set the Ambient part ot material. Useful only if setLighting(true) has been done.

Definition at line 156 of file driver_material_inline.h.

References _Ambient, _Touched, and NL3D::IDRV_TOUCHED_LIGHTING.

Referenced by serial(), and NL3D::UInstanceMaterial::setAmbient().

void NL3D::CMaterial::setBlend ( bool  active  )  [inline]
void NL3D::CMaterial::setBlendFunc ( TBlend  src,
TBlend  dst 
) [inline]
void NL3D::CMaterial::setColor ( NLMISC::CRGBA  rgba  )  [inline]

The Color is used only if lighting is disabled. Also, color is replaced by per vertex color (if any).

Definition at line 116 of file driver_material_inline.h.

References _Color, _Touched, and NL3D::IDRV_TOUCHED_COLOR.

Referenced by NL3D::CreateDummyMesh(), NL3D::CShadowMapManager::CShadowMapManager(), NL3D::CCloud::dispBill(), NL3D::CPSUtil::displayArrow(), NL3D::CPSUtil::displayBBox(), NL3D::CInstanceGroup::displayDebugClusters(), NL3D::CPSLocatedBindable::displayIcon2d(), NL3D::CPSRibbonLookAt::displayRibbons(), NL3D::CPSShockWave::draw(), NL3D::CPSDot::draw(), NL3D::CDRU::drawLine(), NL3D::CDRU::drawQuad(), NL3D::CDRU::drawTriangle(), NL3D::CShadowMapManager::fillBlackBorder(), NL3D::CNoise3d::flush(), NL3D::CCloud::genBill(), NL3D::CCloud::generate(), NL3D::CPSFanLight::init(), NL3D::CNoise3d::init(), initUnlit(), NL3D::CMotionBlur::performMotionBlur(), NL3D::CMeshBlender::prepareRenderForGlobalAlphaCoarseMesh(), NL3D::CVisualCollisionManager::receiveShadowMap(), NL3D::CComputedString::render2D(), NL3D::CComputedString::render3D(), NL3D::CScene::renderOcclusionTestMeshs(), NL3D::CShadowMapManager::renderProject(), NL3D::CCloud::reset(), NL3D::CMeshBlender::restoreRenderCoarseMesh(), NL3D::SCloudTexture3D::SCloudTexture3D(), NL3D::SCloudTextureClamp::SCloudTextureClamp(), NL3D::UInstanceMaterial::setColor(), NL3D::CPSTailDot::setupGlobalColor(), NL3D::CPSConstraintMesh::setupMaterialColor(), NL3D::CWaterModel::setupMaterialNVertexShader(), NL3D::CWaterModel::setupSimpleRender(), NL3D::CPSRibbon::setupTexturedGlobalColor(), NL3D::CPSRibbon::setupUntexturedGlobalColor(), NL3D::CPSGravity::show(), NL3D::CPSEmitter::showTool(), NL3D::CPSTailDot::step(), NL3D::CPSRibbonLookAt::step(), NL3D::CPSRibbon::step(), NL3D::CWaterModel::traverseRender(), NL3D::CFlareModel::traverseRender(), and NL3D::CPSQuad::updateMatBeforeRendering().

void NL3D::CMaterial::setDiffuse ( CRGBA  diffuse = CRGBA(0,0,0)  )  [inline]

Set the Diffuse part ot material. Useful only if setLighting(true) has been done. NB: opacity is NOT copied from diffuse.A.

Definition at line 162 of file driver_material_inline.h.

References _Diffuse, _Touched, NLMISC::CRGBA::B, NLMISC::CRGBA::G, NL3D::IDRV_TOUCHED_LIGHTING, and NLMISC::CRGBA::R.

Referenced by serial(), NL3D::UInstanceMaterial::setDiffuse(), and NL3D::CPSConstraintMesh::setupMaterialColor().

void NL3D::CMaterial::setDoubleSided ( bool  active  )  [inline]
void NL3D::CMaterial::setDstBlend ( TBlend  val  )  [inline]
void NL3D::CMaterial::setEmissive ( CRGBA  emissive = CRGBA(0,0,0)  )  [inline]

Set the emissive part ot material. Useful only if setLighting(true) has been done.

Definition at line 150 of file driver_material_inline.h.

References _Emissive, _Touched, and NL3D::IDRV_TOUCHED_LIGHTING.

Referenced by serial(), and NL3D::UInstanceMaterial::setEmissive().

void NL3D::CMaterial::setLightedVertexColor ( bool  useLightedVertexColor  )  [inline]

Set the color material flag. Used when the material is lighted. True to use the diffuse color of the material when lighted, false to use the color vertex.

Definition at line 189 of file driver_material_inline.h.

References _Flags, _Touched, NL3D::IDRV_MAT_LIGHTED_VERTEX_COLOR, and NL3D::IDRV_TOUCHED_LIGHTING.

Referenced by NL3D::CPSConstraintMesh::setupRenderPasses().

void NL3D::CMaterial::setLighting ( bool  active,
NLMISC::CRGBA  emissive = CRGBA(0,0,0),
NLMISC::CRGBA  ambient = CRGBA(0,0,0),
NLMISC::CRGBA  diffuse = CRGBA(0,0,0),
NLMISC::CRGBA  specular = CRGBA(0,0,0),
float  shininess = 10 
) [inline]
void NL3D::CMaterial::setLightMap ( uint  lmapId,
ITexture lmap 
)

This part is valid for LightMap shaders (nlassert).

See also:
TShader. Set the ith lightmap. undef results if holes in lightmap array.

Definition at line 405 of file material.cpp.

References _LightMaps, _ShaderType, _Touched, NL3D::IDRV_TOUCHED_LIGHTMAP, LightMap, and nlassert.

void NL3D::CMaterial::setLightMapFactor ( uint  lmapId,
CRGBA  factor 
)

Set the lightmap intensity. (def : White).

Definition at line 426 of file material.cpp.

References _LightMaps, _ShaderType, _Touched, NL3D::IDRV_TOUCHED_LIGHTMAP, and LightMap.

void NL3D::CMaterial::setLightMapMulx2 ( bool  val  )  [inline]

Set the multiply x 2 mode to burn colors (used with lightmaps 8 bits) (def: false).

Definition at line 496 of file material.h.

References _LightMapsMulx2.

void NL3D::CMaterial::setLMCColors ( uint  lmapId,
CRGBA  ambColor,
CRGBA  diffColor 
)

Used for LightMap Compression (LMC). Set the LMC color terms. default to black/white (no compression).

Definition at line 439 of file material.cpp.

References _LightMaps, _ShaderType, _Touched, NL3D::IDRV_TOUCHED_LIGHTMAP, and LightMap.

void NL3D::CMaterial::setOpacity ( uint8  opa  )  [inline]

Set the Opacity part ot material. Useful only if setLighting(true) has been done.

Definition at line 171 of file driver_material_inline.h.

References _Diffuse, _Touched, NLMISC::CRGBA::A, and NL3D::IDRV_TOUCHED_LIGHTING.

Referenced by NL3D::CMeshBlender::prepareRenderForGlobalAlpha(), NL3D::CMeshBlender::restoreRender(), and NL3D::UInstanceMaterial::setOpacity().

void NL3D::CMaterial::setShader ( TShader  val  ) 
void NL3D::CMaterial::setShininess ( float  shininess  )  [inline]

Set the shininess part ot material. Useful only if setLighting(true) has been done.

Definition at line 183 of file driver_material_inline.h.

References _Shininess, _Touched, and NL3D::IDRV_TOUCHED_LIGHTING.

Referenced by NL3D::UInstanceMaterial::setShininess().

void NL3D::CMaterial::setSpecular ( CRGBA  specular = CRGBA(0,0,0)  )  [inline]

Set the specular part ot material. Useful only if setLighting(true) has been done.

Definition at line 177 of file driver_material_inline.h.

References _Specular, _Touched, and NL3D::IDRV_TOUCHED_LIGHTING.

Referenced by serial(), and NL3D::UInstanceMaterial::setSpecular().

void NL3D::CMaterial::setSrcBlend ( TBlend  val  )  [inline]
void NL3D::CMaterial::setStainedGlassWindow ( bool  val  )  [inline]

Definition at line 517 of file material.h.

References _StainedGlassWindow.

void NL3D::CMaterial::setTexAddressingMode ( uint8  stage,
TTexAddressingMode  mode 
)

Set a texture addressing mode for the given stage.

You should test if this mode is supported in the driver you plane to use. Texture addressing modes should have been enabled otherwise an assertion is raised

Definition at line 503 of file material.cpp.

References _Flags, _TexAddrMode, NL3D::IDRV_MAT_MAXTEXTURES, NL3D::IDRV_MAT_TEX_ADDR, nlassert, and TexAddrCount.

Referenced by NL3D::CPSMultiTexturedParticle::setupMultiTexEnv().

void NL3D::CMaterial::setTexCoordGen ( uint  stage,
bool  generate 
) [inline]
void NL3D::CMaterial::setTexCoordGenMode ( uint  stage,
TTexCoordGenMode  mode 
) [inline]
void NL3D::CMaterial::setTexEnvMode ( uint  stage,
uint32  packed 
) [inline]

For push/pop only, set the packed version of the environnment mode.

Definition at line 322 of file driver_material_inline.h.

References _ShaderType, _TexEnvs, _Touched, NL3D::CMaterial::CTexEnv::EnvPacked, NL3D::IDRV_MAT_MAXTEXTURES, NL3D::IDRV_TOUCHED_TEXENV, nlassert, and Normal.

Referenced by NL3D::CLandscape::render(), and NL3D::CPSConstraintMesh::setupMaterialColor().

void NL3D::CMaterial::setTexture ( uint8  stage,
ITexture ptex 
)

set a texture for a special stage.

Different usage according to shader:

  • Normal shader do multitexturing (see texEnv*() methods).
  • UserColor assert if stage!=0. (NB: internal only: UserColor setup texture to stage 0 and 1).
  • LightMap assert if stage!=0.

Definition at line 337 of file material.cpp.

References _ShaderType, _Textures, _Touched, NL3D::IDRV_MAT_MAXTEXTURES, NL3D::IDRV_TOUCHED_TEX, LightMap, nlassert, and UserColor.

Referenced by NL3D::CLodCharacterManager::CLodCharacterManager(), NL3D::CreateDummyMesh(), NL3D::CShadowMapManager::CShadowMapManager(), NL3D::CCloud::disp(), NL3D::CCloud::dispBill(), NL3D::CBloomEffect::doBlur(), NL3D::CDeform2d::doDeform(), NL3D::CDRU::drawBitmap(), NL3D::UInstanceMaterial::emptyTexture(), NL3D::CPSMaterial::forceModulateConstantColor(), NL3D::CPSMaterial::forceTexturedMaterialStages(), NL3D::CNoise3d::init(), NL3D::SCloudTextureClamp::init(), NL3D::SCloudTexture3D::init(), NL3D::CBloomEffect::init(), NL3D::CBloomEffect::initBloom(), initUnlit(), CEGUI::NeLTexture::loadFromMemory(), NL3D::CVegetableManager::loadTexture(), NL3D::CMotionBlur::performMotionBlur(), NL3D::CVegetableManager::render(), NL3D::CLandscape::render(), NL3D::CShadowMapManager::renderGenerate(), NL3D::CShadowMapManager::renderProject(), NL3D::CWaterEnvMap::renderTestMesh(), setShader(), NL3D::UInstanceMaterial::setTextureFileName(), NL3D::UInstanceMaterial::setTextureMem(), NL3D::CPSMultiTexturedParticle::setupMaterial(), NL3D::CPSFanLight::setupMaterial(), NL3D::CWaterModel::setupMaterialNVertexShader(), NL3D::CPSMultiTexturedParticle::setupMultiTexEnv(), NL3D::CWaterModel::setupSimpleRender(), NL3D::CDriverUser::stretchRect(), NL3D::CFlareModel::traverseRender(), NL3D::CWaterEnvMap::update(), NL3D::CShadowMapManager::updateBlurTexture(), NL3D::CPSRibbonLookAt::updateMatAndVbForColor(), NL3D::CPSShockWave::updateMatAndVbForTexture(), NL3D::CPSQuad::updateMatAndVbForTexture(), NL3D::CPSTailDot::updateMaterial(), NL3D::CPSRibbon::updateTexturedMaterial(), NL3D::CPSRibbon::updateUntexturedMaterial(), and NL3D::CBloomEffect::~CBloomEffect().

void NL3D::CMaterial::setUserColor ( CRGBA  userColor  )  [inline]

This part is valid for Normal shaders (nlassert).

See also:
TShader.

Definition at line 361 of file driver_material_inline.h.

References _ShaderType, _TexEnvs, _Touched, NL3D::CMaterial::CTexEnv::ConstantColor, NL3D::IDRV_TOUCHED_TEXENV, nlassert, and UserColor.

Referenced by NL3D::UInstanceMaterial::setUserColor().

void NL3D::CMaterial::setUserTexMat ( uint  stage,
const NLMISC::CMatrix m 
) [inline]
void NL3D::CMaterial::setZBias ( float  val  )  [inline]

The z bias is a z dispacement of the object to solve z precision problem.

The bias is gived in world coordinate units. Positive bias give a lower z priority, negative bias give a higher bias priority.

Definition at line 110 of file driver_material_inline.h.

References _Touched, _ZBias, and NL3D::IDRV_TOUCHED_ZBIAS.

Referenced by initUnlit(), NL3D::CLandscape::receiveShadowMap(), and NL3D::CPSMaterial::setZBias().

void NL3D::CMaterial::setZFunc ( ZFunc  val  )  [inline]
void NL3D::CMaterial::setZWrite ( bool  active  )  [inline]
bool NL3D::CMaterial::texAddrEnabled (  )  const

test whether texture addressing mode are enabled

Definition at line 497 of file material.cpp.

References _Flags, and NL3D::IDRV_MAT_TEX_ADDR.

void NL3D::CMaterial::texConstantColor ( uint  stage,
CRGBA  color 
) [inline]
void NL3D::CMaterial::texEnvArg0Alpha ( uint  stage,
TTexSource  src,
TTexOperand  oper 
) [inline]
void NL3D::CMaterial::texEnvArg0RGB ( uint  stage,
TTexSource  src,
TTexOperand  oper 
) [inline]
void NL3D::CMaterial::texEnvArg1Alpha ( uint  stage,
TTexSource  src,
TTexOperand  oper 
) [inline]
void NL3D::CMaterial::texEnvArg1RGB ( uint  stage,
TTexSource  src,
TTexOperand  oper 
) [inline]
void NL3D::CMaterial::texEnvArg2Alpha ( uint  stage,
TTexSource  src,
TTexOperand  oper 
) [inline]
void NL3D::CMaterial::texEnvArg2RGB ( uint  stage,
TTexSource  src,
TTexOperand  oper 
) [inline]
void NL3D::CMaterial::texEnvOpAlpha ( uint  stage,
TTexOperator  ope 
) [inline]
void NL3D::CMaterial::texEnvOpRGB ( uint  stage,
TTexOperator  ope 
) [inline]

This part is valid for Normal shaders (nlassert).

It maps the EXT_texture_env_combine opengl extension. A stage is enabled if his texture is !=NULL. By default, all stages are setup to Modulate style: AlphaOp=RGBOp= Modulate, RGBArg0= TextureSrcColor, RGBArg1= PreviousSrcColor, AlphaArg0= TextureSrcAlpha, AlphaArg1= PreviousSrcAlpha. ConstantColor default to White(255,255,255,255).

For compatibility problems:

  • no scaling is allowed (some cards do not implement this well).
  • Texture can be the source only for Arg0 (DirectX restriction). nlassert...

NB: for Alpha Aguments, only operands SrcAlpha and InvSrcAlpha are valid (nlassert..).

Definition at line 212 of file driver_material_inline.h.

References _ShaderType, _TexEnvs, _Touched, NL3D::CMaterial::CTexEnv::Env, NL3D::IDRV_MAT_MAXTEXTURES, NL3D::IDRV_TOUCHED_TEXENV, nlassert, and Normal.

Referenced by NL3D::CCloudScape::CCloudScape(), NL3D::CShadowMapManager::CShadowMapManager(), NL3D::CCloud::disp(), NL3D::CWaterEnvMap::doInit(), NL3D::CPSMaterial::forceModulateConstantColor(), NL3D::CLandscape::init(), NL3D::CBloomEffect::init(), NL3D::CMotionBlur::performMotionBlur(), NL3D::CVegetableManager::render(), NL3D::CLandscape::render(), NL3D::CWaterEnvMap::renderTestMesh(), NL3D::SCloudTexture3D::SCloudTexture3D(), setShader(), NL3D::CPSMultiTexturedParticle::setupMaterial(), NL3D::CPSConstraintMesh::setupMaterialColor(), NL3D::SetupModulatedStage(), NL3D::CPSMultiTexturedParticle::setupMultiTexEnv(), and NL3D::CWaterModel::setupSimpleRender().

bool NL3D::CMaterial::texturePresent ( uint8  stage  )  const [inline]

Member Data Documentation

Definition at line 690 of file material.h.

Referenced by getAmbient(), operator=(), serial(), setAmbient(), and setLighting().

Definition at line 689 of file material.h.

Referenced by CMaterial(), getColor(), operator=(), serial(), and setColor().

Definition at line 690 of file material.h.

Referenced by getDiffuse(), getOpacity(), operator=(), serial(), setDiffuse(), setLighting(), and setOpacity().

Definition at line 686 of file material.h.

Referenced by CMaterial(), getDstBlend(), operator=(), serial(), setBlendFunc(), and setDstBlend().

Definition at line 690 of file material.h.

Referenced by getEmissive(), operator=(), serial(), setEmissive(), and setLighting().

Definition at line 691 of file material.h.

Referenced by getShininess(), operator=(), serial(), setLighting(), and setShininess().

Definition at line 690 of file material.h.

Referenced by getSpecular(), operator=(), serial(), setLighting(), and setSpecular().

Definition at line 686 of file material.h.

Referenced by CMaterial(), getSrcBlend(), operator=(), serial(), setBlendFunc(), and setSrcBlend().

Definition at line 694 of file material.h.

Referenced by CMaterial(), getStainedGlassWindow(), and setStainedGlassWindow().

Definition at line 696 of file material.h.

Referenced by CMaterial(), getTexCoordGenMode(), operator=(), serial(), and setTexCoordGenMode().

std::auto_ptr<CUserTexMat> NL3D::CMaterial::_TexUserMat [private]

Definition at line 688 of file material.h.

Referenced by CMaterial(), getZBias(), operator=(), serial(), and setZBias().

Definition at line 687 of file material.h.

Referenced by CMaterial(), getZFunc(), operator=(), serial(), and setZFunc().


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

Generated on Thu Jan 7 08:30:05 2010 for NeL by  doxygen 1.6.1