NL3D::CPSColoredParticle Class Reference

#include <ps_particle_basic.h>

Inheritance diagram for NL3D::CPSColoredParticle:

NL3D::CPSConstraintMesh NL3D::CPSDot NL3D::CPSFanLight NL3D::CPSQuad NL3D::CPSRibbon NL3D::CPSRibbonLookAt NL3D::CPSShockWave NL3D::CPSTailDot

Detailed Description

this class adds tunable color to a particle. Can be added using public multiple inheritance

Definition at line 191 of file ps_particle_basic.h.

Public Member Functions

 CPSColoredParticle ()
 ctor : default are white particles (constant color)

NLMISC::CRGBA getColor (void) const
 Get the color.

const CPSAttribMaker< CRGBA > * getColorScheme (void) const
 get the color scheme (NULL if none) const version

CPSAttribMaker< CRGBA > * getColorScheme (void)
 get the color scheme (NULL if none)

void serialColorScheme (NLMISC::IStream &f) throw (NLMISC::EStream)
 serialization.

void setColor (NLMISC::CRGBA col)
 Set a constant color for the particles. remove any previous scheme.

void setColorScheme (CPSAttribMaker< CRGBA > *col)
virtual ~CPSColoredParticle ()
 dtor


Protected Member Functions

void deleteColorElement (uint32 index)
virtual CPSLocatedgetColorOwner (void)=0
 deriver must return their owner there

void newColorElement (CPSLocated *emitterLocated, uint32 emitterIndex)
void resizeColor (uint32 size)
virtual void updateMatAndVbForColor (void)=0
 Update the material and the vb and the like so that they match the color scheme.


Protected Attributes

CRGBA _Color
CPSAttribMaker< CRGBA > * _ColorScheme


Constructor & Destructor Documentation

NL3D::CPSColoredParticle::CPSColoredParticle  ) 
 

ctor : default are white particles (constant color)

Definition at line 144 of file ps_particle_basic.cpp.

00144                                        : _Color(CRGBA(255, 255, 255)), _ColorScheme(NULL)
00145 {       
00146 }

NL3D::CPSColoredParticle::~CPSColoredParticle  )  [virtual]
 

dtor

Definition at line 149 of file ps_particle_basic.cpp.

00150 {       
00151         delete _ColorScheme;    
00152 }


Member Function Documentation

void NL3D::CPSColoredParticle::deleteColorElement uint32  index  )  [inline, protected]
 

Definition at line 237 of file ps_particle_basic.h.

References NL3D::CPSAttribMaker< CRGBA >::deleteElement(), NL3D::CPSAttribMaker< CRGBA >::hasMemory(), index, and uint32.

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

00238                 {
00239                         if (_ColorScheme && _ColorScheme->hasMemory()) _ColorScheme->deleteElement(index);
00240                 }

NLMISC::CRGBA NL3D::CPSColoredParticle::getColor void   )  const [inline]
 

Get the color.

Definition at line 211 of file ps_particle_basic.h.

00211 { return _Color; }

virtual CPSLocated* NL3D::CPSColoredParticle::getColorOwner void   )  [protected, pure virtual]
 

deriver must return their owner there

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

Referenced by resizeColor(), and setColorScheme().

const CPSAttribMaker<CRGBA>* NL3D::CPSColoredParticle::getColorScheme void   )  const [inline]
 

get the color scheme (NULL if none) const version

Definition at line 205 of file ps_particle_basic.h.

00205 { return _ColorScheme; }

CPSAttribMaker<CRGBA>* NL3D::CPSColoredParticle::getColorScheme void   )  [inline]
 

get the color scheme (NULL if none)

Definition at line 202 of file ps_particle_basic.h.

00202 { return _ColorScheme; }

void NL3D::CPSColoredParticle::newColorElement CPSLocated emitterLocated,
uint32  emitterIndex
[inline, protected]
 

Definition at line 233 of file ps_particle_basic.h.

References NL3D::CPSAttribMaker< CRGBA >::hasMemory(), NL3D::CPSAttribMaker< CRGBA >::newElement(), and uint32.

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

00234                 {
00235                         if (_ColorScheme && _ColorScheme->hasMemory()) _ColorScheme->newElement(emitterLocated, emitterIndex);
00236                 }       

void NL3D::CPSColoredParticle::resizeColor uint32  size  )  [inline, protected]
 

Definition at line 241 of file ps_particle_basic.h.

References getColorOwner(), NL3D::CPSAttribMaker< CRGBA >::hasMemory(), nlassert, NL3D::CPSAttribMaker< CRGBA >::resize(), size, and uint32.

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

00242                 {
00243                         nlassert(size < (1 << 16));
00244                         if (_ColorScheme && _ColorScheme->hasMemory()) _ColorScheme->resize(size, getColorOwner()->getSize());
00245                 }

void NL3D::CPSColoredParticle::serialColorScheme NLMISC::IStream f  )  throw (NLMISC::EStream)
 

serialization.

Definition at line 155 of file ps_particle_basic.cpp.

00156 {       
00157         f.serialVersion(1);     
00158         if (f.isReading())
00159         {
00160                 if (_ColorScheme)
00161                 {
00162                         delete _ColorScheme;
00163                         _ColorScheme = NULL;
00164                 }
00165         }
00166         bool useColorScheme = _ColorScheme != NULL;
00167         f.serial(useColorScheme);
00168         if (useColorScheme)
00169         {
00170                 f.serialPolyPtr(_ColorScheme);
00171         }
00172         else
00173         {
00174                 f.serial(_Color);
00175         }
00176 }

void NL3D::CPSColoredParticle::setColor NLMISC::CRGBA  col  ) 
 

Set a constant color for the particles. remove any previous scheme.

Definition at line 135 of file ps_particle_basic.cpp.

References updateMatAndVbForColor().

00136 {       
00137         delete _ColorScheme;
00138         _ColorScheme = NULL;
00139         _Color = col;
00140         updateMatAndVbForColor();
00141 }

void NL3D::CPSColoredParticle::setColorScheme CPSAttribMaker< CRGBA > *  col  ) 
 

Set an attribute maker that produce a color It must have been allocated by new It will be deleted by this object

Definition at line 125 of file ps_particle_basic.cpp.

References getColorOwner(), nlassert, NL3D::CPSAttribMaker< T >::resize(), and updateMatAndVbForColor().

00126 {       
00127         nlassert(col);
00128         delete _ColorScheme;            
00129         _ColorScheme = col;
00130         if (getColorOwner() && col->hasMemory()) col->resize(getColorOwner()->getMaxSize(), getColorOwner()->getSize());
00131         updateMatAndVbForColor();
00132 }

virtual void NL3D::CPSColoredParticle::updateMatAndVbForColor void   )  [protected, pure virtual]
 

Update the material and the vb and the like so that they match the color scheme.

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

Referenced by setColor(), and setColorScheme().


Field Documentation

CRGBA NL3D::CPSColoredParticle::_Color [protected]
 

Definition at line 226 of file ps_particle_basic.h.

CPSAttribMaker<CRGBA>* NL3D::CPSColoredParticle::_ColorScheme [protected]
 

Definition at line 228 of file ps_particle_basic.h.

Referenced by NL3D::CPSFanLightHelper::drawFanLight(), NL3D::CPSConstraintMeshHelper::drawMeshs(), and NL3D::CPSConstraintMeshHelper::drawPrerotatedMeshs().


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