NL3D::CMaterial Class Reference

#include <material.h>

Inheritance diagram for NL3D::CMaterial:

NLMISC::CRefCount

Detailed Description

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

Definition at line 119 of file material.h.

Public Types

enum  TBlend {
  one = 0, zero, srcalpha, invsrcalpha,
  srccolor, invsrccolor, blendConstantColor, blendConstantInvColor,
  blendConstantAlpha, blendConstantInvAlpha, blendCount
}
enum  TShader {
  Normal = 0, Bump, UserColor, LightMap,
  Specular, Caustics, PerPixelLighting, PerPixelLightingNoSpec,
  Cloud, Water, shaderCount
}
enum  TTexCoordGenMode { TexCoordGenReflect = 0, TexCoordGenObjectSpace, TexCoordGenEyeSpace, numTexCoordGenMode }
typedef std::vector< CLightMapTTexturePtrs
enum  ZFunc {
  always = 0, never, equal, notequal,
  less, lessequal, greater, greaterequal,
  zfuncCount
}
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
}
Texture Env Modes.
enum  TTexOperand { SrcColor = 0, InvSrcColor, SrcAlpha, InvSrcAlpha }
enum  TTexOperator {
  Replace = 0, Modulate, Add, AddSigned,
  InterpolateTexture, InterpolatePrevious, InterpolateDiffuse, InterpolateConstant,
  EMBM
}
enum  TTexSource { Texture = 0, Previous, Diffuse, Constant }

Public Member Functions

void clearTouched (uint32 flag)
void flushTextures (IDriver &driver, uint selectedTexture)
 Flush textures. Force texture generation.

uint32 getFlags () const
const sintgetRefCount () const
TShader getShader () const
 get the current material shadertype.

bool getStainedGlassWindow ()
uint32 getTouched (void) const
void serial (NLMISC::IStream &f)
void setShader (TShader val)
void setStainedGlassWindow (bool val)
Object.
 CMaterial (const CMaterial &mat)
 see operator=.

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

 ~CMaterial ()
 dtor.

Texture environnement. Normal shader only.
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.

void enableUserTexMat (uint stage, bool enabled=true)
 Decompose a user texture matrix, We assume that this is only a matrix for 2d texture.

CRGBA getTexConstantColor (uint stage)
 Decompose a user texture matrix, We assume that this is only a matrix for 2d texture.

bool getTexCoordGen (uint stage) const
 Decompose a user texture matrix, We assume that this is only a matrix for 2d texture.

TTexCoordGenMode getTexCoordGenMode (uint stage) const
 Decompose a user texture matrix, We assume that this is only a matrix for 2d texture.

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

const NLMISC::CMatrixgetUserTexMat (uint stage) const
bool isUserTexMatEnabled (uint stage) const
 Decompose a user texture matrix, We assume that this is only a matrix for 2d texture.

void setTexCoordGen (uint stage, bool generate)
 Decompose a user texture matrix, We assume that this is only a matrix for 2d texture.

void setTexCoordGenMode (uint stage, TTexCoordGenMode mode)
 Decompose a user texture matrix, We assume that this is only a matrix for 2d texture.

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

void setUserTexMat (uint stage, const NLMISC::CMatrix &m)
 Set a new texture matrix for the given stage.

void texConstantColor (uint stage, CRGBA color)
 Setup the constant color for a stage. Used for the TTexSource:Constant.

void texEnvArg0Alpha (uint stage, TTexSource src, TTexOperand oper)
 Decompose a user texture matrix, We assume that this is only a matrix for 2d texture.

void texEnvArg0RGB (uint stage, TTexSource src, TTexOperand oper)
 Decompose a user texture matrix, We assume that this is only a matrix for 2d texture.

void texEnvArg1Alpha (uint stage, TTexSource src, TTexOperand oper)
 Decompose a user texture matrix, We assume that this is only a matrix for 2d texture.

void texEnvArg1RGB (uint stage, TTexSource src, TTexOperand oper)
 Decompose a user texture matrix, We assume that this is only a matrix for 2d texture.

void texEnvOpAlpha (uint stage, TTexOperator ope)
 Decompose a user texture matrix, We assume that this is only a matrix for 2d texture.

void texEnvOpRGB (uint stage, TTexOperator ope)
Texture Addressing Mode Method
void enableTexAddrMode (bool enable=true)
TTexAddressingMode getTexAddressingMode (uint8 stage)
 Get the texture addressing mode for the given stage.

void setTexAddressingMode (uint8 stage, TTexAddressingMode mode)
bool texAddrEnabled () const
 test whether texture addressing mode are enabled

Alpha Test
bool getAlphaTest () const
float getAlphaTestThreshold () const
void setAlphaTest (bool active)
void setAlphaTestThreshold (float thre)
Color/Lighting..
CRGBA getAmbient () const
CRGBA getColor (void) const
CRGBA getDiffuse () const
 return diffuse part. NB: A==opacity.

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

uint8 getOpacity () const
float getShininess () const
CRGBA getSpecular () const
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.

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

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

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.

void setEmissive (CRGBA emissive=CRGBA(0, 0, 0))
 Set the emissive part ot material. Usefull 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.

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 setOpacity (uint8 opa)
 Set the Opacity part ot material. Usefull only if setLighting(true) has been done.

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

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

Blending.
bool getBlend () const
TBlend getDstBlend (void) const
TBlend getSrcBlend (void) const
void setBlend (bool active)
void setBlendFunc (TBlend src, TBlend dst)
void setDstBlend (TBlend val)
void setSrcBlend (TBlend val)
Double sided.
bool getDoubleSided () const
void setDoubleSided (bool active)
LightMap. LightMap shader only.
ITexturegetLightMap (uint lmapId) const
 Get the ith lightmap. (NULL if none).

void setLightMap (uint lmapId, ITexture *lmap)
 Set the ith lightmap. undef results if holes in lightmap array.

void setLightMapColor (uint lmapId, CRGBA color)
 Set the lightmap color (usefull in 8 bits format) (def : White).

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

Texture.
ITexturegetTexture (uint8 stage) const
void setTexture (uint8 stage, ITexture *ptex)
bool texturePresent (uint8 stage) const
Texture UserColor. UserColor shader only.
CRGBA getUserColor () const
void setUserColor (CRGBA userColor)
ZBuffer.
float getZBias (void) const
ZFunc getZFunc (void) const
bool getZWrite (void) const
void setZBias (float val)
void setZFunc (ZFunc val)
void setZWrite (bool active)
Tools..
void initLighted ()
void initUnlit ()
void selectTextureSet (uint index)

Data Fields

TTexturePtrs _LightMaps
bool _LightMapsMulx2
uint8 _TexAddrMode [IDRV_MAT_MAXTEXTURES]
CTexEnv _TexEnvs [IDRV_MAT_MAXTEXTURES]
CSmartPtr< ITexture_Textures [IDRV_MAT_MAXTEXTURES]
sint crefs
CPtrInfo * pinfo
CRefPtr< IShaderpShader

Static Public Attributes

CPtrInfo NullPtrInfo

Private Attributes

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

Friends

struct CPtrInfo


Member Typedef Documentation

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

Definition at line 609 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 129 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 
Water 
shaderCount 

Definition at line 161 of file material.h.

Referenced by getShader().

00161                                         { Normal=0,
00162                                                           Bump,
00163                                                           UserColor,
00164                                                           LightMap,
00165                                                           Specular,
00166                                                           Caustics,
00167                                                           PerPixelLighting,
00168                                                           PerPixelLightingNoSpec,
00169                                                           Cloud,
00170                                                           Water,
00171                                                           shaderCount};

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

Referenced by getTexAddressingMode().

enum NL3D::CMaterial::TTexCoordGenMode
 

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

Enumeration values:
TexCoordGenReflect 
TexCoordGenObjectSpace 
TexCoordGenEyeSpace 
numTexCoordGenMode 

Definition at line 231 of file material.h.

Referenced by getTexCoordGenMode().

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 204 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, this must be supported by driver.

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

Definition at line 186 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 195 of file material.h.

00195 { Texture=0, Previous, Diffuse, Constant };

enum NL3D::CMaterial::ZFunc
 

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

Definition at line 123 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, _DstBlend, _Flags, _LightMapsMulx2, _ShaderType, _SrcBlend, _StainedGlassWindow, _TexCoordGenMode, _Touched, _ZBias, _ZFunction, NL3D::IDRV_MAT_ZWRITE, invsrcalpha, lessequal, NLMISC::CRGBA::set(), and srcalpha.

00042 {
00043         _Touched= 0;
00044         _Flags= IDRV_MAT_ZWRITE;
00045         // Must init All the flags by default.
00046         _ShaderType= Normal;
00047         _SrcBlend= srcalpha;
00048         _DstBlend= invsrcalpha;
00049         _ZFunction= lessequal;
00050         _ZBias= 0;
00051         _Color.set(255,255,255,255);
00052         _StainedGlassWindow = false;
00053         _AlphaTestThreshold= 0.5f;      
00054         _TexCoordGenMode= 0;
00055         _LightMapsMulx2= false;
00056 }

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

see operator=.

Definition at line 242 of file material.h.

References _Flags, _Touched, and operator=().

00242 {_Touched= 0;_Flags=0; operator=(mat);}

NL3D::CMaterial::~CMaterial  ) 
 

dtor.

Definition at line 131 of file material.cpp.

References NLMISC::CRefPtr< IShader >::kill(), and pShader.

00132 {
00133         // Must kill the drv mirror of this material.
00134         pShader.kill(); 
00135 }


