NL3D::CPSTexturedParticle Class Reference

#include <ps_particle_basic.h>

Inheritance diagram for NL3D::CPSTexturedParticle:

NL3D::CPSQuad NL3D::CPSShockWave NL3D::CPSFace NL3D::CPSFaceLookAt

Detailed Description

this class adds a texture to a particle. The texture can be animated or not. it can be used by public multiple inheritance. The frame animation are all stored in the same texture for optimisation so it's not suited for large anim...

Definition at line 411 of file ps_particle_basic.h.

Public Member Functions

 CPSTexturedParticle ()
 ===================================================================================

void enumTexs (std::vector< NLMISC::CSmartPtr< ITexture > > &dest)
const ITexturegetTexture (void) const
ITexturegetTexture (void)
 get the constant texture

const CTextureGroupedgetTextureGroup (void) const
 get the texture group used if there's a texture scheme, const version. (if null, there's no texture animation)

CTextureGroupedgetTextureGroup (void)
 get the texture group used. it discard any previous single texture. (if null, there's no texture animation)

sint32 getTextureIndex (void) const
 get the animated texture index. MeaningFul only if a texture group was set

const CPSAttribMaker< sint32 > * getTextureIndexScheme (void) const
 get the texture scheme (null if none) const version

CPSAttribMaker< sint32 > * getTextureIndexScheme (void)
 get the texture scheme (null if none)

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

void setTexture (CSmartPtr< ITexture > tex)
 ===================================================================================

void setTextureGroup (NLMISC::CSmartPtr< CTextureGrouped > texGroup)
 ===================================================================================

void setTextureIndex (sint32 index)
 ===================================================================================

void setTextureIndexScheme (CPSAttribMaker< sint32 > *animOrder)
 ===================================================================================

virtual ~CPSTexturedParticle ()
 ===================================================================================


Protected Member Functions

void deleteTextureIndexElement (uint32 index)
virtual CPSLocatedgetTextureIndexOwner (void)=0
 deriver must return their owner there

void newTextureIndexElement (CPSLocated *emitterLocated, uint32 emitterIndex)
void resizeTextureIndex (uint32 size)
virtual void updateMatAndVbForTexture (void)=0
 Update the material so that it match the texture scheme.


Protected Attributes

CSmartPtr< ITexture_Tex
CSmartPtr< CTextureGrouped_TexGroup
sint32 _TextureIndex
CPSAttribMaker< sint32 > * _TextureIndexScheme


Constructor & Destructor Documentation

NL3D::CPSTexturedParticle::CPSTexturedParticle  ) 
 

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

Definition at line 359 of file ps_particle_basic.cpp.

00359                                          : _TexGroup(NULL),
00360                                                                                          _TextureIndexScheme(NULL),
00361                                                                                          _TextureIndex(0)
00362 {
00363 }

NL3D::CPSTexturedParticle::~CPSTexturedParticle  )  [virtual]
 

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

Definition at line 366 of file ps_particle_basic.cpp.

References _TextureIndexScheme.

00367 {       
00368         delete _TextureIndexScheme;     
00369 }


Member Function Documentation

void NL3D::CPSTexturedParticle::deleteTextureIndexElement uint32  index  )  [inline, protected]
 

Definition at line 489 of file ps_particle_basic.h.

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

Referenced by NL3D::CPSShockWave::deleteElement(), and NL3D::CPSQuad::deleteElement().

00490                 {
00491                         if (_TextureIndexScheme && _TextureIndexScheme->hasMemory()) _TextureIndexScheme->deleteElement(index);
00492                 }

void NL3D::CPSTexturedParticle::enumTexs std::vector< NLMISC::CSmartPtr< ITexture > > &  dest  ) 
 

Definition at line 955 of file ps_particle_basic.cpp.

References getTextureGroup().

00956 {
00957         if (_Tex) 
00958         {
00959                 dest.push_back(_Tex);
00960         }
00961         if (getTextureGroup())
00962         {
00963                 dest.push_back(getTextureGroup());
00964         }
00965 }

const ITexture* NL3D::CPSTexturedParticle::getTexture void   )  const [inline]
 

Definition at line 453 of file ps_particle_basic.h.

00453 { return _Tex; }

ITexture* NL3D::CPSTexturedParticle::getTexture void   )  [inline]
 

get the constant texture

Definition at line 451 of file ps_particle_basic.h.

00451 { return _Tex; }

const CTextureGrouped* NL3D::CPSTexturedParticle::getTextureGroup void   )  const [inline]
 

get the texture group used if there's a texture scheme, const version. (if null, there's no texture animation)

