NL3D::CMaterialUser Class Reference

#include <material_user.h>

Inheritance diagram for NL3D::CMaterialUser:

NL3D::UMaterial

Detailed Description

UMaterial implementation.
Author:
Lionel Berenguier

Nevrax France

Date:
2001

Definition at line 50 of file material_user.h.

Public Types

enum  TBlend {
  one = 0, zero, srcalpha, invsrcalpha,
  srccolor, invsrccolor, blendCount
}
enum  ZFunc {
  always = 0, never, equal, notequal,
  less, lessequal, greater, greaterequal,
  zfuncCount
}
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 }
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

CMaterialgetMaterial ()
Object
 CMaterialUser ()
virtual ~CMaterialUser ()
Blending.
virtual bool getBlend () const
virtual TBlend getDstBlend (void) const
virtual TBlend getSrcBlend (void) const
virtual void setBlend (bool active)
virtual void setBlendFunc (TBlend src, TBlend dst)
virtual void setDstBlend (TBlend val)
virtual void setSrcBlend (TBlend val)
Color/Lighting..
virtual CRGBA getColor (void) const
virtual void setColor (CRGBA rgba)
 The Color is used only if lighting is disabled. Also, color is replaced by per vertex color (if any).

Culling
virtual bool getDoubleSided () const
virtual void setDoubleSided (bool doubleSided=true)
ZBuffer.
virtual float getZBias (void) const
virtual ZFunc getZFunc (void) const
virtual bool getZWrite (void) const
virtual void setZBias (float val)
virtual void setZFunc (ZFunc val)
virtual void setZWrite (bool active)
Misc
virtual void initUnlit ()
Texture.
virtual void selectTextureSet (uint id)
 select from a texture set for this material (if available)

virtual void setTexture (uint stage, UTexture *ptex)
 select from a texture set for this material (if available)

virtual void setTexture (UTexture *ptex)
 select from a texture set for this material (if available)

virtual bool texturePresent (uint stage)
 select from a texture set for this material (if available)

virtual bool texturePresent ()
 select from a texture set for this material (if available)

Texture environnement.
virtual void texEnvArg0Alpha (uint stage, TTexSource src, TTexOperand oper)
virtual void texEnvArg0RGB (uint stage, TTexSource src, TTexOperand oper)
virtual void texEnvArg1Alpha (uint stage, TTexSource src, TTexOperand oper)
virtual void texEnvArg1RGB (uint stage, TTexSource src, TTexOperand oper)
virtual void texEnvOpAlpha (uint stage, TTexOperator ope)
virtual void texEnvOpRGB (uint stage, TTexOperator ope)

Protected Attributes

CMaterial _Material

Friends

class CDriverUser


Member Enumeration Documentation

enum NL3D::UMaterial::TBlend [inherited]
 

Enumeration values:
one 
zero 
srcalpha 
invsrcalpha 
srccolor 
invsrccolor 
blendCount 

Definition at line 61 of file u_material.h.

enum NL3D::UMaterial::TTexOperand [inherited]
 

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 94 of file u_material.h.

enum NL3D::UMaterial::TTexOperator [inherited]
 

Environements operators: Replace: out= arg0 Modulate: out= arg0 * arg1 Add: out= arg0 + arg1 AddSigned: out= arg0 + arg1 -0.5 Interpolate*: out= arg0*As + arg1*(1-As), where As is taken from the SrcAlpha of Texture/Previous/Diffuse/Constant, respectively if operator is InterpolateTexture/InterpolatePrevious/InterpolateDiffuse/InterpolateConstant. EMBM : apply to both color and alpha : the current texture, whose format is DSDT, is used to offset the texture in the next stage. NB : for EMBM and InterpolateConstant, this must be supported by driver.

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

Definition at line 76 of file u_material.h.

enum NL3D::UMaterial::TTexSource [inherited]
 

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 85 of file u_material.h.

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

enum NL3D::UMaterial::ZFunc [inherited]
 

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

Definition at line 60 of file u_material.h.


Constructor & Destructor Documentation

NL3D::CMaterialUser::CMaterialUser  )  [inline]
 

Definition at line 60 of file material_user.h.

References NL3D::CMaterial::initUnlit(), NL3D_MEM_MATERIAL, nlassert, and uint.

00061         {
00062                 NL3D_MEM_MATERIAL
00063                 _Material.initUnlit();
00064                 // Enum assertion. User have access only to 6 first blend modes. Other are internals.
00065                 nlassert((uint)UMaterial::blendCount==(uint)CMaterial::blendConstantColor);
00066                 // Enum assertion.
00067                 nlassert((uint)UMaterial::zfuncCount==(uint)CMaterial::zfuncCount);
00068         }

