|
|
|
|
Documentation |
|
Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages Search
NL3D::CMaterial Class ReferenceA material represent ALL the states relatives to the aspect of a primitive.
More...
#include <material.h>
Inheritance diagram for NL3D::CMaterial
[legend]Collaboration diagram for NL3D::CMaterial:
[legend]List of all members.
Public Types |
enum | ZFunc {
always = 0,
never,
equal,
notequal,
less,
lessequal,
greater,
greaterequal,
zfuncCount
} |
enum | TBlend {
one = 0,
zero,
srcalpha,
invsrcalpha,
srccolor,
invsrccolor,
blendCount
} |
enum | TShader {
Normal = 0,
Bump,
UserColor,
shaderCount
} |
| Normal shader: use simple multitexturing. More...
|
enum | TTexOperator {
Replace = 0,
Modulate,
Add,
AddSigned,
InterpolateTexture,
InterpolatePrevious,
InterpolateDiffuse,
InterpolateConstant
} |
| Environements operators: Replace: out= arg0 Modulate: out= arg0 * arg1 Add: out= arg0 + arg1 AddSigned: out= arg0 + arg1 -0.5 Interpolate*: out= arg0*As + arg1*(1-As), where As is taken from the SrcAlpha of Texture/Previous/Diffuse/Constant, respectively if operator is InterpolateTexture/InterpolatePrevious/InterpolateDiffuse/InterpolateConstant. More...
|
enum | TTexSource {
Previous,
Diffuse,
Constant
} |
| Source argument. More...
|
enum | TTexOperand {
SrcColor = 0,
InvSrcColor,
SrcAlpha,
InvSrcAlpha
} |
| Operand for the argument. More...
|
Public Methods |
| CMaterial () |
| ctor. More...
|
| CMaterial (const CMaterial &mat) |
| see operator=. More...
|
| ~CMaterial () |
| dtor. More...
|
CMaterial& | operator= (const CMaterial &mat) |
| Do not copy DrvInfos, copy all infos and set IDRV_TOUCHED_ALL. More...
|
void | setShader (TShader val) |
| Set the shader for this material. More...
|
TShader | getShader () const |
| get the current material shadertype. More...
|
void | setTexture (uint8 stage, ITexture* ptex) |
| set a texture for a special stage. More...
|
ITexture* | getTexture (uint8 stage) const |
bool | texturePresent (uint8 stage) const |
void | setBlend (bool active) |
void | setBlendFunc (TBlend src, TBlend dst) |
void | setSrcBlend (TBlend val) |
void | setDstBlend (TBlend val) |
bool | getBlend () const |
TBlend | getSrcBlend (void) const |
TBlend | getDstBlend (void) const |
void | setDoubleSided (bool active) |
bool | detDoubleSided () const |
void | setZFunc (ZFunc val) |
void | setZWrite (bool active) |
void | setZBias (float val) |
ZFunc | getZFunc (void) const |
bool | getZWrite (void) const |
float | getZBias (void) const |
void | setColor (CRGBA rgba) |
| The Color is used only if lighting is disabled. Also, color is replaced by per vertex color (if any). More...
|
void | setLighting ( bool active, bool DefMat=true, CRGBA emissive=CRGBA(0,0,0), CRGBA ambient=CRGBA(0,0,0), CRGBA diffuse=CRGBA(0,0,0), CRGBA specular=CRGBA(0,0,0), float shininess= 10) |
| Batch setup lighting. Opacity is in diffuse.A. More...
|
void | setEmissive ( CRGBA emissive=CRGBA(0,0,0) ) |
| Set the emissive part ot material. Usefull only if setLighting(true, false) has been done. More...
|
void | setAmbient ( CRGBA ambient=CRGBA(0,0,0) ) |
| Set the Ambient part ot material. Usefull only if setLighting(true, false) has been done. More...
|
void | setDiffuse ( CRGBA diffuse=CRGBA(0,0,0) ) |
| Set the Diffuse part ot material. Usefull only if setLighting(true, false) has been done. NB: opacity is NOT copied from diffuse.A. More...
|
void | setOpacity ( uint8 opa ) |
| Set the Opacity part ot material. Usefull only if setLighting(true, false) has been done. More...
|
void | setSpecular ( CRGBA specular=CRGBA(0,0,0) ) |
| Set the specular part ot material. Usefull only if setLighting(true, false) has been done. More...
|
void | setShininess ( float shininess ) |
| Set the shininess part ot material. Usefull only if setLighting(true, false) has been done. More...
|
bool | isLighted () const |
CRGBA | getColor (void) const |
CRGBA | getEmissive () const |
CRGBA | getAmbient () const |
CRGBA | getDiffuse () const |
| return diffuse part. NB: A==opacity. More...
|
uint8 | getOpacity () const |
CRGBA | getSpecular () const |
float | getShininess () const |
void | texEnvOpRGB (uint stage, TTexOperator ope) |
| This part is valid for Normal shaders (nlassert). More...
|
void | texEnvArg0RGB (uint stage, TTexSource src, TTexOperand oper) |
void | texEnvArg1RGB (uint stage, TTexSource src, TTexOperand oper) |
void | texEnvOpAlpha (uint stage, TTexOperator ope) |
void | texEnvArg0Alpha (uint stage, TTexSource src, TTexOperand oper) |
void | texEnvArg1Alpha (uint stage, TTexSource src, TTexOperand oper) |
void | texConstantColor (uint stage, CRGBA color) |
| Setup the constant color for a stage. Used for the TTexSource:Constant. More...
|
uint32 | getTexEnvMode (uint stage) |
| For push/pop only, get the packed version of the environnment mode. More...
|
void | setTexEnvMode (uint stage, uint32 packed) |
| For push/pop only, set the packed version of the environnment mode. More...
|
CRGBA | getTexConstantColor (uint stage) |
void | setUserColor (CRGBA userColor) |
| This part is valid for Normal shaders (nlassert). More...
|
CRGBA | getUserColor () const |
void | initUnlit () |
| Init the material as unlit. More...
|
void | initLighted () |
| Init the material as default white lighted material. More...
|
void | serial (NLMISC::IStream &f) |
uint32 | getFlags () const |
uint32 | getTouched (void) const |
void | clearTouched (uint32 flag) |
Public Attributes |
CTexEnv | _TexEnvs [IDRV_MAT_MAXTEXTURES] |
CRefPtr<IShader> | pShader |
Private Attributes |
TShader | _ShaderType |
uint32 | _Flags |
TBlend | _SrcBlend |
TBlend | _DstBlend |
ZFunc | _ZFunction |
float | _ZBias |
CRGBA | _Color |
CRGBA | _Emissive |
CRGBA | _Ambient |
CRGBA | _Diffuse |
CRGBA | _Specular |
float | _Shininess |
uint32 | _Touched |
CSmartPtr<ITexture> | _Textures [IDRV_MAT_MAXTEXTURES] |
Detailed Description
A material represent ALL the states relatives to the aspect of a primitive.
Definition at line 82 of file material.h.
Member Enumeration Documentation
enum NL3D::CMaterial::TBlend
|
|
|
-
Enumeration values:
-
one
|
|
zero
|
|
srcalpha
|
|
invsrcalpha
|
|
srccolor
|
|
invsrccolor
|
|
blendCount
|
|
Definition at line 87 of file material.h. |
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).
-
Enumeration values:
-
Normal
|
|
Bump
|
|
UserColor
|
|
shaderCount
|
|
Definition at line 97 of file material.h. |
enum NL3D::CMaterial::TTexOperand
|
|
|
Operand for the argument.
For Alpha arguments, only SrcAlpha and InvSrcAlpha are Valid!!
SrcColor: arg= ColorSource. InvSrcColor: arg= 1-ColorSource. SrcAlpha: arg= AlphaSource. InvSrcAlpha: arg= 1-AlphaSource. -
Enumeration values:
-
SrcColor
|
|
InvSrcColor
|
|
SrcAlpha
|
|
InvSrcAlpha
|
|
Definition at line 128 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.
-
Enumeration values:
-
Replace
|
|
Modulate
|
|
Add
|
|
AddSigned
|
|
InterpolateTexture
|
|
InterpolatePrevious
|
|
InterpolateDiffuse
|
|
InterpolateConstant
|
|
Definition at line 110 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:
-
Previous
|
|
Diffuse
|
|
Constant
|
|
Definition at line 119 of file material.h. |
enum NL3D::CMaterial::ZFunc
|
|
|
-
Enumeration values:
-
always
|
|
never
|
|
equal
|
|
notequal
|
|
less
|
|
lessequal
|
|
greater
|
|
greaterequal
|
|
zfuncCount
|
|
Definition at line 86 of file material.h. |
Constructor & Destructor Documentation
NL3D::CMaterial::CMaterial (
|
)
|
|
|
ctor.
By default, shader is normal, SrcBlend is srcalpha, dstblend is invsrcalpha, ZFunction is lessequal, ZBias is 0, Color is White: (255,255,255,255), not double sided.
Definition at line 38 of file material.cpp. |
NL3D::CMaterial::CMaterial (
|
const CMaterial & mat ) [inline]
|
|
NL3D::CMaterial::~CMaterial (
|
)
|
|
Member Function Documentation
void NL3D::CMaterial::clearTouched (
|
uint32 flag ) [inline]
|
|
bool NL3D::CMaterial::detDoubleSided (
|
) const [inline]
|
|
CRGBA NL3D::CMaterial::getAmbient (
|
) const [inline]
|
|
bool NL3D::CMaterial::getBlend (
|
) const [inline]
|
|
CRGBA NL3D::CMaterial::getColor (
|
void ) const [inline]
|
|
CRGBA NL3D::CMaterial::getDiffuse (
|
) const [inline]
|
|
|
return diffuse part. NB: A==opacity.
Definition at line 235 of file material.h. |
TBlend NL3D::CMaterial::getDstBlend (
|
void ) const [inline]
|
|
CRGBA NL3D::CMaterial::getEmissive (
|
) const [inline]
|
|
uint32 NL3D::CMaterial::getFlags (
|
) const [inline]
|
|
uint8 NL3D::CMaterial::getOpacity (
|
) const [inline]
|
|
TShader NL3D::CMaterial::getShader (
|
) const [inline]
|
|
|
get the current material shadertype.
Definition at line 153 of file material.h. |
float NL3D::CMaterial::getShininess (
|
) const [inline]
|
|
CRGBA NL3D::CMaterial::getSpecular (
|
) const [inline]
|
|
TBlend NL3D::CMaterial::getSrcBlend (
|
void ) const [inline]
|
|
CRGBA NL3D::CMaterial::getTexConstantColor (
|
uint stage ) [inline]
|
|
uint32 NL3D::CMaterial::getTexEnvMode (
|
uint stage ) [inline]
|
|
ITexture * NL3D::CMaterial::getTexture (
|
uint8 n ) const [inline]
|
|
uint32 NL3D::CMaterial::getTouched (
|
void ) const [inline]
|
|
CRGBA NL3D::CMaterial::getUserColor (
|
) const [inline]
|
|
float NL3D::CMaterial::getZBias (
|
void ) const [inline]
|
|
ZFunc NL3D::CMaterial::getZFunc (
|
void ) const [inline]
|
|
bool NL3D::CMaterial::getZWrite (
|
void ) const [inline]
|
|
void NL3D::CMaterial::initLighted (
|
)
|
|
|
Init the material as default white lighted material.
normal shader, lighting .... Default to: normal shader, lighting to default material, 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 68 of file material.cpp. |
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 53 of file material.cpp. |
bool NL3D::CMaterial::isLighted (
|
) const [inline]
|
|
CMaterial & NL3D::CMaterial::operator= (
|
const CMaterial & mat )
|
|
|
Do not copy DrvInfos, copy all infos and set IDRV_TOUCHED_ALL.
Definition at line 76 of file material.cpp. |
void NL3D::CMaterial::setAmbient (
|
CRGBA ambient = CRGBA(0,0,0) ) [inline]
|
|
|
Set the Ambient part ot material. Usefull only if setLighting(true, false) has been done.
Definition at line 150 of file driver_material_inline.h. |
void NL3D::CMaterial::setBlend (
|
bool active ) [inline]
|
|
void NL3D::CMaterial::setBlendFunc (
|
TBlend src,
|
|
TBlend dst ) [inline]
|
|
|
The Color is used only if lighting is disabled. Also, color is replaced by per vertex color (if any).
Definition at line 105 of file driver_material_inline.h. |
void NL3D::CMaterial::setDiffuse (
|
CRGBA diffuse = CRGBA(0,0,0) ) [inline]
|
|
|
Set the Diffuse part ot material. Usefull only if setLighting(true, false) has been done. NB: opacity is NOT copied from diffuse.A.
Definition at line 156 of file driver_material_inline.h. |
void NL3D::CMaterial::setDoubleSided (
|
bool active ) [inline]
|
|
void NL3D::CMaterial::setDstBlend (
|
TBlend val ) [inline]
|
|
void NL3D::CMaterial::setEmissive (
|
CRGBA emissive = CRGBA(0,0,0) ) [inline]
|
|
|
Set the emissive part ot material. Usefull only if setLighting(true, false) has been done.
Definition at line 144 of file driver_material_inline.h. |
void NL3D::CMaterial::setLighting (
|
bool active,
|
|
bool DefMat = true,
|
|
NLMISC::CRGBA emissive = CRGBA(0,0,0),
|
|
NLMISC::CRGBA ambient = CRGBA(0,0,0),
|
|
NLMISC::CRGBA diffuse = CRGBA(0,0,0),
|
|
NLMISC::CRGBA specular = CRGBA(0,0,0),
|
|
float shininess = 10 ) [inline]
|
|
void NL3D::CMaterial::setOpacity (
|
uint8 opa ) [inline]
|
|
|
Set the Opacity part ot material. Usefull only if setLighting(true, false) has been done.
Definition at line 165 of file driver_material_inline.h. |
void NL3D::CMaterial::setShader (
|
TShader val )
|
|
|
Set the shader for this material.
All textures are reseted!!
Definition at line 179 of file material.cpp. |
void NL3D::CMaterial::setShininess (
|
float shininess ) [inline]
|
|
|
Set the shininess part ot material. Usefull only if setLighting(true, false) has been done.
Definition at line 177 of file driver_material_inline.h. |
void NL3D::CMaterial::setSpecular (
|
CRGBA specular = CRGBA(0,0,0) ) [inline]
|
|
|
Set the specular part ot material. Usefull only if setLighting(true, false) has been done.
Definition at line 171 of file driver_material_inline.h. |
void NL3D::CMaterial::setSrcBlend (
|
TBlend val ) [inline]
|
|
void NL3D::CMaterial::setTexEnvMode (
|
uint stage,
|
|
uint32 packed ) [inline]
|
|
|
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).
Definition at line 214 of file material.cpp. |
void NL3D::CMaterial::setUserColor (
|
CRGBA userColor ) [inline]
|
|
void NL3D::CMaterial::setZBias (
|
float val ) [inline]
|
|
void NL3D::CMaterial::setZFunc (
|
ZFunc val ) [inline]
|
|
void NL3D::CMaterial::setZWrite (
|
bool active ) [inline]
|
|
void NL3D::CMaterial::texConstantColor (
|
uint stage,
|
|
CRGBA color ) [inline]
|
|
|
This part is valid for Normal shaders (nlassert).
It maps the EXT_texture_env_combine opengl extension. A stage is enabled iff 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 191 of file driver_material_inline.h. |
bool NL3D::CMaterial::texturePresent (
|
uint8 n ) const [inline]
|
|
Member Data Documentation
CRGBA NL3D::CMaterial::_Ambient [private]
|
|
CRGBA NL3D::CMaterial::_Color [private]
|
|
CRGBA NL3D::CMaterial::_Diffuse [private]
|
|
TBlend NL3D::CMaterial::_DstBlend [private]
|
|
CRGBA NL3D::CMaterial::_Emissive [private]
|
|
uint32 NL3D::CMaterial::_Flags [private]
|
|
TShader NL3D::CMaterial::_ShaderType [private]
|
|
float NL3D::CMaterial::_Shininess [private]
|
|
CRGBA NL3D::CMaterial::_Specular [private]
|
|
TBlend NL3D::CMaterial::_SrcBlend [private]
|
|
uint32 NL3D::CMaterial::_Touched [private]
|
|
float NL3D::CMaterial::_ZBias [private]
|
|
ZFunc NL3D::CMaterial::_ZFunction [private]
|
|
CRefPtr< IShader > NL3D::CMaterial::pShader
|
|
The documentation for this class was generated from the following files:
|
|