Definition at line 442 of file ps_particle_basic.h.

References _TexGroup.

00442 { return _TexGroup; }

CTextureGrouped* NL3D::CPSTexturedParticle::getTextureGroup void   )  [inline]
 

get the texture group used. it discard any previous single texture. (if null, there's no texture animation)

Definition at line 439 of file ps_particle_basic.h.

References _TexGroup.

Referenced by enumTexs().

00439 {  return _TexGroup; }

sint32 NL3D::CPSTexturedParticle::getTextureIndex void   )  const [inline]
 

get the animated texture index. MeaningFul only if a texture group was set

Definition at line 433 of file ps_particle_basic.h.

References _TextureIndex, and sint32.

00433 { return _TextureIndex; }               

virtual CPSLocated* NL3D::CPSTexturedParticle::getTextureIndexOwner void   )  [protected, pure virtual]
 

deriver must return their owner there

Implemented in NL3D::CPSQuad, and NL3D::CPSShockWave.

Referenced by resizeTextureIndex(), and setTextureIndexScheme().

const CPSAttribMaker<sint32>* NL3D::CPSTexturedParticle::getTextureIndexScheme void   )  const [inline]
 

get the texture scheme (null if none) const version

Definition at line 427 of file ps_particle_basic.h.

References _TextureIndexScheme.

00427 { return _TextureIndexScheme; }

CPSAttribMaker<sint32>* NL3D::CPSTexturedParticle::getTextureIndexScheme void   )  [inline]
 

get the texture scheme (null if none)

Definition at line 424 of file ps_particle_basic.h.

References _TextureIndexScheme.

00424 { return _TextureIndexScheme; }

void NL3D::CPSTexturedParticle::newTextureIndexElement CPSLocated emitterLocated,
uint32  emitterIndex
[inline, protected]
 

Definition at line 485 of file ps_particle_basic.h.

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

Referenced by NL3D::CPSShockWave::newElement(), and NL3D::CPSQuad::newElement().

00486                 {
00487                         if (_TextureIndexScheme && _TextureIndexScheme->hasMemory()) _TextureIndexScheme->newElement(emitterLocated, emitterIndex);
00488                 }       

void NL3D::CPSTexturedParticle::resizeTextureIndex uint32  size  )  [inline, protected]
 

Definition at line 493 of file ps_particle_basic.h.

References _TextureIndexScheme, getTextureIndexOwner(), NL3D::CPSAttribMaker< sint32 >::hasMemory(), nlassert, NL3D::CPSAttribMaker< sint32 >::resize(), size, and uint32.

Referenced by NL3D::CPSShockWave::resize(), and NL3D::CPSQuad::resize().

00494                 {
00495                         nlassert(size < (1 << 16));
00496                         if (_TextureIndexScheme && _TextureIndexScheme->hasMemory()) _TextureIndexScheme->resize(size, getTextureIndexOwner()->getSize() );
00497                 }

void NL3D::CPSTexturedParticle::serialTextureScheme NLMISC::IStream f  )  throw (NLMISC::EStream)
 

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

Definition at line 372 of file ps_particle_basic.cpp.

00373 {
00374         f.serialVersion(1);     
00375         if (f.isReading())
00376         {
00377                 if (_TextureIndexScheme)
00378                 {
00379                         delete _TextureIndexScheme;
00380                         _TextureIndexScheme = NULL;                     
00381                         _Tex = NULL;
00382                         _TexGroup = NULL;
00383                 }
00384         }
00385 
00386         bool useAnimatedTexture;        
00387         if (!f.isReading())
00388         {
00389                 useAnimatedTexture = (_TexGroup != NULL);
00390         }
00391         f.serial(useAnimatedTexture);
00392         if (useAnimatedTexture)
00393         {
00394                 if (f.isReading())
00395                 {
00396                         CTextureGrouped *ptTex = NULL;
00397                         f.serialPolyPtr(ptTex);
00398                         _TexGroup = ptTex;
00399                 }
00400                 else
00401                 {
00402                         CTextureGrouped *ptTex = _TexGroup;
00403                         f.serialPolyPtr(ptTex);
00404                 }
00405                 
00406                 bool useTextureIndexScheme = _TextureIndexScheme != NULL;               
00407                 f.serial(useTextureIndexScheme);
00408                 if (useTextureIndexScheme)
00409                 {
00410                         f.serialPolyPtr(_TextureIndexScheme);
00411                         _TextureIndex = 0;                      
00412                 }
00413                 else
00414                 {                       
00415                         f.serial(_TextureIndex);
00416                 }
00417         }
00418         else
00419         {
00420                 if (f.isReading())
00421                 {
00422                         ITexture *ptTex = NULL;
00423                         f.serialPolyPtr(ptTex);
00424                         _Tex = ptTex;
00425                 }
00426                 else
00427                 {
00428                         ITexture *ptTex = _Tex;
00429                         f.serialPolyPtr(ptTex);
00430                 }
00431         }       
00432 }

