NL3D::CPSAttribMakerT< T, F > Class Template Reference

#include <ps_attrib_maker_helper.h>

Inheritance diagram for NL3D::CPSAttribMakerT< T, F >:

NL3D::CPSAttribMaker< T > NL3D::CPSAttribMakerBase NLMISC::IStreamable NLMISC::IClassable NL3D::CPSValueBlender< NLMISC::CRGBA > NL3D::CPSValueBlenderSample< NLMISC::CRGBA, 64 > NL3D::CPSValueGradient< NLMISC::CRGBA >

Detailed Description

template<typename T, class F>
class NL3D::CPSAttribMakerT< T, F >

This template generate an attrib maker by defining the methods of the CPSCAttribMaker class. You can derive your own class but it is a shortcut to do the job
Parameters:
T : the type to produce
F : a class that override the () operator, the input is chosen by the user (age, speed ...) , and the output is the same type as T. Inline is preferable, as it will be called a lot It can stores info that indicate how to build it

Definition at line 51 of file ps_attrib_maker_helper.h.

Public Types

typedef F functor_type
 the type of the functor object

typedef T value_type
 the type of the attribute to be produced


Public Member Functions

virtual CPSAttribMakerBaseclone () const=0
 CPSAttribMakerT (float nbCycles)
virtual T get (float input)
virtual T get (CPSLocated *loc, uint32 index)
 compute one value of the attribute for the given index

virtual bool getClamping (void) const
virtual std::string getClassName ()=0
virtual CPSInputType getInput (void) const
virtual T getMaxValue (void) const
 get the min value, or an evalution that is guaranteed to be < to it (meaningful for ordered set only)

virtual T getMinValue (void) const
 get the max value, or an evalution that is guaranteed to be > to it (meaningful for ordered set only)

virtual bool hasCustomInput (void)
bool isClampingSupported (void) const
virtual void serial (NLMISC::IStream &f) throw (NLMISC::EStream)
 serialisation of the object

virtual void setClamping (bool enable=true)
virtual void setInput (const CPSInputType &input)
virtual ~CPSAttribMakerT ()
 dtor


Data Fields

_F
 the functor object


Protected Attributes

bool _HasMemory
float _NbCycles

Private Member Functions

void * make (CPSLocated *loc, uint32 startIndex, void *tab, uint32 stride, uint32 numAttrib, bool allowNoCopy, uint32 srcStep) const
void make4 (CPSLocated *loc, uint32 startIndex, void *tab, uint32 stride, uint32 numAttrib, uint32 srcStep) const
template<typename It> void make4ByIterator (It it, void *tab, uint32 stride, uint32 numAttrib, bool canOverlapOne) const
template<typename It> void makeByIterator (It it, void *tab, uint32 stride, uint32 numAttrib, bool canOverlapOne) const
virtual void makeN (CPSLocated *loc, uint32 startIndex, void *tab, uint32 stride, uint32 numAttrib, uint32 nbReplicate, uint32 srcStep) const
template<typename It> void makeNByIterator (It it, void *tab, uint32 stride, uint32 numAttrib, uint32 nbReplicate, bool canOverlapOne) const

Private Attributes

bool _Clamp
CPSInputType _InputType


Member Typedef Documentation

template<typename T, class F>
typedef F NL3D::CPSAttribMakerT< T, F >::functor_type
 

the type of the functor object

Definition at line 174 of file ps_attrib_maker_helper.h.

template<typename T, class F>
typedef T NL3D::CPSAttribMakerT< T, F >::value_type
 

the type of the attribute to be produced

Definition at line 171 of file ps_attrib_maker_helper.h.


Constructor & Destructor Documentation

template<typename T, class F>
NL3D::CPSAttribMakerT< T, F >::CPSAttribMakerT float  nbCycles  )  [inline]
 

construct the attrib maker specifying the number of cycles to do.

See also:
setNbCycles()

Definition at line 128 of file ps_attrib_maker_helper.h.

00128                                                 : CPSAttribMaker<T>(nbCycles)
00129                                                                                   , _Clamp(false)
00130                 {}

template<typename T, class F>
virtual NL3D::CPSAttribMakerT< T, F >::~CPSAttribMakerT  )  [inline, virtual]
 

dtor

Definition at line 133 of file ps_attrib_maker_helper.h.

00133 {}


Member Function Documentation

virtual CPSAttribMakerBase* NL3D::CPSAttribMakerBase::clone  )  const [pure virtual, inherited]
 

Implemented in NL3D::CPSColorBlenderExact, NL3D::CPSColorBlender, NL3D::CPSColorGradient, NL3D::CPSColorMemory, NL3D::CPSColorBinOp, NL3D::CPSFloatBlender, NL3D::CPSFloatGradient, NL3D::CPSFloatMemory, NL3D::CPSFloatBinOp, NL3D::CPSFloatCurve, NL3D::CPSIntBlender, NL3D::CPSUIntBlender, NL3D::CPSIntGradient, NL3D::CPSUIntGradient, NL3D::CPSIntMemory, NL3D::CPSUIntMemory, NL3D::CPSIntBinOp, NL3D::CPSUIntBinOp, NL3D::CPSPlaneBasisBlender, NL3D::CPSPlaneBasisGradient, NL3D::CPSPlaneBasisFollowSpeed, NL3D::CPSPlaneBasisMemory, NL3D::CPSPlaneBasisBinOp, and NL3D::CPSBasisSpinner.

template<typename T>
virtual void NL3D::CPSAttribMaker< T >::deleteElement uint32  index  )  [inline, virtual, inherited]
 

delete an element, given its index. this must be called only if memory management is used.

Reimplemented in NL3D::CPSAttribMakerBinOp< T >, NL3D::CPSAttribMakerMemoryBase< T >, NL3D::CPSAttribMakerBinOp< float >, NL3D::CPSAttribMakerBinOp< CPlaneBasis >, NL3D::CPSAttribMakerBinOp< uint32 >, NL3D::CPSAttribMakerBinOp< NLMISC::CRGBA >, NL3D::CPSAttribMakerBinOp< sint32 >, NL3D::CPSAttribMakerMemoryBase< float >, NL3D::CPSAttribMakerMemoryBase< CPlaneBasis >, NL3D::CPSAttribMakerMemoryBase< NLMISC::CRGBA >, NL3D::CPSAttribMakerMemoryBase< uint32 >, and NL3D::CPSAttribMakerMemoryBase< sint32 >.

Definition at line 285 of file ps_attrib_maker.h.

00285 { nlassert(false) ; }

template<typename T, class F>
virtual T NL3D::CPSAttribMakerT< T, F >::get float  input  )  [inline, virtual]
 