Member Function Documentation

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

Definition at line 616 of file material.h.

References _Touched, and uint32.

Referenced by NL3D::CDriverGL::setupMaterial().

00616 { _Touched&=~flag; }

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.

find the rotation around w

Definition at line 523 of file material.cpp.

References _TexUserMat, NLMISC::CMatrix::getI(), NLMISC::CMatrix::getJ(), NLMISC::CMatrix::getK(), NLMISC::CMatrix::getPos(), NL3D::IDRV_MAT_MAXTEXTURES, NLMISC::CMatrix::invert(), isUserTexMatEnabled(), nlassert, NLMISC::CVector::norm(), NLMISC::CVector::normalize(), offset, NLMISC::CMatrix::setPos(), NLMISC::CMatrix::setRot(), uint, NLMISC::CVector::x, and NLMISC::CVector::y.

Referenced by NL3D::CMaterialBase::copyFromMaterial().

00524 {
00525         nlassert(stage < IDRV_MAT_MAXTEXTURES);
00526         nlassert(isUserTexMatEnabled(stage)); // must activate animated texture matrix for this stage
00527         CMatrix convMat; // exported v are already inverted (todo: optim this...)
00528         convMat.setRot(CVector::I, -CVector::J, CVector::K);
00529         convMat.setPos(CVector::J);
00530 
00531         const NLMISC::CMatrix texMat = convMat * _TexUserMat->TexMat[stage] * convMat;  
00533         NLMISC::CVector i = texMat.getI();
00534         NLMISC::CVector j = texMat.getJ();      
00535         uScale = sqrtf(i.x * i.x + j.x * j.x);
00536         vScale = sqrtf(i.y * i.y + j.y * j.y);          
00537         //
00538         i.normalize();  
00539         //      
00540         float angle = acosf(i.x / i.norm());
00541         if (i.y < 0)
00542         {
00543                 angle = 2.f * (float) NLMISC::Pi - angle;
00544         }
00545         wRot = angle;
00546 
00547         // compute position
00548         CMatrix InvSR;
00549         InvSR.setRot(texMat.getI(), texMat.getJ(), texMat.getK());
00550         InvSR.invert();
00551         CVector half(0.5f, 0.5f, 0.f);
00552         CVector offset = half + InvSR * (texMat.getPos() -half);
00553         uTrans = - offset.x;
00554         vTrans = - offset.y;
00555 }

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

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

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

00480 {
00481         if (enable)
00482         {
00483                 if (!(_Flags & IDRV_MAT_TEX_ADDR))
00484                 {
00485                         _Flags |= IDRV_MAT_TEX_ADDR;
00486                         for (uint32 k = 0; k < IDRV_MAT_MAXTEXTURES; ++k)
00487                         {
00488                                 _TexAddrMode[k] = (uint8) FetchTexture;
00489                         }                       
00490                 }               
00491         }
00492         else
00493         {
00494                 _Flags &= ~IDRV_MAT_TEX_ADDR;                   
00495         }
00496 }

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

Decompose a user texture matrix, We assume that this is only a matrix for 2d texture.

find the rotation around w

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, nlassert, and uint.

Referenced by NL3D::CShadowMapManager::CShadowMapManager(), NL3D::CInstanceMaterialUser::enableUserTexMat(), NL3D::CSegRemanenceShape::setupMaterial(), NL3D::CPSConstraintMesh::setupRenderPasses(), NL3D::CPSRibbon::setupTextureMatrix(), and NL3D::CPSShockWave::setupUFactor().

00338 {
00339         nlassert(stage < IDRV_MAT_MAXTEXTURES);
00340         if (enabled)
00341         {
00342                 if (!(_Flags & IDRV_MAT_USER_TEX_MAT_ALL)) // not usr tex mat setupped before?
00343                 {
00344                         nlassert(_TexUserMat.get() == NULL);
00345                         _TexUserMat.reset(new CUserTexMat);
00346                 }
00347                 _Flags |= (IDRV_MAT_USER_TEX_0_MAT << stage);
00348                 _TexUserMat->TexMat[stage].identity();
00349         }
00350         else
00351         {
00352                 if (!(_Flags & IDRV_MAT_USER_TEX_MAT_ALL)) return; // nothing to do
00353                 _Flags &= ~(IDRV_MAT_USER_TEX_0_MAT << stage);     // clear the stage flag
00354                 if (!(_Flags & IDRV_MAT_USER_TEX_MAT_ALL))                 // no more user textures used ?
00355                 {
00356                         _TexUserMat.reset();
00357                 }
00358         }
00359 }

void NL3D::CMaterial::flushTextures IDriver driver,
uint  selectedTexture
 

Flush textures. Force texture generation.

Definition at line 355 of file material.cpp.

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

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

00356 {
00357         // For each textures
00358         for (uint tex=0; tex<IDRV_MAT_MAXTEXTURES; tex++)
00359         {
00360                 // Texture exist ?
00361                 if (_Textures[tex])
00362                 {
00363                         // Select the good texture
00364                         _Textures[tex]->selectTexture (selectedTexture);
00365                         
00366                         // Force setup texture
00367                         driver.setupTexture (*_Textures[tex]);
00368                 }
00369         }
00370 
00371         // If Lightmap material
00372         if(_ShaderType==LightMap)
00373         {
00374                 // For each lightmap
00375                 for (uint lmap=0; lmap<_LightMaps.size(); lmap++)
00376                 {
00377                         // Texture exist?
00378                         if(_LightMaps[lmap].Texture)
00379                         {
00380                                 // Force setup texture
00381                                 driver.setupTexture (*_LightMaps[lmap].Texture);
00382                         }
00383                 }
00384         }
00385 
00386 }

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

Definition at line 314 of file material.h.

References _Flags, and NL3D::IDRV_MAT_ALPHA_TEST.

Referenced by NL3D::CZoneLighter::getTexture(), NL3D::CMeshBlender::prepareRenderForGlobalAlpha(), and NL3D::CMeshBlender::restoreRender().

00314 { return (_Flags&IDRV_MAT_ALPHA_TEST)!=0; }

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

Definition at line 320 of file material.h.

References _AlphaTestThreshold.

Referenced by NL3D::CZoneLighter::getTexture(), NL3D::CMeshBlender::prepareRenderForGlobalAlpha(), and NL3D::CDriverGL::setupMaterial().

00320 { return _AlphaTestThreshold; }

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

Definition at line 378 of file material.h.

Referenced by NL3D::CRenderTrav::changeVPLightSetupMaterial(), NL3D::CMaterialBase::copyFromMaterial(), NL3D::CInstanceMaterialUser::getAmbient(), and NL3D::CDriverGL::setupMaterial().

00378 { return _Ambient;}

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

Definition at line 278 of file material.h.

References _Flags, and NL3D::IDRV_MAT_BLEND.

Referenced by NL3D::CMaterialUser::getBlend(), NL3D::CInstanceMaterialUser::getBlend(), NL3D::CPSMaterial::getBlendingMode(), NL3D::CZoneLighter::getTexture(), NL3D::CMeshBlender::prepareRenderForGlobalAlpha(), NL3D::CSegRemanenceShape::render(), NL3D::CDriverGL::setupLightMapPass(), and NL3D::CSegRemanence::updateOpacityFromShape().

00278 { return (_Flags&IDRV_MAT_BLEND)!=0; }

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

Definition at line 376 of file material.h.

Referenced by NL3D::CMaterialUser::getColor(), NL3D::CInstanceMaterialUser::getColor(), NL3D::CMeshBlender::prepareRenderForGlobalAlphaCoarseMesh(), NL3D::CDriverGL::setupCloudPass(), and NL3D::CDriverGL::setupMaterial().

00376 { return(_Color); }

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

return diffuse part. NB: A==opacity.

Definition at line 380 of file material.h.

Referenced by NL3D::CRenderTrav::changeVPLightSetupMaterial(), NL3D::CMaterialBase::copyFromMaterial(), NL3D::CInstanceMaterialUser::getDiffuse(), and NL3D::CDriverGL::setupMaterial().

00380 { return _Diffuse;}

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

Definition at line 308 of file material.h.

References _Flags, and NL3D::IDRV_MAT_DOUBLE_SIDED.

Referenced by NL3D::CMaterialUser::getDoubleSided(), and NL3D::CZoneLighter::getTexture().

00308 { return (_Flags&IDRV_MAT_DOUBLE_SIDED)!=0; }

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

Definition at line 280 of file material.h.

References _DstBlend, and TBlend.

Referenced by NL3D::CPSMaterial::getBlendingMode(), NL3D::CMaterialUser::getDstBlend(), NL3D::CInstanceMaterialUser::getDstBlend(), NL3D::CMeshBlender::prepareRenderForGlobalAlpha(), NL3D::CMeshBlender::prepareRenderForGlobalAlphaCoarseMesh(), and NL3D::CDriverGL::setupMaterial().

00280 { return(_DstBlend); }

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

Definition at line 377 of file material.h.

Referenced by NL3D::CRenderTrav::changeVPLightSetupMaterial(), NL3D::CMaterialBase::copyFromMaterial(), NL3D::CInstanceMaterialUser::getEmissive(), and NL3D::CDriverGL::setupMaterial().

00377 { return _Emissive;}

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

Definition at line 614 of file material.h.

References _Flags, and uint32.

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

