#include <material.h>
Inheritance diagram for NL3D::CMaterial:
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< CLightMap > | TTexturePtrs |
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 sint & | getRefCount () 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 () | |
CMaterial & | operator= (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::CMatrix & | getUserTexMat (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. | |
ITexture * | getLightMap (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. | |
ITexture * | getTexture (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< IShader > | pShader |
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 |
|
Definition at line 609 of file material.h. |
|
Blend enums. see setSrcBlend()/setDstBlend()/setBlendFunc(). blendConstant* enums are only valid if dirver->supportBlendConstantColor().
Definition at line 129 of file material.h. Referenced by getDstBlend(), and getSrcBlend().
00129 { one=0, zero, srcalpha, invsrcalpha, srccolor, invsrccolor, 00130 blendConstantColor, blendConstantInvColor, blendConstantAlpha, blendConstantInvAlpha, blendCount }; |
|
Normal shader:
Texture of stage 0 is added to the multiplication of Texture Alpha of stage 0 and Texture of stage 1
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
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}; |
|
Definition at line 213 of file material.h. Referenced by getTexAddressingMode().
00213 { 00214 TextureOff = 0 /* no texture */, FetchTexture, PassThrough, CullFragment, 00215 OffsetTexture, OffsetTextureScale, 00216 DependentARTexture, DependentGBTexture, 00217 DP3, DP3Texture2D, 00218 DP3CubeMap, DP3ReflectCubeMap, DP3ConstEyeReflectCubeMap, 00219 DP3DiffuseCubeMap, 00220 DP3DepthReplace, 00221 TexAddrCount 00222 }; |
|
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...)
Definition at line 231 of file material.h. Referenced by getTexCoordGenMode().
|
|
Operand for the argument. For Alpha arguments, only SrcAlpha and InvSrcAlpha are Valid!! Definition at line 204 of file material.h.
00204 { SrcColor=0, InvSrcColor, SrcAlpha, InvSrcAlpha }; |
|
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.
Definition at line 186 of file material.h.
00186 { Replace=0, Modulate, Add, AddSigned, 00187 InterpolateTexture, InterpolatePrevious, InterpolateDiffuse, InterpolateConstant, EMBM }; |
|
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. Definition at line 195 of file material.h.
|
|
Definition at line 123 of file material.h. Referenced by getZFunc().
00123 { always=0,never,equal,notequal,less,lessequal,greater,greaterequal, zfuncCount }; |
|
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 } |
|
see operator=.
Definition at line 242 of file material.h. References _Flags, _Touched, and operator=().
|
|
dtor.
Definition at line 131 of file material.cpp. References NLMISC::CRefPtr< IShader >::kill(), and pShader.
|
|
Definition at line 616 of file material.h. References _Touched, and uint32. Referenced by NL3D::CDriverGL::setupMaterial().
00616 { _Touched&=~flag; } |
|
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 } |
|
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 } |
|
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 } |
|
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 } |
|
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; } |
|
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; } |
|
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;} |
|
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; } |
|
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); } |
|
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;} |
|
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; } |
|
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); } |
|
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;} |
|
Definition at line 614 of file material.h. References _Flags, and uint32. Referenced by NL3D::CDriverGL::setupMaterial(), and NL3D::CDriverGL::setupUserTextureMatrix().
00614 {return _Flags;} |
|
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 } |
|
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 } |
|
Definition at line 381 of file material.h. References NLMISC::CRGBA::A, and uint8. Referenced by NL3D::CInstanceMaterialUser::getOpacity(), and NL3D::CMeshBlender::prepareRenderForGlobalAlpha().
|
|
Definition at line 70 of file smart_ptr.h. References NLMISC::CRefCount::crefs, and sint.
00071 { 00072 return crefs; 00073 } |
|
|
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;} |
|
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;} |
|
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); } |
|
Definition at line 480 of file material.h. References _StainedGlassWindow.
00480 { return _StainedGlassWindow; } |
|
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 } |
|
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 } |
|
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 } |
|
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().
00420 {return (TTexCoordGenMode)((_TexCoordGenMode >> (stage*IDRV_MAT_TEX_GEN_SHIFT))&IDRV_MAT_TEX_GEN_MASK);} |
|
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().
|
|
|
Definition at line 615 of file material.h. References _Touched, and uint32. Referenced by NL3D::CDriverGL::setupMaterial().
00615 { return(_Touched); } |
|
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 } |
|
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 } |
|
Definition at line 336 of file material.h. References _ZBias. Referenced by NL3D::CMaterialUser::getZBias(), and NL3D::CDriverGL::setupMaterial().
00336 { return(_ZBias); } |
|
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); } |
|
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; } |
|
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 } |
|
|
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;} |
|
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;} |
|
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 } |
|
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 } |
|
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 } |
|
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 } |
|
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 } |
|
change the threshold against alpha is tested. Default is 0.5f.
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 } |
|
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 } |
|
|
|
|
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().
|
|
|
|
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 } |
|
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 } |
|
|
Set the ith lightmap. undef results if holes in lightmap array. This part is valid for LightMap shaders (nlassert).
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 } |
|
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 } |
|
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 } |
|
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; } |
|
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 } |
|
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 } |
|
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 } |
|
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 } |
|
|
Definition at line 481 of file material.h. References _StainedGlassWindow.
00481 { _StainedGlassWindow = val; } |
|
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 } |
|
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 } |
|
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 } |
|
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().
|
|
|
This part is valid for Normal shaders (nlassert).
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 } |
|
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 } |
|
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 } |
|
|
|
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 } |
|
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 } |
|
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().
|
|
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().
|
|
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().
|
|
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().
|
|
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().
|
|
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:
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().
|
|
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().
|
|
Definition at line 67 of file smart_ptr.h. |
|
Definition at line 576 of file material.h. Referenced by CMaterial(), getAlphaTestThreshold(), operator=(), serial(), and setAlphaTestThreshold(). |
|
Definition at line 574 of file material.h. Referenced by operator=(). |
|
Definition at line 573 of file material.h. Referenced by operator=(). |
|
Definition at line 574 of file material.h. Referenced by operator=(). |
|
Definition at line 570 of file material.h. Referenced by CMaterial(), getDstBlend(), operator=(), serial(), setBlendFunc(), and setDstBlend(). |
|
Definition at line 574 of file material.h. Referenced by operator=(). |
|
|
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(). |
|
Definition at line 611 of file material.h. Referenced by CMaterial(), NL3D::CDriverGL::endLightMapMultiPass(), operator=(), serial(), setLightMapMulx2(), and NL3D::CDriverGL::setupLightMapPass(). |
|
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(). |
|
Definition at line 575 of file material.h. Referenced by operator=(). |
|
Definition at line 574 of file material.h. Referenced by operator=(). |
|
Definition at line 570 of file material.h. Referenced by CMaterial(), getSrcBlend(), operator=(), serial(), setBlendFunc(), and setSrcBlend(). |
|
Definition at line 578 of file material.h. Referenced by CMaterial(), getStainedGlassWindow(), and setStainedGlassWindow(). |
|
Definition at line 590 of file material.h. Referenced by enableTexAddrMode(), getTexAddressingMode(), operator=(), serial(), setTexAddressingMode(), and NL3D::CDriverGL::setupMaterial(). |
|
Definition at line 580 of file material.h. Referenced by CMaterial(), getTexCoordGenMode(), and setTexCoordGenMode(). |
|
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(). |
|
Definition at line 589 of file material.h. Referenced by operator=(), NL3D::CDriverGL::setupMaterial(), and NL3D::CDriverGL::setupWaterPassNV20(). |
|
Definition at line 585 of file material.h. Referenced by decompUserTexMat(), enableUserTexMat(), getUserTexMat(), operator=(), serial(), and setUserTexMat(). |
|
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(). |
|
Definition at line 572 of file material.h. Referenced by CMaterial(), getZBias(), operator=(), serial(), and setZBias(). |
|
Definition at line 571 of file material.h. Referenced by CMaterial(), getZFunc(), operator=(), serial(), and setZFunc(). |
|
Definition at line 79 of file smart_ptr.h. Referenced by NLMISC::CRefCount::CRefCount(), NLMISC::CRefCount::getRefCount(), and NLMISC::CRefCount::~CRefCount(). |
|
Referenced by NLMISC::CRefCount::CRefCount(). |
|
Definition at line 80 of file smart_ptr.h. Referenced by NLMISC::CRefCount::CRefCount(), and NLMISC::CRefCount::~CRefCount(). |
|
Definition at line 592 of file material.h. Referenced by NL3D::CDriverGL::setupMaterial(), and ~CMaterial(). |