Direct lookup of the result value from a float input (if it makes sense). This bypass what was set with setInput The input must be in [0, 1[

Reimplemented from NL3D::CPSAttribMaker< T >.

Definition at line 60 of file ps_attrib_maker_helper.h.

00061                 {
00062                         NLMISC::OptFastFloorBegin();
00063                         nlassert(input >= 0.f && input <= 1.f);
00064                         return _F(input);
00065                         NLMISC::OptFastFloorEnd();
00066                 }

template<typename T, class F>
T NL3D::CPSAttribMakerT< T, F >::get CPSLocated loc,
uint32  index
[virtual]
 

compute one value of the attribute for the given index

Implements NL3D::CPSAttribMaker< T >.

Definition at line 1172 of file ps_attrib_maker_helper.h.

References NL3D::CPSAttribMakerT< T, F >::_Clamp, NL3D::CPSAttribMakerT< T, F >::_F, NL3D::CPSAttribMakerT< T, F >::_InputType, NL3D::CPSLocated::getInvMass(), NL3D::CPSLocated::getLODVect(), NL3D::CParticleSystemProcess::getMatrixMode(), NL3D::CPSLocated::getPos(), NL3D::CPSLocated::getSpeed(), NL3D::CPSLocated::getTime(), NL3D::CPSLocated::getUserParam(), index, NL3D::CPSInputType::InputType, NL3D::MaxInputValue, nlassert, NLMISC::OptFastFloorBegin(), NLMISC::OptFastFloorEnd(), r, uint32, NL3D::CPSInputType::UserParamNum, and v.

01173 {       
01174         NLMISC::OptFastFloorBegin();
01175         T result;
01176         nlassert(loc);
01177         switch (_InputType.InputType)
01178         {
01179                 case CPSInputType::attrDate:    
01180                 {
01181                         float v = _NbCycles * loc->getTime()[index];
01182                         if (_Clamp)
01183                         {
01184                                 if (v > MaxInputValue) v = MaxInputValue;
01185                         }
01186 
01187                         result = _F(NLMISC::OptFastFractionnalPart(v));
01188                 }
01189                 break;
01190                 case CPSInputType::attrInverseMass:     
01191                 {
01192                         float v = _NbCycles * loc->getInvMass()[index];
01193                         if (_Clamp)
01194                         {
01195                                 if (v > MaxInputValue) v = MaxInputValue;
01196                         }
01197                         result =  _F(NLMISC::OptFastFractionnalPart(v));
01198                 }
01199                 break;          
01200                 case CPSInputType::attrSpeed:   
01201                 {
01202                         float v = _NbCycles * loc->getSpeed()[index].norm();
01203                         if (_Clamp)
01204                         {
01205                                 if (v > MaxInputValue) v = MaxInputValue;
01206                         }
01207                         result = _F(NLMISC::OptFastFractionnalPart(v));
01208                 }
01209                 break;
01210 
01211                 case CPSInputType::attrPosition:        
01212                 {
01213                         float v = _NbCycles * loc->getPos()[index].norm();
01214                         if (_Clamp)
01215                         {
01216                                 if (v > MaxInputValue) v = MaxInputValue;
01217                         }
01218                         result = _F(NLMISC::OptFastFractionnalPart(v));
01219                 }
01220                 break;
01221                 case CPSInputType::attrUniformRandom:   
01222                 {
01223                         result =  _F(float(rand() * (1 / double(RAND_MAX))));
01224                 }
01225                 break;
01226                 case CPSInputType::attrUserParam:
01227                 {                       
01228                         float v = _NbCycles * loc->getUserParam(_InputType.UserParamNum); 
01229                         if (_Clamp)
01230                         {
01231                                 if (v > MaxInputValue) v = MaxInputValue;
01232                         }
01233                         result = _F(v);
01234                 }
01235                 break;
01236                 case CPSInputType::attrLOD:
01237                 {       
01238                         static NLMISC::CVector lodVect;
01239                         float lodOffset;                        
01240                         loc->getLODVect(lodVect, lodOffset, loc->getMatrixMode());
01241                         float r = fabsf(loc->getPos()[index] * lodVect + lodOffset);
01242                         r = _NbCycles * r > MaxInputValue ? MaxInputValue : r;                  
01243                         if (_Clamp)
01244                         {
01245                                 result = _F(r > MaxInputValue ? MaxInputValue : r);
01246                         }
01247                         else result = _F(r - uint32(r));                                                
01248                 }
01249                 break;
01250                 case CPSInputType::attrSquareLOD:
01251                 {       
01252                         static NLMISC::CVector lodVect;
01253                         float lodOffset;                        
01254                         loc->getLODVect(lodVect, lodOffset, loc->getMatrixMode());                                              
01255                         float r = loc->getPos()[index] * lodVect + lodOffset;
01256                         r = _NbCycles * (r > MaxInputValue ? MaxInputValue : r * r);
01257 
01258                         if (_Clamp)
01259                         {
01260                                 result = _F(r > MaxInputValue ? MaxInputValue : r);
01261                         }
01262                         else result = _F(r - uint32(r));                                                
01263                 }
01264                 break;
01265                 case CPSInputType::attrClampedLOD:
01266                 {       
01267                         static NLMISC::CVector lodVect;
01268                         float lodOffset;                        
01269                         loc->getLODVect(lodVect, lodOffset, loc->getMatrixMode());
01270 
01271                         float r = loc->getPos()[index] * lodVect + lodOffset;
01272                         if (r < 0) 
01273                         {
01274                                 result = _F(MaxInputValue);
01275                                 break;
01276                         }
01277                         r = _NbCycles * (r > MaxInputValue ? MaxInputValue : r);                                                                        
01278                         if (_Clamp)
01279                         {
01280                                 result = _F(r > MaxInputValue ? MaxInputValue : r);
01281                         }
01282                         else result = _F(r - uint32(r));                                                
01283                 }
01284                 break;
01285                 case CPSInputType::attrClampedSquareLOD:
01286                 {       
01287                         static NLMISC::CVector lodVect;
01288                         float lodOffset;                        
01289                         loc->getLODVect(lodVect, lodOffset, loc->getMatrixMode());
01290 
01291                         float r = loc->getPos()[index] * lodVect + lodOffset;
01292                         if (r < 0) 
01293                         {
01294                                 result = _F(MaxInputValue);
01295                                 break; 
01296                         }
01297                         r = _NbCycles * (r > MaxInputValue ? MaxInputValue : r * r);                                                                    
01298                         if (_Clamp)
01299                         {
01300                                 result = _F(r > MaxInputValue ? MaxInputValue : r);
01301                         }
01302                         else result = _F(r - uint32(r));                                                
01303                 }
01304                 break;  
01305                 default:
01306                         result = T();
01307                 break;          
01308         }
01309 
01310         NLMISC::OptFastFloorEnd();
01311         return result;
01312         
01313 }

template<typename T, class F>
virtual bool NL3D::CPSAttribMakerT< T, F >::getClamping void   )  const [inline, virtual]
 

Test if the clamping is enabled.

See also:
isClampingSupported()

Reimplemented from NL3D::CPSAttribMaker< T >.

Definition at line 167 of file ps_attrib_maker_helper.h.

00167 { return _Clamp; };

virtual std::string NLMISC::IClassable::getClassName  )  [pure virtual, inherited]
 

Implemented in NLAIAGENT::CNumericIndex, NLAIC::IPointerGestion, NLAIC::CIdentType, and CAutomataDesc.

Referenced by NLMISC::CClassRegistry::checkObject(), and NL3D::GetTextureSize().

template<typename T, class F>
virtual CPSInputType NL3D::CPSAttribMakerT< T, F >::getInput void   )  const [inline, virtual]
 

get the type of input (if supported). The default return attrDate

See also:
hasCustomInput()

Reimplemented from NL3D::CPSAttribMaker< T >.

Definition at line 150 of file ps_attrib_maker_helper.h.

00150 { return _InputType; }

template<typename T>
virtual T NL3D::CPSAttribMaker< T >::getMaxValue void   )  const [inline, virtual, inherited]
 

get the min value, or an evalution that is guaranteed to be < to it (meaningful for ordered set only)

Reimplemented in NL3D::CPSAttribMakerBinOp< T >, NL3D::CPSAttribMakerMemory< uint32 >, NL3D::CPSAttribMakerMemory< sint32 >, NL3D::CPSAttribMakerMemory< float >, NL3D::CPSValueBlender< T >, NL3D::CPSValueBlenderSample< T, n >, NL3D::CPSValueGradient< T >, NL3D::CPSFloatCurve, NL3D::CPSAttribMakerBinOp< float >, NL3D::CPSAttribMakerBinOp< CPlaneBasis >, NL3D::CPSAttribMakerBinOp< uint32 >, NL3D::CPSAttribMakerBinOp< NLMISC::CRGBA >, NL3D::CPSAttribMakerBinOp< sint32 >, NL3D::CPSValueBlender< float >, NL3D::CPSValueBlender< CPlaneBasis >, NL3D::CPSValueBlender< uint32 >, NL3D::CPSValueBlender< NLMISC::CRGBA >, NL3D::CPSValueBlender< sint32 >, NL3D::CPSValueBlenderSample< NLMISC::CRGBA, 64 >, NL3D::CPSValueGradient< float >, NL3D::CPSValueGradient< CPlaneBasis >, NL3D::CPSValueGradient< NLMISC::CRGBA >, NL3D::CPSValueGradient< uint32 >, and NL3D::CPSValueGradient< sint32 >.

Definition at line 217 of file ps_attrib_maker.h.

00217 { return T() ; /* no mean by default */ }

template<typename T>
virtual T NL3D::CPSAttribMaker< T >::getMinValue void   )  const [inline, virtual, inherited]
 

get the max value, or an evalution that is guaranteed to be > to it (meaningful for ordered set only)

Reimplemented in NL3D::CPSAttribMakerBinOp< T >, NL3D::CPSAttribMakerMemory< uint32 >, NL3D::CPSAttribMakerMemory< sint32 >, NL3D::CPSAttribMakerMemory< float >, NL3D::CPSValueBlender< T >, NL3D::CPSValueBlenderSample< T, n >, NL3D::CPSValueGradient< T >, NL3D::CPSFloatCurve, NL3D::CPSAttribMakerBinOp< float >, NL3D::CPSAttribMakerBinOp< CPlaneBasis >, NL3D::CPSAttribMakerBinOp< uint32 >, NL3D::CPSAttribMakerBinOp< NLMISC::CRGBA >, NL3D::CPSAttribMakerBinOp< sint32 >, NL3D::CPSValueBlender< float >, NL3D::CPSValueBlender< CPlaneBasis >, NL3D::CPSValueBlender< uint32 >, NL3D::CPSValueBlender< NLMISC::CRGBA >, NL3D::CPSValueBlender< sint32 >, NL3D::CPSValueBlenderSample< NLMISC::CRGBA, 64 >, NL3D::CPSValueGradient< float >, NL3D::CPSValueGradient< CPlaneBasis >, NL3D::CPSValueGradient< NLMISC::CRGBA >, NL3D::CPSValueGradient< uint32 >, and NL3D::CPSValueGradient< sint32 >.

Definition at line 215 of file ps_attrib_maker.h.