00614 {return _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.

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

00202 {
00203         return (_Flags & IDRV_MAT_LIGHTED_VERTEX_COLOR) != 0;
00204 }

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

Get the ith lightmap. (NULL if none).

Definition at line 401 of file material.cpp.

References _LightMaps, _ShaderType, nlassert, and uint.

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

00402 {
00403         nlassert(_ShaderType==CMaterial::LightMap);
00404         if(lmapId<_LightMaps.size())
00405                 return _LightMaps[lmapId].Texture;
00406         else
00407                 return NULL;    
00408 }

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

Definition at line 381 of file material.h.

References NLMISC::CRGBA::A, and uint8.

Referenced by NL3D::CInstanceMaterialUser::getOpacity(), and NL3D::CMeshBlender::prepareRenderForGlobalAlpha().

00381 { return _Diffuse.A;}

const sint& NLMISC::CRefCount::getRefCount  )  const [inline, inherited]
 

Definition at line 70 of file smart_ptr.h.

References NLMISC::CRefCount::crefs, and sint.

00071         {
00072                 return  crefs;
00073         }

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

get the current material shadertype.

Definition at line 254 of file material.h.

References _ShaderType, and TShader.

Referenced by NL3D::CDriverGL::beginCloudMultiPass(), NL3D::CDriverGL::beginWaterMultiPass(), NL3D::CDriverGL::endCloudMultiPass(), NL3D::CDriverGL::endWaterMultiPass(), NL3D::CInstanceMaterialUser::isUserColor(), NL3D::CShapeBank::processWaitingShapes(), NL3D::CMeshMRMSkinnedGeom::renderSkinGroupPrimitives(), NL3D::CMeshMRMGeom::renderSkinGroupPrimitives(), NL3D::CAsyncFileManager3D::CMeshLoad::run(), NL3D::CDriverGL::setupCloudPass(), NL3D::CMeshVPPerPixelLight::setupForMaterial(), NL3D::CDriverGL::setupMaterial(), NL3D::CPSConstraintMesh::setupMaterialColor(), and NL3D::CDriverGL::setupWaterPass().

00254 {return _ShaderType;}

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

Definition at line 383 of file material.h.

Referenced by NL3D::CRenderTrav::changeVPLightSetupMaterial(), NL3D::CMaterialBase::copyFromMaterial(), NL3D::CInstanceMaterialUser::getShininess(), NL3D::CMeshVPPerPixelLight::setupForMaterial(), NL3D::CDriverGL::setupMaterial(), and NL3D::CDriverGL::setupPPLPass().

00383 { return _Shininess;}

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

Definition at line 382 of file material.h.

Referenced by NL3D::CRenderTrav::changeVPLightSetupMaterial(), NL3D::CMaterialBase::copyFromMaterial(), NL3D::CInstanceMaterialUser::getSpecular(), and NL3D::CDriverGL::setupMaterial().

00382 { return _Specular;}

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

Definition at line 279 of file material.h.

References _SrcBlend, and TBlend.

Referenced by NL3D::CPSMaterial::getBlendingMode(), NL3D::CMaterialUser::getSrcBlend(), NL3D::CInstanceMaterialUser::getSrcBlend(), NL3D::CMeshBlender::prepareRenderForGlobalAlpha(), NL3D::CMeshBlender::prepareRenderForGlobalAlphaCoarseMesh(), and NL3D::CDriverGL::setupMaterial().

00279 { return(_SrcBlend); }

bool NL3D::CMaterial::getStainedGlassWindow  )  [inline]
 

Definition at line 480 of file material.h.

References _StainedGlassWindow.

00480 { return _StainedGlassWindow; }

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

Get the texture addressing mode for the given stage.

Definition at line 515 of file material.cpp.

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

00516 {
00517         nlassert(_Flags & IDRV_MAT_TEX_ADDR);
00518         nlassert(stage < IDRV_MAT_MAXTEXTURES);
00519         return (TTexAddressingMode) _TexAddrMode[stage];
00520 }

CRGBA NL3D::CMaterial::getTexConstantColor uint  stage  )  [inline]
 

Decompose a user texture matrix, We assume that this is only a matrix for 2d texture.

find the rotation around w

Definition at line 291 of file driver_material_inline.h.

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

Referenced by NL3D::CInstanceMaterialUser::getConstantColor().

00292 {
00293         nlassert(_ShaderType==CMaterial::Normal);
00294         nlassert(stage<IDRV_MAT_MAXTEXTURES);
00295         return _TexEnvs[stage].ConstantColor;
00296 }

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

Decompose a user texture matrix, We assume that this is only a matrix for 2d texture.

find the rotation around w

Definition at line 298 of file driver_material_inline.h.

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

Referenced by NL3D::CDriverGL::setTextureEnvFunction().

00299 {
00300         nlassert(stage<IDRV_MAT_MAXTEXTURES);
00301         return (_Flags&(IDRV_MAT_GEN_TEX_0<<stage))!=0;
00302 }

TTexCoordGenMode NL3D::CMaterial::getTexCoordGenMode uint  stage  )  const [inline]
 

Decompose a user texture matrix, We assume that this is only a matrix for 2d texture.

find the rotation around w

Definition at line 420 of file material.h.

References _TexCoordGenMode, NL3D::IDRV_MAT_TEX_GEN_MASK, NL3D::IDRV_MAT_TEX_GEN_SHIFT, TTexCoordGenMode, and uint.

Referenced by NL3D::CDriverGL::setTextureEnvFunction().

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, nlassert, uint, and uint32.

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

00278 {
00279         nlassert(_ShaderType==CMaterial::Normal);
00280         nlassert(stage<IDRV_MAT_MAXTEXTURES);
00281         return _TexEnvs[stage].EnvPacked;
00282 }

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

Definition at line 46 of file driver_material_inline.h.

References NL3D::IDRV_MAT_MAXTEXTURES, nlassert, and uint8.

Referenced by NL3D::CDriverGL::beginSpecularMultiPass(), NL3D::CCoarseMeshBuild::buildBitmap(), NL3D::CFontManager::computeString(), NL3D::CFontManager::computeStringInfo(), NL3D::CPSMaterial::forceModulateConstantColor(), NL3D::CPSMaterial::forceTexturedMaterialStages(), NL3D::CInstanceMaterialUser::getLastTextureStage(), NL3D::CZoneLighter::getTexture(), NL3D::CInstanceMaterialUser::getTextureFileName(), NL3D::CInstanceMaterialUser::isTextureFile(), 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::CInstanceMaterialUser::setTextureFileName(), NL3D::CDriverGL::setupCloudPass(), NL3D::CDriverGL::setupLightMapPass(), NL3D::CSegRemanenceShape::setupMaterial(), NL3D::CDriverGL::setupMaterial(), NL3D::CDriverGL::setupPPLNoSpecPass(), NL3D::CDriverGL::setupPPLPass(), NL3D::CPSConstraintMesh::setupRenderPasses(), NL3D::CDriverGL::setupSpecularPass(), NL3D::CDriverGL::setupWaterPassARB(), NL3D::CDriverGL::setupWaterPassNV20(), and NL3D::CDriverGL::setupWaterPassR200().

00047 { 
00048         nlassert(n<IDRV_MAT_MAXTEXTURES);
00049         return(_Textures[n]); 
00050 }

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

Definition at line 615 of file material.h.

References _Touched, and uint32.

Referenced by NL3D::CDriverGL::setupMaterial().

00615 { return(_Touched); }

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.

Referenced by NL3D::CInstanceMaterialUser::getUserColor().

00330 {
00331         nlassert(_ShaderType==CMaterial::UserColor);
00332         // setup stage 0 constant color (don't use getTexConstantColor() because of assert).
00333         return _TexEnvs[0].ConstantColor;
00334 }

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(), nlassert, and uint.

Referenced by NL3D::CInstanceMaterialUser::getUserTexMat(), and NL3D::CDriverGL::setupUserTextureMatrix().

00378 {
00379         nlassert(isUserTexMatEnabled(stage));
00380         nlassert(_TexUserMat.get() != NULL);
00381         return _TexUserMat->TexMat[stage];
00382 }

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

Definition at line 336 of file material.h.

References _ZBias.

Referenced by NL3D::CMaterialUser::getZBias(), and NL3D::CDriverGL::setupMaterial().

00336 { return(_ZBias); }

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

Definition at line 334 of file material.h.

References _ZFunction, and ZFunc.

Referenced by NL3D::CMaterialUser::getZFunc(), NL3D::CPSMaterial::isZTestEnabled(), and NL3D::CDriverGL::setupMaterial().

00334 { return(_ZFunction); }         

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

Definition at line 335 of file material.h.

References _Flags, and NL3D::IDRV_MAT_ZWRITE.

Referenced by NL3D::CheckForOpaqueAndTransparentFacesInMesh(), NL3D::CPSConstraintMesh::doRenderPasses(), NL3D::CMaterialUser::getZWrite(), NL3D::CMeshBlender::prepareRenderForGlobalAlpha(), and NL3D::CPSConstraintMesh::setupRenderPasses().

00335 { return (_Flags&IDRV_MAT_ZWRITE)!=0; }

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

References initUnlit(), and setLighting().

00076 {
00077         initUnlit();
00078         setLighting(true);
00079 }

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

References NL3D::IDRV_MAT_MAXTEXTURES, lessequal, setAlphaTestThreshold(), setBlend(), setColor(), setLighting(), setShader(), setTexture(), setZBias(), setZFunc(), setZWrite(), uint32, and uint8.

