![]() |
Plasma Engine
2.0
|
A 1D curve for animating a single value over time. More...
#include <Curve1D.h>
Classes | |
struct | ControlPoint |
Stores position and tangents to control spline interpolation. More... | |
Public Member Functions | |
void | Clear () |
Removes all control points. | |
bool | IsEmpty () const |
Checks whether the curve has any control point. | |
ControlPoint & | AddControlPoint (double fPos) |
Appends a control point. SortControlPoints() must be called to before evaluating the curve. | |
void | RecomputeExtents () |
Updates the min/max X value that can be retrieved through GetExtents(). | |
void | QueryExtents (double &ref_fMinx, double &ref_fMaxx) const |
returns the min and max position value across all control points. | |
void | QueryExtremeValues (double &ref_fMinVal, double &ref_fMaxVal) const |
Returns the min and max Y value across the curve. For this information to be available, the linear approximation of the curve must have been computed, otherwise stale values will be returned. | |
plUInt32 | GetNumControlPoints () const |
Returns the number of control points. | |
const ControlPoint & | GetControlPoint (plUInt32 uiIdx) const |
Const access to a control point. | |
ControlPoint & | ModifyControlPoint (plUInt32 uiIdx) |
Non-const access to a control point. If you modify the position, SortControlPoints() has to be called before evaluating the curve. | |
void | SortControlPoints () |
Sorts the control point arrays by their position. The CPs have to be sorted before calling Evaluate(), otherwise the result will be wrong. | |
double | Evaluate (double fPosition) const |
Evaluates the curve at the given position (x coordinate) and returns the value Y value at that point. | |
double | ConvertNormalizedPos (double fPos) const |
Takes the normalized x coordinate [0;1] and converts it into a valid position on the curve. | |
double | NormalizeValue (double value) const |
Takes a value (typically returned by Evaluate()) and normalizes it into [0;1] range. | |
plUInt64 | GetHeapMemoryUsage () const |
How much heap memory the curve uses. | |
void | Save (plStreamWriter &inout_stream) const |
Stores the current state in a stream. | |
void | Load (plStreamReader &inout_stream) |
Restores the state from a stream. | |
void | CreateLinearApproximation (double fMaxError=0.01, plUInt8 uiMaxSubDivs=8) |
Pre-computes sample points for linear interpolation that approximate the curve within the allowed error threshold. | |
const plHybridArray< plVec2d, 24 > & | GetLinearApproximation () const |
void | ClampTangents () |
Adjusts the tangents such that the curve cannot make loopings. | |
void | ApplyTangentModes () |
Adjusts the tangents in accordance to the specified tangent modes at each control point. | |
void | MakeFixedLengthTangentLeft (plUInt32 uiCpIdx) |
Typically called by ApplyTangentModes() for specific control points. Control points must be in sorted order. | |
void | MakeFixedLengthTangentRight (plUInt32 uiCpIdx) |
Typically called by ApplyTangentModes() for specific control points. Control points must be in sorted order. | |
void | MakeLinearTangentLeft (plUInt32 uiCpIdx) |
Typically called by ApplyTangentModes() for specific control points. Control points must be in sorted order. | |
void | MakeLinearTangentRight (plUInt32 uiCpIdx) |
Typically called by ApplyTangentModes() for specific control points. Control points must be in sorted order. | |
void | MakeAutoTangentLeft (plUInt32 uiCpIdx) |
void | MakeAutoTangentRight (plUInt32 uiCpIdx) |
A 1D curve for animating a single value over time.
void plCurve1D::ApplyTangentModes | ( | ) |
Adjusts the tangents in accordance to the specified tangent modes at each control point.
double plCurve1D::ConvertNormalizedPos | ( | double | fPos | ) | const |
Takes the normalized x coordinate [0;1] and converts it into a valid position on the curve.
void plCurve1D::CreateLinearApproximation | ( | double | fMaxError = 0.01, |
plUInt8 | uiMaxSubDivs = 8 ) |
Pre-computes sample points for linear interpolation that approximate the curve within the allowed error threshold.
double plCurve1D::Evaluate | ( | double | fPosition | ) | const |
Evaluates the curve at the given position (x coordinate) and returns the value Y value at that point.
This uses the linear approximation of the curve, so CreateLinearApproximation() must have been called first.
double plCurve1D::NormalizeValue | ( | double | value | ) | const |
Takes a value (typically returned by Evaluate()) and normalizes it into [0;1] range.
void plCurve1D::QueryExtents | ( | double & | ref_fMinx, |
double & | ref_fMaxx ) const |
returns the min and max position value across all control points.
The returned values are only up to date if either SortControlPoints() or RecomputeExtents() was called before. Otherwise they will contain stale values.
void plCurve1D::RecomputeExtents | ( | ) |
Updates the min/max X value that can be retrieved through GetExtents().
This is automatically done when SortControlPoints() is called. It can be called manually, if the information is required without sorting.