00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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
00071 void render(IDriver *drv, CVertexBuffer &vb, CPrimitiveBlock &pb, CMaterial &mat);
00072
00073 void samplePos(float date);
00076 void setupFromShape();
00077
00078
00080
00081 virtual bool canStartStop() { return true; }
00082
00083 virtual void start();
00085 virtual void stop();
00087 virtual void stopNoUnroll();
00088
00089 virtual bool isStarted() const { return _Started; }
00090
00091 bool isStopping() const { return _Stopping; }
00092
00093 void restart();
00095
00099 void setAnimatedMaterial(CAnimatedMaterial *mat);
00100
00101 CAnimatedMaterial *getAnimatedMaterial() const { return _AniMat; }
00102
00103
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;
00140 uint _NumSlice;
00141 uint _NumCorners;
00142 bool _Started;
00143 bool _Stopping;
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
00154 void clearAnimatedMatFlag()
00155 {
00156 IAnimatable::clearFlag(OwnerBit);
00157 }
00158 };
00159
00166
00167
00168
00169
00170
00171
00172
00173
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