Referenced by NL3D::CCloudScape::CCloudScape(), NL3D::CLodCharacterManager::CLodCharacterManager(), NL3D::CMaterialUser::CMaterialUser(), NL3D::CShadowMapManager::CShadowMapManager(), NL3D::CVegetableManager::CVegetableManager(), NL3D::CCloud::disp(), NL3D::CInstanceGroup::displayDebugClusters(), NL3D::CVisualCollisionEntity::displayDebugGrid(), NL3D::CDRU::drawBitmap(), NL3D::CDRU::drawLine(), NL3D::CDRU::drawQuad(), NL3D::CDRU::drawTriangle(), NL3D::CFontManager::getFontMaterial(), NL3D::CNoise3d::init(), NL3D::CLandscape::init(), initLighted(), NL3D::CMaterialUser::initUnlit(), NL3D::SCloudTexture3D::SCloudTexture3D(), and NL3D::SCloudTextureClamp::SCloudTextureClamp().

00060 {
00061         setShader(Normal);
00062         setLighting(false);
00063         setColor(CRGBA(255,255,255,255));
00064         for(uint32 i=0;i<IDRV_MAT_MAXTEXTURES;i++)
00065                 setTexture((uint8)i ,NULL);
00066         setZBias(0);
00067         setZFunc(lessequal);
00068         setZWrite(true);
00069         setBlend(false);
00070         setAlphaTestThreshold(0.5f);
00071 }

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

Definition at line 371 of file material.h.

References _Flags, and NL3D::IDRV_MAT_LIGHTING.

Referenced by NL3D::CheckForLightableFacesInMesh(), NL3D::CInstanceMaterialUser::isLighted(), and NL3D::CPSConstraintMesh::setupMaterialColor().

00371 {return (_Flags&IDRV_MAT_LIGHTING)!=0;}

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

References _Flags, and NL3D::IDRV_MAT_LIGHTED_VERTEX_COLOR.

Referenced by NL3D::CDriverGL::setupMaterial().

00374 { return (_Flags&IDRV_MAT_LIGHTED_VERTEX_COLOR)!=0;}

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

Decompose a user texture matrix, We assume that this is only a matrix for 2d texture.

find the rotation around w

Definition at line 362 of file driver_material_inline.h.

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

Referenced by NL3D::CMaterialBase::copyFromMaterial(), decompUserTexMat(), NL3D::CInstanceMaterialUser::getUserTexMat(), getUserTexMat(), NL3D::CInstanceMaterialUser::isUserTexMatEnabled(), serial(), NL3D::CInstanceMaterialUser::setUserTexMat(), and setUserTexMat().

00363 {
00364         nlassert(stage < IDRV_MAT_MAXTEXTURES);
00365         return (_Flags & (IDRV_MAT_USER_TEX_0_MAT << stage)) != 0;
00366 }

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

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

Definition at line 83 of file material.cpp.

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

Referenced by CMaterial().

00084 {
00085         _ShaderType= mat._ShaderType;
00086         _Flags= mat._Flags;
00087         _SrcBlend= mat._SrcBlend;
00088         _DstBlend= mat._DstBlend;
00089         _ZFunction= mat._ZFunction;
00090         _ZBias= mat._ZBias;
00091         _Color= mat._Color;
00092         _Emissive= mat._Emissive;
00093         _Ambient= mat._Ambient;
00094         _Diffuse= mat._Diffuse;
00095         _Specular= mat._Specular;
00096         _Shininess= mat._Shininess;
00097         _AlphaTestThreshold= mat._AlphaTestThreshold;
00098 
00099         for(uint32 i=0;i<IDRV_MAT_MAXTEXTURES;i++)
00100         {
00101                 _Textures[i]= mat._Textures[i];
00102                 _TexEnvs[i]= mat._TexEnvs[i];
00103                 _TexAddrMode[i] = mat._TexAddrMode[i];
00104         }
00105 
00106         // copy lightmaps.
00107         _LightMaps= mat._LightMaps;
00108         _LightMapsMulx2= mat._LightMapsMulx2;
00109 
00110         // copy texture matrix if there.
00111         if (mat._TexUserMat.get())
00112         {
00113                 std::auto_ptr<CUserTexMat> texMatClone( new CUserTexMat(*(mat._TexUserMat))); // make cpy
00114                 std::swap(texMatClone, _TexUserMat); // swap with old
00115         }
00116         else
00117         {
00118                 _TexUserMat.reset();    
00119         }
00120 
00121         // Must do not copy drv info.
00122 
00123         // All states of material is modified.
00124         _Touched= IDRV_TOUCHED_ALL;
00125 
00126         return *this;
00127 }

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

References NL3D::IDRV_MAT_MAXTEXTURES, index, and uint.

Referenced by NL3D::CMaterialUser::selectTextureSet().

00559 {
00560         for (uint k = 0; k < IDRV_MAT_MAXTEXTURES; ++k)
00561         {
00562                 if (_Textures[k] != NULL) _Textures[k]->selectTexture(index);
00563         }
00564 }

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

Definition at line 139 of file material.cpp.

References _AlphaTestThreshold, _DstBlend, _Flags, _LightMaps, _LightMapsMulx2, _ShaderType, _SrcBlend, _TexAddrMode, _TexEnvs, _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(), setSpecular(), sint, uint, and uint32.

00140 {
00141         /*
00142         Version 7:
00143                 - Lightmap color and Mulx2
00144         Version 6:
00145                 - Texture matrix animation
00146         Version 5:
00147                 - AlphaTest threshold
00148         Version 4:
00149                 - Texture Addressing modes
00150         Version 3:
00151                 - LightMaps.
00152         Version 2:
00153                 - Shininess.
00154         Version 1:
00155                 - texture environement.
00156         Version 0:
00157                 - base version.
00158         */
00159 
00160         sint    ver= f.serialVersion(7);
00161         // For the version <=1:
00162         nlassert(IDRV_MAT_MAXTEXTURES==4);
00163 
00164         f.serialEnum(_ShaderType);
00165         f.serial(_Flags);
00166         f.serialEnum(_SrcBlend);
00167         f.serialEnum(_DstBlend);
00168         f.serialEnum(_ZFunction);
00169         f.serial(_ZBias);
00170         f.serial(_Color);
00171         f.serial(_Emissive, _Ambient, _Diffuse, _Specular);
00172         if(ver>=2)
00173         {
00174                 f.serial(_Shininess);
00175         }
00176         if(ver>=5)
00177         {
00178                 f.serial(_AlphaTestThreshold);
00179         }
00180 
00181 
00182         for(uint32 i=0;i<IDRV_MAT_MAXTEXTURES;i++)
00183         {
00184                 // Serial texture descriptor.
00185                 ITexture*       text;
00186                 if(f.isReading())
00187                 {
00188                         f.serialPolyPtr(text);
00189                         _Textures[i]= text;
00190                 }
00191                 else
00192                 {
00193                         text= _Textures[i];
00194                         f.serialPolyPtr(text);
00195                 }
00196 
00197                 // Read texture environnement, or setup them.
00198                 if(ver>=1)
00199                 {
00200                         f.serial(_TexEnvs[i]);
00201                 }
00202                 else
00203                 {
00204                         // Else setup as default behavior, like before...
00205                         if(f.isReading())
00206                                 _TexEnvs[i].setDefault();
00207                 }
00208         }
00209 
00210         if(ver>=3)
00211         {
00212                 if(ver>=7)
00213                 {
00214                         uint32 n;
00215                         if (f.isReading())
00216                         {
00217                                 f.serial(n);
00218                                 _LightMaps.resize(n);
00219                         }
00220                         else
00221                         {
00222                                 n = _LightMaps.size();
00223                                 f.serial(n);
00224                         }
00225                         for (uint32 i = 0; i < n; ++i)
00226                                 _LightMaps[i].serial2(f);
00227                         f.serial(_LightMapsMulx2);
00228                 }
00229                 else
00230                 {
00231                         f.serialCont(_LightMaps);
00232                 }
00233         }
00234 
00235         if (ver >= 4)
00236         {
00237                 if (_Flags & IDRV_MAT_TEX_ADDR)
00238                 {
00239                         for(uint32 i=0;i<IDRV_MAT_MAXTEXTURES;i++)
00240                         {
00241                                 f.serial(_TexAddrMode[i]);
00242                         }
00243                 }
00244         }
00245 
00246         if(f.isReading())
00247         {
00248                 // Converte Deprecated DEFMAT to std Mat.
00249                 if(_Flags & IDRV_MAT_DEFMAT)
00250                 {
00251                         setEmissive(CRGBA::Black);
00252                         setAmbient(CRGBA::White);
00253                         setDiffuse(CRGBA::White);
00254                         setSpecular(CRGBA::Black);
00255                 }
00256 
00257                 // All states of material are modified.
00258                 _Touched= IDRV_TOUCHED_ALL;
00259 
00260                 if ((_Flags & IDRV_MAT_USER_TEX_MAT_ALL)) // are there user textrue coordinates matrix ?
00261                 {
00262                         std::auto_ptr<CUserTexMat> newPtr(new CUserTexMat); // create new                       
00263                         std::swap(_TexUserMat, newPtr); // replace old
00264                 }
00265         }
00266 
00267         if (ver >= 6)
00268         {
00269                 for(uint i=0; i < IDRV_MAT_MAXTEXTURES; ++i)
00270                 {
00271                         if (isUserTexMatEnabled(i))
00272                         {                               
00273                                 f.serial(_TexUserMat->TexMat[i]);                               
00274                         }                       
00275                 }
00276         }
00277 
00278 }

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(), NL3D::CLodCharacterManager::CLodCharacterManager(), NL3D::CShadowMapManager::CShadowMapManager(), NL3D::CVegetableManager::CVegetableManager(), and NL3D::CPSMaterial::setBlendingMode().