void NL3D::CPSTexturedParticle::setTexture CSmartPtr< ITexture tex  ) 
 

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

Set a constant texture for the particle This discard any previous scheme

See also:
setTextureScheme()

Definition at line 349 of file ps_particle_basic.cpp.

References _TexGroup, _TextureIndexScheme, and updateMatAndVbForTexture().

Referenced by NL3D::CPSQuad::CPSQuad(), and NL3D::CPSShockWave::CPSShockWave().

00350 {       
00351         delete _TextureIndexScheme;
00352         _TextureIndexScheme = NULL;     
00353         _Tex = tex;
00354         _TexGroup = NULL; // release any grouped texture if one was set before
00355         updateMatAndVbForTexture();
00356 }

void NL3D::CPSTexturedParticle::setTextureGroup NLMISC::CSmartPtr< CTextureGrouped texGroup  ) 
 

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

Definition at line 337 of file ps_particle_basic.cpp.

References _TexGroup, nlassert, and updateMatAndVbForTexture().

00338 {
00339         nlassert(texGroup);
00340         if (_Tex)
00341         {
00342                 _Tex = NULL;
00343         }
00344         _TexGroup = texGroup;
00345         updateMatAndVbForTexture();
00346 }

void NL3D::CPSTexturedParticle::setTextureIndex sint32  index  ) 
 

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

Definition at line 329 of file ps_particle_basic.cpp.

References _TextureIndex, _TextureIndexScheme, index, and sint32.

00330 {       
00331         delete _TextureIndexScheme;     
00332         _TextureIndexScheme = NULL;     
00333         _TextureIndex = index;
00334 }

void NL3D::CPSTexturedParticle::setTextureIndexScheme CPSAttribMaker< sint32 > *  animOrder  ) 
 

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

Set an attribute maker that produce a sint32 It must have been allocated by new It will be deleted by this object a texture group must have been set before this, an assertion occurs otherwise The integer is used as an index in a grouped texture. It tells which frame to use

Definition at line 316 of file ps_particle_basic.cpp.

References _TexGroup, _TextureIndexScheme, getTextureIndexOwner(), nlassert, NL3D::CPSAttribMaker< T >::resize(), and updateMatAndVbForTexture().

00317 {
00318         nlassert(animOrder);
00319         nlassert(_TexGroup); // setTextureGroup must have been called before this       
00320         delete _TextureIndexScheme;             
00321         _TextureIndexScheme = animOrder;
00322         if (getTextureIndexOwner() && animOrder->hasMemory()) animOrder->resize(getTextureIndexOwner()->getMaxSize(), getTextureIndexOwner()->getSize());
00323 
00324 
00325         updateMatAndVbForTexture();
00326 }

virtual void NL3D::CPSTexturedParticle::updateMatAndVbForTexture void   )  [protected, pure virtual]
 

Update the material so that it match the texture scheme.

Implemented in NL3D::CPSQuad, and NL3D::CPSShockWave.

Referenced by setTexture(), setTextureGroup(), and setTextureIndexScheme().


Field Documentation

CSmartPtr<ITexture> NL3D::CPSTexturedParticle::_Tex [protected]
 

Definition at line 472 of file ps_particle_basic.h.

Referenced by NL3D::CPSFaceHelper::drawFaces().

CSmartPtr<CTextureGrouped> NL3D::CPSTexturedParticle::_TexGroup [protected]
 

Definition at line 475 of file ps_particle_basic.h.

Referenced by getTextureGroup(), setTexture(), setTextureGroup(), and setTextureIndexScheme().

sint32 NL3D::CPSTexturedParticle::_TextureIndex [protected]
 

Definition at line 480 of file ps_particle_basic.h.

Referenced by getTextureIndex(), and setTextureIndex().

CPSAttribMaker<sint32>* NL3D::CPSTexturedParticle::_TextureIndexScheme [protected]
 

Definition at line 477 of file ps_particle_basic.h.

Referenced by deleteTextureIndexElement(), getTextureIndexScheme(), newTextureIndexElement(), resizeTextureIndex(), setTexture(), setTextureIndex(), setTextureIndexScheme(), and ~CPSTexturedParticle().


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