00215 { return T() ; /* no mean by default */ }

template<typename T>
float NL3D::CPSAttribMaker< T >::getNbCycles void   )  const [inline, inherited]
 

Retrieve the number of cycles

See also:
setNbCycles()

Definition at line 236 of file ps_attrib_maker.h.

00236 { return _NbCycles ; }

template<typename T>
virtual const char* NL3D::CPSAttribMaker< T >::getType  )  [inline, virtual, inherited]
 

inherited from CPSAttribMakerBase. Template specialization will do the job

Implements NL3D::CPSAttribMakerBase.

Definition at line 147 of file ps_attrib_maker.h.

00147 { return "UNKNOWN"; }

template<typename T, class F>
virtual bool NL3D::CPSAttribMakerT< T, F >::hasCustomInput void   )  [inline, virtual]
 

tells wether one may choose one attribute from a CPSLocated to use as an input. If false, the input(s) is fixed For this class, it is supported

Reimplemented from NL3D::CPSAttribMaker< T >.

Definition at line 139 of file ps_attrib_maker_helper.h.

00139 { return true; } 

template<typename T>
bool NL3D::CPSAttribMaker< T >::hasMemory void   )  const [inline, inherited]
 

Some attribute makers may hold memory. this return true when this is the case. This also mean that you must call newElement, deleteElement, and resize, when it is called for the owning object (which is likely to be a CPSLocatedBindable)

Definition at line 282 of file ps_attrib_maker.h.

Referenced by NL3D::CPSLocated::setLifeScheme(), and NL3D::CPSLocated::setMassScheme().

00282 { return _HasMemory ; }

template<typename T, class F>
bool NL3D::CPSAttribMakerT< T, F >::isClampingSupported void   )  const [inline, virtual]
 