00079 {
00080         if (active)     _Flags|=IDRV_MAT_ALPHA_TEST;
00081         else            _Flags&=~IDRV_MAT_ALPHA_TEST;
00082         _Touched|=IDRV_TOUCHED_ALPHA_TEST;
00083 }

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(), NL3D::CShadowMapManager::CShadowMapManager(), initUnlit(), NL3D::CMeshBlender::prepareRenderForGlobalAlpha(), NL3D::CMeshBlender::prepareRenderForGlobalAlphaCoarseMesh(), NL3D::CVegetableManager::render(), NL3D::CMeshBlender::restoreRender(), NL3D::CMeshBlender::restoreRenderCoarseMesh(), and NL3D::CInstanceMaterialUser::setAlphaTestThreshold().

00086 {
00087         _AlphaTestThreshold= thre;
00088         _Touched|=IDRV_TOUCHED_ALPHA_TEST_THRE;
00089 }

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 _Touched, and NL3D::IDRV_TOUCHED_LIGHTING.

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

00159 {
00160         _Ambient= ambient;
00161         _Touched|=IDRV_TOUCHED_LIGHTING;
00162 }

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::CPSMaterial::CPSMaterial(), NL3D::CShadowMapManager::CShadowMapManager(), NL3D::CCloud::disp(), NL3D::CCloud::dispBill(), NL3D::CPSUtil::displayArrow(), NL3D::CPSUtil::displayBBox(), NL3D::CInstanceGroup::displayDebugClusters(), NL3D::CPSLocatedBindable::displayIcon2d(), NL3D::CWaterModel::doSimpleRender(), NL3D::CDRU::drawBitmap(), NL3D::CDRU::drawLine(), NL3D::CDRU::drawQuad(), NL3D::CDRU::drawTriangle(), NL3D::CFontManager::getFontMaterial(), NL3D::CNoise3d::init(), initUnlit(), NL3D::CCloud::light(), NL3D::CMotionBlur::performMotionBlur(), NL3D::CMeshBlender::prepareRenderForGlobalAlpha(), NL3D::CMeshBlender::prepareRenderForGlobalAlphaCoarseMesh(), NL3D::CVegetableManager::render(), NL3D::CLandscape::render(), NL3D::CMeshBlender::restoreRender(), NL3D::CMeshBlender::restoreRenderCoarseMesh(), NL3D::SCloudTexture3D::SCloudTexture3D(), NL3D::SCloudTextureClamp::SCloudTextureClamp(), NL3D::CMaterialUser::setBlend(), NL3D::CInstanceMaterialUser::setBlend(), NL3D::CPSMaterial::setBlendingMode(), NL3D::CWaterModel::setupMaterialNVertexShader(), NL3D::CPSGravity::show(), NL3D::CPSEmitter::showTool(), and NL3D::CFlareModel::traverseRender().

00065 {
00066         if (active)     _Flags|=IDRV_MAT_BLEND;
00067         else            _Flags&=~IDRV_MAT_BLEND;
00068         _Touched|=IDRV_TOUCHED_BLEND;
00069 }

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::CPSMaterial::CPSMaterial(), NL3D::CShadowMapManager::CShadowMapManager(), NL3D::CVegetableManager::CVegetableManager(), NL3D::CPSUtil::displayArrow(), NL3D::CPSUtil::displayBBox(), NL3D::CInstanceGroup::displayDebugClusters(), NL3D::CPSLocatedBindable::displayIcon2d(), NL3D::CNoise3d::init(), NL3D::CMotionBlur::performMotionBlur(), NL3D::CLandscape::render(), NL3D::SCloudTexture3D::SCloudTexture3D(), NL3D::SCloudTextureClamp::SCloudTextureClamp(), NL3D::CMaterialUser::setBlendFunc(), NL3D::CInstanceMaterialUser::setBlendFunc(), NL3D::CPSMaterial::setBlendingMode(), NL3D::CPSGravity::show(), NL3D::CPSEmitter::showTool(), and NL3D::CFlareModel::traverseRender().

00092 {
00093         _SrcBlend=src;
00094         _DstBlend=dst;
00095         _Touched|=IDRV_TOUCHED_BLENDFUNC;
00096 }

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 _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::CWaterModel::doSimpleRender(), 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::CCloud::light(), NL3D::CMotionBlur::performMotionBlur(), NL3D::CMeshBlender::prepareRenderForGlobalAlphaCoarseMesh(), NL3D::CComputedString::render2D(), NL3D::CComputedString::render3D(), NL3D::CShadowMapManager::renderProject(), NL3D::CCloud::reset(), NL3D::CMeshBlender::restoreRenderCoarseMesh(), NL3D::SCloudTexture3D::SCloudTexture3D(), NL3D::SCloudTextureClamp::SCloudTextureClamp(), NL3D::CMaterialUser::setColor(), NL3D::CInstanceMaterialUser::setColor(), NL3D::CPSTailDot::setupGlobalColor(), NL3D::CPSConstraintMesh::setupMaterialColor(), NL3D::CWaterModel::setupMaterialNVertexShader(), NL3D::CPSRibbon::setupTexturedGlobalColor(), NL3D::CPSRibbon::setupUntexturedGlobalColor(), NL3D::CPSGravity::show(), NL3D::CPSEmitter::showTool(), NL3D::CPSTailDot::step(), NL3D::CPSRibbonLookAt::step(), NL3D::CPSRibbon::step(), NL3D::CFlareModel::traverseRender(), and NL3D::CPSQuad::updateMatBeforeRendering().

00119 {
00120         if (_Color != rgba)
00121         {
00122                 _Color=rgba;
00123                 _Touched|=IDRV_TOUCHED_COLOR;
00124         }
00125 }

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 _Touched, NLMISC::CRGBA::B, NLMISC::CRGBA::G, NL3D::IDRV_TOUCHED_LIGHTING, and NLMISC::CRGBA::R.

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

00165 {
00166         // Keep opacity.
00167         _Diffuse.R= diffuse.R;
00168         _Diffuse.G= diffuse.G;
00169         _Diffuse.B= diffuse.B;
00170         _Touched|=IDRV_TOUCHED_LIGHTING;
00171 }

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(), NL3D::CLodCharacterManager::CLodCharacterManager(), NL3D::CPSRibbon::CPSRibbon(), NL3D::CShadowMapManager::CShadowMapManager(), NL3D::CCloud::disp(), NL3D::CCloud::dispBill(), NL3D::CPSUtil::displayArrow(), NL3D::CInstanceGroup::displayDebugClusters(), NL3D::CDeform2d::doDeform(), NL3D::CWaterModel::doSimpleRender(), NL3D::CPSShockWave::init(), NL3D::CPSQuad::init(), NL3D::CPSFanLight::init(), NL3D::CMotionBlur::performMotionBlur(), NL3D::CVegetableManager::render(), NL3D::SCloudTexture3D::SCloudTexture3D(), NL3D::CMaterialUser::setDoubleSided(), NL3D::CSegRemanenceShape::setupMaterial(), NL3D::CWaterModel::setupMaterialNVertexShader(), and NL3D::CFlareModel::traverseRender().

00072 {
00073         if (active)     _Flags|=IDRV_MAT_DOUBLE_SIDED;
00074         else            _Flags&=~IDRV_MAT_DOUBLE_SIDED;
00075         _Touched|=IDRV_TOUCHED_DOUBLE_SIDED;
00076 }

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.

Referenced by NL3D::CWaterModel::doSimpleRender(), NL3D::CDRU::drawLine(), NL3D::CDRU::drawQuad(), NL3D::CDRU::drawTriangle(), NL3D::CFontManager::getFontMaterial(), NL3D::CLandscape::init(), NL3D::CMeshBlender::prepareRenderForGlobalAlpha(), NL3D::CMeshBlender::prepareRenderForGlobalAlphaCoarseMesh(), NL3D::CMeshBlender::restoreRender(), NL3D::CMeshBlender::restoreRenderCoarseMesh(), NL3D::CMaterialUser::setDstBlend(), NL3D::CInstanceMaterialUser::setDstBlend(), and NL3D::CWaterModel::setupMaterialNVertexShader().

00059 {
00060         _DstBlend=val;
00061         _Touched|=IDRV_TOUCHED_BLENDFUNC;
00062 }

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 _Touched, and NL3D::IDRV_TOUCHED_LIGHTING.

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

00153 {
00154         _Emissive= emissive;
00155         _Touched|=IDRV_TOUCHED_LIGHTING;
00156 }

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.

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

00192 {
00193         if (useLightedVertexColor)
00194                 _Flags |= IDRV_MAT_LIGHTED_VERTEX_COLOR;
00195         else
00196                 _Flags &= ~IDRV_MAT_LIGHTED_VERTEX_COLOR;
00197         _Touched|=IDRV_TOUCHED_LIGHTING;
00198 }

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 _Flags, _Touched, NL3D::IDRV_MAT_LIGHTING, and NL3D::IDRV_TOUCHED_LIGHTING.

Referenced by NL3D::CreateDummyMesh(), NL3D::CPSUtil::displayArrow(), NL3D::CPSUtil::displayBBox(), NL3D::CPSLocatedBindable::displayIcon2d(), NL3D::CDeform2d::doDeform(), NL3D::CWaterModel::doSimpleRender(), NL3D::CPSShockWave::init(), NL3D::CPSQuad::init(), NL3D::CPSFanLight::init(), NL3D::CPSDot::init(), initLighted(), initUnlit(), NL3D::CSegRemanenceShape::setupMaterial(), NL3D::CWaterModel::setupMaterialNVertexShader(), NL3D::CPSGravity::show(), NL3D::CPSEmitter::showTool(), and NL3D::CFlareModel::traverseRender().

