an abstract class that allows matrix transformations More...
Public Member Functions | |
Transformable () | |
Constructor of Transformable. | |
virtual | ~Transformable () |
Destructor of Transformable. | |
void | setTransform (const float *transform) |
Sets the local transform of this Transformable. | |
void | setTransformNC (const float *transform) |
Sets the local transfom of this Transformable from a "non contiguous vector coordinates" matrix. | |
void | setTransformPosition (const Vector3D &pos) |
Sets the position of the local transform. | |
void | setTransformOrientationRH (Vector3D look, Vector3D up) |
Sets the orientation of the local transform in a right-handed system. | |
void | setTransformOrientationLH (Vector3D look, Vector3D up) |
Sets the orientation of the local transform in a left-handed system. | |
void | setTransformOrientation (Vector3D axis, float angle) |
Sets the orientation of the local transform. | |
void | setTransformOrientationX (float angle) |
Sets the orientation of the local transform. | |
void | setTransformOrientationY (float angle) |
Sets the orientation of the local transform. | |
void | setTransformOrientationZ (float angle) |
Sets the orientation of the local transform. | |
const float * | getLocalTransform () const |
Gets the local transform of this Transformable. | |
const float * | getWorldTransform () const |
Gets the world transform of this Transformable. | |
bool | isLocalIdentity () const |
Tells whether the local transform is the identity or not. | |
Vector3D | getLocalTransformPos () const |
Gets the position of the local transform. | |
Vector3D | getLocalTransformSide () const |
Gets the side vector of the local transform. | |
Vector3D | getLocalTransformUp () const |
Gets the up vector of the local transform. | |
Vector3D | getLocalTransformLookRH () const |
Gets the look vector of the local transform in a right-handed system. | |
Vector3D | getLocalTransformLookLH () const |
Gets the look vector of the local transform in a left-handed system. | |
Vector3D | getWorldTransformPos () const |
Gets the position of the world transform. | |
Vector3D | getWorldTransformSide () const |
Gets the side vector of the world transform. | |
Vector3D | getWorldTransformUp () const |
Gets the up vector of the world transform. | |
Vector3D | getWorldTransformLookRH () const |
Gets the look vector of the world transform in a right-handed system. | |
Vector3D | getWorldTransformLookLH () const |
Gets the look vector of the world transform in a left-handed system. | |
void | lookAtRH (const Vector3D &target, Vector3D up, const Vector3D &pos) |
lookAt method for a right-handed system | |
void | lookAtLH (const Vector3D &target, Vector3D up, const Vector3D &pos) |
lookAt method for a left-handed system | |
void | updateTransform (const Transformable *parent=NULL) |
Updates the world transform of this Transformable. | |
void | resetTransform () |
Resets the transform to identity. | |
Static Public Attributes | |
static const size_t | TRANSFORM_LENGTH = 16 |
The number of floats held by a transform. | |
static const float | IDENTITY [TRANSFORM_LENGTH] |
The identity matrix. | |
Protected Member Functions | |
void | transformPos (Vector3D &tPos, const Vector3D &pos) |
A helper method to transform a position from local to world coordinates. | |
void | transformDir (Vector3D &tDir, const Vector3D &dir) |
A helper method to transform a direction from local to world coordinates. | |
bool | isUpdateNotified () const |
Tells whether this Transformable needs update or not. | |
void | notifyForUpdate () |
Notifies the Transformable for a update need. | |
const Transformable * | getParentTransform () const |
Gets the latest parent of this Transformable. | |
virtual void | innerUpdateTransform () |
Updates all the parameters in the world coordinates. | |
virtual void | propagateUpdateTransform () |
Propagates the update of the transform to transformable children of this transformable. |
an abstract class that allows matrix transformations
Every SPARK object that can be transformated thanks to a matrix should derive from this class.
A Transformable stores a matrix and performs operation on object parameters function of its matrix.
It allows for instance to transform all emitters and zones in a system with a transform matrix.
Particles are still living in the world coordinates (unlike transforming the rendering process).
Note that SPARK is not a linear algebra library, so this class does not offers lots of matri operations.
It is rather designed to be plugged within an existing engine with its own matrix system.
SPARK was not designed to offer a complete scene graph. Even if the library can handle matrices stack, it does not offer lots of possibilities. Once again it was designed to be used with an existing outer scene graph.
The transforms used are continuous-in-memory homogeneous matrices with vectors being stored with their coordinates contiguous :
[side.x side.y side.z side.w up.x up.y up.z up.w look.x look.y look.z look.w pos.x pos.y pos.z pos.w]
(look being -look in right-handed coordinate systems)
Definition at line 56 of file SPK_Transformable.h.
Transformable | ( | ) |
Constructor of Transformable.
virtual ~Transformable | ( | ) | [virtual] |
Destructor of Transformable.
Definition at line 84 of file SPK_Transformable.h.
const float * getLocalTransform | ( | ) | const |
Gets the local transform of this Transformable.
Definition at line 447 of file SPK_Transformable.h.
Vector3D getLocalTransformLookLH | ( | ) | const |
Gets the look vector of the local transform in a left-handed system.
Definition at line 482 of file SPK_Transformable.h.
Vector3D getLocalTransformLookRH | ( | ) | const |
Gets the look vector of the local transform in a right-handed system.
Definition at line 477 of file SPK_Transformable.h.
Vector3D getLocalTransformPos | ( | ) | const |
Gets the position of the local transform.
Definition at line 462 of file SPK_Transformable.h.
Vector3D getLocalTransformSide | ( | ) | const |
Gets the side vector of the local transform.
Definition at line 467 of file SPK_Transformable.h.
Vector3D getLocalTransformUp | ( | ) | const |
Gets the up vector of the local transform.
Definition at line 472 of file SPK_Transformable.h.
const Transformable * getParentTransform | ( | ) | const [protected] |
Gets the latest parent of this Transformable.
Definition at line 540 of file SPK_Transformable.h.
const float * getWorldTransform | ( | ) | const |
Gets the world transform of this Transformable.
Definition at line 452 of file SPK_Transformable.h.
Vector3D getWorldTransformLookLH | ( | ) | const |
Gets the look vector of the world transform in a left-handed system.
Definition at line 507 of file SPK_Transformable.h.
Vector3D getWorldTransformLookRH | ( | ) | const |
Gets the look vector of the world transform in a right-handed system.
Definition at line 502 of file SPK_Transformable.h.
Vector3D getWorldTransformPos | ( | ) | const |
Gets the position of the world transform.
Definition at line 487 of file SPK_Transformable.h.
Vector3D getWorldTransformSide | ( | ) | const |
Gets the side vector of the world transform.
Definition at line 492 of file SPK_Transformable.h.
Vector3D getWorldTransformUp | ( | ) | const |
Gets the up vector of the world transform.
Definition at line 497 of file SPK_Transformable.h.
virtual void innerUpdateTransform | ( | ) | [protected, virtual] |
Updates all the parameters in the world coordinates.
This method can be overriden in derived classes of Transformable (By default it does nothing).
It is this method task to compute all parameters of the class that are dependent of the world transform.
Reimplemented in Zone, SphericEmitter, StraightEmitter, LinearForce, PointMass, Vortex, Cylinder, Line, Plane, and Ring.
Definition at line 399 of file SPK_Transformable.h.
bool isLocalIdentity | ( | ) | const |
Tells whether the local transform is the identity or not.
Definition at line 457 of file SPK_Transformable.h.
bool isUpdateNotified | ( | ) | const [protected] |
Tells whether this Transformable needs update or not.
Definition at line 530 of file SPK_Transformable.h.
lookAt method for a left-handed system
The vectors are normalized internally.
Note that this methods sets the local transform. To compute the world transform and propagate it, updateTransform(const Transformable*) must be called afterwards.
target | : the point the transformable is looking at | |
up | : the up vector of the transformable | |
pos | : the position of the transformable |
Definition at line 518 of file SPK_Transformable.h.
lookAt method for a right-handed system
The vectors are normalized internally.
Note that this methods sets the local transform. To compute the world transform and propagate it, updateTransform(const Transformable*) must be called afterwards.
target | : the point the transformable is looking at | |
up | : the up vector of the transformable | |
pos | : the position of the transformable |
Definition at line 512 of file SPK_Transformable.h.
void notifyForUpdate | ( | ) | [protected] |
Notifies the Transformable for a update need.
This method has to be called when modifying a parameter that impose the transform's recomputation.
Definition at line 535 of file SPK_Transformable.h.
virtual void propagateUpdateTransform | ( | ) | [protected, virtual] |
Propagates the update of the transform to transformable children of this transformable.
This method can be overriden in derived classes of Transformable (By default it does nothing).
It is this method task to call the updateTransform method of transformable children of this transformable.
Reimplemented in Emitter, Group, Modifier, and System.
Definition at line 409 of file SPK_Transformable.h.
void resetTransform | ( | ) |
Resets the transform to identity.
Definition at line 524 of file SPK_Transformable.h.
void setTransform | ( | const float * | transform | ) |
Sets the local transform of this Transformable.
Note that the matrix must contain the following value in that order :
[side.x side.y side.z side.w up.x up.y up.z up.w look.x look.y look.z look.w pos.x pos.y pos.z pos.w]
(look being -look in right-handed coordinate systems)
The matrix being row or column major is just a convention which is not important.
The only thing that matters is that vectors coordinates are contiguous in memory.
If not, see setTransformNC(const float*)
transform | : the transform to copy its content from |
Definition at line 440 of file SPK_Transformable.h.
void setTransformNC | ( | const float * | transform | ) |
Sets the local transfom of this Transformable from a "non contiguous vector coordinates" matrix.
Note that the matrix must contain the following value in that order :
[side.x up.x look.x pos.x side.x up.x look.x pos.x side.x up.x look.x pos.x side.w up.w look.w pos.w]
(look being -look in right-handed coordinate systems)
Note the inner transform is stored with vector coordinates being contiguous in memory.
See setTransform(const float*)
transform | : the transform to copy its content from |
void setTransformOrientation | ( | Vector3D | axis, | |
float | angle | |||
) |
Sets the orientation of the local transform.
This method allows to set the orientation around an arbitrary axis.
The position is left untouched.
Note that this methods sets the local transform. To compute the world transform and propagate it, updateTransform(const Transformable*) must be called afterwards.
axis | : the axis of rotation | |
angle | : the angle of rotation around the axis |
Sets the orientation of the local transform in a left-handed system.
The position is left untouched.
Note that this methods sets the local transform. To compute the world transform and propagate it, updateTransform(const Transformable*) must be called afterwards.
look | : the look vector of the transformable | |
up | : the up vector of the transformable |
Sets the orientation of the local transform in a right-handed system.
The position is left untouched.
Note that this methods sets the local transform. To compute the world transform and propagate it, updateTransform(const Transformable*) must be called afterwards.
look | : the look vector of the transformable | |
up | : the up vector of the transformable |
void setTransformOrientationX | ( | float | angle | ) |
Sets the orientation of the local transform.
This method allows to set the orientation around an the x axis.
The position is left untouched.
Note that this methods sets the local transform. To compute the world transform and propagate it, updateTransform(const Transformable*) must be called afterwards.
angle | : the angle of rotation around the x axis |
void setTransformOrientationY | ( | float | angle | ) |
Sets the orientation of the local transform.
This method allows to set the orientation around an the y axis.
The position is left untouched.
Note that this methods sets the local transform. To compute the world transform and propagate it, updateTransform(const Transformable*) must be called afterwards.
angle | : the angle of rotation around the y axis |
void setTransformOrientationZ | ( | float | angle | ) |
Sets the orientation of the local transform.
This method allows to set the orientation around an the z axis.
The position is left untouched.
Note that this methods sets the local transform. To compute the world transform and propagate it, updateTransform(const Transformable*) must be called afterwards.
angle | : the angle of rotation around the z axis |
void setTransformPosition | ( | const Vector3D & | pos | ) |
Sets the position of the local transform.
The orientation is left untouched.
Note that this methods sets the local transform. To compute the world transform and propagate it, updateTransform(const Transformable*) must be called afterwards.
pos | : the position of the local transform |
A helper method to transform a direction from local to world coordinates.
tDir | : the resulting transformed direction | |
dir | : the direction in local coordinates |
A helper method to transform a position from local to world coordinates.
tPos | : the resulting transformed position | |
pos | : the position in local coordinates |
void updateTransform | ( | const Transformable * | parent = NULL |
) |
Updates the world transform of this Transformable.
The parent transform and the local transform is used to derive the world transform.
If parent is NULL, the local transform is simply copied to the world transform.
Note that this method only updates the transform if needed
parent | : the parent node of this Transformable or NULL |
const float IDENTITY[TRANSFORM_LENGTH] [static] |
The identity matrix.
Definition at line 68 of file SPK_Transformable.h.
const size_t TRANSFORM_LENGTH = 16 [static] |
The number of floats held by a transform.
Definition at line 65 of file SPK_Transformable.h.