tells wether clamping is supported for the input (value can't go above MaxInputValue)

Reimplemented from NL3D::CPSAttribMaker< T >.

Definition at line 155 of file ps_attrib_maker_helper.h.

00155 { return true; }

template<typename T, class F>
void* NL3D::CPSAttribMakerT< T, F >::make CPSLocated loc,
uint32  startIndex,
void *  tab,
uint32  stride,
uint32  numAttrib,
bool  allowNoCopy,
uint32  srcStep
const [inline, private, virtual]
 

Fill tab with an attribute by using the given stride. It fills numAttrib attributes.

Parameters:
loc the 'located' that hold the 'located bindable' that need an attribute to be filled
startIndex usually 0, it gives the index of the first element in the located (is it multiplied by the step)
tab where the data will be written
stride the stride, in byte, between each value to write
numAttrib the number of attributes to compute
allowNoCopy data may be already present in memory, and may not need computation. When set to true, this allow no computation to be made the return parameter is then le location of the datas. this may be tab (if recomputation where needed), or another value for this to work, the stride must most of the time be sizeof(T). This is intended to be used with derivers of CPSAttribMaker that store values that do not depend on the input. The make method then just copy the data, we is sometime useless
srcStep A fixed-point 16:16 value that gives the step for the source iterator
Returns:
where the data have been copied, this is always tab, unless allowNoCopy is set to true, in which case this may be different

Implements NL3D::CPSAttribMaker< T >.

Definition at line 596 of file ps_attrib_maker_helper.h.

00604                         {
00605 
00606                                 NLMISC::OptFastFloorBegin();
00607                                 nlassert(loc);
00608 
00609                                 if (srcStep == (1 << 16))
00610                                 {                                       
00611                                         switch (_InputType.InputType)
00612                                         {
00613                                                 case CPSInputType::attrDate:    
00614                                                 {
00615                                                         CPSBaseIterator<TIteratorFloatStep1> 
00616                                                                 it(TIteratorFloatStep1(loc->getTime().begin(), startIndex));
00617                                                         makeByIterator(it, tab, stride, numAttrib, loc->getLastForever());
00618                                                 }
00619                                                 break;
00620                                                 case CPSInputType::attrInverseMass:     
00621                                                 {
00622                                                         CPSBaseIterator<TIteratorFloatStep1> 
00623                                                                 it(TIteratorFloatStep1(loc->getInvMass().begin() , startIndex));
00624                                                         makeByIterator(it, tab, stride, numAttrib, true);
00625                                                 }
00626                                                 break;          
00627                                                 case CPSInputType::attrSpeed:   
00628                                                 {
00629                                                         CVectNormIterator<TIteratorVectStep1> 
00630                                                                 it(TIteratorVectStep1(loc->getSpeed().begin(), startIndex));
00631                                                         makeByIterator(it, tab, stride, numAttrib, true);
00632                                                 }
00633                                                 break;
00634 
00635                                                 case CPSInputType::attrPosition:        
00636                                                 {
00637                                                         CVectNormIterator<TIteratorVectStep1> 
00638                                                                 it( TIteratorVectStep1(loc->getPos().begin(), startIndex) );
00639                                                         makeByIterator(it, tab, stride, numAttrib, true);
00640                                                 }
00641                                                 break;
00642                                                 case CPSInputType::attrUniformRandom:   
00643                                                 {
00644                                                         CRandomIterator it;
00645                                                         makeByIterator(it, tab, stride, numAttrib, true);
00646                                                 }
00647                                                 break;
00648                                                 case CPSInputType::attrUserParam:
00649                                                 {                       
00650                                                         CDecalIterator it;
00651                                                         it.Value = loc->getUserParam(_InputType.UserParamNum); 
00652                                                         makeByIterator(it, tab, stride, numAttrib, false);
00653                                                 }
00654                                                 break;
00655                                                 case CPSInputType::attrLOD:
00656                                                 {       
00657                                                         
00658                                                         CFDot3AddIterator<TIteratorVectStep1> 
00659                                                                 it(TIteratorVectStep1(loc->getPos().begin(), startIndex));
00660                                                         loc->getLODVect(it.V, it.Offset, loc->getMatrixMode());                 
00661                                                         makeByIterator(it, tab, stride, numAttrib, false);
00662                                                 }
00663                                                 break;  
00664                                                 case CPSInputType::attrSquareLOD:
00665                                                 {       
00666                                                         
00667                                                         CFSquareDot3AddIterator<TIteratorVectStep1> 
00668                                                                 it(TIteratorVectStep1(loc->getPos().begin(), startIndex));
00669                                                         loc->getLODVect(it.V, it.Offset, loc->getMatrixMode());                 
00670                                                         makeByIterator(it, tab, stride, numAttrib, false);
00671                                                 }
00672                                                 break;  
00673                                                 case CPSInputType::attrClampedLOD:
00674                                                 {       
00675                                                         
00676                                                         CFClampDot3AddIterator<TIteratorVectStep1> 
00677                                                                 it(TIteratorVectStep1(loc->getPos().begin(), startIndex));
00678                                                         loc->getLODVect(it.V, it.Offset, loc->getMatrixMode());                 
00679                                                         makeByIterator(it, tab, stride, numAttrib, false);
00680                                                 }
00681                                                 break;
00682                                                 case CPSInputType::attrClampedSquareLOD:
00683                                                 {       
00684                                                         
00685                                                         CFClampSquareDot3AddIterator<TIteratorVectStep1> 
00686                                                                 it(TIteratorVectStep1(loc->getPos().begin(), startIndex));
00687                                                         loc->getLODVect(it.V, it.Offset, loc->getMatrixMode());                 
00688                                                         makeByIterator(it, tab, stride, numAttrib, false);
00689                                                 }
00690                                                 break;
00691                                         }
00692 
00693                                         NLMISC::OptFastFloorEnd();
00694                                         // we must alway copy the data there ...
00695                                         return tab;
00696                                 }
00697                                 else // fixed point steps
00698                                 {
00699                                         switch (_InputType.InputType)
00700                                         {
00701                                                 case CPSInputType::attrDate:    
00702                                                 {
00703                                                         CPSBaseIterator<TIteratorFloatStep1616> 
00704                                                                 it(TIteratorFloatStep1616(loc->getTime().begin(), startIndex, srcStep));
00705                                                         makeByIterator(it, tab, stride, numAttrib, loc->getLastForever());
00706                                                 }
00707                                                 break;
00708                                                 case CPSInputType::attrInverseMass:     
00709                                                 {
00710                                                         CPSBaseIterator<TIteratorFloatStep1616> 
00711                                                                 it( TIteratorFloatStep1616(loc->getInvMass().begin(), startIndex, srcStep));
00712                                                         makeByIterator(it, tab, stride, numAttrib, true);
00713                                                 }
00714                                                 break;          
00715                                                 case CPSInputType::attrSpeed:   
00716                                                 {
00717                                                         CVectNormIterator<TIteratorVectStep1616> 
00718                                                                 it( TIteratorVectStep1616(loc->getSpeed().begin(), startIndex, srcStep) );
00719                                                         makeByIterator(it, tab, stride, numAttrib, true);
00720                                                 }
00721                                                 break;
00722 
00723                                                 case CPSInputType::attrPosition:        
00724                                                 {
00725                                                         CVectNormIterator<TIteratorVectStep1616> 
00726                                                                 it( TIteratorVectStep1616(loc->getPos().begin(), startIndex, srcStep) );
00727                                                         makeByIterator(it, tab, stride, numAttrib, true);
00728                                                 }
00729                                                 break;
00730                                                 case CPSInputType::attrUniformRandom:   
00731                                                 {
00732                                                         CRandomIterator it;
00733                                                         makeByIterator(it, tab, stride, numAttrib, true);
00734                                                 }
00735                                                 break;
00736                                                 case CPSInputType::attrUserParam:
00737                                                 {                       
00738                                                         CDecalIterator it;
00739                                                         it.Value = loc->getUserParam(_InputType.UserParamNum); 
00740                                                         makeByIterator(it, tab, stride, numAttrib, false);
00741                                                 }
00742                                                 break;
00743                                                 case CPSInputType::attrLOD:
00744                                                 {       
00745                                                         
00746                                                         CFDot3AddIterator<TIteratorVectStep1616> 
00747                                                                 it( TIteratorVectStep1616(loc->getPos().begin(), startIndex, srcStep) );
00748                                                         loc->getLODVect(it.V, it.Offset, loc->getMatrixMode());                 
00749                                                         makeByIterator(it, tab, stride, numAttrib, false);
00750                                                 }
00751                                                 break;  
00752                                                 case CPSInputType::attrSquareLOD:
00753                                                 {       
00754                                                         
00755                                                         CFSquareDot3AddIterator<TIteratorVectStep1616> 
00756                                                                 it( TIteratorVectStep1616(loc->getPos().begin(), startIndex, srcStep) );
00757                                                         loc->getLODVect(it.V, it.Offset, loc->getMatrixMode());                 
00758                                                         makeByIterator(it, tab, stride, numAttrib, false);
00759                                                 }
00760                                                 break;  
00761                                                 case CPSInputType::attrClampedLOD:
00762                                                 {       
00763                                                         
00764                                                         CFClampDot3AddIterator<TIteratorVectStep1616> 
00765                                                                 it( TIteratorVectStep1616(loc->getPos().begin(), startIndex, srcStep) );
00766                                                         loc->getLODVect(it.V, it.Offset, loc->getMatrixMode());                 
00767                                                         makeByIterator(it, tab, stride, numAttrib, false);
00768                                                 }
00769                                                 break;
00770                                                 case CPSInputType::attrClampedSquareLOD:
00771                                                 {       
00772                                                         
00773                                                         CFClampSquareDot3AddIterator<TIteratorVectStep1616> 
00774                                                                 it( TIteratorVectStep1616(loc->getPos().begin(), startIndex, srcStep) );
00775                                                         loc->getLODVect(it.V, it.Offset, loc->getMatrixMode());                 
00776                                                         makeByIterator(it, tab, stride, numAttrib, false);
00777                                                 }
00778                                                 break;
00779                                         }
00780 
00781                                         NLMISC::OptFastFloorEnd();
00782                                         // we must alway copy the data there ...
00783                                         return tab;
00784                                 }
00785                         }

template<typename T, class F>
void NL3D::CPSAttribMakerT< T, F >::make4 CPSLocated loc,
uint32  startIndex,
void *  tab,
uint32  stride,
uint32  numAttrib,
uint32  srcStep
const [inline, private, virtual]
 

The same as make, but it replicate each attribute 4 times, thus filling 4*numAttrib. Useful for facelookat and the like

See also:
make()

Implements NL3D::CPSAttribMaker< T >.

Definition at line 790 of file ps_attrib_maker_helper.h.

00797                         {
00798                                 NLMISC::OptFastFloorBegin();
00799                                 nlassert(loc);
00800 
00801                                 if (srcStep == (1 << 16))
00802                                 {
00803                                         switch (_InputType.InputType)
00804                                         {
00805                                                 case CPSInputType::attrDate:    
00806                                                 {
00807                                                         CPSBaseIterator<TIteratorFloatStep1> 
00808                                                                 it(TIteratorFloatStep1( loc->getTime().begin(), startIndex) );
00809                                                         make4ByIterator(it, tab, stride, numAttrib, loc->getLastForever());
00810                                                 }
00811                                                 break;
00812                                                 case CPSInputType::attrInverseMass:     
00813                                                 {
00814                                                         CPSBaseIterator<TIteratorFloatStep1> 
00815                                                                 it( TIteratorFloatStep1(loc->getInvMass().begin(), startIndex) );
00816                                                         make4ByIterator(it, tab, stride, numAttrib, true);
00817                                                 }
00818                                                 break;          
00819                                                 case CPSInputType::attrSpeed:   
00820                                                 {
00821                                                         CVectNormIterator<TIteratorVectStep1> 
00822                                                                 it( TIteratorVectStep1(loc->getSpeed().begin(), startIndex) );
00823                                                         make4ByIterator(it, tab, stride, numAttrib, true);
00824                                                 }
00825                                                 break;
00826 
00827                                                 case CPSInputType::attrPosition:        
00828                                                 {
00829                                                         CVectNormIterator<TIteratorVectStep1> 
00830                                                                 it( TIteratorVectStep1(loc->getPos().begin() , startIndex) );
00831                                                         make4ByIterator(it, tab, stride, numAttrib, true);
00832                                                 }
00833                                                 break;
00834                                                 case CPSInputType::attrUniformRandom:   
00835                                                 {
00836                                                         CRandomIterator it;
00837                                                         make4ByIterator(it, tab, stride, numAttrib, true);
00838                                                 }
00839                                                 break;
00840                                                 case CPSInputType::attrUserParam:
00841                                                 {                       
00842                                                         CDecalIterator it;
00843                                                         it.Value = loc->getUserParam(_InputType.UserParamNum); 
00844                                                         make4ByIterator(it, tab, stride, numAttrib, false);
00845                                                 }
00846                                                 break;
00847                                                 case CPSInputType::attrLOD:
00848                                                 {       
00849                                                         
00850                                                         CFDot3AddIterator<TIteratorVectStep1> 
00851                                                                 it(TIteratorVectStep1(loc->getPos().begin(), startIndex) );
00852                                                         loc->getLODVect(it.V, it.Offset, loc->getMatrixMode());                 
00853                                                         make4ByIterator(it, tab, stride, numAttrib, false);
00854                                                 }
00855                                                 break;  
00856                                                 case CPSInputType::attrSquareLOD:
00857                                                 {       
00858                                                         
00859                                                         CFSquareDot3AddIterator<TIteratorVectStep1> 
00860                                                                 it(TIteratorVectStep1(loc->getPos().begin(), startIndex));
00861                                                         loc->getLODVect(it.V, it.Offset, loc->getMatrixMode());                 
00862                                                         make4ByIterator(it, tab, stride, numAttrib, false);
00863                                                 }
00864                                                 break;  
00865                                                 case CPSInputType::attrClampedLOD:
00866                                                 {       
00867                                                         
00868                                                         CFClampDot3AddIterator<TIteratorVectStep1> 
00869                                                                 it(TIteratorVectStep1(loc->getPos().begin(), startIndex));
00870                                                         loc->getLODVect(it.V, it.Offset, loc->getMatrixMode());                 
00871                                                         make4ByIterator(it, tab, stride, numAttrib, false);
00872                                                 }
00873                                                 break;
00874                                                 case CPSInputType::attrClampedSquareLOD:
00875                                                 {       
00876                                                         
00877                                                         CFClampSquareDot3AddIterator<TIteratorVectStep1> 
00878                                                                 it(TIteratorVectStep1(loc->getPos().begin(), startIndex));
00879                                                         loc->getLODVect(it.V, it.Offset, loc->getMatrixMode());                 
00880                                                         make4ByIterator(it, tab, stride, numAttrib, false);
00881                                                 }
00882                                                 break;
00883                                         }
00884 
00885                                         NLMISC::OptFastFloorEnd();
00886                                 }
00887                                 else // fixed point steps
00888                                 {
00889                                         switch (_InputType.InputType)
00890                                         {
00891                                                 case CPSInputType::attrDate:    
00892                                                 {
00893                                                         CPSBaseIterator<TIteratorFloatStep1616> 
00894                                                                 it(TIteratorFloatStep1616(loc->getTime().begin(), startIndex, srcStep));
00895                                                         make4ByIterator(it, tab, stride, numAttrib, loc->getLastForever());
00896                                                 }
00897                                                 break;
00898                                                 case CPSInputType::attrInverseMass:     
00899                                                 {
00900                                                         CPSBaseIterator<TIteratorFloatStep1616> 
00901                                                                 it( TIteratorFloatStep1616(loc->getInvMass().begin() , startIndex, srcStep));
00902                                                         make4ByIterator(it, tab, stride, numAttrib, true);
00903                                                 }
00904                                                 break;          
00905                                                 case CPSInputType::attrSpeed:   
00906                                                 {
00907                                                         CVectNormIterator<TIteratorVectStep1616> 
00908                                                                 it( TIteratorVectStep1616(loc->getSpeed().begin(), startIndex, srcStep) );
00909                                                         make4ByIterator(it, tab, stride, numAttrib, true);
00910                                                 }
00911                                                 break;
00912 
00913                                                 case CPSInputType::attrPosition:        
00914                                                 {
00915                                                         CVectNormIterator<TIteratorVectStep1616> 
00916                                                                 it( TIteratorVectStep1616(loc->getPos().begin() , startIndex, srcStep) );
00917                                                         make4ByIterator(it, tab, stride, numAttrib, true);
00918                                                 }
00919                                                 break;
00920                                                 case CPSInputType::attrUniformRandom:   
00921                                                 {
00922                                                         CRandomIterator it;
00923                                                         make4ByIterator(it, tab, stride, numAttrib, true);
00924                                                 }
00925                                                 break;
00926                                                 case CPSInputType::attrUserParam:
00927                                                 {                       
00928                                                         CDecalIterator it;
00929                                                         it.Value = loc->getUserParam(_InputType.UserParamNum); 
00930                                                         make4ByIterator(it, tab, stride, numAttrib, false);
00931                                                 }
00932                                                 break;
00933                                                 case CPSInputType::attrLOD:
00934                                                 {       
00935                                                         
00936                                                         CFDot3AddIterator<TIteratorVectStep1616> 
00937                                                                 it( TIteratorVectStep1616(loc->getPos().begin(), startIndex, srcStep) );
00938                                                         loc->getLODVect(it.V, it.Offset, loc->getMatrixMode());                 
00939                                                         make4ByIterator(it, tab, stride, numAttrib, false);
00940                                                 }
00941                                                 break;  
00942                                                 case CPSInputType::attrSquareLOD:
00943                                                 {       
00944                                                         
00945                                                         CFSquareDot3AddIterator<TIteratorVectStep1616> 
00946                                                                 it( TIteratorVectStep1616(loc->getPos().begin(), startIndex, srcStep) );
00947                                                         loc->getLODVect(it.V, it.Offset, loc->getMatrixMode());                 
00948                                                         make4ByIterator(it, tab, stride, numAttrib, false);
00949                                                 }
00950                                                 break;  
00951                                                 case CPSInputType::attrClampedLOD:
00952                                                 {       
00953                                                         
00954                                                         CFClampDot3AddIterator<TIteratorVectStep1616> 
00955                                                                 it( TIteratorVectStep1616(loc->getPos().begin(), startIndex, srcStep) );
00956                                                         loc->getLODVect(it.V, it.Offset, loc->getMatrixMode());                 
00957                                                         make4ByIterator(it, tab, stride, numAttrib, false);
00958                                                 }
00959                                                 break;
00960                                                 case CPSInputType::attrClampedSquareLOD:
00961                                                 {       
00962                                                         
00963                                                         CFClampSquareDot3AddIterator<TIteratorVectStep1616> 
00964                                                                 it( TIteratorVectStep1616(loc->getPos().begin(), startIndex, srcStep) );
00965                                                         loc->getLODVect(it.V, it.Offset, loc->getMatrixMode());                 
00966                                                         make4ByIterator(it, tab, stride, numAttrib, false);
00967                                                 }
00968                                                 break;
00969                                         }
00970 
00971                                         NLMISC::OptFastFloorEnd();
00972                                 
00973                                 }
00974                         }

template<typename T, class F>
template<typename It>
void NL3D::CPSAttribMakerT< T, F >::make4ByIterator It  it,
void *  tab,
uint32  stride,
uint32  numAttrib,
bool  canOverlapOne
const [inline, private]
 

The same as make, but it replicate each attribute 4 times, thus filling 4*numAttrib. Useful for facelookat and the like

Parameters:
canOverlapOne must be true if the entry iterator can give values above 1
See also:
makeByIterator()

Definition at line 293 of file ps_attrib_maker_helper.h.

Referenced by NL3D::CPSAttribMakerT< uint32, CPSValueBlendFunc< uint32 > >::make4().

00298                  {
00299                         
00300 
00301                         uint8 *pt = (uint8 *) tab;
00302 
00303 
00304                         // first precompute the various strides (stride * 2, 3 and 4)
00305                         // const uint32 stride2 = stride << 1, stride3 = stride + stride2, stride4 = stride2 << 1;
00306 
00307                         const uint32 stride2 = stride << 1;
00308 
00309                         if (_NbCycles > 1 || canOverlapOne)
00310                         {
00311                                 
00312                                 if (!_Clamp)
00313                                 {
00314                                         if (_NbCycles == 1)
00315                                         {                       
00316                                                 while (numAttrib --)
00317                                                 {               
00318                                                         // fill 4 attrib with the same value at once 
00319                                                         //*(T *)pt = *(T *)(pt + stride) = *(T *)(pt + stride2)  = *(T *)(pt + stride3) = _F(OptFastFractionnalPart(it.get()));         
00320                                                         *(T *) pt = _F(NLMISC::OptFastFractionnalPart(it.get()));
00321                                                         *(T *) (pt + stride) = *(T *) pt;
00322                                                         pt += stride;
00323                                                         *(T *) (pt + stride) = *(T *) pt;
00324                                                         pt += stride;
00325                                                         *(T *) (pt + stride) = *(T *) pt;
00326                                                         pt += stride2;                                                  
00327                                                         it.advance();
00328                                                 }
00329                                         }
00330                                         else
00331                                         {                       
00332                                                 while (numAttrib --)
00333                                                 {               
00334                                                         const float time =  _NbCycles * (it.get());
00335                                                         // fill 4 attrib with the same value at once 
00336                                                         //*(T *)pt = *(T *)(pt + stride) = *(T *)(pt + stride2)  = *(T *)(pt + stride3) = _F(OptFastFractionnalPart(time));             
00337                                                         *(T *) pt =     _F(NLMISC::OptFastFractionnalPart(time));
00338                                                         *(T *) (pt + stride) = *(T *) pt;
00339                                                         pt += stride;
00340                                                         *(T *) (pt + stride) = *(T *) pt;
00341                                                         pt += stride;
00342                                                         *(T *) (pt + stride) = *(T *) pt;
00343                                                         pt += stride2;                                                  
00344                                                 
00345                                                         it.advance();
00346                                                 }
00347                                         }
00348                                 }
00349                                 else
00350                                 {
00351                                         float value;
00352 
00353                                         if (_NbCycles == 1)
00354                                         {                       
00355                                                 while (numAttrib --)
00356                                                 {               
00357                                                         value = it.get();
00358                                                         if (value > MaxInputValue)
00359                                                         {
00360                                                                 value = MaxInputValue;
00361                                                         }
00362                                                         // fill 4 attrib with the same value at once 
00363                                                         //*(T *)pt = *(T *)(pt + stride) = *(T *)(pt + stride2)  = *(T *)(pt + stride3) = _F(value);            
00364                                                         *(T *) pt =     _F(value);
00365                                                         *(T *) (pt + stride) = *(T *) pt;
00366                                                         pt += stride;
00367                                                         *(T *) (pt + stride) = *(T *) pt;
00368                                                         pt += stride;
00369                                                         *(T *) (pt + stride) = *(T *) pt;
00370                                                         pt += stride2;                                                  
00371                                                 
00372                                                         it.advance();
00373                                                 }
00374                                         }
00375                                         else
00376                                         {                       
00377                                                 while (numAttrib --)
00378                                                 {               
00379                                                         value =   _NbCycles * (it.get());
00380                                                         if (value > MaxInputValue)
00381                                                         {
00382                                                                 value = MaxInputValue;
00383                                                         }
00384                                                         // fill 4 attrib with the same value at once 
00385                                                         //*(T *)pt = *(T *)(pt + stride) = *(T *)(pt + stride2)  = *(T *)(pt + stride3) = _F(value);            
00386                                                         *(T *) pt =     _F(value);
00387                                                         *(T *) (pt + stride) = *(T *) pt;
00388                                                         pt += stride;
00389                                                         *(T *) (pt + stride) = *(T *) pt;
00390                                                         pt += stride;
00391                                                         *(T *) (pt + stride) = *(T *) pt;
00392                                                         pt += stride2;                                                  
00393                                                         //pt += stride4; // advance of 4 
00394                                                         it.advance();
00395                                                 }
00396                                         }                                       
00397                                 }
00398                         }
00399                         else
00400                         {
00401                                 // the fastest case : it match the particle's life perfeclty
00402 
00403                                 if (_NbCycles == 1)
00404                                 {
00405                                         while (numAttrib --)
00406                                         {               
00407                                                 // fill 4 attrib with the same value at once 
00408                                                 //*(T *)pt = *(T *)(pt + stride) = *(T *)(pt + stride2)  = *(T *)(pt + stride3) = _F(it.get());         
00409                                                 *(T *) pt =     _F(it.get());
00410                                                 *(T *) (pt + stride) = *(T *) pt;
00411                                                 pt += stride;
00412                                                 *(T *) (pt + stride) = *(T *) pt;
00413                                                 pt += stride;
00414                                                 *(T *) (pt + stride) = *(T *) pt;
00415                                                 pt += stride2;                                                  
00416 
00417                                                 //pt += stride4; // advance of 4 
00418                                                 it.advance();
00419                                         }
00420                                 }
00421                                 else
00422                                 {
00423                                         // the particle won't cover the whole pattern durin his life
00424 
00425                                         while (numAttrib --)
00426                                         {               
00427                                                 // fill 4 attrib with the same value at once 
00428                                                 *(T *) pt =     _F(_NbCycles * it.get());
00429                                                 *(T *) (pt + stride) = *(T *) pt;
00430                                                 pt += stride;
00431                                                 *(T *) (pt + stride) = *(T *) pt;
00432                                                 pt += stride;
00433                                                 *(T *) (pt + stride) = *(T *) pt;
00434                                                 pt += stride2;  
00435                                                 //*(T *)pt = *(T *)(pt + stride) = *(T *)(pt + stride2)  = *(T *)(pt + stride3) = _F(_NbCycles * it.get());             
00436                                                 //pt += stride4; // advance of 4 
00437                                                 it.advance();
00438                                         }
00439                                 }
00440                         }       
00441                  }

template<typename T, class F>
template<typename It>
void NL3D::CPSAttribMakerT< T, F >::makeByIterator It  it,
void *  tab,
uint32  stride,
uint32  numAttrib,
bool  canOverlapOne
const [inline, private]
 

generate an attribute by using the given iterator. this allow to choose the input of tha attribute maker

Parameters:
canOverlapOne must be true if the entry iterator can give values above 1 the attribute maker with no speed penalty

Definition at line 191 of file ps_attrib_maker_helper.h.

Referenced by NL3D::CPSAttribMakerT< uint32, CPSValueBlendFunc< uint32 > >::make().

00197                  {                                              
00198                         uint8 *pt = (uint8 *) tab;
00199 
00200                         
00201                         if (_NbCycles > 1 || canOverlapOne)
00202                         {
00203                                 // the value could cycle, so we need to clamp it to 0.0f 1.0f
00204 
00205                                 if (!_Clamp)
00206                                 {
00207                                         if (_NbCycles == 1)
00208                                         {
00209                                                 while (numAttrib --)
00210                                                 {       
00211                                                         *(T *)pt = _F(NLMISC::OptFastFractionnalPart(it.get())); 
00212                                                         pt += stride;
00213                                                         it.advance();
00214                                                 }
00215                                         }
00216                                         else
00217                                         {
00218                                                 while (numAttrib --)
00219                                                 {
00220                                                         const float time =  _NbCycles * (it.get());
00221                                                         *(T *)pt = _F(NLMISC::OptFastFractionnalPart(time)); 
00222                                                         pt += stride;
00223                                                         it.advance();
00224                                                 }       
00225                                         }
00226                                 }
00227                                 else
00228                                 {
00229                                         // clamping is on
00230 
00231                                         float value;
00232 
00233                                         if (_NbCycles == 1)
00234                                         {
00235                                                 while (numAttrib --)
00236                                                 {       
00237                                                         value = (it.get());
00238                                                         if (value > MaxInputValue)
00239                                                         {
00240                                                                 value = MaxInputValue;
00241                                                         }
00242                                                         *(T *)pt = _F(value); 
00243                                                         pt += stride;
00244                                                         it.advance();
00245                                                 }
00246                                         }
00247                                         else
00248                                         {
00249                                                 while (numAttrib --)
00250                                                 {
00251                                                         float value =  _NbCycles * (it.get());
00252                                                         if (value > MaxInputValue)
00253                                                         {
00254                                                                 value = MaxInputValue;
00255                                                         }                                                                                                               
00256                                                         *(T *)pt = _F(value); 
00257                                                         pt += stride;
00258                                                         it.advance();
00259                                                 }       
00260                                         }
00261                                 }
00262                         }
00263                         else
00264                         {
00265                                 // the fastest case : it match the particle's life perfeclty
00266 
00267                                 if (_NbCycles == 1)
00268                                 {
00269                                         while (numAttrib --)
00270                                         {
00271                                                 *(T *)pt = _F(it.get()); 
00272                                                 pt += stride;
00273                                                 it.advance();
00274                                         }
00275                                 }
00276                                 else
00277                                 {
00278                                         // the particle won't cover the whole pattern durin his life
00279                                         while (numAttrib --)
00280                                         {
00281                                                 *(T *)pt = _F(_NbCycles  * (it.get())); 
00282                                                 pt += stride;
00283                                                 it.advance();
00284                                         }
00285                                 }
00286                         }                                               
00287                 }

template<typename T, class F>
virtual void NL3D::CPSAttribMakerT< T, F >::makeN CPSLocated loc,
uint32  startIndex,
void *  tab,
uint32  stride,
uint32  numAttrib,
uint32  nbReplicate,
uint32  srcStep
const [inline, private, virtual]
 

The same as make4, but with n replication instead of 4

See also:
make4

Implements NL3D::CPSAttribMaker< T >.

Definition at line 978 of file ps_attrib_maker_helper.h.

00986                         {
00987                                 NLMISC::OptFastFloorBegin();
00988                                 nlassert(loc);
00989                                 if (srcStep == (1 << 16))
00990                                 {                                       
00991                                         switch (_InputType.InputType)
00992                                         {
00993                                                 case CPSInputType::attrDate:    
00994                                                 {
00995                                                         CPSBaseIterator<TIteratorFloatStep1> 
00996                                                                 it(TIteratorFloatStep1(loc->getTime().begin(), startIndex) );
00997                                                         makeNByIterator(it, tab, stride, numAttrib, nbReplicate, loc->getLastForever());
00998                                                 }
00999                                                 break;
01000                                                 case CPSInputType::attrInverseMass:     
01001                                                 {
01002                                                         CPSBaseIterator<TIteratorFloatStep1> 
01003                                                                 it( TIteratorFloatStep1(loc->getInvMass().begin() , startIndex) );
01004                                                         makeNByIterator(it, tab, stride, numAttrib, nbReplicate, true);
01005                                                 }
01006                                                 break;          
01007                                                 case CPSInputType::attrSpeed:   
01008                                                 {
01009                                                         CVectNormIterator<TIteratorVectStep1> 
01010                                                                 it( TIteratorVectStep1(loc->getSpeed().begin(), startIndex) );
01011                                                         makeNByIterator(it, tab, stride, numAttrib, nbReplicate, true);
01012                                                 }
01013                                                 break;
01014 
01015                                                 case CPSInputType::attrPosition:        
01016                                                 {
01017                                                         CVectNormIterator<TIteratorVectStep1> 
01018                                                                 it( TIteratorVectStep1( loc->getPos().begin() , startIndex ) );
01019                                                         makeNByIterator(it, tab, stride, numAttrib, nbReplicate, true);
01020                                                 }
01021                                                 break;
01022                                                 case CPSInputType::attrUniformRandom:   
01023                                                 {
01024                                                         CRandomIterator it;
01025                                                         makeNByIterator(it, tab, stride, numAttrib, nbReplicate, true);
01026                                                 }
01027                                                 break;
01028                                                 case CPSInputType::attrUserParam:
01029                                                 {                       
01030                                                         CDecalIterator it;
01031                                                         it.Value = loc->getUserParam(_InputType.UserParamNum); 
01032                                                         makeNByIterator(it, tab, stride, numAttrib, nbReplicate, false);
01033                                                 }
01034                                                 break;
01035                                                 case CPSInputType::attrLOD:
01036                                                 {       
01037                                                         
01038                                                         CFDot3AddIterator<TIteratorVectStep1> 
01039                                                                 it( TIteratorVectStep1(loc->getPos().begin(), startIndex) );
01040                                                         loc->getLODVect(it.V, it.Offset, loc->getMatrixMode());                 
01041                                                         makeNByIterator(it, tab, stride, numAttrib, nbReplicate, false);
01042                                                 }
01043                                                 break;  
01044                                                 case CPSInputType::attrSquareLOD:
01045                                                 {       
01046                                                         
01047                                                         CFSquareDot3AddIterator<TIteratorVectStep1> 
01048                                                                 it(TIteratorVectStep1(loc->getPos().begin(), startIndex));
01049                                                         loc->getLODVect(it.V, it.Offset, loc->getMatrixMode());                 
01050                                                         makeNByIterator(it, tab, stride, numAttrib, nbReplicate, false);
01051                                                 }
01052                                                 break;  
01053                                                 case CPSInputType::attrClampedLOD:
01054                                                 {       
01055                                                         
01056                                                         CFClampDot3AddIterator<TIteratorVectStep1>
01057                                                                 it(TIteratorVectStep1(loc->getPos().begin(), startIndex));
01058                                                         loc->getLODVect(it.V, it.Offset, loc->getMatrixMode());                 
01059                                                         makeNByIterator(it, tab, stride, numAttrib, nbReplicate, false);
01060                                                 }
01061                                                 break;
01062                                                 case CPSInputType::attrClampedSquareLOD:
01063                                                 {       
01064                                                         
01065                                                         CFClampSquareDot3AddIterator<TIteratorVectStep1> 
01066                                                                 it(TIteratorVectStep1(loc->getPos().begin(), startIndex));
01067                                                         loc->getLODVect(it.V, it.Offset, loc->getMatrixMode());                 
01068                                                         makeNByIterator(it, tab, stride, numAttrib, nbReplicate, false);
01069                                                 }
01070                                                 break;
01071                                         }
01072 
01073                                         NLMISC::OptFastFloorEnd();                                      
01074                                 }
01075                                 else // fixed point steps
01076                                 {
01077                                         switch (_InputType.InputType)
01078                                         {
01079                                                 case CPSInputType::attrDate:    
01080                                                 {
01081                                                         CPSBaseIterator<TIteratorFloatStep1616> 
01082                                                                 it(TIteratorFloatStep1616(loc->getTime().begin(), startIndex, srcStep));
01083                                                         makeNByIterator(it, tab, stride, numAttrib, nbReplicate, loc->getLastForever());
01084                                                 }
01085                                                 break;
01086                                                 case CPSInputType::attrInverseMass:     
01087                                                 {
01088                                                         CPSBaseIterator<TIteratorFloatStep1616> 
01089                                                                 it( TIteratorFloatStep1616(loc->getInvMass().begin() , startIndex, srcStep) );
01090                                                         makeNByIterator(it, tab, stride, numAttrib, nbReplicate, true);
01091                                                 }
01092                                                 break;          
01093                                                 case CPSInputType::attrSpeed:   
01094                                                 {
01095                                                         CVectNormIterator<TIteratorVectStep1616> 
01096                                                                 it( TIteratorVectStep1616(loc->getSpeed().begin(), startIndex, srcStep) );
01097                                                         makeNByIterator(it, tab, stride, numAttrib, nbReplicate, true);
01098                                                 }
01099                                                 break;
01100 
01101                                                 case CPSInputType::attrPosition:        
01102                                                 {
01103                                                         CVectNormIterator<TIteratorVectStep1616> 
01104                                                                 it( TIteratorVectStep1616(loc->getPos().begin(), startIndex, srcStep) );
01105                                                         makeNByIterator(it, tab, stride, numAttrib, nbReplicate, true);
01106                                                 }
01107                                                 break;
01108                                                 case CPSInputType::attrUniformRandom:   
01109                                                 {
01110                                                         CRandomIterator it;
01111                                                         makeNByIterator(it, tab, stride, numAttrib, nbReplicate, true);
01112                                                 }
01113                                                 break;
01114                                                 case CPSInputType::attrUserParam:
01115                                                 {                       
01116                                                         CDecalIterator it;
01117                                                         it.Value = loc->getUserParam(_InputType.UserParamNum); 
01118                                                         makeNByIterator(it, tab, stride, numAttrib, nbReplicate, false);
01119                                                 }
01120                                                 break;
01121                                                 case CPSInputType::attrLOD:
01122                                                 {       
01123                                                         
01124                                                         CFDot3AddIterator<TIteratorVectStep1616> 
01125                                                                 it( TIteratorVectStep1616(loc->getPos().begin(), startIndex, srcStep) );
01126                                                         loc->getLODVect(it.V, it.Offset, loc->getMatrixMode());                 
01127                                                         makeNByIterator(it, tab, stride, numAttrib, nbReplicate, false);
01128                                                 }
01129                                                 break;  
01130                                                 case CPSInputType::attrSquareLOD:
01131                                                 {       
01132                                                         
01133                                                         CFSquareDot3AddIterator<TIteratorVectStep1616> 
01134                                                                 it( TIteratorVectStep1616(loc->getPos().begin(), startIndex, srcStep) );
01135                                                         loc->getLODVect(it.V, it.Offset, loc->getMatrixMode());                 
01136                                                         makeNByIterator(it, tab, stride, numAttrib, nbReplicate, false);
01137                                                 }
01138                                                 break;  
01139                                                 case CPSInputType::attrClampedLOD:
01140                                                 {       
01141                                                         
01142                                                         CFClampDot3AddIterator<TIteratorVectStep1616> 
01143                                                                 it( TIteratorVectStep1616( loc->getPos().begin(), startIndex, srcStep) );
01144                                                         loc->getLODVect(it.V, it.Offset, loc->getMatrixMode());                 
01145                                                         makeNByIterator(it, tab, stride, numAttrib, nbReplicate, false);
01146                                                 }
01147                                                 break;
01148                                                 case CPSInputType::attrClampedSquareLOD:
01149                                                 {       
01150                                                         
01151                                                         CFClampSquareDot3AddIterator<TIteratorVectStep1616> 
01152                                                                 it( TIteratorVectStep1616( loc->getPos().begin(), startIndex,  srcStep) );
01153                                                         loc->getLODVect(it.V, it.Offset, loc->getMatrixMode());                 
01154                                                         makeNByIterator(it, tab, stride, numAttrib, nbReplicate, false);
01155                                                 }
01156                                                 break;
01157                                         }
01158 
01159                                         NLMISC::OptFastFloorEnd();                              
01160                                 }       
01161                         }

template<typename T, class F>
template<typename It>
void NL3D::CPSAttribMakerT< T, F >::makeNByIterator It  it,
void *  tab,
uint32  stride,
uint32  numAttrib,
uint32  nbReplicate,
bool  canOverlapOne
const [inline, private]
 

The same as make4, but with n replication instead of 4

Parameters:
canOverlapOne must be true if the entry iterator can give values above 1
See also:
make4ByIterator

Definition at line 448 of file ps_attrib_maker_helper.h.

Referenced by NL3D::CPSAttribMakerT< uint32, CPSValueBlendFunc< uint32 > >::makeN().

00450                  {
00451                                 
00452                                 nlassert(nbReplicate > 1);                              
00453 
00454                                 uint8 *pt = (uint8 *) tab;
00455 
00456                                 // loop counter
00457                                 uint k;
00458 
00459 
00460                                 if (_NbCycles > 1 || canOverlapOne)
00461                                 {
00462                                         
00463                                         if (!_Clamp)
00464                                         {
00465                                                 if (_NbCycles == 1)
00466                                                 {                       
00467                                                         while (numAttrib --)
00468                                                         {               
00469                                                                 // fill 4 attrib with the same value at once 
00470                                                                 *(T *)pt = _F(NLMISC::OptFastFractionnalPart(it.get()));                                                
00471                                                                 k = nbReplicate - 1;
00472                                                                 do 
00473                                                                 {
00474                                                                         *(T *) (pt + stride) = *(T *) pt;
00475                                                                         pt += stride;
00476                                                                 }
00477                                                                 while (--k);
00478                                                                 pt += stride;
00479                                                                 it.advance();
00480                                                         }
00481                                                 }
00482                                                 else
00483                                                 {                       
00484                                                         while (numAttrib --)
00485                                                         {               
00486                                                                 const float time =  _NbCycles * (it.get());
00487                                                                 // fill 4 attrib with the same value at once 
00488                                                                 *(T *)pt = _F(NLMISC::OptFastFractionnalPart(time));                                    
00489                                                                 k = nbReplicate - 1;
00490                                                                 do 
00491                                                                 {
00492                                                                         *(T *) (pt + stride) = *(T *) pt;
00493                                                                         pt += stride;
00494                                                                 }
00495                                                                 while (--k);
00496                                                                 pt += stride;
00497                                                                 it.advance();
00498                                                         }
00499                                                 }
00500                                         }
00501                                         else
00502                                         {
00503                                                 float value;
00504                                                 // clamping is on
00505                                                 if (_NbCycles == 1)
00506                                                 {                       
00507                                                         while (numAttrib --)
00508                                                         {               
00509                                                                 // fill 4 attrib with the same value at once 
00510                                                                 value = it.get();
00511                                                                 if (value > MaxInputValue)
00512                                                                 {
00513                                                                         value = MaxInputValue;
00514                                                                 }
00515                                                                 *(T *)pt = _F(value);                                           
00516                                                                 k = nbReplicate - 1;
00517                                                                 do 
00518                                                                 {
00519                                                                         *(T *) (pt + stride) = *(T *) pt;
00520                                                                         pt += stride;
00521                                                                 }
00522                                                                 while (--k);
00523                                                                 pt += stride;
00524                                                                 it.advance();
00525                                                         }
00526                                                 }
00527                                                 else
00528                                                 {                       
00529                                                         while (numAttrib --)
00530                                                         {               
00531                                                                 value =  _NbCycles * (it.get());
00532                                                                 if (value > MaxInputValue)
00533                                                                 {
00534                                                                         value = MaxInputValue;
00535                                                                 }
00536                                                                 // fill 4 attrib with the same value at once 
00537                                                                 *(T *)pt = _F(value);                                   
00538                                                                 k = nbReplicate - 1;
00539                                                                 do 
00540                                                                 {
00541                                                                         *(T *) (pt + stride) = *(T *) pt;
00542                                                                         pt += stride;
00543                                                                 }
00544                                                                 while (--k);
00545                                                                 pt += stride;
00546                                                                 it.advance();
00547                                                         }
00548                                                 }
00549                                         }
00550                                 }
00551                                 else
00552                                 {
00553                                         // the fastest case : it match the particle's life perfeclty
00554 
00555                                         if (_NbCycles == 1)
00556                                         {
00557                                                 while (numAttrib --)
00558                                                 {               
00559                                                         // fill 4 attrib with the same value at once 
00560                                                         *(T *)pt = _F(it.get());                                                
00561                                                         k = nbReplicate - 1;
00562                                                         do 
00563                                                         {
00564                                                                 *(T *) (pt + stride) = *(T *) pt;
00565                                                                 pt += stride;
00566                                                         }
00567                                                         while (--k);
00568                                                         pt += stride;
00569                                                         it.advance();
00570                                                 }
00571                                         }
00572                                         else
00573                                         {
00574                                                 // the particle won't cover the whole pattern durin his life
00575 
00576                                                 while (numAttrib --)
00577                                                 {               
00578                                                         // fill 4 attrib with the same value at once 
00579                                                         *(T *)pt =  _F(_NbCycles * it.get());                                   
00580                                                         k = nbReplicate - 1;
00581                                                         do 
00582                                                         {
00583                                                                 *(T *) (pt + stride) = *(T *) pt;
00584                                                                 pt += stride;
00585                                                         }
00586                                                         while (--k);
00587                                                         pt += stride;
00588                                                         it.advance();
00589                                                 }
00590                                         }
00591                                 }       
00592                         }

template<typename T>
virtual void NL3D::CPSAttribMaker< T >::newElement CPSLocated emitterLocated,
uint32  emitterIndex
[inline, virtual, inherited]
 

create a new element, and provides the emitter, this must be called only if this attribute maker has its own memory

Reimplemented in NL3D::CPSAttribMakerBinOp< T >, NL3D::CPSAttribMakerMemoryBase< T >, NL3D::CPSAttribMakerMemory< uint32 >, NL3D::CPSAttribMakerMemory< sint32 >, NL3D::CPSAttribMakerMemory< float >, NL3D::CPSAttribMakerBinOp< float >, NL3D::CPSAttribMakerBinOp< CPlaneBasis >, NL3D::CPSAttribMakerBinOp< uint32 >, NL3D::CPSAttribMakerBinOp< NLMISC::CRGBA >, NL3D::CPSAttribMakerBinOp< sint32 >, NL3D::CPSAttribMakerMemoryBase< float >, NL3D::CPSAttribMakerMemoryBase< CPlaneBasis >, NL3D::CPSAttribMakerMemoryBase< NLMISC::CRGBA >, NL3D::CPSAttribMakerMemoryBase< uint32 >, and NL3D::CPSAttribMakerMemoryBase< sint32 >.

Definition at line 290 of file ps_attrib_maker.h.

00290 { nlassert(false) ; }

template<typename T>
virtual void NL3D::CPSAttribMaker< T >::resize uint32  capacity,
uint32  nbPresentElements
[inline, virtual, inherited]
 

set a new capacity for the memorized attribute, and a number of used element. This usually is 0 , but during edition, this may not be ... so new element are created. this must be called only if this attribute maker has its own memory

Reimplemented in NL3D::CPSAttribMakerBinOp< T >, NL3D::CPSAttribMakerMemoryBase< T >, NL3D::CPSAttribMakerBinOp< float >, NL3D::CPSAttribMakerBinOp< CPlaneBasis >, NL3D::CPSAttribMakerBinOp< uint32 >, NL3D::CPSAttribMakerBinOp< NLMISC::CRGBA >, NL3D::CPSAttribMakerBinOp< sint32 >, NL3D::CPSAttribMakerMemoryBase< float >, NL3D::CPSAttribMakerMemoryBase< CPlaneBasis >, NL3D::CPSAttribMakerMemoryBase< NLMISC::CRGBA >, NL3D::CPSAttribMakerMemoryBase< uint32 >, and NL3D::CPSAttribMakerMemoryBase< sint32 >.

Definition at line 296 of file ps_attrib_maker.h.

Referenced by NL3D::CPSRotated2DParticle::setAngle2DScheme(), NL3D::CPSAttribMakerBinOp< sint32 >::setArg(), NL3D::CPSColoredParticle::setColorScheme(), NL3D::CPSModulatedEmitter::setEmitteeSpeedScheme(), NL3D::CPSEmitter::setGenNbScheme(), NL3D::CPSForceIntensity::setIntensityScheme(), NL3D::CPSEmitter::setPeriodScheme(), NL3D::CPSRotated3DPlaneParticle::setPlaneBasisScheme(), and NL3D::CPSTexturedParticle::setTextureIndexScheme().

00296 { nlassert(false) ; }

template<typename T, class F>
virtual void NL3D::CPSAttribMakerT< T, F >::serial NLMISC::IStream f  )  throw (NLMISC::EStream) [inline, virtual]
 