00133 {
00134         if (active)
00135         {
00136                 _Flags|=IDRV_MAT_LIGHTING;
00137         }
00138         else
00139         {
00140                 _Flags&=~IDRV_MAT_LIGHTING;
00141         }
00142         _Emissive=emissive;
00143         _Ambient=ambient;
00144         _Diffuse=diffuse;
00145         _Specular=specular;
00146         _Shininess= shininess;
00147         _Touched|=IDRV_TOUCHED_LIGHTING;
00148 }

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

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

This part is valid for LightMap shaders (nlassert).

See also:
TShader.

Definition at line 390 of file material.cpp.

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

00391 {
00392         nlassert(_ShaderType==CMaterial::LightMap);
00393         if(lmapId>=_LightMaps.size())
00394                 _LightMaps.resize(lmapId+1);
00395         _LightMaps[lmapId].Texture= lmap;
00396 
00397         _Touched|=IDRV_TOUCHED_LIGHTMAP;
00398 }

void NL3D::CMaterial::setLightMapColor uint  lmapId,
CRGBA  color
 

Set the lightmap color (usefull in 8 bits format) (def : White).

Definition at line 424 of file material.cpp.

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

00425 {
00426         if (_ShaderType==CMaterial::LightMap)
00427         {
00428                 if(lmapId>=_LightMaps.size())
00429                         _LightMaps.resize(lmapId+1);
00430                 _LightMaps[lmapId].Color= color;
00431 
00432                 _Touched|=IDRV_TOUCHED_LIGHTMAP;
00433         }
00434 }

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

Set the lightmap intensity. (def : White).

Definition at line 411 of file material.cpp.

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

00412 {
00413         if (_ShaderType==CMaterial::LightMap)
00414         {
00415                 if(lmapId>=_LightMaps.size())
00416                         _LightMaps.resize(lmapId+1);
00417                 _LightMaps[lmapId].Factor= factor;
00418 
00419                 _Touched|=IDRV_TOUCHED_LIGHTMAP;
00420         }
00421 }

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

References _LightMapsMulx2.

00461 { _LightMapsMulx2 = val; }

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 _Touched, NLMISC::CRGBA::A, NL3D::IDRV_TOUCHED_LIGHTING, and uint8.

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

00174 {
00175         _Diffuse.A= opa;
00176         _Touched|=IDRV_TOUCHED_LIGHTING;
00177 }

void NL3D::CMaterial::setShader TShader  val  ) 
 

Set the shader for this material. All textures are reseted!!

Definition at line 282 of file material.cpp.

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

Referenced by NL3D::CCloudScape::CCloudScape(), NL3D::CWaterModel::doSimpleRender(), NL3D::CNoise3d::init(), initUnlit(), NL3D::SCloudTexture3D::SCloudTexture3D(), NL3D::SCloudTextureClamp::SCloudTextureClamp(), and NL3D::CWaterModel::setupMaterialNVertexShader().

00283 {
00284         // First, reset all textures.
00285         uint    nTexts= IDRV_MAT_MAXTEXTURES;
00286         // If user color or lightmap, set only the 1st.
00287         if(_ShaderType==LightMap || _ShaderType==UserColor)
00288                 nTexts=1;
00289         // reset all needed
00290         for(uint i=0;i<nTexts;i++)
00291                 setTexture(i ,NULL);
00292 
00293         // If userColor, use TexEnv caps (we got it, so use it :) ).
00294         if(val== CMaterial::UserColor)
00295         {
00296                 // force normal, to setup TexEnvMode correclty. 
00297                 _ShaderType=CMaterial::Normal;
00298 
00299                 // First stage, interpolate Constant and texture with Alpha of texture.
00300                 texEnvOpRGB(0, InterpolateTexture);
00301                 texEnvArg0RGB(0, Texture, SrcColor);
00302                 texEnvArg1RGB(0, Constant, SrcColor);
00303                 // And just use Alpha Diffuse.
00304                 texEnvOpAlpha(0, Replace);
00305                 texEnvArg0Alpha(0, Previous, SrcAlpha);
00306 
00307                 // Second stage, modulate result with diffuse color.
00308                 texEnvOpRGB(1, Modulate);
00309                 texEnvArg0RGB(1, Previous, SrcColor);
00310                 texEnvArg1RGB(1, Diffuse, SrcColor);
00311                 // And just use Alpha Diffuse.
00312                 texEnvOpAlpha(1, Replace);
00313                 texEnvArg0Alpha(1, Previous, SrcAlpha);
00314         }
00315 
00316         _ShaderType= val;
00317         _Touched|=IDRV_TOUCHED_SHADER;
00318 }

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 _Touched, and NL3D::IDRV_TOUCHED_LIGHTING.

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

00186 {
00187         _Shininess= shininess;
00188         _Touched|=IDRV_TOUCHED_LIGHTING;
00189 }

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 _Touched, and NL3D::IDRV_TOUCHED_LIGHTING.

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

00180 {
00181         _Specular= specular;
00182         _Touched|=IDRV_TOUCHED_LIGHTING;
00183 }

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.

Referenced by NL3D::CWaterModel::doSimpleRender(), NL3D::CDRU::drawLine(), NL3D::CDRU::drawQuad(), NL3D::CDRU::drawTriangle(), NL3D::CFontManager::getFontMaterial(), NL3D::CLandscape::init(), NL3D::CMeshBlender::prepareRenderForGlobalAlpha(), NL3D::CMeshBlender::prepareRenderForGlobalAlphaCoarseMesh(), NL3D::CMeshBlender::restoreRender(), NL3D::CMeshBlender::restoreRenderCoarseMesh(), NL3D::CMaterialUser::setSrcBlend(), NL3D::CInstanceMaterialUser::setSrcBlend(), and NL3D::CWaterModel::setupMaterialNVertexShader().

00053 {
00054         _SrcBlend=val;
00055         _Touched|=IDRV_TOUCHED_BLENDFUNC;
00056 }

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

Definition at line 481 of file material.h.

References _StainedGlassWindow.

00481 { _StainedGlassWindow = val; }

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

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

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

00506 {
00507         nlassert(_Flags & IDRV_MAT_TEX_ADDR);
00508         nlassert(stage < IDRV_MAT_MAXTEXTURES);
00509         nlassert(mode < TexAddrCount);
00510         _TexAddrMode[stage] = (uint8) mode;     
00511 }

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

Decompose a user texture matrix, We assume that this is only a matrix for 2d texture.

find the rotation around w

Definition at line 304 of file driver_material_inline.h.

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

Referenced by NL3D::CShadowMapManager::CShadowMapManager().

00305 {
00306         nlassert(stage<IDRV_MAT_MAXTEXTURES);
00307         if (generate)
00308                 _Flags|=(IDRV_MAT_GEN_TEX_0<<stage);
00309         else
00310                 _Flags&=~(IDRV_MAT_GEN_TEX_0<<stage);
00311 }

void NL3D::CMaterial::setTexCoordGenMode uint  stage,
TTexCoordGenMode  mode
 

Decompose a user texture matrix, We assume that this is only a matrix for 2d texture.

find the rotation around w

Definition at line 567 of file material.cpp.

References _TexCoordGenMode, NL3D::IDRV_MAT_MAXTEXTURES, NL3D::IDRV_MAT_TEX_GEN_MASK, NL3D::IDRV_MAT_TEX_GEN_SHIFT, and uint.

Referenced by NL3D::CShadowMapManager::CShadowMapManager().

00568 {
00569         if(stage>=IDRV_MAT_MAXTEXTURES)
00570                 return;
00571         _TexCoordGenMode&= ~ (IDRV_MAT_TEX_GEN_MASK << (stage*IDRV_MAT_TEX_GEN_SHIFT));
00572         _TexCoordGenMode|=   ((mode&IDRV_MAT_TEX_GEN_MASK) << (stage*IDRV_MAT_TEX_GEN_SHIFT));
00573 }

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, nlassert, uint, and uint32.

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

00285 {
00286         nlassert(_ShaderType==CMaterial::Normal);
00287         nlassert(stage<IDRV_MAT_MAXTEXTURES);
00288         _TexEnvs[stage].EnvPacked= packed;
00289 }

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

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

Referenced by NL3D::CLodCharacterManager::CLodCharacterManager(), NL3D::CreateDummyMesh(), NL3D::CShadowMapManager::CShadowMapManager(), NL3D::CCloud::disp(), NL3D::CCloud::dispBill(), NL3D::CDeform2d::doDeform(), NL3D::CWaterModel::doSimpleRender(), NL3D::CDRU::drawBitmap(), NL3D::CInstanceMaterialUser::emptyTexture(), NL3D::CPSMaterial::forceModulateConstantColor(), NL3D::CPSMaterial::forceTexturedMaterialStages(), NL3D::CFontManager::getFontMaterial(), NL3D::CNoise3d::init(), NL3D::SCloudTextureClamp::init(), NL3D::SCloudTexture3D::init(), initUnlit(), NL3D::CVegetableManager::loadTexture(), NL3D::CMotionBlur::performMotionBlur(), NL3D::CVegetableManager::render(), NL3D::CLandscape::render(), NL3D::CShadowMapManager::renderProject(), setShader(), NL3D::CMaterialUser::setTexture(), NL3D::CInstanceMaterialUser::setTextureFileName(), NL3D::CPSMultiTexturedParticle::setupMaterial(), NL3D::CPSFanLight::setupMaterial(), NL3D::CPSMultiTexturedParticle::setupMultiTexEnv(), NL3D::CFlareModel::traverseRender(), NL3D::CShadowMapManager::updateBlurTexture(), NL3D::CPSRibbonLookAt::updateMatAndVbForColor(), NL3D::CPSShockWave::updateMatAndVbForTexture(), NL3D::CPSQuad::updateMatAndVbForTexture(), NL3D::CPSTailDot::updateMaterial(), NL3D::CPSRibbon::updateTexturedMaterial(), and NL3D::CPSRibbon::updateUntexturedMaterial().

