|
resonance 1.0.1
|
Value that moves toward a target at a fixed rate, read through a linear mapping. More...
#include <linearanim.h>
Public Member Functions | |
| LinearAnim () | |
| Start at 0 with no time recorded, mapping 0 through 1 onto 0 through 100 over 240 units. | |
| void | SetParams (float flFrom, float flTo, float flDuration) |
| Set the mapping and the rate. | |
| void | SetTarget (float flTarget) |
| Set the raw value to move toward. | |
| void | Jump (float flTarget) |
| Set the target and move the raw value almost onto it at once. | |
| float | Val () const |
| Report the mapped value. | |
| int | Execute (float flTime) |
| Move the raw value toward the target by the time elapsed since the last call. | |
Value that moves toward a target at a fixed rate, read through a linear mapping.
The class is not polymorphic and emits no RTTI. Its name comes from the debugging symbols of the North American demo release. The head-up display and the tunnel both embed it by value.
The raw value runs from 0 toward mTarget at mRate per unit of Execute()'s time, and Val() reports it as mCurrent * mScale + mOffset. SetParams() fixes the mapping and the rate.
| LinearAnim::LinearAnim | ( | ) |
Start at 0 with no time recorded, mapping 0 through 1 onto 0 through 100 over 240 units.
| void LinearAnim::SetParams | ( | float | flFrom, |
| float | flTo, | ||
| float | flDuration ) |
Set the mapping and the rate.
A raw value of 0 maps to flFrom and 1 maps to flTo, and the raw value covers that span in flDuration units of time.
| flFrom | The mapped value at raw 0. |
| flTo | The mapped value at raw 1. |
| flDuration | The time the raw value takes to cover 0 through 1. |
| void LinearAnim::SetTarget | ( | float | flTarget | ) |
Set the raw value to move toward.
| flTarget | The raw target. |
| void LinearAnim::Jump | ( | float | flTarget | ) |
Set the target and move the raw value almost onto it at once.
The raw value lands one millionth short of the target, computed in double precision. The next Execute() then finishes the move and reports a change. The title is inferred.
| flTarget | The raw target. |
| float LinearAnim::Val | ( | ) | const |
Report the mapped value.
| int LinearAnim::Execute | ( | float | flTime | ) |
Move the raw value toward the target by the time elapsed since the last call.
The first call after construction only records the time. A step that would overshoot lands on the target.
| flTime | The current time. |