# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

NL3D::CMaterial Class Reference

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

#include <material.h>

Inheritance diagram for NL3D::CMaterial:

NLMISC::CRefCount List of all members.

Public Types

typedef std::vector< CLightMapTTexturePtrs
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, shaderCount
}
 Normal shader: use simple multitexturing. More...

Texture Env Modes.
enum  TTexOperator {
  Replace = 0, Modulate, Add, AddSigned,
  InterpolateTexture, InterpolatePrevious, InterpolateDiffuse, InterpolateConstant,
  EMBM
}
 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 }
 Source argument. More...

enum  TTexOperand { SrcColor = 0, InvSrcColor, SrcAlpha, InvSrcAlpha }
 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 Methods

void setShader (TShader val)
 Set the shader for this material. More...

TShader getShader () const
 get the current material shadertype. More...

bool getStainedGlassWindow ()
void setStainedGlassWindow (bool val)
void flushTextures (IDriver &driver)
 Flush textures. Force texture generation. More...

void serial (NLMISC::IStream &f)
uint32 getFlags () const
uint32 getTouched (void) const
void clearTouched (uint32 flag)
Object.
 CMaterial ()
 ctor. More...

 CMaterial (const CMaterial &mat)
 see operator=. More...

 ~CMaterial ()
 dtor. More...

CMaterial & operator= (const CMaterial &mat)
 Do not copy DrvInfos, copy all infos and set IDRV_TOUCHED_ALL. More...

Texture.
void setTexture (uint8 stage, ITexture *ptex)
 set a texture for a special stage. More...

ITexturegetTexture (uint8 stage) const
bool texturePresent (uint8 stage) 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'. More...

bool texAddrEnabled () const
 test whether texture addressing mode are enabled. More...

void setTexAddressingMode (uint8 stage, TTexAddressingMode mode)
 Set a texture addressing mode for the given stage. More...

TTexAddressingMode getTexAddressingMode (uint8 stage)
 Get the texture addressing mode for the given stage. More...

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. More...

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. The bias is gived in world coordinate units. Positive bias give a lower z priority, negative bias give a higher bias priority. More...

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). More...

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. More...

void setEmissive (CRGBA emissive=CRGBA(0, 0, 0))
 Set the emissive part ot material. Usefull only if setLighting(true) has been done. More...

void setAmbient (CRGBA ambient=CRGBA(0, 0, 0))
 Set the Ambient part ot material. Usefull only if setLighting(true) has been done. More...

void setDiffuse (CRGBA diffuse=CRGBA(0, 0, 0))
 Set the Diffuse part ot material. Usefull only if setLighting(true) has been done. NB: opacity is NOT copied from diffuse.A. More...

void setOpacity (uint8 opa)
 Set the Opacity part ot material. Usefull only if setLighting(true) has been done. More...

void setSpecular (CRGBA specular=CRGBA(0, 0, 0))
 Set the specular part ot material. Usefull only if setLighting(true) has been done. More...

void setShininess (float shininess)
 Set the shininess part ot material. Usefull only if setLighting(true) has been done. More...

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. More...

bool getLightedVertexColor () const
 Get the lighted vertex color flag. More...

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. More...

CRGBA getColor (void) const
CRGBA getEmissive () const
CRGBA getAmbient () const
CRGBA getDiffuse () const
 return diffuse part. NB: A==opacity. More...