00323 {
00324         nlassert(n<IDRV_MAT_MAXTEXTURES);
00325 
00326         // User Color material?
00327         if( _ShaderType== CMaterial::UserColor)
00328         {
00329                 // user color. Only texture 0 can be set.
00330                 nlassert( n==0 );
00331 
00332                 // Affect the 2 first textures.
00333                 _Textures[0]=ptex;
00334                 _Textures[1]=ptex;
00335                 _Touched|=IDRV_TOUCHED_TEX[0];
00336                 _Touched|=IDRV_TOUCHED_TEX[1];
00337         }
00338         else if( _ShaderType== CMaterial::LightMap)
00339         {
00340                 // Only texture 0 can be set.
00341                 nlassert( n==0 );
00342                 _Textures[n]=ptex;
00343                 _Touched|=IDRV_TOUCHED_TEX[n];
00344         }
00345         // Normal material?
00346         else
00347         {
00348                 _Textures[n]=ptex;
00349                 _Touched|=IDRV_TOUCHED_TEX[n];
00350         }
00351 }

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

This part is valid for Normal shaders (nlassert).

See also:
TShader.

Definition at line 321 of file driver_material_inline.h.

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

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

00322 {
00323         nlassert(_ShaderType==CMaterial::UserColor);
00324         // setup stage 0 constant color (don't use texConstantColor() because of assert).
00325         _TexEnvs[0].ConstantColor= userColor;
00326 }

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(), nlassert, and uint.

Referenced by NL3D::CSegRemanence::render(), NL3D::CShadowMapManager::renderProject(), NL3D::CPSConstraintMesh::setupRenderPasses(), NL3D::CPSRibbon::setupTextureMatrix(), NL3D::CPSShockWave::setupUFactor(), and NL3D::CInstanceMaterialUser::setUserTexMat().

00370 {
00371         nlassert(isUserTexMatEnabled(stage));
00372         nlassert(_TexUserMat.get() != NULL);
00373         _TexUserMat->TexMat[stage] = m;
00374 }

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(), NL3D::CPSMaterial::setZBias(), and NL3D::CMaterialUser::setZBias().

00113 {
00114         _ZBias=val;
00115         _Touched|=IDRV_TOUCHED_ZBIAS;
00116 }

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::CShadowMapManager::CShadowMapManager(), NL3D::CCloud::disp(), NL3D::CInstanceGroup::displayDebugClusters(), NL3D::CPSLocatedBindable::displayIcon2d(), NL3D::CDeform2d::doDeform(), NL3D::CDRU::drawBitmap(), NL3D::CDRU::drawLine(), NL3D::CDRU::drawQuad(), NL3D::CDRU::drawTriangle(), NL3D::CPSMaterial::enableZTest(), NL3D::CRenderStringBuffer::flush(), NL3D::CRenderStringBuffer::flushUnProjected(), NL3D::CPSShockWave::init(), NL3D::CPSFanLight::init(), NL3D::CPSDot::init(), NL3D::CNoise3d::init(), initUnlit(), NL3D::CMotionBlur::performMotionBlur(), NL3D::CComputedString::render2D(), NL3D::CComputedString::render3D(), NL3D::SCloudTexture3D::SCloudTexture3D(), NL3D::SCloudTextureClamp::SCloudTextureClamp(), NL3D::CMaterialUser::setZFunc(), NL3D::CPSEmitter::showTool(), and NL3D::CFlareModel::traverseRender().

00100 {
00101         _ZFunction=val;
00102         _Touched|=IDRV_TOUCHED_ZFUNC;
00103 }

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::CPSMaterial::CPSMaterial(), NL3D::CShadowMapManager::CShadowMapManager(), NL3D::CCloud::disp(), NL3D::CPSUtil::displayArrow(), NL3D::CPSUtil::displayBBox(), NL3D::CInstanceGroup::displayDebugClusters(), NL3D::CPSLocatedBindable::displayIcon2d(), NL3D::CWaterModel::doSimpleRender(), NL3D::CRenderStringBuffer::flush(), NL3D::CRenderStringBuffer::flushUnProjected(), NL3D::CNoise3d::init(), initUnlit(), NL3D::CMotionBlur::performMotionBlur(), NL3D::CMeshBlender::prepareRenderForGlobalAlpha(), NL3D::CMeshBlender::prepareRenderForGlobalAlphaCoarseMesh(), NL3D::CVegetableManager::render(), NL3D::CComputedString::render2D(), NL3D::CComputedString::render3D(), NL3D::CMeshBlender::restoreRender(), NL3D::CMeshBlender::restoreRenderCoarseMesh(), NL3D::SCloudTexture3D::SCloudTexture3D(), NL3D::SCloudTextureClamp::SCloudTextureClamp(), NL3D::CPSMaterial::setBlendingMode(), NL3D::CWaterModel::setupMaterialNVertexShader(), NL3D::CMaterialUser::setZWrite(), NL3D::CInstanceMaterialUser::setZWrite(), NL3D::CPSGravity::show(), NL3D::CPSEmitter::showTool(), and NL3D::CFlareModel::traverseRender().

00106 {
00107         if (active)     _Flags|=IDRV_MAT_ZWRITE;
00108         else            _Flags&=~IDRV_MAT_ZWRITE;
00109         _Touched|=IDRV_TOUCHED_ZWRITE;
00110 }

bool NL3D::CMaterial::texAddrEnabled  )  const
 

test whether texture addressing mode are enabled

Definition at line 499 of file material.cpp.

References _Flags, and NL3D::IDRV_MAT_TEX_ADDR.

00500 {
00501         return( _Flags & IDRV_MAT_TEX_ADDR) != 0;
00502 }

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, nlassert, and uint.

Referenced by NL3D::CShadowMapManager::CShadowMapManager(), NL3D::CPSDot::draw(), NL3D::CPSMaterial::forceModulateConstantColor(), NL3D::CLandscape::render(), NL3D::CInstanceMaterialUser::setConstantColor(), NL3D::CPSTailDot::setupGlobalColor(), NL3D::CPSFanLight::setupMaterial(), NL3D::CPSRibbon::setupTexturedGlobalColor(), and NL3D::CPSRibbon::setupUntexturedGlobalColor().

00269 {
00270         nlassert(_ShaderType==CMaterial::Normal);
00271         nlassert(stage<IDRV_MAT_MAXTEXTURES);
00272         _TexEnvs[stage].ConstantColor= color;
00273 }

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

Decompose a user texture matrix, We assume that this is only a matrix for 2d texture.

find the rotation around w

Definition at line 247 of file driver_material_inline.h.

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

Referenced by NL3D::CCloudScape::CCloudScape(), NL3D::CShadowMapManager::CShadowMapManager(), NL3D::CWaterModel::doSimpleRender(), NL3D::CPSMaterial::forceModulateConstantColor(), NL3D::CLandscape::init(), NL3D::CMotionBlur::performMotionBlur(), NL3D::CVegetableManager::render(), NL3D::CLandscape::render(), NL3D::SCloudTexture3D::SCloudTexture3D(), NL3D::SCloudTextureClamp::SCloudTextureClamp(), setShader(), NL3D::CPSConstraintMesh::setupMaterialColor(), NL3D::SetupModulatedStage(), and NL3D::CMaterialUser::texEnvArg0Alpha().

00248 {
00249         nlassert(_ShaderType==CMaterial::Normal);
00250         nlassert(stage<IDRV_MAT_MAXTEXTURES);
00251         nlassert(oper==SrcAlpha || oper==InvSrcAlpha);
00252         _TexEnvs[stage].Env.SrcArg0Alpha= src;
00253         _TexEnvs[stage].Env.OpArg0Alpha= oper;
00254 }

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

Decompose a user texture matrix, We assume that this is only a matrix for 2d texture.

find the rotation around w

Definition at line 221 of file driver_material_inline.h.

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

Referenced by NL3D::CCloudScape::CCloudScape(), NL3D::CShadowMapManager::CShadowMapManager(), NL3D::CCloud::disp(), NL3D::CWaterModel::doSimpleRender(), NL3D::CPSMaterial::forceModulateConstantColor(), NL3D::CFontManager::getFontMaterial(), NL3D::CLandscape::init(), NL3D::CVegetableManager::render(), NL3D::CLandscape::render(), NL3D::SCloudTexture3D::SCloudTexture3D(), setShader(), NL3D::CPSConstraintMesh::setupMaterialColor(), NL3D::SetupModulatedStage(), and NL3D::CMaterialUser::texEnvArg0RGB().

00222 {
00223         nlassert(_ShaderType==CMaterial::Normal);
00224         nlassert(stage<IDRV_MAT_MAXTEXTURES);
00225         _TexEnvs[stage].Env.SrcArg0RGB= src;
00226         _TexEnvs[stage].Env.OpArg0RGB= oper;
00227 }

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

