Radium Engine  1.5.20
Loading...
Searching...
No Matches
Ra::Core::Animation::KeyFramedValue< VALUE_TYPE > Class Template Reference

#include <Core/Animation/KeyFramedValue.hpp>

+ Inheritance diagram for Ra::Core::Animation::KeyFramedValue< VALUE_TYPE >:
+ Collaboration diagram for Ra::Core::Animation::KeyFramedValue< VALUE_TYPE >:

Public Types

using KeyFrame = std::pair<Scalar, VALUE_TYPE>
 The type for a keyframe.
 
using KeyFrames = std::vector<KeyFrame>
 The type for the keyframes container.
 
using Interpolator = std::function<VALUE_TYPE( const KeyFramedValue<VALUE_TYPE>&, Scalar )>
 The type for interpolators.
 

Public Member Functions

 KeyFramedValue (Scalar t, VALUE_TYPE frame)
 
 KeyFramedValue (const KeyFramedValue &keyframe)=default
 
KeyFramedValueoperator= (const KeyFramedValue &keyframe)=default
 
std::vector< Scalar > getTimes () const override
 
KeyFrame Management
size_t size () const override
 
const KeyFramesgetKeyFrames () const
 
const KeyFrameoperator[] (size_t i) const
 
void insertKeyFrame (const Scalar &t, const VALUE_TYPE &frame)
 
void insertInterpolatedKeyFrame (const Scalar &t, const Interpolator &interpolator)
 
bool removeKeyFrame (size_t i) override
 
void moveKeyFrame (size_t i, const Scalar &t) override
 
VALUE_TYPE at (const Scalar &t, const Interpolator &interpolator) const
 
std::tuple< size_t, size_t, Scalar > findRange (Scalar t) const
 
Comparison operators
bool operator== (const KeyFramedValue &keyframe) const
 
bool operator!= (const KeyFramedValue &keyframe) const
 
- Public Member Functions inherited from Ra::Core::Animation::KeyFramedValueBase

Protected Attributes

KeyFrames m_keyframes
 The list of keyframes.
 

Detailed Description

template<typename VALUE_TYPE>
class Ra::Core::Animation::KeyFramedValue< VALUE_TYPE >

KeyFramedValue extends KeyFramedValueBase by implementing its interface, adding management for the VALUE_TYPE KeyFramedValue::KeyFrame, which are pairs (time,value) sorted by time.

It also introduces the concept of Interpolator: a KeyFramedValue::Interpolator is a function that takes as input a KeyFramedValue and returns the value for a given time t (see for instance Ra::Core::Animation::linearInterpolate).

Note
There is always at least one keyframe defined.

Definition at line 62 of file KeyFramedValue.hpp.

Member Typedef Documentation

◆ Interpolator

template<typename VALUE_TYPE >
using Ra::Core::Animation::KeyFramedValue< VALUE_TYPE >::Interpolator = std::function<VALUE_TYPE( const KeyFramedValue<VALUE_TYPE>&, Scalar )>

The type for interpolators.

Definition at line 72 of file KeyFramedValue.hpp.

◆ KeyFrame

template<typename VALUE_TYPE >
using Ra::Core::Animation::KeyFramedValue< VALUE_TYPE >::KeyFrame = std::pair<Scalar, VALUE_TYPE>

The type for a keyframe.

Definition at line 66 of file KeyFramedValue.hpp.

◆ KeyFrames

template<typename VALUE_TYPE >
using Ra::Core::Animation::KeyFramedValue< VALUE_TYPE >::KeyFrames = std::vector<KeyFrame>

The type for the keyframes container.

Definition at line 69 of file KeyFramedValue.hpp.

Constructor & Destructor Documentation

◆ KeyFramedValue()

template<typename VALUE_TYPE >
Ra::Core::Animation::KeyFramedValue< VALUE_TYPE >::KeyFramedValue ( Scalar t,
VALUE_TYPE frame )
inline

Creates a KeyFramedValue from a first keyframe.

Parameters
tthe first keyframe point in time.
framethe first keyframe value.

Definition at line 79 of file KeyFramedValue.hpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ at()

template<typename VALUE_TYPE >
VALUE_TYPE Ra::Core::Animation::KeyFramedValue< VALUE_TYPE >::at ( const Scalar & t,
const Interpolator & interpolator ) const
inline
Returns
the value at time t, interpolated from the keyframes using the given interpolator.

Definition at line 163 of file KeyFramedValue.hpp.

◆ findRange()

template<typename VALUE_TYPE >
std::tuple< size_t, size_t, Scalar > Ra::Core::Animation::KeyFramedValue< VALUE_TYPE >::findRange ( Scalar t) const
inline

Look for the keyframes around time t.

