#include <animation_playlist.h>
Inheritance diagram for NL3D::CAnimationPlaylist:
Nevrax France
Definition at line 43 of file animation_playlist.h.
Public Types | |
enum | { empty = 0xffffffff } |
enum | TWrapMode { Clamp = 0, Repeat, Disable, WrapModeCount } |
Wrap mode for the play list. More... | |
Public Member Functions | |
CAnimationPlaylist () | |
Constructor. | |
void | emptyPlayList () |
uint | getAnimation (uint8 slot) const |
float | getEndWeight (uint8 slot, TGlobalAnimationTime &time) const |
TAnimationTime | getLocalTime (uint8 slot, TGlobalAnimationTime globalTime, const CAnimationSet &animSet) const |
float | getLocalWeight (uint8 slot, TGlobalAnimationTime globalTime) const |
const sint & | getRefCount () const |
uint | getSkeletonWeight (uint8 slot, bool &inverted) const |
float | getSpeedFactor (uint8 slot) const |
float | getStartWeight (uint8 slot, TGlobalAnimationTime &time) const |
TGlobalAnimationTime | getTimeOrigin (uint8 slot) const |
float | getWeightSmoothness (uint8 slot) const |
TWrapMode | getWrapMode (uint8 slot) const |
void | serial (NLMISC::IStream &f) |
void | setAnimation (uint8 slot, uint animation) |
void | setEndWeight (uint8 slot, float endWeight, TGlobalAnimationTime time) |
void | setSkeletonWeight (uint8 slot, uint skeletonId, bool inverted=false) |
void | setSpeedFactor (uint8 slot, float speedFactor) |
void | setStartWeight (uint8 slot, float startWeight, TGlobalAnimationTime time) |
void | setTimeOrigin (uint8 slot, TGlobalAnimationTime timeOrigin) |
void | setupMixer (CChannelMixer &mixer, TGlobalAnimationTime time) const |
void | setWeightSmoothness (uint8 slot, float smoothness) |
void | setWrapMode (uint8 slot, TWrapMode wrapMode) |
Static Public Member Functions | |
float | getWeightValue (TGlobalAnimationTime startWeightTime, TGlobalAnimationTime endWeightTime, TGlobalAnimationTime time, float startWeight, float endWeight, float smoothness) |
Data Fields | |
sint | crefs |
CPtrInfo * | pinfo |
Static Public Attributes | |
CPtrInfo | NullPtrInfo |
Private Attributes | |
uint32 | _Animations [CChannelMixer::NumAnimationSlot] |
float | _EndWeight [CChannelMixer::NumAnimationSlot] |
TGlobalAnimationTime | _EndWeightTime [CChannelMixer::NumAnimationSlot] |
bool | _InvertWeight [CChannelMixer::NumAnimationSlot] |
uint32 | _SkeletonWeight [CChannelMixer::NumAnimationSlot] |
float | _Smoothness [CChannelMixer::NumAnimationSlot] |
float | _SpeedFactor [CChannelMixer::NumAnimationSlot] |
float | _StartWeight [CChannelMixer::NumAnimationSlot] |
TGlobalAnimationTime | _StartWeightTime [CChannelMixer::NumAnimationSlot] |
TGlobalAnimationTime | _TimeOrigin [CChannelMixer::NumAnimationSlot] |
TWrapMode | _WrapMode [CChannelMixer::NumAnimationSlot] |
Friends | |
struct | CPtrInfo |
|
Definition at line 46 of file animation_playlist.h.
00047 { 00048 // 00049 empty=0xffffffff 00050 }; |
|
Wrap mode for the play list.
Definition at line 53 of file animation_playlist.h.
00054 { 00056 Clamp=0, 00057 00059 Repeat, 00060 00062 Disable, 00063 00064 WrapModeCount 00065 }; |
|
Constructor.
Definition at line 40 of file animation_playlist.cpp. References _WrapMode, Clamp, emptyPlayList(), and uint.
00041 { 00042 // Empty the playlist 00043 emptyPlayList (); 00044 00045 // Set default wrap mode 00046 for (uint i=0; i<CChannelMixer::NumAnimationSlot; i++) 00047 _WrapMode[i]=Clamp; 00048 } |
|
Empty the playlist. Each slot is set to its default value. Definition at line 52 of file animation_playlist.cpp. References _Animations, _EndWeight, _EndWeightTime, _InvertWeight, _SkeletonWeight, _Smoothness, _SpeedFactor, _StartWeight, _StartWeightTime, _TimeOrigin, empty, and uint. Referenced by CAnimationPlaylist(), and NL3D::CPlayListUser::emptyPlayList().
00053 { 00054 // Empty each slot 00055 for (uint i=0; i<CChannelMixer::NumAnimationSlot; i++) 00056 { 00057 _Animations[i]=empty; 00058 _SkeletonWeight[i]=empty; 00059 _InvertWeight[i]=false; 00060 _TimeOrigin[i]=0.f; 00061 _SpeedFactor[i]=1.f; 00062 _StartWeight[i]=1.f; 00063 _EndWeight[i]=1.f; 00064 _StartWeightTime[i]= 0.f; 00065 _EndWeightTime[i]= 0.f; 00066 _Smoothness[i]= 0.f; 00067 } 00068 } |
|
Get the animation of a slot. Default value is empty.
Definition at line 79 of file animation_playlist.cpp. References _Animations, uint, and uint8. Referenced by NL3D::CPlayListUser::getAnimation().
00080 { 00081 return _Animations[slot]; 00082 } |
|
Get animation end weight. Default value is 1.f.
Definition at line 154 of file animation_playlist.cpp. References _EndWeight, _EndWeightTime, NL3D::TGlobalAnimationTime, and uint8. Referenced by NL3D::CPlayListUser::getEndWeight().
00155 { 00156 time=_EndWeightTime[slot]; 00157 return _EndWeight[slot]; 00158 } |
|
Convert a playlist global time in local time in a slot animation including wrap evaluation.
Definition at line 316 of file animation_playlist.cpp. References _Animations, _SpeedFactor, _TimeOrigin, _WrapMode, NLMISC::clamp(), Clamp, NL3D::CAnimationSet::getAnimation(), NL3D::CAnimation::getBeginTime(), NL3D::CAnimation::getEndTime(), Repeat, NL3D::TAnimationTime, NL3D::TGlobalAnimationTime, and uint8. Referenced by setupMixer().
00317 { 00318 // Get the animation 00319 const CAnimation *pAnimation=animSet.getAnimation (_Animations[slot]); 00320 00321 // If this animation exists 00322 if (pAnimation) 00323 { 00324 // Compute the non-wrapped time 00325 TAnimationTime wrappedTime=pAnimation->getBeginTime ()+(TAnimationTime)((globalTime-_TimeOrigin[slot])*_SpeedFactor[slot]); 00326 00327 // Wrap mode 00328 switch (_WrapMode[slot]) 00329 { 00330 case Clamp: 00331 clamp (wrappedTime, pAnimation->getBeginTime (), pAnimation->getEndTime ()); 00332 break; 00333 case Repeat: 00334 // Mod repeat the time 00335 { 00336 float length=pAnimation->getEndTime ()-pAnimation->getBeginTime(); 00337 if (wrappedTime>=pAnimation->getBeginTime()) 00338 wrappedTime=pAnimation->getBeginTime()+(float)fmod (wrappedTime-pAnimation->getBeginTime(), length); 00339 else 00340 wrappedTime=pAnimation->getBeginTime()+(float)fmod (wrappedTime-pAnimation->getBeginTime(), length)+length; 00341 } 00342 break; 00343 default: break; 00344 } 00345 00346 // Return localTime 00347 return wrappedTime; 00348 } 00349 00350 return (TAnimationTime)globalTime; 00351 } |
|
Compute weight of a slot at a given global playlist time
Definition at line 355 of file animation_playlist.cpp. References _EndWeight, _EndWeightTime, _Smoothness, _StartWeight, _StartWeightTime, getWeightValue(), NL3D::TGlobalAnimationTime, and uint8. Referenced by NL3D::CPlayListUser::getLocalWeight().
00356 { 00357 return getWeightValue (_StartWeightTime[slot], _EndWeightTime[slot], globalTime, _StartWeight[slot], _EndWeight[slot], _Smoothness[slot]); 00358 } |
|
Definition at line 70 of file smart_ptr.h. References NLMISC::CRefCount::crefs, and sint.
00071 { 00072 return crefs; 00073 } |
|
Get the skeleton weight of a slot. Default value is empty.
Definition at line 94 of file animation_playlist.cpp. References _InvertWeight, _SkeletonWeight, uint, and uint8. Referenced by NL3D::CPlayListUser::getSkeletonWeight().
00095 { 00096 inverted=_InvertWeight[slot]; 00097 return _SkeletonWeight[slot]; 00098 } |
|
Get animation speed factor. Default value is 1.f.
Definition at line 123 of file animation_playlist.cpp. References _SpeedFactor, and uint8. Referenced by NL3D::CPlayListUser::getSpeedFactor().
00124 { 00125 return _SpeedFactor[slot]; 00126 } |
|
Get animation start weight. Default value is 1.f.
Definition at line 138 of file animation_playlist.cpp. References _StartWeight, _StartWeightTime, NL3D::TGlobalAnimationTime, and uint8. Referenced by NL3D::CPlayListUser::getStartWeight().
00139 { 00140 time=_StartWeightTime[slot]; 00141 return _StartWeight[slot]; 00142 } |
|
Get animation time origin, ie, the time in the playlist for which slot time is the startTime of the slot animation. Default value is 0.f.
Definition at line 109 of file animation_playlist.cpp. References _TimeOrigin, NL3D::TGlobalAnimationTime, and uint8. Referenced by NL3D::CPlayListUser::getTimeOrigin().
00110 { 00111 return _TimeOrigin[slot]; 00112 } |
|
Get weight smoothness. This is the smoothness of the weight interpolation. Must be between 0.f and 1.f. 0.f is a sharp interpolation (linear), 1.f is a smooth interpolation (quadratic). Default value is 0.f.
Definition at line 169 of file animation_playlist.cpp. References _Smoothness, and uint8. Referenced by NL3D::CPlayListUser::getWeightSmoothness().
00170 { 00171 return _Smoothness[slot]; 00172 } |
|
Static interpolation method of blend value
Definition at line 246 of file animation_playlist.cpp. References NL3D::TGlobalAnimationTime, and x. Referenced by getLocalWeight(), and setupMixer().
00247 { 00248 // Clamp left 00249 if (time<=startWeightTime) 00250 return startWeight; 00251 // Clamp left 00252 if (time>=endWeightTime) 00253 return endWeight; 00254 00255 // *** Interpolate 00256 00257 // Linear value 00258 TGlobalAnimationTime linear=startWeight+(endWeight-startWeight)*(time-startWeightTime)/(endWeightTime-startWeightTime); 00259 00260 // Linear ? 00261 if (smoothness<0.0001f) 00262 return (float)linear; 00263 00264 // Quadratic value 00265 double a=2.f*startWeight-2.f*endWeight; 00266 double b=3.f*endWeight-3.f*startWeight; 00267 double x=(time-startWeightTime)/(endWeightTime-startWeightTime); 00268 double xSquare=x*x; 00269 double xCube=x*xSquare; 00270 double quad=a*xCube+b*xSquare+startWeight; 00271 00272 // Interpolate between linear and quadratic 00273 return (float)(smoothness*quad+(1.f-smoothness)*linear); 00274 } |
|
Get the wrap mode in use in the play list. Wrap mode tells the play list how to use an animation when current time is not in the animation.
Definition at line 285 of file animation_playlist.cpp. References _WrapMode, and uint8. Referenced by NL3D::CPlayListUser::getWrapMode().
00286 { 00287 return _WrapMode[slot]; 00288 } |
|
Serial Definition at line 292 of file animation_playlist.cpp. References _Animations, _EndWeight, _EndWeightTime, _InvertWeight, _SkeletonWeight, _Smoothness, _SpeedFactor, _StartWeight, _StartWeightTime, _TimeOrigin, _WrapMode, NLMISC::IStream::serial(), NLMISC::IStream::serialEnum(), NLMISC::IStream::serialVersion(), and uint.
00293 { 00294 // Serial a version 00295 (void)f.serialVersion (0); 00296 00297 // Serial all the values 00298 for (uint i=0; i<CChannelMixer::NumAnimationSlot; i++) 00299 { 00300 f.serial (_Animations[i]); 00301 f.serial (_SkeletonWeight[i]); 00302 f.serial (_InvertWeight[i]); 00303 f.serial (_TimeOrigin[i]); 00304 f.serial (_SpeedFactor[i]); 00305 f.serial (_StartWeight[i]); 00306 f.serial (_StartWeightTime[i]); 00307 f.serial (_EndWeight[i]); 00308 f.serial (_EndWeightTime[i]); 00309 f.serial (_Smoothness[i]); 00310 f.serialEnum (_WrapMode[i]); 00311 } 00312 } |
|
Set the animation of a slot. Default value is empty.
Definition at line 72 of file animation_playlist.cpp. References _Animations, uint, and uint8. Referenced by NL3D::CPlayListUser::setAnimation(), and NL3D::CScene::setAutomaticAnimationSet().
00073 { 00074 _Animations[slot]=animation; 00075 } |
|
Set animation end weight. This is the weight for this animation use at the end of the animation slot. Default value is 1.f.
Definition at line 146 of file animation_playlist.cpp. References _EndWeight, _EndWeightTime, NL3D::TGlobalAnimationTime, and uint8. Referenced by NL3D::CPlayListUser::setEndWeight(), and NL3D::CPlayListUser::setWeight().
00147 { 00148 _EndWeight[slot]=endWeight; 00149 _EndWeightTime[slot]=time; 00150 } |
|
Set the skeleton weight animation of a slot. Default value is empty.
Definition at line 86 of file animation_playlist.cpp. References _InvertWeight, _SkeletonWeight, uint, and uint8. Referenced by NL3D::CPlayListUser::setSkeletonWeight().
00087 { 00088 _SkeletonWeight[slot]=skeletonId; 00089 _InvertWeight[slot]=inverted; 00090 } |
|
Set animation speed factor. Default value is 1.f.
Definition at line 116 of file animation_playlist.cpp. References _SpeedFactor, and uint8. Referenced by NL3D::CPlayListUser::setSpeedFactor().
00117 { 00118 _SpeedFactor[slot]=speedFactor; 00119 } |
|
Set animation start weight. This is the weight for this animation use at the beginning of the animation slot. Default value is 1.f.
Definition at line 130 of file animation_playlist.cpp. References _StartWeight, _StartWeightTime, NL3D::TGlobalAnimationTime, and uint8. Referenced by NL3D::CPlayListUser::setStartWeight(), and NL3D::CPlayListUser::setWeight().
00131 { 00132 _StartWeight[slot]=startWeight; 00133 _StartWeightTime[slot]=time; 00134 } |
|
Set animation time origin, ie, the time in the playlist for which slot time is the startTime of the slot animation. Default value is 0.f.
Definition at line 102 of file animation_playlist.cpp. References _TimeOrigin, NL3D::TGlobalAnimationTime, and uint8. Referenced by NL3D::CPlayListUser::setTimeOrigin().
00103 { 00104 _TimeOrigin[slot]=timeOrigin; 00105 } |
|
Setup a channel mixer. For each slot, it sets : * the animation id used by the slot. * the animation time according with the begin time of each slot, the speed factor of each slot and the current time passed in parameter. * the skeleton weight id. * the weight interpolated with the start and end values. The weight value are clamped before and after the animation. Definition at line 176 of file animation_playlist.cpp. References _Animations, _EndWeight, _EndWeightTime, _InvertWeight, _SkeletonWeight, _Smoothness, _StartWeight, _StartWeightTime, _WrapMode, NL3D::CChannelMixer::applySkeletonWeight(), Disable, empty, NL3D::CChannelMixer::emptySlot(), NL3D::CAnimationSet::getAnimation(), NL3D::CChannelMixer::getAnimationSet(), NL3D::CAnimation::getBeginTime(), NL3D::CAnimation::getEndTime(), getLocalTime(), getWeightValue(), NL3D::CChannelMixer::resetSkeletonWeight(), s, NL3D::CChannelMixer::setSlotAnimation(), NL3D::CChannelMixer::setSlotTime(), NL3D::CChannelMixer::setSlotWeight(), NL3D::TAnimationTime, NL3D::TGlobalAnimationTime, and uint8. Referenced by NL3D::CPlayListUser::evalPlayList().
00177 { 00178 // For each slot 00179 for (uint8 s=0; s<CChannelMixer::NumAnimationSlot; s++) 00180 { 00181 // *** Set the time 00182 00183 // Animation enabled 00184 bool enabled=true; 00185 00186 // Get the animationSet pointer from the mixer 00187 const CAnimationSet *animSet=mixer.getAnimationSet (); 00188 00189 // If is exists 00190 if (animSet) 00191 { 00192 if (_Animations[s]!=empty) 00193 { 00194 // Get the local time 00195 TAnimationTime wrappedTime = getLocalTime (s, time, *animSet); 00196 00197 // Get the animation 00198 const CAnimation *pAnimation=animSet->getAnimation (_Animations[s]); 00199 00200 // Disable mode ? 00201 if ((_WrapMode[s]==Disable)&&((wrappedTime<pAnimation->getBeginTime ())||(wrappedTime>pAnimation->getEndTime ()))) 00202 enabled=false; 00203 00204 // Set the time 00205 if (enabled) 00206 mixer.setSlotTime (s, wrappedTime); 00207 } 00208 } 00209 00210 // *** Set the animation 00211 00212 // Still enabled 00213 if (enabled) 00214 { 00215 // empty ? 00216 if (_Animations[s]==empty) 00217 // Empty the slot 00218 mixer.emptySlot (s); 00219 else 00220 // Set the animation id 00221 mixer.setSlotAnimation (s, _Animations[s]); 00222 00223 // *** Set the skeleton weight 00224 00225 // empty ? 00226 if (_SkeletonWeight[s]==empty) 00227 // Empty the slot 00228 mixer.resetSkeletonWeight (s); 00229 else 00230 // Set the animation id 00231 mixer.applySkeletonWeight (s, _SkeletonWeight[s], _InvertWeight[s]); 00232 00233 // *** Set the weight 00234 mixer.setSlotWeight (s, getWeightValue (_StartWeightTime[s], _EndWeightTime[s], time, _StartWeight[s], _EndWeight[s], _Smoothness[s])); 00235 } 00236 else 00237 { 00238 // Disable this slot 00239 mixer.emptySlot (s); 00240 } 00241 } 00242 } |
|
Set weight smoothness. This is the smoothness of the weight interpolation. Must be between 0.f and 1.f. 0.f is a sharp interpolation (linear), 1.f is a smooth interpolation (quadratic). Default value is 0.f.
Definition at line 162 of file animation_playlist.cpp. References _Smoothness, and uint8. Referenced by NL3D::CPlayListUser::setWeightSmoothness().
00163 { 00164 _Smoothness[slot]=smoothness; 00165 } |
|
Set the wrap mode to use in the play list. Wrap mode tells the play list how to use an animation when current time is not in the animation.
Definition at line 278 of file animation_playlist.cpp. References _WrapMode, and uint8. Referenced by NL3D::CScene::setAutomaticAnimationSet(), and NL3D::CPlayListUser::setWrapMode().
00279 { 00280 _WrapMode[slot]=wrapMode; 00281 } |
|
Definition at line 67 of file smart_ptr.h. |
|
Definition at line 274 of file animation_playlist.h. Referenced by emptyPlayList(), getAnimation(), getLocalTime(), serial(), setAnimation(), and setupMixer(). |
|
Definition at line 295 of file animation_playlist.h. Referenced by emptyPlayList(), getEndWeight(), getLocalWeight(), serial(), setEndWeight(), and setupMixer(). |
|
Definition at line 298 of file animation_playlist.h. Referenced by emptyPlayList(), getEndWeight(), getLocalWeight(), serial(), setEndWeight(), and setupMixer(). |
|
Definition at line 280 of file animation_playlist.h. Referenced by emptyPlayList(), getSkeletonWeight(), serial(), setSkeletonWeight(), and setupMixer(). |
|
Definition at line 277 of file animation_playlist.h. Referenced by emptyPlayList(), getSkeletonWeight(), serial(), setSkeletonWeight(), and setupMixer(). |
|
Definition at line 301 of file animation_playlist.h. Referenced by emptyPlayList(), getLocalWeight(), getWeightSmoothness(), serial(), setupMixer(), and setWeightSmoothness(). |
|
Definition at line 286 of file animation_playlist.h. Referenced by emptyPlayList(), getLocalTime(), getSpeedFactor(), serial(), and setSpeedFactor(). |
|
Definition at line 289 of file animation_playlist.h. Referenced by emptyPlayList(), getLocalWeight(), getStartWeight(), serial(), setStartWeight(), and setupMixer(). |
|
Definition at line 292 of file animation_playlist.h. Referenced by emptyPlayList(), getLocalWeight(), getStartWeight(), serial(), setStartWeight(), and setupMixer(). |
|
Definition at line 283 of file animation_playlist.h. Referenced by emptyPlayList(), getLocalTime(), getTimeOrigin(), serial(), and setTimeOrigin(). |
|
Definition at line 304 of file animation_playlist.h. Referenced by CAnimationPlaylist(), getLocalTime(), getWrapMode(), serial(), setupMixer(), and setWrapMode(). |
|
Definition at line 79 of file smart_ptr.h. Referenced by NLMISC::CRefCount::CRefCount(), NLMISC::CRefCount::getRefCount(), and NLMISC::CRefCount::~CRefCount(). |
|
Referenced by NLMISC::CRefCount::CRefCount(). |
|
Definition at line 80 of file smart_ptr.h. Referenced by NLMISC::CRefCount::CRefCount(), and NLMISC::CRefCount::~CRefCount(). |