15#include <vsg/core/Allocator.h>
16#include <vsg/core/Inherit.h>
17#include <vsg/core/Visitor.h>
23 class VSG_DECLSPEC AnimationSampler :
public Inherit<Visitor, AnimationSampler>
27 AnimationSampler(
const AnimationSampler& rhs,
const CopyOp& copyop = {});
31 virtual void update(
double time) = 0;
32 virtual double maxTime()
const = 0;
37 void read(
Input& input)
override;
38 void write(
Output& output)
const override;
43 class VSG_DECLSPEC Animation :
public Inherit<Object, Animation>
47 Animation(
const Animation& rhs,
const CopyOp& copyop = {});
68 using Samplers = std::vector<ref_ptr<AnimationSampler>>;
72 virtual bool start(
double simulationTime,
double startTime = 0.0);
75 virtual bool update(
double simulationTime);
78 virtual bool stop(
double simulationTime);
81 bool active()
const {
return _active; }
90 template<
class N,
class V>
91 static void t_traverse(N& node, V& visitor)
93 for (
auto& sampler : node.samplers) sampler->accept(visitor);
95 void traverse(
Visitor& visitor)
override { t_traverse(*
this, visitor); }
96 void traverse(ConstVisitor& visitor)
const override { t_traverse(*
this, visitor); }
98 void read(Input& input)
override;
99 void write(Output& output)
const override;
103 bool _active =
false;
104 double _previousSimulationTime = 0.0;
105 double _maxTime = 0.0;
107 VSG_type_name(vsg::Animation);
109 using Animations = std::vector<ref_ptr<Animation>, allocator_affinity_nodes<ref_ptr<Animation>>>;
virtual double maxTime() const
compute the max time from the highest time keyframes in the available samplers
Mode mode
specify how time value outside the sampler maxTime period is managed
Definition Animation.h:59
double speed
speed multiplier for how quickly the Animation::time changes with changes in simulationTime
Definition Animation.h:65
ref_ptr< Object > clone(const CopyOp ©op={}) const override
Definition Animation.h:87
bool active() const
return true if this animation is being actively updated.
Definition Animation.h:81
double time
local animation time used to look up samplers, automatically updated by the Animation::update(....
Definition Animation.h:62
std::vector< ref_ptr< AnimationSampler > > Samplers
Animation samplers provide the means for mapping the local animation time.
Definition Animation.h:68
virtual bool update(double simulationTime)
update the samplers
virtual bool stop(double simulationTime)
signal that this animation is to stop
int compare(const Object &rhs) const override
compare two objects, return -1 if this object is less than rhs, return 0 if it's equal,...
virtual bool start(double simulationTime, double startTime=0.0)
initialize this animation start time
Base class for animation samplers that sample animation data and set associated scene graph objects.
Definition Animation.h:24
int compare(const Object &rhs) const override
compare two objects, return -1 if this object is less than rhs, return 0 if it's equal,...