00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef NL_PS_RIBBON_BASE_H
00027 #define NL_PS_RIBBON_BASE_H
00028
00029
00030 #include "3d/ps_particle_basic.h"
00031
00032
00033 namespace NL3D
00034 {
00035
00044 class CPSRibbonBase : public CPSParticle, public CPSTailParticle
00045 {
00046 public:
00047 enum TRibbonMode { VariableSize = 0, FixedSize, RibbonModeLast };
00048 enum TInterpolationMode { Linear = 0, Hermitte, InterpModeLast };
00049
00052 CPSRibbonBase();
00054 virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream);
00056
00060 void setRibbonMode(TRibbonMode mode);
00061 TRibbonMode getRibbonMode() const { return _RibbonMode; }
00062 void setInterpolationMode(TInterpolationMode mode);
00063 TInterpolationMode getInterpolationMode() const { return _InterpolationMode; }
00065
00069 void setTailNbSeg(uint32 nbSegs);
00071 uint32 getTailNbSeg(void) const { return _NbSegs; }
00075 void setSegDuration(TAnimationTime ellapsedTime);
00076 TAnimationTime getSegDuration(void) const { return _SegDuration; }
00077
00082 void setRibbonLength(float length);
00083 float getRibbonLength() const { return _RibbonLength; }
00085
00089 void setLODDegradation(float percent)
00090 {
00091 nlassert(percent >= 0 && percent <= 1)
00092 _LODDegradation = percent;
00093 }
00094 float getLODDegradation() const { return _LODDegradation; }
00095
00096 protected:
00097 uint32 _NbSegs;
00098 TAnimationTime _SegDuration;
00099 bool _Parametric;
00100
00102 virtual void newElement(CPSLocated *emitterLocated, uint32 emitterIndex) ;
00104 virtual void deleteElement(uint32 index);
00106 virtual void resize(uint32 size);
00108 virtual void motionTypeChanged(bool parametric);
00109
00114 void computeRibbon( uint index,
00115 NLMISC::CVector *dest,
00116 uint stride = sizeof(NLMISC::CVector)
00117 );
00118
00120 void updateGlobals();
00121
00123 void updateLOD();
00124
00125
00127 uint32 _UsedNbSegs;
00128 TAnimationTime _UsedSegDuration;
00129 float _UsedSegLength;
00130
00131 private:
00132 typedef std::vector<NLMISC::CVector> TPosVect;
00133 typedef std::vector<float> TFloatVect;
00134
00135 TPosVect _Ribbons;
00136 TFloatVect _SamplingDate;
00137 uint _RibbonIndex;
00138 TAnimationTime _LastUpdateDate;
00139 TRibbonMode _RibbonMode;
00140 TInterpolationMode _InterpolationMode;
00141 float _RibbonLength;
00142 float _SegLength;
00143 float _LODDegradation;
00144
00145 protected:
00146 void initDateVect();
00147 void resetFromOwner();
00148 private:
00149 void resetSingleRibbon(uint index, const NLMISC::CVector &pos);
00150
00151
00153 void dupRibbon(uint dest, uint src);
00154
00156 void computeLinearRibbon( uint index,
00157 NLMISC::CVector *dest,
00158 uint stride = sizeof(NLMISC::CVector)
00159 );
00161 void computeLinearCstSizeRibbon( uint index,
00162 NLMISC::CVector *dest,
00163 uint stride = sizeof(NLMISC::CVector)
00164 );
00166 void computeHermitteRibbon( uint index,
00167 NLMISC::CVector *dest,
00168 uint stride = sizeof(NLMISC::CVector)
00169 );
00170
00174 void computeHermitteCstSizeRibbon( uint index,
00175 NLMISC::CVector *dest,
00176 uint stride = sizeof(NLMISC::CVector)
00177 );
00178 };
00179
00180 }
00181
00182
00183 #endif // NL_PS_RIBBON_BASE_H
00184
00185