Motive Animation System
An open source project by FPL.
 All Classes Functions Variables Typedefs Friends Pages
motive::MotivatorXfTemplate< VectorConverter, kDimensionsParam > Class Template Reference

Animate a vector of floating-point values. More...

#include <motivator.h>

Inheritance diagram for motive::MotivatorXfTemplate< VectorConverter, kDimensionsParam >:
motive::MotivatorNf motive::Motivator

Detailed Description

template<class VectorConverter, MotiveDimension kDimensionsParam>
class motive::MotivatorXfTemplate< VectorConverter, kDimensionsParam >

Animate a vector of floating-point values.

Wraps MotivatorNf to return by value, instead of using out arrays. For kDimension = 1, the vector type is just float. For kDimension > 1, the vector type is determined by VectorConverter. We use MathFuVectorConverter below to create 2, 3, and 4 dimensional motivators (see Motivator2f, Motivator3f, and Motivator4f). You can use your own VectorConverter to create Motivators of that match your vector types.

Public Types

typedef VectorConverter C
 
typedef VectorT< C,
kDimensions >::type 
Vec
 
typedef MotiveTargetT
< kDimensions >::type 
Target
 
typedef
MotiveTargetBuilderTemplate< C,
kDimensions > 
TargetBuilder
 

Public Member Functions

 MotivatorXfTemplate ()
 
 MotivatorXfTemplate (const MotivatorInit &init, MotiveEngine *engine)
 
 MotivatorXfTemplate (const MotivatorInit &init, MotiveEngine *engine, const Target &t)
 
void Initialize (const MotivatorInit &init, MotiveEngine *engine)
 Initialize to the motion algorithm specified by init.
 
void InitializeWithTarget (const MotivatorInit &init, MotiveEngine *engine, const Target &t)
 
void InitializeWithTargetShape (const MotivatorInit &init, MotiveEngine *engine, MotiveDimension dimensions, const MotiveCurveShape &shape, const Vec &target_values, const Vec &target_velocities)
 
Vec Value () const
 
Vec Velocity () const
 
Vec Direction () const
 
Vec TargetValue () const
 
Vec TargetVelocity () const
 
Vec Difference () const
 
void SetTarget (const Target &t)
 
void SetTargetWithShape (const Vec &target_value, const Vec &target_velocity, const MotiveCurveShape &shape)
 
MotiveDimension Dimensions () const
 
- Public Member Functions inherited from motive::MotivatorNf
 MotivatorNf ()
 
 MotivatorNf (const MotivatorInit &init, MotiveEngine *engine, MotiveDimension dimensions)
 
 MotivatorNf (const MotivatorInit &init, MotiveEngine *engine, MotiveDimension dimensions, const MotiveTarget1f *ts)
 
void Initialize (const MotivatorInit &init, MotiveEngine *engine, MotiveDimension dimensions)
 
void InitializeWithTargets (const MotivatorInit &init, MotiveEngine *engine, MotiveDimension dimensions, const MotiveTarget1f *targets)
 
void InitializeWithTargetShape (const MotivatorInit &init, MotiveEngine *engine, MotiveDimension dimensions, const MotiveCurveShape &shape, const float *target_values, const float *target_velocities)
 
void InitializeWithSplines (const MotivatorInit &init, MotiveEngine *engine, MotiveDimension dimensions, const CompactSpline *splines, const SplinePlayback &playback)
 
const float * Values () const
 
void Velocities (float *out) const
 
void Directions (float *out) const
 
void TargetValues (float *out) const
 
void TargetVelocities (float *out) const
 
void Differences (float *out) const
 
MotiveTime TargetTime () const
 
MotiveCurveShape MotiveShape () const
 Returns the shape of the current curve.
 
MotiveTime SplineTime () const
 
void Splines (const CompactSpline **splines) const
 
void SetSpline (const CompactSpline &spline, const SplinePlayback &playback)
 
void SetSplines (const CompactSpline *splines, const SplinePlayback &playback)
 
void SetSplineTime (MotiveTime time)
 
void SetSplinePlaybackRate (float playback_rate)
 
void SetTargets (const MotiveTarget1f *targets)
 
void SetTargetWithShape (const float *target_values, const float *target_velocities, const MotiveCurveShape &shape)
 
void SetSplinesAndTargets (const CompactSpline *const *splines, const SplinePlayback &playback, const MotiveTarget1f *targets)
 
- Public Member Functions inherited from motive::Motivator
 Motivator (const Motivator &original)
 
Motivatoroperator= (const Motivator &original)
 
 ~Motivator ()
 Remove ourselves from the MotiveProcessor when we're deleted.
 
void Invalidate ()
 
bool Valid () const
 
bool Sane () const
 
MotivatorType Type () const
 
MotiveDimension Dimensions () const
 

Static Public Attributes

static const MotiveDimension kDimensions = kDimensionsParam
 

Additional Inherited Members

- Protected Member Functions inherited from motive::MotivatorNf
MotiveProcessorNfProcessor ()
 
const MotiveProcessorNfProcessor () const
 
- Protected Member Functions inherited from motive::Motivator
 Motivator (const MotivatorInit &init, MotiveEngine *engine, MotiveDimension dimensions)
 
void InitializeWithDimension (const MotivatorInit &init, MotiveEngine *engine, MotiveDimension dimensions)
 
void Init (MotiveProcessor *processor, MotiveIndex index)
 These should only be called by MotiveProcessor!
 
void Reset ()
 
const MotiveProcessorProcessor () const
 
- Protected Attributes inherited from motive::Motivator
MotiveProcessorprocessor_
 
