This object stores the read-only data of an IPO.
More...
|
enum | { IP_CONST
, IP_LINEAR
, IP_BEZIER
} |
| The three interpolations defined by blender.
|
|
enum | { ET_CONST
, ET_EXTRAP
, ET_CYCLIC_EXTRAP
, ET_CYCLIC
} |
| The four extend types.
|
|
|
| IpoData (const XMLNode &curve, float fps, bool reverse) |
| Initialise the Ipo from the specifications in the XML file.
|
|
void | readCurve (const XMLNode &node, bool reverse) |
| Reads in 3 dimensional curve data - i.e.
|
|
void | readIPO (const XMLNode &node, float fps, bool reverse) |
| Reads a blender IPO curve, which constists of a frame number and a control point.
|
|
float | approximateLength (float t0, float t1, const Vec3 &p0, const Vec3 &p1, const Vec3 &h1, const Vec3 &h2) |
| Approximates the length of a bezier curve using a simple Euler approximation by dividing the interval [t0, t1] into 10 pieces.
|
|
float | adjustTime (float time) |
| Adjusts the time so that it is between start and end of this Ipo.
|
|
float | get (float time, unsigned int index, unsigned int n) |
|
float | getDerivative (float time, unsigned int index, unsigned int n) |
| Determines the derivative of a IPO at a given point.
|
|
|
IpoChannelType | m_channel |
| The type of this IPO.
|
|
enum Ipo::IpoData:: { ... } | m_interpolation |
| The three interpolations defined by blender.
|
|
enum Ipo::IpoData:: { ... } | m_extend |
| The four extend types.
|
|
std::vector< Vec3 > | m_points |
| The actual control points.
|
|
std::vector< Vec3 > | m_handle1 |
| Only used for bezier curves: the two handles.
|
|
std::vector< Vec3 > | m_handle2 |
|
float | m_start_time |
| Time of the first control point.
|
|
float | m_end_time |
| Time of the last control point.
|
|
Vec3 | m_initial_xyz |
| Stores the inital position of the object.
|
|
Vec3 | m_initial_hpr |
| Stores the inital rotation of the object.
|
|
|
float | getCubicBezier (float t, float p0, float p1, float p2, float p3) const |
| Computes a cubic bezier curve for a given t in [0,1] and four control points.
|
|
float | getCubicBezierDerivative (float t, float p0, float p1, float p2, float p3) const |
| Returns the derivative of a cubic bezier curve for a given t in [0,1] and four control points.
|
|
void | approximateBezier (float t0, float t1, const Vec3 &p0, const Vec3 &p1, const Vec3 &h0, const Vec3 &h2, unsigned int rec_level=0) |
| This function approximates a bezier curve by piecewise linear functions.
|
|
This object stores the read-only data of an IPO.
It might be shared among several instances of an Ipo (e.g. in a cannon animation).
◆ IpoData()
Ipo::IpoData::IpoData |
( |
const XMLNode & |
curve, |
|
|
float |
fps, |
|
|
bool |
reverse |
|
) |
| |
Initialise the Ipo from the specifications in the XML file.
- Parameters
-
curve | The XML node with the IPO data. |
fps | Frames per second value, necessary to convert frame values into time. |
reverse | If this is set to true, the ipo data will be reverse. This is used by the cannon if the track is driven in reverse. |
◆ adjustTime()
float Ipo::IpoData::adjustTime |
( |
float |
time | ) |
|
Adjusts the time so that it is between start and end of this Ipo.
This takes the extend type into account, e.g. cyclic animations will just use a modulo operation, while constant extends will return start or end time directly.
- Parameters
-
◆ approximateBezier()
void Ipo::IpoData::approximateBezier |
( |
float |
t0, |
|
|
float |
t1, |
|
|
const Vec3 & |
p0, |
|
|
const Vec3 & |
p1, |
|
|
const Vec3 & |
h0, |
|
|
const Vec3 & |
h1, |
|
|
unsigned int |
rec_level = 0 |
|
) |
| |
|
private |
This function approximates a bezier curve by piecewise linear functions.
It uses quite primitive approximations: if the estimated distance of the bezier curve at between t=t0 and t=t1 is greater than 2, it inserts one point at (t0+t1)/2, and recursively splits the two intervals further. End condition is either a maximum recursion depth of 6 or an estimated curve length of less than 2. It does not add any points at t=t0 or t=t1, only between this interval.
- Parameters
-
t0,t1 | The interval which is approximated. |
p0,p1,h0,h1 | The bezier parameters. |
rec_level | The recursion level to avoid creating too many points. |
◆ approximateLength()
float Ipo::IpoData::approximateLength |
( |
float |
t0, |
|
|
float |
t1, |
|
|
const Vec3 & |
p0, |
|
|
const Vec3 & |
p1, |
|
|
const Vec3 & |
h0, |
|
|
const Vec3 & |
h1 |
|
) |
| |
Approximates the length of a bezier curve using a simple Euler approximation by dividing the interval [t0, t1] into 10 pieces.
Good enough for our needs in STK.
- Parameters
-
t0,t1 | Approximate for t in [t0, t1]. |
p0,p1 | The start and end point of the curve. |
h0,h1 | The control points for the corresponding points. |
◆ getCubicBezier()
float Ipo::IpoData::getCubicBezier |
( |
float |
t, |
|
|
float |
p0, |
|
|
float |
p1, |
|
|
float |
p2, |
|
|
float |
p3 |
|
) |
| const |
|
private |
Computes a cubic bezier curve for a given t in [0,1] and four control points.
The curve will go through p0 (t=0), p3 (t=1).
- Parameters
-
t | The parameter for the bezier curve, must be in [0,1]. |
p0,p1,p2,p3 | The four control points. |
◆ getCubicBezierDerivative()
float Ipo::IpoData::getCubicBezierDerivative |
( |
float |
t, |
|
|
float |
p0, |
|
|
float |
p1, |
|
|
float |
p2, |
|
|
float |
p3 |
|
) |
| const |
|
private |
Returns the derivative of a cubic bezier curve for a given t in [0,1] and four control points.
The curve will go through p0 (t=0).
- Parameters
-
t | The parameter for the bezier curve, must be in [0,1]. |
p0,p1,p2,p3 | The four control points. |
◆ getDerivative()
float Ipo::IpoData::getDerivative |
( |
float |
time, |
|
|
unsigned int |
index, |
|
|
unsigned int |
n |
|
) |
| |
Determines the derivative of a IPO at a given point.
- Parameters
-
time | At what time value the derivative is to be computed. |
index | IpoData is based on 3d data. The index specified which value to use (0=x, 1=y, 2=z). |
n | Curve segment to be used for the computation. It must be correct for the specified time value. |
◆ readCurve()
void Ipo::IpoData::readCurve |
( |
const XMLNode & |
curve, |
|
|
bool |
reverse |
|
) |
| |
Reads in 3 dimensional curve data - i.e.
the xml file contains xyz, but no time. If the curve is using bezier interpolation, the curve is approximated by piecewise linear functions. Reason is that bezier curves can not (easily) be used for smooth (i.e. constant speed) driving: A linear time variation in [0, 1] will result in non-linear distances for the bezier function, which is a 3rd degree polynomial (--> the speed which is the deviation of this function is a 2nd degree polynomial, and therefore not constant!
- Parameters
-
node | The root node with all curve data points. |
reverse | If this is set, the data are read in reverse. This is used for a cannon in reverse mode. |
◆ readIPO()
void Ipo::IpoData::readIPO |
( |
const XMLNode & |
curve, |
|
|
float |
fps, |
|
|
bool |
reverse |
|
) |
| |
Reads a blender IPO curve, which constists of a frame number and a control point.
This only handles a single axis.
- Parameters
-
node | The root node with all curve data points. |
fps | Frames per second value, necessary to convert the frame based data from blender into times. |
reverse | If this is set, the data are read in reverse. This is used for a cannon in reverse mode. |
The documentation for this class was generated from the following files:
- animations/ipo.hpp
- animations/ipo.cpp