virtual NL3D::CMaterialUser::~CMaterialUser  )  [inline, virtual]
 

Definition at line 69 of file material_user.h.

References NL3D_MEM_MATERIAL.

00070         {
00071                 NL3D_MEM_MATERIAL
00072         }


Member Function Documentation

virtual bool NL3D::CMaterialUser::getBlend  )  const [inline, virtual]
 

Implements NL3D::UMaterial.

Definition at line 140 of file material_user.h.

References NL3D::CMaterial::getBlend(), and NL3D_MEM_MATERIAL.

00141         {
00142                 NL3D_MEM_MATERIAL
00143                 return _Material.getBlend();
00144         }

virtual CRGBA NL3D::CMaterialUser::getColor void   )  const [inline, virtual]
 

Implements NL3D::UMaterial.

Definition at line 242 of file material_user.h.

References NL3D::CMaterial::getColor(), and NL3D_MEM_MATERIAL.

00243         {
00244                 NL3D_MEM_MATERIAL
00245                 return _Material.getColor();
00246         }

virtual bool NL3D::CMaterialUser::getDoubleSided  )  const [inline, virtual]
 

Implements NL3D::UMaterial.

Definition at line 256 of file material_user.h.

References NL3D::CMaterial::getDoubleSided(), and NL3D_MEM_MATERIAL.

00257                 {
00258                         NL3D_MEM_MATERIAL
00259                         return _Material.getDoubleSided();
00260                 }

virtual TBlend NL3D::CMaterialUser::getDstBlend void   )  const [inline, virtual]
 

Implements NL3D::UMaterial.

Definition at line 150 of file material_user.h.

References NL3D::CMaterial::getDstBlend(), NL3D_MEM_MATERIAL, and uint32.

00151         {
00152                 NL3D_MEM_MATERIAL
00153                 return (UMaterial::TBlend)(uint32)_Material.getDstBlend();
00154         }

CMaterial& NL3D::CMaterialUser::getMaterial  )  [inline]
 

Definition at line 281 of file material_user.h.

References NL3D_MEM_MATERIAL.

00282         {
00283                 NL3D_MEM_MATERIAL
00284                 return _Material;
00285         }

virtual TBlend NL3D::CMaterialUser::getSrcBlend void   )  const [inline, virtual]
 

Implements NL3D::UMaterial.

Definition at line 145 of file material_user.h.

References NL3D::CMaterial::getSrcBlend(), NL3D_MEM_MATERIAL, and uint32.

00146         {
00147                 NL3D_MEM_MATERIAL
00148                 return (UMaterial::TBlend)(uint32)_Material.getSrcBlend();
00149         }

virtual float NL3D::CMaterialUser::getZBias void   )  const [inline, virtual]
 

Implements NL3D::UMaterial.

Definition at line 225 of file material_user.h.

References NL3D::CMaterial::getZBias(), and NL3D_MEM_MATERIAL.

00226         {
00227                 NL3D_MEM_MATERIAL
00228                 return _Material.getZBias();
00229         }

virtual ZFunc NL3D::CMaterialUser::getZFunc void   )  const [inline, virtual]
 

Implements NL3D::UMaterial.

Definition at line 215 of file material_user.h.

References NL3D::CMaterial::getZFunc(), NL3D_MEM_MATERIAL, and uint32.

00216         {
00217                 NL3D_MEM_MATERIAL
00218                 return (UMaterial::ZFunc)(uint32)_Material.getZFunc();
00219         }

virtual bool NL3D::CMaterialUser::getZWrite void   )  const [inline, virtual]
 

Implements NL3D::UMaterial.

Definition at line 220 of file material_user.h.

References NL3D::CMaterial::getZWrite(), and NL3D_MEM_MATERIAL.

00221         {
00222                 NL3D_MEM_MATERIAL
00223                 return _Material.getZWrite();
00224         }

virtual void NL3D::CMaterialUser::initUnlit  )  [inline, virtual]
 

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

Implements NL3D::UMaterial.

Definition at line 269 of file material_user.h.

References NL3D::CMaterial::initUnlit(), and NL3D_MEM_MATERIAL.

Referenced by NL3D::CDriverUser::release(), and NL3D::CDriverUser::setDisplay().

00270         {
00271                 NL3D_MEM_MATERIAL
00272                 _Material.initUnlit();
00273         }

virtual void NL3D::CMaterialUser::selectTextureSet uint  id  )  [inline, virtual]
 

select from a texture set for this material (if available)

Implements NL3D::UMaterial.

Definition at line 108 of file material_user.h.