Parameters
tThe time to search for.
Returns
a triplet(i,j,dt), where i is the index for the keyframe preceding t, j is the index for the keyframe following t and dt \( \in [0;1] \) is the linear parameter of t between times ti and tj at keyframes i and j.
Note
If t is lower than the first keyframe's time tf, then i = j = 0 and dt = 0. If t is higher than the last keyframe's time tl, then i = j = the index of the last keyframe and dt = 0. If t is an exact match on a keyframe's time tt, then i = j = the index of the keyframe and dt = 0.

Definition at line 181 of file KeyFramedValue.hpp.

+ Here is the call graph for this function:

◆ getKeyFrames()

template<typename VALUE_TYPE >
const KeyFrames & Ra::Core::Animation::KeyFramedValue< VALUE_TYPE >::getKeyFrames ( ) const
inline
Returns
the collection of keyframes.

Definition at line 105 of file KeyFramedValue.hpp.

◆ getTimes()

template<typename VALUE_TYPE >
std::vector< Scalar > Ra::Core::Animation::KeyFramedValue< VALUE_TYPE >::getTimes ( ) const
inlineoverridevirtual
Returns
the ordered list of the points in time where a keyframe is defined.

Implements Ra::Core::Animation::KeyFramedValueBase.

Definition at line 85 of file KeyFramedValue.hpp.

+ Here is the call graph for this function:

◆ insertInterpolatedKeyFrame()

template<typename VALUE_TYPE >
void Ra::Core::Animation::KeyFramedValue< VALUE_TYPE >::insertInterpolatedKeyFrame ( const Scalar & t,
const Interpolator & interpolator )
inline

Inserts a keyframe at time t corresponding to the value interpolated at t using the given interpolator.

Definition at line 134 of file KeyFramedValue.hpp.

+ Here is the call graph for this function:

◆ insertKeyFrame()

template<typename VALUE_TYPE >
void Ra::Core::Animation::KeyFramedValue< VALUE_TYPE >::insertKeyFrame ( const Scalar & t,
const VALUE_TYPE & frame )
inline

Inserts a new keyframe with value frame at time t.

Note
If a keyframe already exists for t, it will be overwritten.

Definition at line 116 of file KeyFramedValue.hpp.

+ Here is the call graph for this function:

◆ moveKeyFrame()

template<typename VALUE_TYPE >
void Ra::Core::Animation::KeyFramedValue< VALUE_TYPE >::moveKeyFrame ( size_t i,
const Scalar & t )
inlineoverridevirtual

Moves the i-th keyframe to time t.

Implements Ra::Core::Animation::KeyFramedValueBase.

Definition at line 151 of file KeyFramedValue.hpp.

+ Here is the call graph for this function:

◆ operator!=()

template<typename VALUE_TYPE >
bool Ra::Core::Animation::KeyFramedValue< VALUE_TYPE >::operator!= ( const KeyFramedValue< VALUE_TYPE > & keyframe) const
inline
Returns
true if *this and keyframe do not have the exact same keyframes, false otherwise.

Definition at line 227 of file KeyFramedValue.hpp.

◆ operator==()

template<typename VALUE_TYPE >
bool Ra::Core::Animation::KeyFramedValue< VALUE_TYPE >::operator== ( const KeyFramedValue< VALUE_TYPE > & keyframe) const
inline
Returns
true if *this and keyframe have the exact same keyframes, false otherwise.

Definition at line 219 of file KeyFramedValue.hpp.

◆ operator[]()

template<typename VALUE_TYPE >
const KeyFrame & Ra::Core::Animation::KeyFramedValue< VALUE_TYPE >::operator[] ( size_t i) const
inline
Returns
the i-th keyframe.

Definition at line 110 of file KeyFramedValue.hpp.

◆ removeKeyFrame()

template<typename VALUE_TYPE >
bool Ra::Core::Animation::KeyFramedValue< VALUE_TYPE >::removeKeyFrame ( size_t i)
inlineoverridevirtual

Removes the i-th keyframe, if not the only one.

Returns
true if the keyframed has been removed, false otherwise.

Implements Ra::Core::Animation::KeyFramedValueBase.

Definition at line 142 of file KeyFramedValue.hpp.

+ Here is the call graph for this function:

◆ size()

template<typename VALUE_TYPE >
size_t Ra::Core::Animation::KeyFramedValue< VALUE_TYPE >::size ( ) const
inlineoverridevirtual
Returns
the number of keyframes.

Implements Ra::Core::Animation::KeyFramedValueBase.

Definition at line 100 of file KeyFramedValue.hpp.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_keyframes

template<typename VALUE_TYPE >
KeyFrames Ra::Core::Animation::KeyFramedValue< VALUE_TYPE >::m_keyframes
protected

The list of keyframes.

Definition at line 234 of file KeyFramedValue.hpp.


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