NL3D::CPSMaterial Class Reference

#include <ps_particle_basic.h>

Inheritance diagram for NL3D::CPSMaterial:

NL3D::CPSDot NL3D::CPSFanLight NL3D::CPSQuad NL3D::CPSRibbon NL3D::CPSRibbonLookAt NL3D::CPSShockWave NL3D::CPSTailDot NL3D::CPSFace NL3D::CPSFaceLookAt

Detailed Description

this contains material of a particle, this doesn't initiliaze anything, this just give the abylity to change the blending mode

Definition at line 802 of file ps_particle_basic.h.

Public Types

enum  TBlendingMode { add, modulate, alphaBlend, alphaTest }
 this enum summarize the useful modes for blending to the framebuffer More...


Public Member Functions

 CPSMaterial ()
 ===================================================================================

void enableZTest (bool enabled)
 ===================================================================================

void forceModulateConstantColor (bool force, const NLMISC::CRGBA &col=NLMISC::CRGBA::White)
 ===================================================================================

void forceTexturedMaterialStages (uint numStages)
 ===================================================================================

CPSMaterial::TBlendingMode getBlendingMode (void) const
 ===================================================================================

bool isZTestEnabled () const
 ===================================================================================

void serialMaterial (NLMISC::IStream &f) throw (NLMISC::EStream)
 ===================================================================================

void setBlendingMode (CPSMaterial::TBlendingMode mode)
 ===================================================================================

void setZBias (float value)

Protected Attributes

CMaterial _Mat


Member Enumeration Documentation

enum NL3D::CPSMaterial::TBlendingMode
 

this enum summarize the useful modes for blending to the framebuffer

Enumeration values:
add 
modulate 
alphaBlend 
alphaTest 

Definition at line 809 of file ps_particle_basic.h.


Constructor & Destructor Documentation

NL3D::CPSMaterial::CPSMaterial  ) 
 

===================================================================================

Definition at line 485 of file ps_particle_basic.cpp.

References NL3D::CMaterial::setBlend(), NL3D::CMaterial::setBlendFunc(), and NL3D::CMaterial::setZWrite().

00486 {
00487         _Mat.setBlend(true);
00488         _Mat.setBlendFunc(CMaterial::one, CMaterial::one);
00489         _Mat.setZWrite(false);  
00490 }


Member Function Documentation

void NL3D::CPSMaterial::enableZTest bool  enabled  ) 
 

===================================================================================

Definition at line 508 of file ps_particle_basic.cpp.

References NL3D::CMaterial::setZFunc().

00509 {
00510         _Mat.setZFunc(enabled ? CMaterial::less : CMaterial::always);
00511 }

void NL3D::CPSMaterial::forceModulateConstantColor bool  force,
const NLMISC::CRGBA col = NLMISC::CRGBA::White
 

===================================================================================

Force the material to have one texture that is modulated by diffuse, and a constant color and its diffuse color. This is not compatible with multitextureing, however.

Parameters:
force true to force constant color modulation

Definition at line 573 of file ps_particle_basic.cpp.

References forceTexturedMaterialStages(), NL3D::CMaterial::getTexture(), NL3D::CMaterial::setTexture(), NL3D::CMaterial::texConstantColor(), NL3D::CMaterial::texEnvArg0Alpha(), NL3D::CMaterial::texEnvArg0RGB(), NL3D::CMaterial::texEnvArg1Alpha(), NL3D::CMaterial::texEnvArg1RGB(), NL3D::CMaterial::texEnvOpAlpha(), and NL3D::CMaterial::texEnvOpRGB().

Referenced by NL3D::CPSRibbonLookAt::displayRibbons(), NL3D::CPSShockWave::draw(), and NL3D::CPSQuad::updateMatBeforeRendering().

00574 {
00575         if (force)
00576         {
00578                 _Mat.texConstantColor(1, col);
00579                 _Mat.texEnvOpRGB(1, CMaterial::Modulate);
00580                 _Mat.texEnvOpAlpha(1, CMaterial::Modulate);
00581                 _Mat.texEnvArg0RGB(1, CMaterial::Previous, CMaterial::SrcColor);
00582                 _Mat.texEnvArg1RGB(1, CMaterial::Constant, CMaterial::SrcColor);
00583                 _Mat.texEnvArg0Alpha(1, CMaterial::Previous, CMaterial::SrcAlpha);
00584                 _Mat.texEnvArg1Alpha(1, CMaterial::Constant, CMaterial::SrcAlpha);
00585                 forceTexturedMaterialStages(2);
00586         }
00587         else
00588         {               
00589                 if (_Mat.getTexture(1) != NULL)
00590                 {
00591                         _Mat.setTexture(1, NULL);
00592                 }
00593         }
00594 }

void NL3D::CPSMaterial::forceTexturedMaterialStages uint  numStages  ) 
 

===================================================================================

This setup n stage of a material with at least texture.

  • If a texture was present for a given stage it still is
  • If a texture wasn't present, it create a dummy white texture there
  • Above numStages, textures are disabled. It can be used to do extra math with stages that have no textures (required by the driver)

Definition at line 598 of file ps_particle_basic.cpp.

References NL3D::CMaterial::getTexture(), NL3D::IDRV_MAT_MAXTEXTURES, NL3D::CMaterial::setTexture(), and uint.

Referenced by NL3D::CPSDot::draw(), forceModulateConstantColor(), and NL3D::CPSFanLight::setupMaterial().