References NL3D_MEM_MATERIAL, NL3D::CMaterial::selectTextureSet(), and uint.

00109         {
00110                 NL3D_MEM_MATERIAL
00111                 _Material.selectTextureSet(id);
00112         }

virtual void NL3D::CMaterialUser::setBlend bool  active  )  [inline, virtual]
 

Implements NL3D::UMaterial.

Definition at line 119 of file material_user.h.

References NL3D_MEM_MATERIAL, and NL3D::CMaterial::setBlend().

Referenced by NL3D::CDriverUser::drawBitmap(), NL3D::CDriverUser::drawLine(), NL3D::CDriverUser::drawQuad(), and NL3D::CDriverUser::drawTriangle().

00120         {
00121                 NL3D_MEM_MATERIAL
00122                 _Material.setBlend(active);
00123         }

virtual void NL3D::CMaterialUser::setBlendFunc TBlend  src,
TBlend  dst
[inline, virtual]
 

Implements NL3D::UMaterial.

Definition at line 124 of file material_user.h.

References NL3D_MEM_MATERIAL, NL3D::CMaterial::setBlendFunc(), src, and uint32.

00125         {
00126                 NL3D_MEM_MATERIAL
00127                 _Material.setBlendFunc((CMaterial::TBlend)(uint32)src, (CMaterial::TBlend)(uint32)dst);
00128         }

virtual void NL3D::CMaterialUser::setColor CRGBA  rgba  )  [inline, virtual]
 

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

Implements NL3D::UMaterial.

Definition at line 236 of file material_user.h.

References NL3D_MEM_MATERIAL, and NL3D::CMaterial::setColor().

Referenced by NL3D::CDriverUser::drawBitmap(), NL3D::CDriverUser::drawLine(), NL3D::CDriverUser::drawQuad(), and NL3D::CDriverUser::drawTriangle().

00237         {
00238                 NL3D_MEM_MATERIAL
00239                 _Material.setColor(rgba);
00240         }

virtual void NL3D::CMaterialUser::setDoubleSided bool  doubleSided = true  )  [inline, virtual]
 

Implements NL3D::UMaterial.

Definition at line 251 of file material_user.h.

References NL3D_MEM_MATERIAL, and NL3D::CMaterial::setDoubleSided().

00252                 {
00253                         NL3D_MEM_MATERIAL
00254                         _Material.setDoubleSided(doubleSided);
00255                 }

virtual void NL3D::CMaterialUser::setDstBlend TBlend  val  )  [inline, virtual]
 

Implements NL3D::UMaterial.

Definition at line 134 of file material_user.h.

References NL3D_MEM_MATERIAL, NL3D::CMaterial::setDstBlend(), and uint32.

00135         {
00136                 NL3D_MEM_MATERIAL
00137                 _Material.setDstBlend((CMaterial::TBlend)(uint32)val);
00138         }

virtual void NL3D::CMaterialUser::setSrcBlend TBlend  val  )  [inline, virtual]
 

Implements NL3D::UMaterial.

Definition at line 129 of file material_user.h.

References NL3D_MEM_MATERIAL, NL3D::CMaterial::setSrcBlend(), and uint32.

00130         {
00131                 NL3D_MEM_MATERIAL
00132                 _Material.setSrcBlend((CMaterial::TBlend)(uint32)val);
00133         }

virtual void NL3D::CMaterialUser::setTexture uint  stage,
UTexture ptex
[inline, virtual]
 

select from a texture set for this material (if available)

Implements NL3D::UMaterial.

Definition at line 82 of file material_user.h.

References NL3D_MEM_MATERIAL, NL3D::CMaterial::setTexture(), and uint.

00083         {
00084                 NL3D_MEM_MATERIAL
00085                 CTextureUser    *text= dynamic_cast<CTextureUser*>(ptex);
00086                 if (text != NULL)
00087                 {
00088                         _Material.setTexture (stage, text->getITexture());
00089                 }
00090                 else
00091                 {
00092                         _Material.setTexture (stage, NULL);
00093                 }
00094                 // NB: _Material smartpoint to this ITexture. But this is correct because so does CTextureUser.
00095         }

virtual void NL3D::CMaterialUser::setTexture UTexture ptex  )  [inline, virtual]
 

select from a texture set for this material (if available)

Implements NL3D::UMaterial.

Definition at line 77 of file material_user.h.

Referenced by NL3D::CDriverUser::drawBitmap().

00078         {
00079                 setTexture (0, ptex);
00080         }

virtual void NL3D::CMaterialUser::setZBias float  val  )  [inline, virtual]
 

Implements NL3D::UMaterial.

Definition at line 210 of file material_user.h.

