C4 Engine
C4 Engine API Documentation

class Interpolator

Defined in:  C4Time.h
Encapsulates a general interpolator.
Definition

class Interpolator : public Completable<Interpolator>

Member Functions
Interpolator::GetValue Returns the current value of an interpolator.
Interpolator::SetValue Sets the current value of an interpolator.
Interpolator::GetRange Returns the range of an interpolator.
Interpolator::SetMinValue Sets the minimum value of an interpolator.
Interpolator::SetMaxValue Sets the maximum value of an interpolator.
Interpolator::SetRange Sets the minimum and maximum values of an interpolator.
Interpolator::GetRate Returns the rate at which an interpolator changes.
Interpolator::SetRate Sets the rate at which an interpolator changes.
Interpolator::GetMode Returns the current mode for an interpolator.
Interpolator::SetMode Sets the current mode for an interpolator.
Interpolator::SetLoopCallback Sets the loop callback function for an interpolator.
Interpolator::SetState Sets the current value, rate, and mode for an interpolator.
Interpolator::UpdateValue Updates an interpolator.
Constructor

Interpolator();

Interpolator(float value, float rate = 0.0F, uint32 mode = kInterpolatorStop);

Parameters
value The initial value of the interpolator.
rate The rate at which the interpolated value changes. This is measured in value change per millisecond.
mode The initial interpolation mode. See below for possible values.
Description
The Interpolator class is used to represent a generic value that is being interpolated between two other values. An Interpolator object stores a current value, the range of values through which it is interpolated, the rate at which it moves from one end of the range to the other, and a mode that determinates what happens when an endpoint is reached.

The value parameter specifies the initial value of the interpolator. If the default constructor is used, then the initial value of the interpolator is zero. The initial value can be outside the minimum and maximum values that are initially assigned as the range of the interpolator.

The rate parameter specifies the rate at which the interpolated value changes as a difference applied for each millisecond of time. For example, if a rate of 0.005 is specified, it would take 200 ms to interpolate from an initial value of 0.0 to a final value of 1.0. If the default constructor is used, then the initial rate is 0.0, meaning that the interpolator's value will never change.

The mode parameter specifies the initial mode of the interpolator, which can be a combination (through logical OR) of the following constants.
kInterpolatorStop The interpolator is stopped.
kInterpolatorForward The interpolator is moving forward. Only one of kInterpolatorForward and kInterpolatorBackward may be set.
kInterpolatorBackward The interpolator is moving backward. Only one of kInterpolatorForward and kInterpolatorBackward may be set.
kInterpolatorLoop The interpolator is loops in the same direction when it reaches the maximum or minimum value.
kInterpolatorOscillate The interpolator reverses direction when it reaches the maximum value. If kInterpolatorLoop is also set, the interpolator reverses direction when it reaches the minimum value as well.
If the default constructor is used, then the initial mode is kInterpolatorStop.

The initial range for an interpolator object is [0.0, 1.0].

The interpolated value is changed based on the current rate and mode when the Interpolator::UpdateValue function is called.
Base Classes
Completable<Interpolator> The completion callback function is called when an interpolator goes into the stopped state.