# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

ps_ribbon_base.h

Go to the documentation of this file.
00001 
00007 /* Copyright, 2001 Nevrax Ltd.
00008  *
00009  * This file is part of NEVRAX NEL.
00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2, or (at your option)
00013  * any later version.
00014 
00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018  * General Public License for more details.
00019 
00020  * You should have received a copy of the GNU General Public License
00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00023  * MA 02111-1307, USA.
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; // if this is set to true, then the owner has activated parametric motion.       
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; // all positions for each ribbons packed in a single vector
00134 
00135         TPosVect                                                  _Ribbons;     
00136         TFloatVect                                            _SamplingDate;
00137         uint                                                      _RibbonIndex;  // indicate which is the first index for the ribbons head      
00138         TAnimationTime                                    _LastUpdateDate;      
00139         TRibbonMode                                               _RibbonMode;
00140         TInterpolationMode                                _InterpolationMode;
00141         float                                                     _RibbonLength; // used if _RibbonMode == FixedSize
00142         float                                                     _SegLength;
00143         float                                                     _LODDegradation;
00144 
00145 protected: // should be call by derivers for backward compatibility only
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 } // NL3D
00181 
00182 
00183 #endif // NL_PS_RIBBON_BASE_H
00184 
00185 /* End of ps_ribbon_base.h */