MotiveIndex index_
 

Constructor & Destructor Documentation

template<class VectorConverter , MotiveDimension kDimensionsParam>
motive::MotivatorXfTemplate< VectorConverter, kDimensionsParam >::MotivatorXfTemplate ( )
inline

Motivator is created in a reset state. When in the reset state, it is not being driven, and Value(), Velocity(), etc. cannot be called.

template<class VectorConverter , MotiveDimension kDimensionsParam>
motive::MotivatorXfTemplate< VectorConverter, kDimensionsParam >::MotivatorXfTemplate ( const MotivatorInit init,
MotiveEngine engine 
)
inline

Initialize to the motion algorithm specified by init. Current and target values are not set.

template<class VectorConverter , MotiveDimension kDimensionsParam>
motive::MotivatorXfTemplate< VectorConverter, kDimensionsParam >::MotivatorXfTemplate ( const MotivatorInit init,
MotiveEngine engine,
const Target &  t 
)
inline

Initialize to the motion algorithm specified by init. Set current and target values as specified by t.

Member Function Documentation

template<class VectorConverter , MotiveDimension kDimensionsParam>
Vec motive::MotivatorXfTemplate< VectorConverter, kDimensionsParam >::Difference ( ) const
inline

Returns TargetValue() minus Value(). If we're driving a modular type (e.g. an angle), this may not be the naive subtraction. For example, if TargetValue() = 170 degrees, Value() = -170 degrees, then Difference() = -20 degrees.

template<class VectorConverter , MotiveDimension kDimensionsParam>
Vec motive::MotivatorXfTemplate< VectorConverter, kDimensionsParam >::Direction ( ) const
inline

Returns the velocity when playback rate is 1. Useful to know the direction of a multi-dimensional motivator, even when playback rate is 0.

template<class VectorConverter , MotiveDimension kDimensionsParam>
void motive::MotivatorXfTemplate< VectorConverter, kDimensionsParam >::InitializeWithTarget ( const MotivatorInit init,
MotiveEngine engine,
const Target &  t 
)
inline

Initialize to the motion algorithm specified by init. Set current and target values as specified by t.

template<class VectorConverter , MotiveDimension kDimensionsParam>
void motive::MotivatorXfTemplate< VectorConverter, kDimensionsParam >::InitializeWithTargetShape ( const MotivatorInit init,
MotiveEngine engine,
MotiveDimension  dimensions,
const MotiveCurveShape shape,
const Vec &  target_values,
const Vec &  target_velocities 
)
inline

Initialize to the motion algorithm specified by init. Set target values and velocities as specified by 'target_values' and 'target_velocities', arrays of length dimensions, with shape specified by 'shape'.

template<class VectorConverter , MotiveDimension kDimensionsParam>
void motive::MotivatorXfTemplate< VectorConverter, kDimensionsParam >::SetTarget ( const Target &  t)
inline

Set the target and (optionally the current) motivator values. Use this call to procedurally drive the Motivator towards a specific target. The Motivator will transition smoothly to the new target. You can change the target value every frame if you like, and the Motivator value should behave calmly but responsively, with the movement qualities of the underlying MotiveProcessor. Note that the underlying MotiveProcessor is allowed to ignore parts of t that are irrelevent to its algorithm. Note also that if the time needed to achieve a value is to be user-provided, this function should be used. If the time should be calculated instead of user-specified, SetTargetWithShape should be used instead.

Parameters
tA set of waypoints to hit, optionally including the current value. If the current value is not included, maintain the existing current value.
template<class VectorConverter , MotiveDimension kDimensionsParam>
void motive::MotivatorXfTemplate< VectorConverter, kDimensionsParam >::SetTargetWithShape ( const Vec &  target_value,
const Vec &  target_velocity,
const MotiveCurveShape shape 
)
inline

Set the target values, velocity, and curve shape for the motivator. Use this call to procedurally drive the Motivator towards that target. Setting the target with the shape makes it so that a time does not need to be specified, as it will be calculated. In contrast, if the time needed to achieve a value is to be user-provided, SetTarget should be used instead.

Parameters
target_valueThe target value to hit.
target_velocityThe velocity with which to hit the target value.
shapeThe shape of the curve we'll create, such as the curve's typical delta value, typical total time, and bias.
template<class VectorConverter , MotiveDimension kDimensionsParam>
Vec motive::MotivatorXfTemplate< VectorConverter, kDimensionsParam >::TargetValue ( ) const
inline

Returns the value this Motivator is driving towards. If being driven by a spline, returns the value at the end of the spline.

template<class VectorConverter , MotiveDimension kDimensionsParam>
Vec motive::MotivatorXfTemplate< VectorConverter, kDimensionsParam >::TargetVelocity ( ) const
inline

Returns the rate-of-change of this Motivator once it reaches TargetValue().

template<class VectorConverter , MotiveDimension kDimensionsParam>
Vec motive::MotivatorXfTemplate< VectorConverter, kDimensionsParam >::Value ( ) const
inline

Returns the current motivator value. The current value is updated when engine->AdvanceFrame() is called on the engine that initialized this Motivator. Note that the "Vec()" parameter is just a syntactic hack used to access the correct overloaded function in the processor.

template<class VectorConverter , MotiveDimension kDimensionsParam>
Vec motive::MotivatorXfTemplate< VectorConverter, kDimensionsParam >::Velocity ( ) const
inline

Returns the current rate of change of this motivator. For example, if this Motivator is being driven by a spline, returns the derivative at the current time in the spline curve.


The documentation for this class was generated from the following file: