NL3D::CPSRotated2DParticle Class Reference

#include <ps_particle_basic.h>

Inheritance diagram for NL3D::CPSRotated2DParticle:

NL3D::CDummy2DAngle NL3D::CPSFaceLookAt NL3D::CPSFanLight NL3D::CPSMesh NL3D::CPSShockWave

Detailed Description

this class adds tunable 2D rotation to a particle, it can be used by public multiple inheritance

Definition at line 311 of file ps_particle_basic.h.

Public Member Functions

 CPSRotated2DParticle ()
 ===================================================================================

float getAngle2D (void) const
 get the constant

const CPSAttribMaker< float > * getAngle2DScheme (void) const
 get the angle 2D scheme (NULL if none) const version

CPSAttribMaker< float > * getAngle2DScheme (void)
 get the angle 2D scheme (NULL if none)

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

void setAngle2D (float angle)
 ===================================================================================

void setAngle2DScheme (CPSAttribMaker< float > *scheme)
 ===================================================================================

virtual ~CPSRotated2DParticle ()
 ===================================================================================


Static Public Member Functions

const float * getRotTable (void)
void initRotTable (void)
 ===================================================================================


Protected Member Functions

void deleteAngle2DElement (uint32 index)
virtual CPSLocatedgetAngle2DOwner (void)=0
 deriver must return their owner there

void newAngle2DElement (CPSLocated *emitterLocated, uint32 emitterIndex)
void resizeAngle2D (uint32 size)

Protected Attributes

float _Angle2D
CPSAttribMaker< float > * _Angle2DScheme

Static Protected Attributes

bool _InitializedRotTab = false
 it is true if the table has been initialized, for debug purposes

float _RotTable [4 *256]


Constructor & Destructor Documentation

NL3D::CPSRotated2DParticle::CPSRotated2DParticle  ) 
 

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

Definition at line 259 of file ps_particle_basic.cpp.

00259                                            : _Angle2D(0), _Angle2DScheme(NULL)
00260 {
00261 }

NL3D::CPSRotated2DParticle::~CPSRotated2DParticle  )  [virtual]
 

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

Definition at line 264 of file ps_particle_basic.cpp.

References _Angle2DScheme.

00265 {       
00266         delete _Angle2DScheme;  
00267 }


Member Function Documentation

void NL3D::CPSRotated2DParticle::deleteAngle2DElement uint32  index  )  [inline, protected]
 

Definition at line 380 of file ps_particle_basic.h.

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

Referenced by NL3D::CPSShockWave::deleteElement(), NL3D::CPSMesh::deleteElement(), NL3D::CPSFanLight::deleteElement(), and NL3D::CPSFaceLookAt::deleteElement().

00381                 {
00382                         if (_Angle2DScheme && _Angle2DScheme->hasMemory()) _Angle2DScheme->deleteElement(index);
00383                 }

float NL3D::CPSRotated2DParticle::getAngle2D void   )  const [inline]
 

get the constant

Definition at line 336 of file ps_particle_basic.h.

References _Angle2D.

00336 { return _Angle2D; }

virtual CPSLocated* NL3D::CPSRotated2DParticle::getAngle2DOwner void   )  [protected, pure virtual]
 

deriver must return their owner there

Implemented in NL3D::CPSFaceLookAt, NL3D::CPSFanLight, NL3D::CPSMesh, NL3D::CDummy2DAngle, and NL3D::CPSShockWave.

Referenced by resizeAngle2D(), and setAngle2DScheme().

const CPSAttribMaker<float>* NL3D::CPSRotated2DParticle::getAngle2DScheme void   )  const [inline]
 

get the angle 2D scheme (NULL if none) const version

Definition at line 326 of file ps_particle_basic.h.

References _Angle2DScheme.

00326 { return _Angle2DScheme; }

CPSAttribMaker<float>* NL3D::CPSRotated2DParticle::getAngle2DScheme void   )  [inline]
 

get the angle 2D scheme (NULL if none)

Definition at line 323 of file ps_particle_basic.h.

References _Angle2DScheme.

00323 { return _Angle2DScheme; }

const float* NL3D::CPSRotated2DParticle::getRotTable void   )  [inline, static]
 

this return a float table used to speed up rotations of face look at and the like for each angle, there are 4 float : 2 couple of float : a1, b1, a2, b2 a1 * I + b1 * K = up left corner, a2 * I + b2 * K = up right corner, This table must have been initialized with initRotTable

Definition at line 354 of file ps_particle_basic.h.

References _InitializedRotTab, _RotTable, and nlassert.

00355                 {
00356                         nlassert(_InitializedRotTab); // must have called initRotTable at the start of the apply
00357                         return _RotTable;
00358                 }

void NL3D::CPSRotated2DParticle::initRotTable void   )  [static]
 

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

Definition at line 294 of file ps_particle_basic.cpp.

References _InitializedRotTab, _RotTable, and uint32.

00295 {
00296         float *ptFloat = _RotTable;
00297         for (uint32 k = 0; k < 256; ++k)
00298         {
00299                 const float ca = (float) cos(k * (1.0f / 256.0f) * 2.0f * NLMISC::Pi);
00300                 const float sa = (float) sin(k * (1.0f / 256.0f) * 2.0f * NLMISC::Pi);
00301 
00302                 *ptFloat++ = -ca - sa;
00303                 *ptFloat++ = -sa + ca;
00304 
00305                 *ptFloat++ = ca - sa;
00306                 *ptFloat++ = sa + ca;
00307         }
00308         _InitializedRotTab = true;
00309 }

void NL3D::CPSRotated2DParticle::newAngle2DElement CPSLocated emitterLocated,
uint32  emitterIndex
[inline, protected]
 

Definition at line 376 of file ps_particle_basic.h.

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

Referenced by NL3D::CPSShockWave::newElement(), NL3D::CPSMesh::newElement(), NL3D::CPSFanLight::newElement(), and NL3D::CPSFaceLookAt::newElement().

00377                 {
00378                         if (_Angle2DScheme && _Angle2DScheme->hasMemory()) _Angle2DScheme->newElement(emitterLocated, emitterIndex);
00379                 }       

void NL3D::CPSRotated2DParticle::resizeAngle2D uint32  size  )  [inline, protected]
 

Definition at line 384 of file ps_particle_basic.h.

References _Angle2DScheme, getAngle2DOwner(), NL3D::CPSAttribMaker< float >::hasMemory(), nlassert, NL3D::CPSAttribMaker< float >::resize(), size, and uint32.

Referenced by NL3D::CPSShockWave::resize(), NL3D::CPSMesh::resize(), NL3D::CPSFanLight::resize(), and NL3D::CPSFaceLookAt::resize().

00385                 {
00386                         nlassert(size < (1 << 16));
00387                         if (_Angle2DScheme && _Angle2DScheme->hasMemory()) _Angle2DScheme->resize(size, getAngle2DOwner()->getSize());
00388                 }

void NL3D::CPSRotated2DParticle::serialAngle2DScheme NLMISC::IStream f  )  throw (NLMISC::EStream)
 

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

Definition at line 270 of file ps_particle_basic.cpp.

Referenced by NL3D::CPSRibbon::serial().

00271 {
00272         f.serialVersion(1);     
00273         if (f.isReading())
00274         {
00275                 if (_Angle2DScheme)
00276                 {
00277                         delete _Angle2DScheme;
00278                         _Angle2DScheme = NULL;
00279                 }
00280         }
00281         bool useAngle2DScheme = _Angle2DScheme != NULL;
00282         f.serial(useAngle2DScheme);
00283         if (useAngle2DScheme)
00284         {
00285                 f.serialPolyPtr(_Angle2DScheme);
00286         }
00287         else
00288         {               
00289                 f.serial(_Angle2D);
00290         }       
00291 }

void NL3D::CPSRotated2DParticle::setAngle2D float  angle  ) 
 

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

Set a constant angle for the particle. Angles range from 0.0f to 256.0f (2 pi) This discrad any previous scheme

See also:
setAngle2DScheme()

Definition at line 251 of file ps_particle_basic.cpp.

References _Angle2D, and _Angle2DScheme.

00252 {       
00253         delete _Angle2DScheme;
00254         _Angle2DScheme = NULL;  
00255         _Angle2D = angle2DScheme;
00256 }

void NL3D::CPSRotated2DParticle::setAngle2DScheme CPSAttribMaker< float > *  scheme  ) 
 

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

Set an attribute maker that produce a float It must have been allocated by new It will be deleted by this object Output angles must range from 0.0f to 256.0f

Definition at line 242 of file ps_particle_basic.cpp.

References _Angle2DScheme, getAngle2DOwner(), nlassert, and NL3D::CPSAttribMaker< T >::resize().

00243 {
00244         nlassert(angle2DScheme);
00245         delete _Angle2DScheme;  
00246         _Angle2DScheme = angle2DScheme;
00247         if (getAngle2DOwner() && angle2DScheme->hasMemory()) angle2DScheme->resize(getAngle2DOwner()->getMaxSize(), getAngle2DOwner()->getSize());
00248 }


Field Documentation

float NL3D::CPSRotated2DParticle::_Angle2D [protected]
 

Definition at line 367 of file ps_particle_basic.h.

Referenced by NL3D::CPSFanLightHelper::drawFanLight(), NL3D::CPSFaceLookAtHelper::drawLookAt(), NL3D::CPSFaceLookAtHelper::drawLookAtAlignOnMotion(), getAngle2D(), and setAngle2D().

CPSAttribMaker<float>* NL3D::CPSRotated2DParticle::_Angle2DScheme [protected]
 

Definition at line 368 of file ps_particle_basic.h.

Referenced by deleteAngle2DElement(), NL3D::CPSFanLightHelper::drawFanLight(), NL3D::CPSFaceLookAtHelper::drawLookAt(), NL3D::CPSFaceLookAtHelper::drawLookAtAlignOnMotion(), getAngle2DScheme(), newAngle2DElement(), resizeAngle2D(), setAngle2D(), setAngle2DScheme(), and ~CPSRotated2DParticle().

bool NL3D::CPSRotated2DParticle::_InitializedRotTab = false [static, protected]
 

it is true if the table has been initialized, for debug purposes

Definition at line 239 of file ps_particle_basic.cpp.

Referenced by getRotTable(), and initRotTable().

float NL3D::CPSRotated2DParticle::_RotTable [static, protected]
 

Definition at line 238 of file ps_particle_basic.cpp.

Referenced by getRotTable(), and initRotTable().


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