00599 {
00600         ITexture *blankTex = NULL;
00601         uint k;
00602         for (k = 0; k < numStages; ++k)
00603         {
00604                 if (_Mat.getTexture(k) == NULL)
00605                 {
00606                         if (!blankTex)
00607                         {
00608                                 blankTex = CTextureMem::Create1x1WhiteTex();
00609                         }
00610                         _Mat.setTexture(k, blankTex);
00611                 }
00612         }
00613         for (; k < IDRV_MAT_MAXTEXTURES; ++k)
00614         {
00615                 if (_Mat.getTexture(k) != NULL)
00616                 {
00617                         _Mat.setTexture(k, NULL);
00618                 }               
00619         }
00620 }

CPSMaterial::TBlendingMode NL3D::CPSMaterial::getBlendingMode void   )  const
 

===================================================================================

Definition at line 551 of file ps_particle_basic.cpp.

References alphaBlend, alphaTest, NL3D::CMaterial::getBlend(), NL3D::CMaterial::getDstBlend(), NL3D::CMaterial::getSrcBlend(), and nlassert.

Referenced by NL3D::CPSTailDot::hasTransparentFaces(), NL3D::CPSShockWave::hasTransparentFaces(), NL3D::CPSRibbonLookAt::hasTransparentFaces(), NL3D::CPSRibbon::hasTransparentFaces(), NL3D::CPSQuad::hasTransparentFaces(), NL3D::CPSFanLight::hasTransparentFaces(), and NL3D::CPSDot::hasTransparentFaces().

00552 {
00553         if (_Mat.getBlend())
00554         {
00555                 CMaterial::TBlend srcBlend = _Mat.getSrcBlend();        
00556                 CMaterial::TBlend destBlend = _Mat.getDstBlend();
00557 
00558                 if (srcBlend == CMaterial::one && destBlend == CMaterial::one) return add;
00559                 if (srcBlend == CMaterial::zero && destBlend == CMaterial::srccolor) return modulate;
00560                 if (srcBlend == CMaterial::srcalpha && destBlend == CMaterial::invsrcalpha) return alphaBlend;
00561 
00562                 // unrecognized mode
00563                 nlassert(0);
00564                 return alphaTest; // to avoid a warning only ...
00565         }
00566         else
00567         {
00568                 return alphaTest;
00569         }
00570 }

bool NL3D::CPSMaterial::isZTestEnabled  )  const
 

===================================================================================

Definition at line 514 of file ps_particle_basic.cpp.

References NL3D::CMaterial::getZFunc().

00515 {
00516         return _Mat.getZFunc() != CMaterial::always;
00517 }

void NL3D::CPSMaterial::serialMaterial NLMISC::IStream f  )  throw (NLMISC::EStream)
 

===================================================================================

Definition at line 493 of file ps_particle_basic.cpp.

References sint.

00494 {
00495         sint ver = f.serialVersion(2);  
00496         TBlendingMode m = getBlendingMode();
00497         f.serialEnum(m);
00498         setBlendingMode(m);     
00499         if (ver >= 2)
00500         {       
00501                 bool zTest = isZTestEnabled();
00502                 f.serial(zTest);
00503                 enableZTest(zTest);
00504         }
00505 }

void NL3D::CPSMaterial::setBlendingMode CPSMaterial::TBlendingMode  mode  ) 
 

===================================================================================

Definition at line 520 of file ps_particle_basic.cpp.

References alphaBlend, alphaTest, NL3D::CMaterial::setAlphaTest(), NL3D::CMaterial::setBlend(), NL3D::CMaterial::setBlendFunc(), and NL3D::CMaterial::setZWrite().

00521 {
00522         switch (mode)
00523         {               
00524                 case add:
00525                         _Mat.setBlend(true);
00526                         _Mat.setBlendFunc(CMaterial::one, CMaterial::one);
00527                         _Mat.setZWrite(false);
00528                         _Mat.setAlphaTest(false);
00529                 break;
00530                 case modulate:
00531                         _Mat.setBlend(true);
00532                         _Mat.setBlendFunc(CMaterial::zero, CMaterial::srccolor);
00533                         _Mat.setZWrite(false);
00534                         _Mat.setAlphaTest(false);
00535                 break;
00536                 case alphaBlend:
00537                         _Mat.setBlend(true);
00538                         _Mat.setBlendFunc(CMaterial::srcalpha, CMaterial::invsrcalpha);
00539                         _Mat.setZWrite(false);
00540                         _Mat.setAlphaTest(false);
00541                 break;
00542                 case alphaTest:
00543                         _Mat.setBlend(false);
00544                         _Mat.setZWrite(true);
00545                         _Mat.setAlphaTest(true);
00546                 break;
00547         }
00548 }

void NL3D::CPSMaterial::setZBias float  value  )  [inline]
 

Reimplemented in NL3D::CPSDot, NL3D::CPSFanLight, NL3D::CPSQuad, NL3D::CPSRibbon, NL3D::CPSRibbonLookAt, NL3D::CPSShockWave, and NL3D::CPSTailDot.

Definition at line 841 of file ps_particle_basic.h.

References NL3D::CMaterial::setZBias(), and value.

00841 { _Mat.setZBias(value); }       


Field Documentation

CMaterial NL3D::CPSMaterial::_Mat [protected]
 

Definition at line 844 of file ps_particle_basic.h.

Referenced by NL3D::CPSFaceHelper::drawFaces(), NL3D::CPSFanLightHelper::drawFanLight(), NL3D::CPSFaceLookAtHelper::drawLookAt(), and NL3D::CPSFaceLookAtHelper::drawLookAtAlignOnMotion().


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 07:17:56 2004 for NeL by doxygen 1.3.6