serialisation of the object

The same as make4, but with n replication instead of 4

See also:
make4

Reimplemented from NL3D::CPSAttribMaker< T >.

Definition at line 104 of file ps_attrib_maker_helper.h.

00105                 {
00106                         sint ver = f.serialVersion(2);
00107                         CPSAttribMaker<T>::serial(f);
00108                     f.serial(_F);
00109                         switch (ver)
00110                         {
00111                                 case 1:
00112                                 {
00113                                         CPSInputType it;
00114                                         f.serialEnum(it.InputType);
00115                                         _InputType = it;
00116                                 }
00117                                 break;
00118                                 case 2:
00119                                         f.serial(_InputType);
00120                                 break;
00121                         }
00122                         f.serial(_Clamp);
00123                 }

template<typename T, class F>
virtual void NL3D::CPSAttribMakerT< T, F >::setClamping bool  enable = true  )  [inline, virtual]
 

Enable, disable the clamping of input values.

See also:
isClampingSupported()

Reimplemented from NL3D::CPSAttribMaker< T >.

Definition at line 161 of file ps_attrib_maker_helper.h.

00161 { _Clamp = enable; };

template<typename T, class F>
virtual void NL3D::CPSAttribMakerT< T, F >::setInput const CPSInputType input  )  [inline, virtual]
 

