Nebula
Loading...
Searching...
No Matches
animjob.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
20#include "core/refcounted.h"
21#include "coreanimation/animresource.h"
23#include "jobs/jobport.h"
24#include "math/vector.h"
25#include "math/point.h"
27#include "characters/characterjointmask.h"
28
29//------------------------------------------------------------------------------
30namespace Animation
31{
32class AnimSequencer;
33class AnimEventInfo;
34
36{
38public:
40 AnimJob();
42 virtual ~AnimJob();
43
45 void SetName(const Util::StringAtom& id);
47 const Util::StringAtom& GetName() const;
48
50 bool IsAttachedToSequencer() const;
52 bool IsActive(Timing::Tick time) const;
54 bool IsPending(Timing::Tick time) const;
56 bool IsStoppingOrExpired(Timing::Tick time) const;
58 bool IsExpired(Timing::Tick time) const;
60 bool IsPaused() const;
61
65 IndexT GetTrackIndex() const;
71 void SetExclusiveTag(IndexT id);
73 IndexT GetExclusiveTag() const;
74
76 void SetStartTime(Timing::Tick time);
80 void SetDuration(Timing::Tick time);
84 bool IsInfinite() const;
94 void SetTime(Timing::Tick time);
96 Timing::Tick GetTime() const;
98 void SetTimeFactor(float timeFactor);
100 float GetTimeFactor() const;
105
107 void SetBlendWeight(float w);
109 float GetBlendWeight() const;
110
112 void SetMask(const Characters::CharacterJointMask* mask);
114 const Characters::CharacterJointMask* GetMask() const;
115
122
123protected:
124 friend class AnimSequencer;
125
127 void SetBaseTime(Timing::Tick time);
133 virtual void OnRemoveFromSequencer();
135 float ComputeBlendWeight(Timing::Tick relEvalTime) const;
137 void FixFadeTimes();
143 virtual void UpdateTimes(Timing::Tick time);
145 virtual void Stop(Timing::Tick time);
147 virtual void Pause(bool pause);
148
149
151 const Characters::CharacterJointMask* mask;
169};
170
171//------------------------------------------------------------------------------
174inline void
179
180//------------------------------------------------------------------------------
185{
186 return this->enqueueMode;
187}
188
189//------------------------------------------------------------------------------
192inline void
194{
195 this->name = n;
196}
197
198//------------------------------------------------------------------------------
201inline const Util::StringAtom&
203{
204 return this->name;
205}
206
207//------------------------------------------------------------------------------
210inline void
212{
213 this->exclusiveTag = i;
214}
215
216//------------------------------------------------------------------------------
219inline IndexT
221{
222 return this->exclusiveTag;
223}
224
225//------------------------------------------------------------------------------
228inline void
230{
231 this->trackIndex = i;
232}
233
234//------------------------------------------------------------------------------
237inline IndexT
239{
240 return this->trackIndex;
241}
242
243//------------------------------------------------------------------------------
246inline void
248{
249 this->baseTime = t;
250}
251
252//------------------------------------------------------------------------------
255inline Timing::Tick
257{
258 return this->baseTime;
259}
260
261//------------------------------------------------------------------------------
264inline void
266{
267 this->startTime = t;
268 this->lastSampleTime = t;
269}
270
271//------------------------------------------------------------------------------
274inline Timing::Tick
276{
277 return this->startTime;
278}
279
280//------------------------------------------------------------------------------
283inline void
285{
286 this->duration = t;
287}
288
289//------------------------------------------------------------------------------
292inline Timing::Tick
294{
295 return this->duration;
296}
297
298//------------------------------------------------------------------------------
301inline bool
303{
304 return (0 == this->duration);
305}
306
307//------------------------------------------------------------------------------
310inline void
315
316//------------------------------------------------------------------------------
319inline Timing::Tick
321{
322 return this->fadeInTime;
323}
324
325//------------------------------------------------------------------------------
328inline void
333
334//------------------------------------------------------------------------------
337inline Timing::Tick
339{
340 return this->fadeOutTime;
341}
342
343//------------------------------------------------------------------------------
346inline void
348{
349 this->curSampleTime = this->startTime + time;
350 this->lastSampleTime = this->curSampleTime;
351}
352
353//------------------------------------------------------------------------------
356inline Timing::Tick
358{
359 return this->curSampleTime;
360}
361
362//------------------------------------------------------------------------------
365inline void
367{
368 this->blendWeight = w;
369}
370
371//------------------------------------------------------------------------------
374inline float
376{
377 return this->blendWeight;
378}
379
380//------------------------------------------------------------------------------
383inline void
384AnimJob::SetMask(const Characters::CharacterJointMask* mask)
385{
386 this->mask = mask;
387}
388
389//------------------------------------------------------------------------------
392inline const Characters::CharacterJointMask*
394{
395 return this->mask;
396}
397
398//------------------------------------------------------------------------------
401inline void
403{
404 this->timeFactor = f;
405}
406
407//------------------------------------------------------------------------------
410inline float
412{
413 return this->timeFactor;
414}
415
416//------------------------------------------------------------------------------
419inline void
424
425//------------------------------------------------------------------------------
428inline Timing::Tick
430{
431 return this->timeOffset;
432}
433
434//------------------------------------------------------------------------------
437inline bool
439{
440 return this->isPaused;
441}
442
443} // namespace Animation
444//------------------------------------------------------------------------------
Code
enqueue modes
Definition animjobenqueuemode.h:22
Descibes a single animation sampling job in the AnimController.
Definition animjob.h:36
void SetTrackIndex(IndexT trackIndex)
set track index, defines blend priority and relationship to other jobs on same track
Definition animjob.h:229
bool IsActive(Timing::Tick time) const
return true if the job has currently playing (EvalTime within start/end time)
Definition animjob.cc:127
Timing::Tick GetFadeInTime() const
get the fade-in time of the anim job
Definition animjob.h:320
bool IsAttachedToSequencer() const
return true if the job is currently attached to a sequencer
Definition animjob.cc:116
AnimJobEnqueueMode::Code GetEnqueueMode() const
get the enqueue behaviour of the new job
Definition animjob.h:184
Timing::Tick lastRelEvalTime
Definition animjob.h:162
void SetExclusiveTag(IndexT id)
exclusive tag (for AnimJobEnqueueMode::IgnoreIfSameExclTagActive)
Definition animjob.h:211
float GetBlendWeight() const
get blend weight of the anim job
Definition animjob.h:375
float blendWeight
Definition animjob.h:167
const Util::StringAtom & GetName() const
get human readable name (only used for debugging)
Definition animjob.h:202
void SetTimeFactor(float timeFactor)
set time factor
Definition animjob.h:402
void SetStartTime(Timing::Tick time)
set the start time of the anim job (relative to base time)
Definition animjob.h:265
float ComputeBlendWeight(Timing::Tick relEvalTime) const
compute current blend weight, this should take fade-in into account
Definition animjob.cc:228
virtual void Stop(Timing::Tick time)
stop the anim job at the given time
Definition animjob.cc:281
Timing::Tick GetDuration() const
get the duration of the anim job
Definition animjob.h:293
bool IsPending(Timing::Tick time) const
return true if the job has been queued for playback but has not started yet
Definition animjob.cc:147
Timing::Tick GetFadeOutTime() const
get the fade-out time of the anim job
Definition animjob.h:338
Timing::Tick duration
Definition animjob.h:158
bool IsStoppingOrExpired(Timing::Tick time) const
return true if anim job is stopping or expired
Definition animjob.cc:157
Timing::Tick timeOffset
Definition animjob.h:165
void SetMask(const Characters::CharacterJointMask *mask)
set joint mask
Definition animjob.h:384
Timing::Tick fadeInTime
Definition animjob.h:159
Timing::Tick GetAbsoluteEndTime() const
get the absolute end time (BaseTime + StartTime + Duration)
Definition animjob.cc:203
void SetName(const Util::StringAtom &id)
set human readable name (only used for debugging)
Definition animjob.h:193
Timing::Tick GetAbsoluteStartTime() const
get the absolute start time (BaseTime + StartTime)
Definition animjob.cc:192
virtual void OnRemoveFromSequencer()
called when removed from sequencer
Definition animjob.cc:82
Timing::Tick GetStartTime() const
get the start time of the anim job (relative to base time)
Definition animjob.h:275
const AnimSequencer * animSequencer
Definition animjob.h:150
AnimJob()
constructor
Definition animjob.cc:21
Timing::Tick lastSampleTime
Definition animjob.h:164
virtual void Pause(bool pause)
pause the anim job at the given time
Definition animjob.cc:302
IndexT GetTrackIndex() const
get track index
Definition animjob.h:238
void SetBlendWeight(float w)
set blend weight of the anim job (default is 1.0)
Definition animjob.h:366
virtual Util::Array< AnimEventInfo > EmitAnimEvents(Timing::Tick startTime, Timing::Tick endTime, const Util::String &optionalCatgeory)
emit anim events inside given time range
Definition animjob.cc:336
bool IsInfinite() const
return true if the anim job is infinite
Definition animjob.h:302
void SetEnqueueMode(AnimJobEnqueueMode::Code enqueueMode)
set the enqueue behaviour of the new job (default is intercept)
Definition animjob.h:175
Util::StringAtom name
Definition animjob.h:152
Timing::Tick GetBaseTime() const
get the base time of the anim job
Definition animjob.h:256
virtual ~AnimJob()
destructor
Definition animjob.cc:47
IndexT GetExclusiveTag() const
exclusive flag set?
Definition animjob.h:220
virtual void UpdateTimes(Timing::Tick time)
compute sample time for next evaluation, always done, also if character isn't visible and no evaluati...
Definition animjob.cc:259
void FixFadeTimes()
fix fade-in/fade-out times if the sum is bigger then the play duration
Definition animjob.cc:95
IndexT exclusiveTag
Definition animjob.h:155
virtual Ptr< Jobs::Job > CreateEvaluationJob(Timing::Tick time, const Ptr< CoreAnimation::AnimSampleBuffer > &mixIn, const Ptr< CoreAnimation::AnimSampleBuffer > &result)
create evaluation job for asynchronous evaluation
Definition animjob.cc:326
bool IsPaused() const
returns true if the clip is playing, but has been paused
Definition animjob.h:438
float timeFactor
Definition animjob.h:166
void SetTimeOffset(Timing::Tick timeOffset)
set sample time offset (if sampling should not start at the beginning)
Definition animjob.h:420
Timing::Tick fadeOutTime
Definition animjob.h:160
Timing::Tick startTime
Definition animjob.h:157
void SetBaseTime(Timing::Tick time)
set the base time of the anim job (set by sequencer when job is attached)
Definition animjob.h:247
IndexT trackIndex
Definition animjob.h:154
virtual void OnAttachedToSequencer(const AnimSequencer &animSequencer)
called when attached to anim sequencer
Definition animjob.cc:56
void SetDuration(Timing::Tick time)
set the duration of the anim job (0 == infinite)
Definition animjob.h:284
Timing::Tick GetTime() const
get current time of anim job
Definition animjob.h:357
float GetTimeFactor() const
get time factor
Definition animjob.h:411
bool IsExpired(Timing::Tick time) const
return true when the job has expired
Definition animjob.cc:175
Timing::Tick GetAbsoluteStopTime() const
get the absolute, computed end time ((BaseTime + StartTime + Duration) - FadeOutTime)
Definition animjob.cc:215
Timing::Tick baseTime
Definition animjob.h:156
const Characters::CharacterJointMask * GetMask() const
get joint mask
Definition animjob.h:393
__DeclareClass(AnimJob)
void SetFadeInTime(Timing::Tick fadeInTime)
set the fade-in time of the anim job
Definition animjob.h:311
Timing::Tick curSampleTime
Definition animjob.h:163
Timing::Tick curRelEvalTime
Definition animjob.h:161
Timing::Tick GetTimeOffset() const
get sample time offset
Definition animjob.h:429
void SetTime(Timing::Tick time)
jump to a specific time in the job
Definition animjob.h:347
AnimJobEnqueueMode::Code enqueueMode
Definition animjob.h:153
bool isPaused
Definition animjob.h:168
void SetFadeOutTime(Timing::Tick fadeOutTime)
set the fade-out time of the anim job
Definition animjob.h:329
const Characters::CharacterJointMask * mask
Definition animjob.h:151
An AnimSequencer object arranges AnimJobs along the time line to produce a single,...
Definition animsequencer.h:28
The common base class of Nebula.
Definition refcounted.h:38
Nebula's smart pointer class which manages the life time of RefCounted objects.
Definition ptr.h:38
Nebula's dynamic array class.
Definition array.h:60
A StringAtom.
Definition stringatom.h:22
Definition animeventhandlerbase.cc:10
int Tick
the tick datatype (one tick == 1 millisecond)
Definition time.h:20
Nebula's universal string class.
Definition string.h:50
int IndexT
Definition types.h:48