References NL3D::CMaterial::setZBias().

00211         {
00212                 _Material.setZBias(val);
00213         }

virtual void NL3D::CMaterialUser::setZFunc ZFunc  val  )  [inline, virtual]
 

Implements NL3D::UMaterial.

Definition at line 200 of file material_user.h.

References NL3D_MEM_MATERIAL, NL3D::CMaterial::setZFunc(), and uint32.

Referenced by NL3D::CDriverUser::setDisplay().

00201         {
00202                 NL3D_MEM_MATERIAL
00203                 _Material.setZFunc((CMaterial::ZFunc)(uint32) val);
00204         }

virtual void NL3D::CMaterialUser::setZWrite bool  active  )  [inline, virtual]
 

Implements NL3D::UMaterial.

Definition at line 205 of file material_user.h.

References NL3D_MEM_MATERIAL, and NL3D::CMaterial::setZWrite().

Referenced by NL3D::CDriverUser::setDisplay().

00206         {
00207                 NL3D_MEM_MATERIAL
00208                 _Material.setZWrite(active);
00209         }

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

Implements NL3D::UMaterial.

Definition at line 184 of file material_user.h.

References NL3D_MEM_MATERIAL, src, NL3D::CMaterial::texEnvArg0Alpha(), uint, and uint32.

00185         {
00186                 NL3D_MEM_MATERIAL
00187                 _Material.texEnvArg0Alpha (stage, (CMaterial::TTexSource)(uint32)src, (CMaterial::TTexOperand)(uint32)oper);
00188         }

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

Implements NL3D::UMaterial.

Definition at line 166 of file material_user.h.

References NL3D_MEM_MATERIAL, src, NL3D::CMaterial::texEnvArg0RGB(), uint, and uint32.

00167         {
00168                 NL3D_MEM_MATERIAL
00169                 _Material.texEnvArg0RGB (stage, (CMaterial::TTexSource)(uint32)src, (CMaterial::TTexOperand)(uint32)oper);
00170         }

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

Implements NL3D::UMaterial.

Definition at line 190 of file material_user.h.

References NL3D_MEM_MATERIAL, src, NL3D::CMaterial::texEnvArg1Alpha(), uint, and uint32.

00191         {
00192                 NL3D_MEM_MATERIAL
00193                 _Material.texEnvArg1Alpha (stage, (CMaterial::TTexSource)(uint32)src, (CMaterial::TTexOperand)(uint32)oper);
00194         }

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

Implements NL3D::UMaterial.

Definition at line 172 of file material_user.h.

References NL3D_MEM_MATERIAL, src, NL3D::CMaterial::texEnvArg1RGB(), uint, and uint32.

00173         {
00174                 NL3D_MEM_MATERIAL
00175                 _Material.texEnvArg1RGB (stage, (CMaterial::TTexSource)(uint32)src, (CMaterial::TTexOperand)(uint32)oper);
00176         }

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

Implements NL3D::UMaterial.

Definition at line 178 of file material_user.h.

References NL3D_MEM_MATERIAL, NL3D::CMaterial::texEnvOpAlpha(), uint, and uint32.

00179         {
00180                 NL3D_MEM_MATERIAL
00181                 _Material.texEnvOpAlpha (stage, (CMaterial::TTexOperator)(uint32)ope);
00182         }

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

Implements NL3D::UMaterial.

Definition at line 160 of file material_user.h.

References NL3D_MEM_MATERIAL, NL3D::CMaterial::texEnvOpRGB(), uint, and uint32.

00161         {
00162                 NL3D_MEM_MATERIAL
00163                 _Material.texEnvOpRGB(stage, (CMaterial::TTexOperator)(uint32)ope);
00164         }

virtual bool NL3D::CMaterialUser::texturePresent uint  stage  )  [inline, virtual]
 

select from a texture set for this material (if available)

Implements NL3D::UMaterial.

Definition at line 102 of file material_user.h.

References NL3D_MEM_MATERIAL, NL3D::CMaterial::texturePresent(), and uint.

00103         {
00104                 NL3D_MEM_MATERIAL
00105                 return _Material.texturePresent (stage);
00106         }

virtual bool NL3D::CMaterialUser::texturePresent  )  [inline, virtual]
 

select from a texture set for this material (if available)

Implements NL3D::UMaterial.

Definition at line 97 of file material_user.h.

00098         {
00099                 return texturePresent (0);
00100         }


Friends And Related Function Documentation

friend class CDriverUser [friend]
 

Definition at line 54 of file material_user.h.


Field Documentation

CMaterial NL3D::CMaterialUser::_Material [protected]
 

Definition at line 53 of file material_user.h.


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