00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef NL_CHANNEL_MIXER_H
00027 #define NL_CHANNEL_MIXER_H
00028
00029 #include "nel/misc/types_nl.h"
00030 #include "nel/misc/debug.h"
00031 #include "nel/misc/smart_ptr.h"
00032 #include "nel/3d/animation_time.h"
00033 #include "3d/animation_set.h"
00034 #include <map>
00035 #include <vector>
00036
00037 namespace NL3D
00038 {
00039
00040 class CAnimation;
00041 class IAnimatable;
00042 class IAnimatedValue;
00043 class ITrack;
00044 class CAnimationSet;
00045
00064 class CChannelMixer : public NLMISC::CRefCount
00065 {
00066 public:
00067
00069
00070 enum
00071 {
00073 NumAnimationSlot=8
00074 };
00075
00076 private:
00077
00079
00081 class CSlot
00082 {
00083 friend class CChannelMixer;
00084
00086 CSlot ()
00087 {
00088
00089 _Dirt=false;
00090
00091
00092 _Weight= 1.f;
00093
00094
00095 empty ();
00096 }
00097
00099 void empty ()
00100 {
00101 _Animation=NULL;
00102 _SkeletonWeight=NULL;
00103 _InvertedSkeletonWeight=false;
00104 }
00105
00107 bool isEmpty ()
00108 {
00109 return _Animation==NULL;
00110 }
00111
00112 private:
00114 const CAnimation* _Animation;
00115
00117 const CSkeletonWeight* _SkeletonWeight;
00118
00120 bool _InvertedSkeletonWeight;
00121
00123 TAnimationTime _Time;
00124
00131 float _Weight;
00132
00134 bool _Dirt;
00135 };
00136
00145 class CChannel
00146 {
00147 friend class CChannelMixer;
00148 public:
00149 enum {EnableUserFlag= 1, EnableLodFlag= 2, EnableAllFlag= 3};
00150
00151 public:
00153 CChannel ()
00154 {
00155
00156 _InTheList=false;
00157
00158 _EnableFlags= EnableAllFlag;
00159 }
00160 private:
00162 bool _InTheList;
00163
00165 bool _Detail;
00166
00168 uint8 _EnableFlags;
00169
00171 bool _IsQuat;
00172
00173
00175 std::string _ChannelName;
00176
00178 IAnimatable* _Object;
00179
00181 IAnimatedValue* _Value;
00182
00184 uint32 _ValueId;
00185
00187 uint32 _OwnerValueId;
00188
00190 const ITrack* _DefaultTracks;
00191
00196 const ITrack* _Tracks[NumAnimationSlot];
00197
00204 float _Weights[NumAnimationSlot];
00205
00212 CChannel* _Next;
00213
00214 };
00215 public:
00217 CChannelMixer();
00218
00220
00225 void setAnimationSet (const CAnimationSet* animationSet);
00226
00231 const CAnimationSet* getAnimationSet () const;
00232
00248 void eval (bool detail, uint64 evalDetailDate=0);
00249
00251
00269 sint addChannel (const std::string& channelName, IAnimatable* animatable, IAnimatedValue* value, ITrack* defaultValue, uint32 valueId, uint32 ownerValueId, bool detail);
00270
00272 void resetChannels ();
00273
00274
00279 void enableChannel (uint channelId, bool enable);
00280
00284 bool isChannelEnabled (uint channelId) const;
00285
00291 void lodEnableChannel (uint channelId, bool enable);
00292
00296 bool isChannelLodEnabled (uint channelId) const;
00297
00298
00300
00314 void setSlotAnimation (uint slot, uint animation);
00315
00317 const CAnimation *getSlotAnimation(uint slot) const;
00318
00331 void setSlotTime (uint slot, TAnimationTime time)
00332 {
00333
00334 nlassert (slot<NumAnimationSlot);
00335
00336
00337 _SlotArray[slot]._Time=time;
00338 }
00339
00352 void setSlotWeight (uint slot, float weight)
00353 {
00354
00355 nlassert (slot<NumAnimationSlot);
00356
00357
00358 _SlotArray[slot]._Weight=weight;
00359 }
00360
00372 void emptySlot (uint slot);
00373
00382 void resetSlots ();
00383
00394 void applySkeletonWeight (uint slot, uint skeleton, bool invert=false);
00395
00403 void resetSkeletonWeight (uint slot);
00404
00406 void resetEvalDetailDate();
00407
00408 private:
00409
00411
00413 void cleanAll ();
00414
00416 void dirtAll ();
00417
00419 void refreshList ();
00420
00421
00422 CSlot _SlotArray[NumAnimationSlot];
00423
00424
00425 const CAnimationSet* _AnimationSet;
00426
00427
00428 std::map<uint, CChannel> _Channels;
00429
00430
00431 CChannel* _FirstChannelGlobal;
00432
00433
00434 CChannel* _FirstChannelDetail;
00435
00436
00437 sint64 _LastEvalDetailDate;
00438
00439
00440 bool _Dirt;
00441
00442
00443 bool _ListToEvalDirt;
00444
00445
00446 std::vector<CChannel*> _GlobalListToEval;
00447 std::vector<CChannel*> _DetailListToEval;
00448
00450 void refreshListToEval ();
00451
00452
00453 };
00454
00455
00456 }
00457
00458
00459 #endif // NL_CHANNEL_MIXER_H
00460
00461