Decompose a user texture matrix, We assume that this is only a matrix for 2d texture.

find the rotation around w

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

Referenced by NL3D::CCloudScape::CCloudScape(), NL3D::CShadowMapManager::CShadowMapManager(), NL3D::CWaterModel::doSimpleRender(), NL3D::CPSMaterial::forceModulateConstantColor(), NL3D::CVegetableManager::render(), NL3D::CLandscape::render(), NL3D::SCloudTextureClamp::SCloudTextureClamp(), NL3D::CPSConstraintMesh::setupMaterialColor(), NL3D::SetupModulatedStage(), and NL3D::CMaterialUser::texEnvArg1Alpha().

00257 {
00258         nlassert(_ShaderType==CMaterial::Normal);
00259         nlassert(stage<IDRV_MAT_MAXTEXTURES);
00260         nlassert(oper==SrcAlpha || oper==InvSrcAlpha);
00261         nlassert(src!=Texture);
00262         _TexEnvs[stage].Env.SrcArg1Alpha= src;
00263         _TexEnvs[stage].Env.OpArg1Alpha= oper;
00264 }

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

Decompose a user texture matrix, We assume that this is only a matrix for 2d texture.

find the rotation around w

Definition at line 229 of file driver_material_inline.h.

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

Referenced by NL3D::CCloudScape::CCloudScape(), NL3D::CShadowMapManager::CShadowMapManager(), NL3D::CWaterModel::doSimpleRender(), NL3D::CPSMaterial::forceModulateConstantColor(), NL3D::CLandscape::init(), NL3D::CVegetableManager::render(), NL3D::CLandscape::render(), NL3D::SCloudTexture3D::SCloudTexture3D(), setShader(), NL3D::CPSConstraintMesh::setupMaterialColor(), NL3D::SetupModulatedStage(), and NL3D::CMaterialUser::texEnvArg1RGB().

00230 {
00231         nlassert(_ShaderType==CMaterial::Normal);
00232         nlassert(stage<IDRV_MAT_MAXTEXTURES);
00233         nlassert(src!=Texture);
00234         _TexEnvs[stage].Env.SrcArg1RGB= src;
00235         _TexEnvs[stage].Env.OpArg1RGB= oper;
00236 }

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

Decompose a user texture matrix, We assume that this is only a matrix for 2d texture.

find the rotation around w

Definition at line 240 of file driver_material_inline.h.

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

Referenced by NL3D::CCloudScape::CCloudScape(), NL3D::CShadowMapManager::CShadowMapManager(), NL3D::CWaterModel::doSimpleRender(), NL3D::CPSMaterial::forceModulateConstantColor(), NL3D::CLandscape::init(), NL3D::CMotionBlur::performMotionBlur(), NL3D::CVegetableManager::render(), NL3D::CLandscape::render(), NL3D::SCloudTexture3D::SCloudTexture3D(), NL3D::SCloudTextureClamp::SCloudTextureClamp(), setShader(), NL3D::CPSConstraintMesh::setupMaterialColor(), NL3D::SetupModulatedStage(), and NL3D::CMaterialUser::texEnvOpAlpha().

00241 {
00242         nlassert(_ShaderType==CMaterial::Normal);
00243         nlassert(stage<IDRV_MAT_MAXTEXTURES);
00244         _TexEnvs[stage].Env.OpAlpha= ope;
00245 }

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

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

Referenced by NL3D::CCloudScape::CCloudScape(), NL3D::CShadowMapManager::CShadowMapManager(), NL3D::CCloud::disp(), NL3D::CWaterModel::doSimpleRender(), NL3D::CPSMaterial::forceModulateConstantColor(), NL3D::CFontManager::getFontMaterial(), NL3D::CLandscape::init(), NL3D::CMotionBlur::performMotionBlur(), NL3D::CVegetableManager::render(), NL3D::CLandscape::render(), NL3D::SCloudTexture3D::SCloudTexture3D(), setShader(), NL3D::CPSMultiTexturedParticle::setupMaterial(), NL3D::CPSConstraintMesh::setupMaterialColor(), NL3D::SetupModulatedStage(), NL3D::CPSMultiTexturedParticle::setupMultiTexEnv(), and NL3D::CMaterialUser::texEnvOpRGB().

00215 {
00216         nlassert(_ShaderType==CMaterial::Normal);
00217         nlassert(stage<IDRV_MAT_MAXTEXTURES);
00218         _TexEnvs[stage].Env.OpRGB= ope;
00219 }

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

Definition at line 36 of file driver_material_inline.h.

References NL3D::IDRV_MAT_MAXTEXTURES, nlassert, and uint8.

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

00037 {
00038         nlassert(n<IDRV_MAT_MAXTEXTURES);
00039         if (_Textures[n])
00040         {
00041                 return(true);
00042         }
00043         return(false);
00044 }


Friends And Related Function Documentation

friend struct CPtrInfo [friend, inherited]
 

Definition at line 67 of file smart_ptr.h.


Field Documentation

float NL3D::CMaterial::_AlphaTestThreshold [private]
 

Definition at line 576 of file material.h.

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

CRGBA NL3D::CMaterial::_Ambient [private]
 

Definition at line 574 of file material.h.

Referenced by operator=().

CRGBA NL3D::CMaterial::_Color [private]
 

Definition at line 573 of file material.h.

Referenced by operator=().

CRGBA NL3D::CMaterial::_Diffuse [private]
 

Definition at line 574 of file material.h.

Referenced by operator=().

TBlend NL3D::CMaterial::_DstBlend [private]
 

Definition at line 570 of file material.h.

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

CRGBA NL3D::CMaterial::_Emissive [private]
 

Definition at line 574 of file material.h.

Referenced by operator=().

uint32 NL3D::CMaterial::_Flags [private]
 

Definition at line 569 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 610 of file material.h.

Referenced by NL3D::CDriverGL::computeLightMapInfos(), flushTextures(), getLightMap(), operator=(), serial(), setLightMap(), setLightMapColor(), setLightMapFactor(), NL3D::CDriverGL::setupLightMapPass(), and NL3D::CDriverGL::setupMaterial().

bool NL3D::CMaterial::_LightMapsMulx2
 

Definition at line 611 of file material.h.

Referenced by CMaterial(), NL3D::CDriverGL::endLightMapMultiPass(), operator=(), serial(), setLightMapMulx2(), and NL3D::CDriverGL::setupLightMapPass().

TShader NL3D::CMaterial::_ShaderType [private]
 

Definition at line 568 of file material.h.

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

float NL3D::CMaterial::_Shininess [private]
 

Definition at line 575 of file material.h.

Referenced by operator=().

CRGBA NL3D::CMaterial::_Specular [private]
 

Definition at line 574 of file material.h.

Referenced by operator=().

TBlend NL3D::CMaterial::_SrcBlend [private]
 

Definition at line 570 of file material.h.

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

bool NL3D::CMaterial::_StainedGlassWindow [private]
 

Definition at line 578 of file material.h.

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

uint8 NL3D::CMaterial::_TexAddrMode[IDRV_MAT_MAXTEXTURES]
 

Definition at line 590 of file material.h.

Referenced by enableTexAddrMode(), getTexAddressingMode(), operator=(), serial(), setTexAddressingMode(), and NL3D::CDriverGL::setupMaterial().

uint16 NL3D::CMaterial::_TexCoordGenMode [private]
 

Definition at line 580 of file material.h.

Referenced by CMaterial(), getTexCoordGenMode(), and setTexCoordGenMode().

CTexEnv NL3D::CMaterial::_TexEnvs[IDRV_MAT_MAXTEXTURES]
 

Definition at line 591 of file material.h.

Referenced by getTexConstantColor(), getTexEnvMode(), getUserColor(), operator=(), serial(), setTexEnvMode(), NL3D::CDriverGL::setTextureEnvFunction(), setUserColor(), texConstantColor(), texEnvArg0Alpha(), texEnvArg0RGB(), texEnvArg1Alpha(), texEnvArg1RGB(), texEnvOpAlpha(), and texEnvOpRGB().

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

Definition at line 589 of file material.h.

Referenced by operator=(), NL3D::CDriverGL::setupMaterial(), and NL3D::CDriverGL::setupWaterPassNV20().

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

Definition at line 585 of file material.h.

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

uint32 NL3D::CMaterial::_Touched [private]
 

Definition at line 577 of file material.h.

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

float NL3D::CMaterial::_ZBias [private]
 

Definition at line 572 of file material.h.

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

ZFunc NL3D::CMaterial::_ZFunction [private]
 

Definition at line 571 of file material.h.

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

sint NLMISC::CRefCount::crefs [mutable, inherited]
 

Definition at line 79 of file smart_ptr.h.

Referenced by NLMISC::CRefCount::CRefCount(), NLMISC::CRefCount::getRefCount(), and NLMISC::CRefCount::~CRefCount().

CRefCount::CPtrInfo NLMISC::CRefCount::NullPtrInfo [static, inherited]
 

Referenced by NLMISC::CRefCount::CRefCount().

CPtrInfo* NLMISC::CRefCount::pinfo [mutable, inherited]
 

Definition at line 80 of file smart_ptr.h.

Referenced by NLMISC::CRefCount::CRefCount(), and NLMISC::CRefCount::~CRefCount().

CRefPtr<IShader> NL3D::CMaterial::pShader
 

Definition at line 592 of file material.h.

Referenced by NL3D::CDriverGL::setupMaterial(), and ~CMaterial().


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 06:50:28 2004 for NeL by doxygen 1.3.6