set a new input type

Reimplemented from NL3D::CPSAttribMaker< T >.

Definition at line 144 of file ps_attrib_maker_helper.h.

00144 { _InputType = input; }

template<typename T>
void NL3D::CPSAttribMaker< T >::setNbCycles float  nbCycles  )  [inline, inherited]
 

Set the number of cycles that must be done during the life of a particle, or the number of cycle per second for a particle that has no life limit. It is used to multiply the input used by this attribute maker It must be >= 0

Definition at line 227 of file ps_attrib_maker.h.

00228                 { 
00229                         nlassert(nbCycles >= 0) ;
00230                         _NbCycles = nbCycles ; 
00231                 }


Field Documentation

template<typename T, class F>
bool NL3D::CPSAttribMakerT< T, F >::_Clamp [private]
 

Definition at line 182 of file ps_attrib_maker_helper.h.

Referenced by NL3D::CPSAttribMakerT< T, F >::get().

template<typename T, class F>
F NL3D::CPSAttribMakerT< T, F >::_F
 

the functor object

Definition at line 55 of file ps_attrib_maker_helper.h.

Referenced by NL3D::CPSAttribMakerT< T, F >::get(), NL3D::CPSAttribMakerT< uint32, CPSValueBlendFunc< uint32 > >::get(), NL3D::CPSAttribMakerT< uint32, CPSValueBlendFunc< uint32 > >::make4ByIterator(), NL3D::CPSAttribMakerT< uint32, CPSValueBlendFunc< uint32 > >::makeByIterator(), and NL3D::CPSAttribMakerT< uint32, CPSValueBlendFunc< uint32 > >::makeNByIterator().

template<typename T>
bool NL3D::CPSAttribMaker< T >::_HasMemory [protected, inherited]
 

Definition at line 304 of file ps_attrib_maker.h.

template<typename T, class F>
CPSInputType NL3D::CPSAttribMakerT< T, F >::_InputType [private]
 

Definition at line 179 of file ps_attrib_maker_helper.h.

Referenced by NL3D::CPSAttribMakerT< T, F >::get().

template<typename T>
float NL3D::CPSAttribMaker< T >::_NbCycles [protected, inherited]
 

Definition at line 301 of file ps_attrib_maker.h.


The documentation for this class was generated from the following file:
Generated on Tue Mar 16 07:04:12 2004 for NeL by doxygen 1.3.6