uint8 getOpacity () const
CRGBA getSpecular () const
float getShininess () const
Texture environnement. Normal shader only.
void texEnvOpRGB (uint stage, TTexOperator ope)
void texEnvArg0RGB (uint stage, TTexSource src, TTexOperand oper)
void texEnvArg1RGB (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 texConstantColor (uint stage, CRGBA color)
 Setup the constant color for a stage. Used for the TTexSource:Constant. More...

uint32 getTexEnvMode (uint stage)
 For push/pop only, get the packed version of the environnment mode. More...

void setTexEnvMode (uint stage, uint32 packed)
 For push/pop only, set the packed version of the environnment mode. More...

CRGBA getTexConstantColor (uint stage)
void setTexCoordGen (uint stage, bool generate)
bool getTexCoordGen (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. More...

const NLMISC::CMatrixgetUserTexMat (uint stage) const
 Get a const ref. More...

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. More...

Texture UserColor. UserColor shader only.
void setUserColor (CRGBA userColor)
CRGBA getUserColor () const
LightMap. LightMap shader only.
void setLightMap (uint lmapId, ITexture *lmap)
 Set the ith lightmap. undef results if holes in lightmap array. More...

ITexturegetLightMap (uint lmapId) const
 Get the ith lightmap. (NULl if none). More...

void setLightMapFactor (uint lmapId, CRGBA factor)
 Set the lightmap intensity. (default to 255). More...

Tools..
void initUnlit ()
 Init the material as unlit. More...

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

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


Public Attributes

uint8 _TexAddrMode [IDRV_MAT_MAXTEXTURES]
CTexEnv _TexEnvs [IDRV_MAT_MAXTEXTURES]
CRefPtr< IShaderpShader
TTexturePtrs _LightMaps

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
std::auto_ptr< CUserTexMat_TexUserMat
CSmartPtr< ITexture_Textures [IDRV_MAT_MAXTEXTURES]

Detailed Description

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

Definition at line 115 of file material.h.


Member Typedef Documentation

typedef std::vector<CLightMap> NL3D::CMaterial::TTexturePtrs
 

Definition at line 583 of file material.h.


Member Enumeration Documentation

enum NL3D::CMaterial::TBlend
 

Blend enums.

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

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

Definition at line 125 of file material.h.

Referenced by getDstBlend, and getSrcBlend.

enum NL3D::CMaterial::TShader
 

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
Enumeration values:
Normal 
Bump 
UserColor 
LightMap 
Specular 
Caustics 
PerPixelLighting 
PerPixelLightingNoSpec 
Cloud 
shaderCount 

Definition at line 157 of file material.h.

Referenced by getShader.

enum NL3D::CMaterial::TTexAddressingMode
 

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

Definition at line 208 of file material.h.

enum NL3D::CMaterial::TTexOperand
 

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.

Enumeration values:
SrcColor 
InvSrcColor 
SrcAlpha 
InvSrcAlpha 

Definition at line 199 of file material.h.

enum NL3D::CMaterial::TTexOperator
 

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.

EMBM : apply to both color and alpha : the current texture, whose format is DSDT, is used to offset the texture in the next stage. NB : for EMBM and InterpolateConstant, this must be supported by driver.

Enumeration values:
Replace 
Modulate 
Add 
AddSigned 
InterpolateTexture 
InterpolatePrevious 
InterpolateDiffuse 
InterpolateConstant 
EMBM 

Definition at line 181 of file material.h.

enum NL3D::CMaterial::TTexSource
 

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.

Enumeration values:
Texture 
Previous 
Diffuse 
Constant 

Definition at line 190 of file material.h.

enum NL3D::CMaterial::ZFunc
 

Enumeration values:
always 
never 
equal 
notequal 
less 
lessequal 
greater 
greaterequal 
zfuncCount 

Definition at line 119 of file material.h.

Referenced by getZFunc.


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 41 of file material.cpp.

References _AlphaTestThreshold, _Color, _DstBlend, _Flags, _ShaderType, _SrcBlend, _StainedGlassWindow, _Touched, _ZBias, _ZFunction, NL3D::IDRV_MAT_ZWRITE, invsrcalpha, lessequal, Normal, and srcalpha.

Referenced by CMaterial.

NL3D::CMaterial::CMaterial const CMaterial &    mat [inline]
 

see operator=.

Definition at line 230 of file material.h.

References _Flags, _Touched, CMaterial, and operator=.

NL3D::CMaterial::~CMaterial  
 

dtor.

Definition at line 128 of file material.cpp.

References pShader.


Member Function Documentation

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

Definition at line 589 of file material.h.

References _Touched.

void NL3D::CMaterial::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.

Definition at line 461 of file material.cpp.

References _TexUserMat, NLMISC::CMatrix::getI, NLMISC::CMatrix::getJ, NLMISC::CMatrix::getPos, NL3D::IDRV_MAT_MAXTEXTURES, isUserTexMatEnabled, nlassert, NLMISC::CVector::norm, NLMISC::CVector::x, and NLMISC::CVector::y.

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 417 of file material.cpp.

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

void NL3D::CMaterial::enableUserTexMat uint    stage,
bool    enabled = true
[inline]
 

Definition at line 337 of file driver_material_inline.h.

References _Flags, _TexUserMat, NL3D::IDRV_MAT_MAXTEXTURES, NL3D::IDRV_MAT_USER_TEX_0_MAT, NL3D::IDRV_MAT_USER_TEX_MAT_ALL, and nlassert.

void NL3D::CMaterial::flushTextures IDriver   driver
 

Flush textures. Force texture generation.

Definition at line 330 of file material.cpp.

References _LightMaps, _ShaderType, _Textures, NL3D::IDRV_MAT_MAXTEXTURES, LightMap, and Texture.

bool NL3D::CMaterial::getAlphaTest   const [inline]
 

Definition at line 302 of file material.h.

References _Flags, and NL3D::IDRV_MAT_ALPHA_TEST.

float NL3D::CMaterial::getAlphaTestThreshold   const [inline]
 

Definition at line 308 of file material.h.

References _AlphaTestThreshold.

CRGBA NL3D::CMaterial::getAmbient   const [inline]
 

Definition at line 366 of file material.h.

References _Ambient.

bool NL3D::CMaterial::getBlend   const [inline]
 

Definition at line 266 of file material.h.

References _Flags, and NL3D::IDRV_MAT_BLEND.

CRGBA NL3D::CMaterial::getColor void    const [inline]
 

Definition at line 364 of file material.h.

CRGBA NL3D::CMaterial::getDiffuse   const [inline]
 

return diffuse part. NB: A==opacity.

Definition at line 368 of file material.h.

References _Diffuse.

bool NL3D::CMaterial::getDoubleSided   const [inline]
 

Definition at line 296 of file material.h.

References _Flags, and NL3D::IDRV_MAT_DOUBLE_SIDED.

TBlend NL3D::CMaterial::getDstBlend void    const [inline]
 

Definition at line 268 of file material.h.

References TBlend.

CRGBA NL3D::CMaterial::getEmissive   const [inline]
 

Definition at line 365 of file material.h.

References _Emissive.

uint32 NL3D::CMaterial::getFlags   const [inline]
 

Definition at line 587 of file material.h.

References _Flags.

bool NL3D::CMaterial::getLightedVertexColor   const [inline]
 

Get the lighted vertex color flag.

Definition at line 201 of file driver_material_inline.h.

References _Flags, and NL3D::IDRV_MAT_LIGHTED_VERTEX_COLOR.

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

Get the ith lightmap. (NULl if none).

Definition at line 373 of file material.cpp.

References _LightMaps, _ShaderType, and nlassert.

uint8 NL3D::CMaterial::getOpacity   const [inline]
 

Definition at line 369 of file material.h.

References _Diffuse.

TShader NL3D::CMaterial::getShader   const [inline]
 

get the current material shadertype.

Definition at line 242 of file material.h.

References _ShaderType, and TShader.

float NL3D::CMaterial::getShininess   const [inline]
 

Definition at line 371 of file material.h.

References _Shininess.

CRGBA NL3D::CMaterial::getSpecular   const [inline]
 

Definition at line 370 of file material.h.

References _Specular.

TBlend NL3D::CMaterial::getSrcBlend void    const [inline]
 

Definition at line 267 of file material.h.

References TBlend.

bool NL3D::CMaterial::getStainedGlassWindow   [inline]
 

Definition at line 459 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 453 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]
 

Definition at line 291 of file driver_material_inline.h.

References _ShaderType, _TexEnvs, NL3D::CMaterial::CTexEnv::ConstantColor, NL3D::IDRV_MAT_MAXTEXTURES, and nlassert.

bool NL3D::CMaterial::getTexCoordGen uint    stage const [inline]
 

Definition at line 298 of file driver_material_inline.h.

References _Flags, NL3D::IDRV_MAT_GEN_TEX_0, NL3D::IDRV_MAT_MAXTEXTURES, and nlassert.

uint32 NL3D::CMaterial::getTexEnvMode uint    stage [inline]
 

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

Definition at line 277 of file driver_material_inline.h.

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

ITexture * NL3D::CMaterial::getTexture uint8    stage const [inline]
 

Definition at line 46 of file driver_material_inline.h.

References _Textures, NL3D::IDRV_MAT_MAXTEXTURES, and nlassert.

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

Definition at line 588 of file material.h.

CRGBA NL3D::CMaterial::getUserColor   const [inline]
 

Definition at line 329 of file driver_material_inline.h.

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

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 377 of file driver_material_inline.h.

References _TexUserMat, isUserTexMatEnabled, and nlassert.

float NL3D::CMaterial::getZBias void    const [inline]
 

Definition at line 324 of file material.h.

ZFunc NL3D::CMaterial::getZFunc void    const [inline]
 

Definition at line 322 of file material.h.

References ZFunc.

bool NL3D::CMaterial::getZWrite void    const [inline]
 

Definition at line 323 of file material.h.

References _Flags, and NL3D::IDRV_MAT_ZWRITE.

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 73 of file material.cpp.

References initUnlit, and setLighting.

void NL3D::CMaterial::initUnlit  
 

Init the material as unlit.

normal shader, no lighting .... Default to: normal shader, no lighting, color to White(1,1,1,1), 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 57 of file material.cpp.

References NL3D::IDRV_MAT_MAXTEXTURES, lessequal, Normal, setAlphaTestThreshold, setBlend, setColor, setLighting, setShader, setTexture, setZBias, setZFunc, and setZWrite.

Referenced by NL3D::CCloudScape::CCloudScape, NL3D::CNoise3d::init, initLighted, NL3D::SCloudTexture3D::SCloudTexture3D, and NL3D::SCloudTextureClamp::SCloudTextureClamp.

bool NL3D::CMaterial::isLighted   const [inline]
 

Definition at line 359 of file material.h.

References _Flags, and NL3D::IDRV_MAT_LIGHTING.

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 362 of file material.h.

References _Flags, and NL3D::IDRV_MAT_LIGHTED_VERTEX_COLOR.

bool NL3D::CMaterial::isUserTexMatEnabled uint    stage const [inline]
 

Definition at line 362 of file driver_material_inline.h.

References _Flags, NL3D::IDRV_MAT_MAXTEXTURES, NL3D::IDRV_MAT_USER_TEX_0_MAT, and nlassert.

Referenced by decompUserTexMat, getUserTexMat, serial, and setUserTexMat.

CMaterial & NL3D::CMaterial::operator= const CMaterial &    mat
 

Do not copy DrvInfos, copy all infos and set IDRV_TOUCHED_ALL.

Definition at line 81 of file material.cpp.

References _AlphaTestThreshold, _Ambient, _Color, _Diffuse, _DstBlend, _Emissive, _Flags, _LightMaps, _ShaderType, _Shininess, _Specular, _SrcBlend, _TexAddrMode, _TexEnvs, _Textures, _TexUserMat, _Touched, _ZBias, _ZFunction, NL3D::IDRV_MAT_MAXTEXTURES, and NL3D::IDRV_TOUCHED_ALL.

Referenced by CMaterial.

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 486 of file material.cpp.

References _Textures, NL3D::IDRV_MAT_MAXTEXTURES, and index.

void NL3D::CMaterial::serial NLMISC::IStream   f
 

Definition at line 136 of file material.cpp.

References _AlphaTestThreshold, _Ambient, _Color, _Diffuse, _DstBlend, _Emissive, _Flags, _LightMaps, _ShaderType, _Shininess, _Specular, _SrcBlend, _TexAddrMode, _TexEnvs, _Textures, _TexUserMat, _Touched, _ZBias, _ZFunction, NL3D::IDRV_MAT_DEFMAT, NL3D::IDRV_MAT_MAXTEXTURES, NL3D::IDRV_MAT_TEX_ADDR, NL3D::IDRV_MAT_USER_TEX_MAT_ALL, NL3D::IDRV_TOUCHED_ALL, NLMISC::IStream::isReading, isUserTexMatEnabled, nlassert, NLMISC::IStream::serial, NLMISC::IStream::serialCont, NLMISC::IStream::serialEnum, NLMISC::IStream::serialPolyPtr, NLMISC::IStream::serialVersion, setAmbient, NL3D::CMaterial::CTexEnv::setDefault, setDiffuse, setEmissive, and setSpecular.

void NL3D::CMaterial::setAlphaTest bool    active [inline]
 

Definition at line 78 of file driver_material_inline.h.

References _Flags, _Touched, NL3D::IDRV_MAT_ALPHA_TEST, and NL3D::IDRV_TOUCHED_ALPHA_TEST.

Referenced by NL3D::CCloudScape::CCloudScape.

void NL3D::CMaterial::setAlphaTestThreshold float    thre [inline]
 

change the threshold against alpha is tested.

Default is 0.5f.

Parameters:
thre  threshold, should be in [0..1], not clamped.

Definition at line 85 of file driver_material_inline.h.

References _AlphaTestThreshold, _Touched, and NL3D::IDRV_TOUCHED_ALPHA_TEST_THRE.

Referenced by NL3D::CCloudScape::CCloudScape, and initUnlit.

void NL3D::CMaterial::setAmbient CRGBA    ambient = CRGBA(0, 0, 0) [inline]
 

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

Definition at line 158 of file driver_material_inline.h.

References _Ambient, _Touched, and NL3D::IDRV_TOUCHED_LIGHTING.

Referenced by serial.

void NL3D::CMaterial::setBlend bool    active [inline]
 

Definition at line 64 of file driver_material_inline.h.

References _Flags, _Touched, NL3D::IDRV_MAT_BLEND, and NL3D::IDRV_TOUCHED_BLEND.

Referenced by NL3D::CCloudScape::CCloudScape, NL3D::CNoise3d::init, initUnlit, NL3D::SCloudTexture3D::SCloudTexture3D, and NL3D::SCloudTextureClamp::SCloudTextureClamp.

void NL3D::CMaterial::setBlendFunc TBlend    src,
TBlend    dst
[inline]
 

Definition at line 91 of file driver_material_inline.h.

References _DstBlend, _SrcBlend, _Touched, NL3D::IDRV_TOUCHED_BLENDFUNC, and src.

Referenced by NL3D::CCloudScape::CCloudScape, NL3D::CNoise3d::init, NL3D::SCloudTexture3D::SCloudTexture3D, and NL3D::SCloudTextureClamp::SCloudTextureClamp.

void NL3D::CMaterial::setColor 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 118 of file driver_material_inline.h.

References _Color, _Touched, and NL3D::IDRV_TOUCHED_COLOR.

Referenced by NL3D::CNoise3d::flush, NL3D::CNoise3d::init, initUnlit, NL3D::SCloudTexture3D::SCloudTexture3D, and NL3D::SCloudTextureClamp::SCloudTextureClamp.

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

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

Definition at line 164 of file driver_material_inline.h.

References _Diffuse, _Touched, and NL3D::IDRV_TOUCHED_LIGHTING.

Referenced by serial.

void NL3D::CMaterial::setDoubleSided bool    active [inline]
 

Definition at line 71 of file driver_material_inline.h.

References _Flags, _Touched, NL3D::IDRV_MAT_DOUBLE_SIDED, and NL3D::IDRV_TOUCHED_DOUBLE_SIDED.

Referenced by NL3D::CCloudScape::CCloudScape, and NL3D::SCloudTexture3D::SCloudTexture3D.

void NL3D::CMaterial::setDstBlend TBlend    val [inline]
 

Definition at line 58 of file driver_material_inline.h.

References _DstBlend, _Touched, and NL3D::IDRV_TOUCHED_BLENDFUNC.

void NL3D::CMaterial::setEmissive CRGBA    emissive = CRGBA(0, 0, 0) [inline]
 

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

Definition at line 152 of file driver_material_inline.h.

References _Emissive, _Touched, and NL3D::IDRV_TOUCHED_LIGHTING.

Referenced by serial.

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 191 of file driver_material_inline.h.

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

void NL3D::CMaterial::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
[inline]
 

Batch setup lighting. Opacity is in diffuse.A.

Definition at line 127 of file driver_material_inline.h.

References _Ambient, _Diffuse, _Emissive, _Flags, _Shininess, _Specular, _Touched, NL3D::IDRV_MAT_LIGHTING, and NL3D::IDRV_TOUCHED_LIGHTING.

Referenced by initLighted, and initUnlit.

void NL3D::CMaterial::setLightMap uint    lmapId,
ITexture   lmap
 

Set the ith lightmap. undef results if holes in lightmap array.

See also:
TShader.

Definition at line 362 of file material.cpp.

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

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

Set the lightmap intensity. (default to 255).

Definition at line 383 of file material.cpp.

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

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

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

Definition at line 173 of file driver_material_inline.h.

References _Diffuse, _Touched, and NL3D::IDRV_TOUCHED_LIGHTING.

void NL3D::CMaterial::setShader TShader    val
 

Set the shader for this material.

All textures are reseted!!

Definition at line 257 of file material.cpp.

References _ShaderType, _Touched, Constant, Diffuse, NL3D::IDRV_MAT_MAXTEXTURES, NL3D::IDRV_TOUCHED_SHADER, InterpolateTexture, LightMap, Modulate, Previous, Replace, setTexture, SrcAlpha, SrcColor, texEnvArg0Alpha, texEnvArg0RGB, texEnvArg1RGB, texEnvOpAlpha, texEnvOpRGB, Texture, and UserColor.

Referenced by NL3D::CCloudScape::CCloudScape, NL3D::CNoise3d::init, initUnlit, NL3D::SCloudTexture3D::SCloudTexture3D, and NL3D::SCloudTextureClamp::SCloudTextureClamp.

void NL3D::CMaterial::setShininess float    shininess [inline]
 

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

Definition at line 185 of file driver_material_inline.h.

References _Shininess, _Touched, and NL3D::IDRV_TOUCHED_LIGHTING.

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

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

Definition at line 179 of file driver_material_inline.h.

References _Specular, _Touched, and NL3D::IDRV_TOUCHED_LIGHTING.

Referenced by serial.

void NL3D::CMaterial::setSrcBlend TBlend    val [inline]
 

Definition at line 52 of file driver_material_inline.h.

References _SrcBlend, _Touched, and NL3D::IDRV_TOUCHED_BLENDFUNC.

void NL3D::CMaterial::setStainedGlassWindow bool    val [inline]
 

Definition at line 460 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 443 of file material.cpp.

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

void NL3D::CMaterial::setTexCoordGen uint    stage,
bool    generate
[inline]
 

Definition at line 304 of file driver_material_inline.h.

References _Flags, NL3D::IDRV_MAT_GEN_TEX_0, NL3D::IDRV_MAT_MAXTEXTURES, and nlassert.

void NL3D::CMaterial::setTexEnvMode uint    stage,
uint32    packed
[inline]
 

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

Definition at line 284 of file driver_material_inline.h.

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

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 297 of file material.cpp.

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

Referenced by NL3D::CNoise3d::init, NL3D::SCloudTextureClamp::init, NL3D::SCloudTexture3D::init, initUnlit, and setShader.

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

See also:
TShader.

Definition at line 321 of file driver_material_inline.h.

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

void NL3D::CMaterial::setUserTexMat uint    stage,
const NLMISC::CMatrix   m
[inline]
 

Set a new texture matrix for the given stage.

Definition at line 369 of file driver_material_inline.h.

References _TexUserMat, isUserTexMatEnabled, and nlassert.

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 112 of file driver_material_inline.h.

References _Touched, _ZBias, and NL3D::IDRV_TOUCHED_ZBIAS.

Referenced by initUnlit.

void NL3D::CMaterial::setZFunc ZFunc    val [inline]
 

Definition at line 99 of file driver_material_inline.h.

References _Touched, _ZFunction, and NL3D::IDRV_TOUCHED_ZFUNC.

Referenced by NL3D::CCloudScape::CCloudScape, NL3D::CNoise3d::init, initUnlit, NL3D::SCloudTexture3D::SCloudTexture3D, and NL3D::SCloudTextureClamp::SCloudTextureClamp.

void NL3D::CMaterial::setZWrite bool    active [inline]
 

Definition at line 105 of file driver_material_inline.h.

References _Flags, _Touched, NL3D::IDRV_MAT_ZWRITE, and NL3D::IDRV_TOUCHED_ZWRITE.

Referenced by NL3D::CCloudScape::CCloudScape, NL3D::CNoise3d::init, initUnlit, NL3D::SCloudTexture3D::SCloudTexture3D, and NL3D::SCloudTextureClamp::SCloudTextureClamp.

bool NL3D::CMaterial::texAddrEnabled   const
 

test whether texture addressing mode are enabled.

Definition at line 437 of file material.cpp.

References _Flags, and NL3D::IDRV_MAT_TEX_ADDR.

void NL3D::CMaterial::texConstantColor uint    stage,
CRGBA    color
[inline]
 

Setup the constant color for a stage. Used for the TTexSource:Constant.

Definition at line 268 of file driver_material_inline.h.

References _ShaderType, _TexEnvs, NL3D::CMaterial::CTexEnv::ConstantColor, NL3D::IDRV_MAT_MAXTEXTURES, and nlassert.

void NL3D::CMaterial::texEnvArg0Alpha uint    stage,
TTexSource    src,
TTexOperand    oper
[inline]
 

Definition at line 247 of file driver_material_inline.h.

References _ShaderType, _TexEnvs, NL3D::CMaterial::CTexEnv::Env, NL3D::IDRV_MAT_MAXTEXTURES, InvSrcAlpha, nlassert, src, and SrcAlpha.

Referenced by NL3D::CCloudScape::CCloudScape, NL3D::SCloudTexture3D::SCloudTexture3D, NL3D::SCloudTextureClamp::SCloudTextureClamp, and setShader.

void NL3D::CMaterial::texEnvArg0RGB uint    stage,
TTexSource    src,
TTexOperand    oper
[inline]
 

Definition at line 221 of file driver_material_inline.h.

References _ShaderType, _TexEnvs, NL3D::CMaterial::CTexEnv::Env, NL3D::IDRV_MAT_MAXTEXTURES, nlassert, and src.

Referenced by NL3D::CCloudScape::CCloudScape, NL3D::SCloudTexture3D::SCloudTexture3D, and setShader.

void NL3D::CMaterial::texEnvArg1Alpha uint    stage,
TTexSource    src,
TTexOperand    oper
[inline]
 

Definition at line 256 of file driver_material_inline.h.

References _ShaderType, _TexEnvs, NL3D::CMaterial::CTexEnv::Env, NL3D::IDRV_MAT_MAXTEXTURES, InvSrcAlpha, nlassert, src, SrcAlpha, and Texture.

Referenced by NL3D::CCloudScape::CCloudScape, and NL3D::SCloudTextureClamp::SCloudTextureClamp.

void NL3D::CMaterial::texEnvArg1RGB uint    stage,
TTexSource    src,
TTexOperand    oper
[inline]
 

Definition at line 229 of file driver_material_inline.h.

References _ShaderType, _TexEnvs, NL3D::CMaterial::CTexEnv::Env, NL3D::IDRV_MAT_MAXTEXTURES, nlassert, src, and Texture.

Referenced by NL3D::CCloudScape::CCloudScape, NL3D::SCloudTexture3D::SCloudTexture3D, and setShader.

void NL3D::CMaterial::texEnvOpAlpha uint    stage,
TTexOperator    ope
[inline]
 

Definition at line 240 of file driver_material_inline.h.

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

Referenced by NL3D::CCloudScape::CCloudScape, NL3D::SCloudTexture3D::SCloudTexture3D, NL3D::SCloudTextureClamp::SCloudTextureClamp, and setShader.

void NL3D::CMaterial::texEnvOpRGB uint    stage,
TTexOperator    ope
[inline]
 

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 214 of file driver_material_inline.h.

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

Referenced by NL3D::CCloudScape::CCloudScape, NL3D::SCloudTexture3D::SCloudTexture3D, and setShader.

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

Definition at line 36 of file driver_material_inline.h.

References _Textures, NL3D::IDRV_MAT_MAXTEXTURES, and nlassert.


Member Data Documentation

float NL3D::CMaterial::_AlphaTestThreshold [private]
 

Definition at line 555 of file material.h.

Referenced by CMaterial, getAlphaTestThreshold, operator=, serial, and setAlphaTestThreshold.

CRGBA NL3D::CMaterial::_Ambient [private]
 

Definition at line 553 of file material.h.

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

CRGBA NL3D::CMaterial::_Color [private]
 

Definition at line 552 of file material.h.

Referenced by CMaterial, operator=, serial, and setColor.

CRGBA NL3D::CMaterial::_Diffuse [private]
 

Definition at line 553 of file material.h.

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

TBlend NL3D::CMaterial::_DstBlend [private]
 

Definition at line 549 of file material.h.

Referenced by CMaterial, operator=, serial, setBlendFunc, and setDstBlend.

CRGBA NL3D::CMaterial::_Emissive [private]
 

Definition at line 553 of file material.h.

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

uint32 NL3D::CMaterial::_Flags [private]
 

Definition at line 548 of file material.h.

Referenced by CMaterial, enableTexAddrMode, enableUserTexMat, getAlphaTest, getBlend, getDoubleSided, getFlags, getLightedVertexColor, getTexAddressingMode, getTexCoordGen, getZWrite, isLighted, isLightedVertexColor, isUserTexMatEnabled, operator=, serial, setAlphaTest, setBlend, setDoubleSided, setLightedVertexColor, setLighting, setTexAddressingMode, setTexCoordGen, setZWrite, and texAddrEnabled.

TTexturePtrs NL3D::CMaterial::_LightMaps
 

Definition at line 584 of file material.h.

Referenced by flushTextures, getLightMap, operator=, serial, setLightMap, and setLightMapFactor.

TShader NL3D::CMaterial::_ShaderType [private]
 

Definition at line 547 of file material.h.

Referenced by CMaterial, flushTextures, getLightMap, getShader, getTexConstantColor, getTexEnvMode, getUserColor, operator=, serial, setLightMap, setLightMapFactor, setShader, setTexEnvMode, setTexture, setUserColor, texConstantColor, texEnvArg0Alpha, texEnvArg0RGB, texEnvArg1Alpha, texEnvArg1RGB, texEnvOpAlpha, and texEnvOpRGB.

float NL3D::CMaterial::_Shininess [private]
 

Definition at line 554 of file material.h.

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

CRGBA NL3D::CMaterial::_Specular [private]
 

Definition at line 553 of file material.h.

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

TBlend NL3D::CMaterial::_SrcBlend [private]
 

Definition at line 549 of file material.h.

Referenced by CMaterial, operator=, serial, setBlendFunc, and setSrcBlend.

bool NL3D::CMaterial::_StainedGlassWindow [private]
 

Definition at line 557 of file material.h.

Referenced by CMaterial, getStainedGlassWindow, and setStainedGlassWindow.

uint8 NL3D::CMaterial::_TexAddrMode[IDRV_MAT_MAXTEXTURES]
 

Definition at line 567 of file material.h.

Referenced by enableTexAddrMode, getTexAddressingMode, operator=, serial, and setTexAddressingMode.

CTexEnv NL3D::CMaterial::_TexEnvs[IDRV_MAT_MAXTEXTURES]
 

Definition at line 568 of file material.h.

Referenced by getTexConstantColor, getTexEnvMode, getUserColor, operator=, serial, setTexEnvMode, setUserColor, texConstantColor, texEnvArg0Alpha, texEnvArg0RGB, texEnvArg1Alpha, texEnvArg1RGB, texEnvOpAlpha, and texEnvOpRGB.

CSmartPtr<ITexture> NL3D::CMaterial::_Textures[IDRV_MAT_MAXTEXTURES] [private]
 

Definition at line 563 of file material.h.

Referenced by flushTextures, getTexture, operator=, selectTextureSet, serial, setTexture, and texturePresent.

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

Definition at line 562 of file material.h.

Referenced by decompUserTexMat, enableUserTexMat, getUserTexMat, operator=, serial, and setUserTexMat.

uint32 NL3D::CMaterial::_Touched [private]
 

Definition at line 556 of file material.h.

Referenced by clearTouched, CMaterial, operator=, serial, setAlphaTest, setAlphaTestThreshold, setAmbient, setBlend, setBlendFunc, setColor, setDiffuse, setDoubleSided, setDstBlend, setEmissive, setLightedVertexColor, setLighting, setLightMap, setLightMapFactor, setOpacity, setShader, setShininess, setSpecular, setSrcBlend, setTexture, setZBias, setZFunc, and setZWrite.

float NL3D::CMaterial::_ZBias [private]
 

Definition at line 551 of file material.h.

Referenced by CMaterial, operator=, serial, and setZBias.

ZFunc NL3D::CMaterial::_ZFunction [private]
 

Definition at line 550 of file material.h.

Referenced by CMaterial, operator=, serial, and setZFunc.

CRefPtr<IShader> NL3D::CMaterial::pShader
 

Definition at line 569 of file material.h.

Referenced by ~CMaterial.


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