# 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  

seg_remanence.h

Go to the documentation of this file.
00001 
00006 /* Copyright, 2000, 2001, 2002 Nevrax Ltd.
00007  *
00008  * This file is part of NEVRAX NEL.
00009  * NEVRAX NEL is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2, or (at your option)
00012  * any later version.
00013 
00014  * NEVRAX NEL is distributed in the hope that it will be useful, but
00015  * WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00017  * General Public License for more details.
00018 
00019  * You should have received a copy of the GNU General Public License
00020  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00021  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00022  * MA 02111-1307, USA.
00023  */
00024 
00025 
00026 #ifndef NL_SEG_REMANENCE_H
00027 #define NL_SEG_REMANENCE_H
00028 
00029 #include "nel/misc/vector.h"
00030 #include "3d/transform_shape.h"
00031 #include "3d/transform.h"
00032 #include "3d/animated_material.h"
00033 
00034 #include <deque>
00035 
00036 
00037 namespace NL3D
00038 {
00039 
00040 class IDriver;
00041 class CVertexBuffer;
00042 class CPrimitiveBlock;
00043 class CMaterial;
00044 class CScene;
00045 
00046 
00047 
00056 class CSegRemanence : public CTransformShape
00057 {
00058 public:
00060 
00061                 CSegRemanence();
00062                 ~CSegRemanence();
00063                 CSegRemanence(CSegRemanence &other);            
00064                 CSegRemanence &operator = (CSegRemanence &other);
00066 
00067         static  void                    registerBasic();
00069         static IModel                   *creator() { return new CSegRemanence; }        
00070         // Render this model with currently setupped material and matrix
00071         void                                    render(IDriver *drv, CVertexBuffer &vb, CPrimitiveBlock &pb, CMaterial &mat);
00072         // sample current position
00073         void                                    samplePos(float date);
00076         void                                    setupFromShape();
00077 
00078 
00080 
00081                 virtual bool                            canStartStop() { return true; }
00082                 // start the fx (by default it is off).
00083                 virtual void                            start();
00085                 virtual void                            stop();
00087                 virtual void                            stopNoUnroll();
00088                 // Test wether the fx is started
00089                 virtual bool                            isStarted() const { return _Started; }
00090                 // Test if the fx is stopping (unrollinh)
00091                 bool                                            isStopping() const { return _Stopping; }
00092                 // Equivalent to a call to start, then stop
00093                 void                                            restart();
00095 
00099         void                                    setAnimatedMaterial(CAnimatedMaterial *mat);
00100         //
00101         CAnimatedMaterial               *getAnimatedMaterial() const { return _AniMat; }        
00102 
00103         // Register to a channel mixer.
00104         void                                    registerToChannelMixer(CChannelMixer *chanMixer, const std::string &prefix);
00105 
00106         enum    TAnimValues
00107         {
00108                 OwnerBit= CTransformShape::AnimValueLast, 
00109 
00110                 AnimValueLast,
00111         };
00112         
00115 private:        
00116         struct CSampledPos
00117         {
00118                 CSampledPos(const NLMISC::CVector &pos = NLMISC::CVector::Null, float date = 0.f) : Pos(pos), SamplingDate(date)
00119                 {
00120                 }
00121                 NLMISC::CVector Pos;
00122                 float                   SamplingDate;           
00123         };
00124         class CRibbon
00125         {
00126                 public:
00127                         CRibbon();
00128                         void setNumSlices(uint numSlices);
00129                         void samplePos(const NLMISC::CVector &pos, float date, float sliceDuration);
00130                         void fillVB(uint8 *dest, uint stride, uint nbSegs, float sliceTime);
00131                         void duplicateFirstPos();
00132                 private:
00133                         typedef std::deque<CSampledPos> TSampledPosVect;
00134                         TSampledPosVect _Ribbon;
00135                         float                   _LastSamplingDate;
00136         };      
00137         typedef std::vector<CRibbon> TRibbonVect;
00138 private:        
00139         TRibbonVect                     _Ribbons; // sampled positions at each extremities of segment
00140         uint                            _NumSlice;
00141         uint                            _NumCorners;
00142         bool                            _Started;
00143         bool                            _Stopping; // true if the effect is unrolling
00144         bool                            _Restarted;
00145         float                           _StartDate;
00146         float                           _CurrDate;
00147         float                           _UnrollRatio;   
00148         CAnimatedMaterial   *_AniMat;   
00149 private:
00150         void            updateOpacityFromShape();
00151         void            copyFromOther(CSegRemanence &other);
00152 public:
00153         // for anim detail obs
00154         void clearAnimatedMatFlag()
00155         {
00156                 IAnimatable::clearFlag(OwnerBit);
00157         }
00158 };
00159 
00166 /* class CSegRemanenceHrcObs : public CTransformHrcObs
00167 {
00168 public:
00169         CSegRemanenceHrcObs();
00170         virtual void traverse (IObs *caller);
00171         static IObs     *creator () { return new CSegRemanenceHrcObs; } 
00172 private:
00173         uint64                          _LastSampleFrame;
00174 }; */
00175 
00182 class CSegRemanenceAnimDetailObs : public CTransformAnimDetailObs
00183 {
00184 public:
00185 
00186         CSegRemanenceAnimDetailObs();
00191         virtual void    traverse(IObs *caller);
00192 
00193 
00194 public:
00195         static IObs     *creator() {return new CSegRemanenceAnimDetailObs;}
00196 private:
00197         uint64                          _LastSampleFrame;
00198 };
00199 
00200 
00201 
00202 
00203 }
00204 
00205 #endif
00206 
00207