overview wiki api reference download
 All Classes Functions Variables Typedefs Enumerations Enumerator
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes
gameplay::Transform Class Reference

#include <Transform.h>

Inheritance diagram for gameplay::Transform:
gameplay::AnimationTarget gameplay::ScriptTarget gameplay::Node gameplay::Joint

List of all members.

Classes

class  Listener
struct  TransformListener

Public Member Functions

 Transform ()
 Transform (const Vector3 &scale, const Quaternion &rotation, const Vector3 &translation)
 Transform (const Vector3 &scale, const Matrix &rotation, const Vector3 &translation)
 Transform (const Transform &copy)
virtual ~Transform ()
const char * getTypeName () const
const MatrixgetMatrix () const
const Vector3getScale () const
void getScale (Vector3 *scale) const
float getScaleX () const
float getScaleY () const
float getScaleZ () const
const QuaterniongetRotation () const
void getRotation (Quaternion *rotation) const
void getRotation (Matrix *rotation) const
float getRotation (Vector3 *axis) const
const Vector3getTranslation () const
void getTranslation (Vector3 *translation) const
float getTranslationX () const
float getTranslationY () const
float getTranslationZ () const
Vector3 getForwardVector () const
void getForwardVector (Vector3 *dst) const
Vector3 getBackVector () const
void getBackVector (Vector3 *dst) const
Vector3 getUpVector () const
void getUpVector (Vector3 *dst) const
Vector3 getDownVector () const
void getDownVector (Vector3 *dst) const
Vector3 getLeftVector () const
void getLeftVector (Vector3 *dst) const
Vector3 getRightVector () const
void getRightVector (Vector3 *dst) const
void rotate (float qx, float qy, float qz, float qw)
void rotate (const Quaternion &rotation)
void rotate (const Vector3 &axis, float angle)
void rotate (const Matrix &rotation)
void rotateX (float angle)
void rotateY (float angle)
void rotateZ (float angle)
void scale (float scale)
void scale (float sx, float sy, float sz)
void scale (const Vector3 &scale)
void scaleX (float sx)
void scaleY (float sy)
void scaleZ (float sz)
void set (const Vector3 &scale, const Quaternion &rotation, const Vector3 &translation)
void set (const Vector3 &scale, const Matrix &rotation, const Vector3 &translation)
void set (const Vector3 &scale, const Vector3 &axis, float angle, const Vector3 &translation)
void set (const Transform &transform)
void setIdentity ()
void setScale (float scale)
void setScale (float sx, float sy, float sz)
void setScale (const Vector3 &scale)
void setScaleX (float sx)
void setScaleY (float sy)
void setScaleZ (float sz)
void setRotation (float qx, float qy, float qz, float qw)
void setRotation (const Quaternion &rotation)
void setRotation (const Matrix &rotation)
void setRotation (const Vector3 &axis, float angle)
void setTranslation (const Vector3 &translation)
void setTranslation (float tx, float ty, float tz)
void setTranslationX (float tx)
void setTranslationY (float ty)
void setTranslationZ (float tz)
void translate (float tx, float ty, float tz)
void translate (const Vector3 &translation)
void translateX (float tx)
void translateY (float ty)
void translateZ (float tz)
void translateLeft (float amount)
void translateUp (float amount)
void translateForward (float amount)
void translateSmooth (const Vector3 &target, float elapsedTime, float responseTime)
void transformPoint (Vector3 *point)
void transformPoint (const Vector3 &point, Vector3 *dst)
void transformVector (Vector3 *vector)
void transformVector (const Vector3 &transformVector, Vector3 *dst)
void transformVector (float x, float y, float z, float w, Vector3 *dst)
virtual bool isStatic () const
void addListener (Transform::Listener *listener, long cookie=0)
void removeListener (Transform::Listener *listener)
unsigned int getAnimationPropertyComponentCount (int propertyId) const
void getAnimationPropertyValue (int propertyId, AnimationValue *value)
void setAnimationPropertyValue (int propertyId, AnimationValue *value, float blendWeight=1.0f)

Static Public Member Functions

static void suspendTransformChanged ()
static void resumeTransformChanged ()
static bool isTransformChangedSuspended ()

Static Public Attributes

static const int ANIMATE_SCALE_UNIT = 0
static const int ANIMATE_SCALE = 1
static const int ANIMATE_SCALE_X = 2
static const int ANIMATE_SCALE_Y = 3
static const int ANIMATE_SCALE_Z = 4
static const int ANIMATE_ROTATE = 8
static const int ANIMATE_TRANSLATE = 9
static const int ANIMATE_TRANSLATE_X = 10
static const int ANIMATE_TRANSLATE_Y = 11
static const int ANIMATE_TRANSLATE_Z = 12
static const int ANIMATE_ROTATE_TRANSLATE = 16
static const int ANIMATE_SCALE_ROTATE_TRANSLATE = 17
static const int ANIMATE_SCALE_TRANSLATE = 18
static const int ANIMATE_SCALE_ROTATE = 19

Protected Types

enum  MatrixDirtyBits { DIRTY_TRANSLATION = 0x01, DIRTY_SCALE = 0x02, DIRTY_ROTATION = 0x04, DIRTY_NOTIFY = 0x08 }

Protected Member Functions

void dirty (char matrixDirtyBits)
bool isDirty (char matrixDirtyBits) const
virtual void transformChanged ()
void cloneInto (Transform *transform, NodeCloneContext &context) const

Static Protected Member Functions

static void suspendTransformChange (Transform *transform)

Protected Attributes

Vector3 _scale
Quaternion _rotation
Vector3 _translation
Matrix _matrix
char _matrixDirtyBits
std::list< TransformListener > * _listeners

Detailed Description

Defines a 3-dimensional transformation.

When using the scale, rotate, and translate methods, only the transform's corresponding scale, rotation, or translation component is updated (it is not as if the scale, rotate, or translate is applied to the transform's matrix).

Note: To construct a Transform from a transformation matrix stored as a Matrix, first decompose the Matrix into its separate translation, scale, and rotation components using matrix.decompose(Vector3, Quaternion, Vector3) and then pass those arguments to the appropriate constructor or set methods of Transform.


Member Enumeration Documentation

Defines the matrix dirty bits for marking the translation, scale and rotation components of the Transform.


Constructor & Destructor Documentation

Constructs the identity transform.

gameplay::Transform::Transform ( const Vector3 scale,
const Quaternion rotation,
const Vector3 translation 
)

Constructs a new transform from the specified values.

Parameters:
scaleThe scale vector.
rotationThe rotation quaternion.
translationThe translation vector.
gameplay::Transform::Transform ( const Vector3 scale,
const Matrix rotation,
const Vector3 translation 
)

Constructs a new transform from the specified values.

Parameters:
scaleThe scale vector.
rotationThe rotation matrix.
translationThe translation vector.

Constructs a new transform from the given transform.

Parameters:
copyThe transform to copy.
virtual gameplay::Transform::~Transform ( ) [virtual]

Destructor.


Member Function Documentation

void gameplay::Transform::addListener ( Transform::Listener listener,
long  cookie = 0 
)

Adds a transform listener.

Parameters:
listenerThe listener to add.
cookieAn optional long value that is passed to the specified listener when it is called.
void gameplay::Transform::cloneInto ( Transform transform,
NodeCloneContext context 
) const [protected]

Copies from data from this node into transform for the purpose of cloning.

Parameters:
transformThe transform to copy into.
contextThe clone context.
void gameplay::Transform::dirty ( char  matrixDirtyBits) [protected]

Marks this transform as dirty and fires transformChanged().

unsigned int gameplay::Transform::getAnimationPropertyComponentCount ( int  propertyId) const [virtual]
void gameplay::Transform::getAnimationPropertyValue ( int  propertyId,
AnimationValue value 
) [virtual]
See also:
AnimationTarget::getAnimationProperty

Implements gameplay::AnimationTarget.

Returns the back vector for this transform.

Returns the back vector for this Transform.

Parameters:
dstThe vector to store the result in.

Returns the down vector for this transform.

Returns the down vector for this Transform.

Parameters:
dstThe vector to store the result in.

Returns the forward vector for this Transform.

Returns the forward vector for this Transform.

Parameters:
dstThe vector to store the result in.

Returns the left vector for this Transform.

Returns the left vector for this Transform.

Parameters:
dstThe vector to store the result in.

Gets the matrix corresponding to this transform.

The matrix returned from this method is mathematically equivalent to this transform only as long as this transform is not changed (i.e. by calling set(), setScale(), translate(), rotateX(), etc.). Once the transform has been changed, the user must call getMatrix() again to get the updated matrix. Also note that changing the matrix returned from this method does not change this transform.

Returns:
The matrix of this transform.

Returns the right vector for this transform.

Returns the right vector for this Transform.

Parameters:
dstThe vector to store the result in.

Returns the rotation for this transform.

void gameplay::Transform::getRotation ( Quaternion rotation) const

Gets the rotation component of this transform in the specified quaternion.

Parameters:
rotationThe quaternion to store the rotation in.
void gameplay::Transform::getRotation ( Matrix rotation) const

Gets the rotation component of this transform in the specified matrix.

Parameters:
rotationThe matrix to store the rotation in.
float gameplay::Transform::getRotation ( Vector3 axis) const

Gets the angle of rotation, and stores the axis of rotation of this transform in the specified Vector3.

Parameters:
axisThe vector to store the axis of rotation.
Returns:
The angle of rotation.

Returns the scale for this transform.

void gameplay::Transform::getScale ( Vector3 scale) const

Gets the scale component of this transform in the specified vector.

Parameters:
scaleThe vector to store the scale in.

Gets the scale factor along the x-axis of this transform.

Returns:
The scale factor along the x-axis.

Gets the scale factor along the y-axis of this transform.

Returns:
The scale factor along the y-axis.

Gets the scale factor along the z-axis of this transform.

Returns:
The scale factor along the z-axis.

Returns the translation for this transform.

void gameplay::Transform::getTranslation ( Vector3 translation) const

Gets the translation component of this transform in the specified vector.

Parameters:
translationThe vector to store the translation in.

Gets the translation factor along the x-axis of this transform.

Returns:
The translation factor along the x-axis.

Gets the translation factor along the y-axis of this transform.

Returns:
The translation factor along the y-axis.

Gets the translation factor along the z-axis of this transform.

Returns:
The translation factor along the z-axis.
const char* gameplay::Transform::getTypeName ( ) const [virtual]

Extends ScriptTarget::getTypeName() to return the type name of this class.

Returns:
The type name of this class: "Transform"
See also:
ScriptTarget::getTypeName()

Implements gameplay::ScriptTarget.

Reimplemented in gameplay::Node.

Returns the up vector for this Transform.

Returns the up vector for this Transform.

Parameters:
dstThe vector to store the result in.
bool gameplay::Transform::isDirty ( char  matrixDirtyBits) const [protected]

Determines if the specified matrix dirty bit is set.

Parameters:
matrixDirtyBitsthe matrix dirty bit to check for dirtiness.
Returns:
TRUE if the specified matrix dirty bit is set; FALSE if the specified matrix dirty bit is unset.
virtual bool gameplay::Transform::isStatic ( ) const [virtual]

Returns whether or not this Transform object is static.

A static transform object cannot be transformed. This may be the case for special types of Transform objects, such as Nodes that have a static rigid body attached to them.

Returns:
True if this Transform is static, false otherwise.

Reimplemented in gameplay::Node.

Gets whether all transform changed events are suspended.

Returns:
TRUE if transform changed events are suspended; FALSE if transform changed events are not suspended.

Removes a transform listener.

Parameters:
listenerThe listener to remove.

Globally resumes all transform changed events.

void gameplay::Transform::rotate ( float  qx,
float  qy,
float  qz,
float  qw 
)

Rotates this transform's rotation component by the given rotation.

Parameters:
qxThe quaternion x value.
qyThe quaternion y value.
qzThe quaternion z value.
qwThe quaternion w value.
void gameplay::Transform::rotate ( const Quaternion rotation)

Rotates this transform's rotation component by the given rotation.

Parameters:
rotationThe rotation to rotate by (as a quaternion).
void gameplay::Transform::rotate ( const Vector3 axis,
float  angle 
)

Rotates this transform's rotation component by the given rotation (defined as an axis angle rotation).

Parameters:
axisThe axis to rotate about.
angleThe axis to rotate about (in radians).
void gameplay::Transform::rotate ( const Matrix rotation)

Rotates this transform's rotation component by the given rotation.

Parameters:
rotationThe rotation to rotate by (as a matrix).
void gameplay::Transform::rotateX ( float  angle)

Rotates this transform's rotation component by the given angle about the x-axis.

Parameters:
angleThe angle to rotate by about the x-axis (in radians).
void gameplay::Transform::rotateY ( float  angle)

Rotates this transform's rotation component by the given angle about the y-axis.

Parameters:
angleThe angle to rotate by about the y-axis (in radians).
void gameplay::Transform::rotateZ ( float  angle)

Rotates this transform's rotation component by the given angle about the z-axis.

Parameters:
angleThe angle to rotate by about the z-axis (in radians).
void gameplay::Transform::scale ( float  scale)

Scales this transform's scale component by the given factor along all axes.

Parameters:
scaleThe factor to scale by along all axis.
void gameplay::Transform::scale ( float  sx,
float  sy,
float  sz 
)

Scales this transform's scale component by the given factors along each axis.

Parameters:
sxThe factor to scale by in the x direction.
syThe factor to scale by in the y direction.
szThe factor to scale by in the z direction.
void gameplay::Transform::scale ( const Vector3 scale)

Scales this transform's scale component by the given scale vector.

Parameters:
scaleThe vector to scale by.
void gameplay::Transform::scaleX ( float  sx)

Scales this transform's scale component by the given scale factor along the x axis.

Parameters:
sxThe scale factor along the x axis.
void gameplay::Transform::scaleY ( float  sy)

Scales this transform's scale component by the given scale factor along the y axis.

Parameters:
syThe scale factor along the y axis.
void gameplay::Transform::scaleZ ( float  sz)

Scales this transform's scale component by the given scale factor along the z axis.

Parameters:
szThe scale factor along the z axis.
void gameplay::Transform::set ( const Vector3 scale,
const Quaternion rotation,
const Vector3 translation 
)

Sets the transform to the specified values.

Parameters:
scaleThe scale vector.
rotationThe rotation quaternion.
translationThe translation vector.
void gameplay::Transform::set ( const Vector3 scale,
const Matrix rotation,
const Vector3 translation 
)

Sets the transform to the specified values.

Parameters:
scaleThe scale vector.
rotationThe rotation matrix.
translationThe translation vector.
void gameplay::Transform::set ( const Vector3 scale,
const Vector3 axis,
float  angle,
const Vector3 translation 
)

Sets the transform to the specified values.

Parameters:
scaleThe scale vector.
axisThe axis of rotation.
angleThe angle of rotation (in radians).
translationThe translation vector.
void gameplay::Transform::set ( const Transform transform)

Sets this transform to the specified transform.

Parameters:
transformThe transform to set this transform to.
void gameplay::Transform::setAnimationPropertyValue ( int  propertyId,
AnimationValue value,
float  blendWeight = 1.0f 
) [virtual]
See also:
AnimationTarget::setAnimationProperty

Implements gameplay::AnimationTarget.

Sets this transform to the identity transform.

void gameplay::Transform::setRotation ( float  qx,
float  qy,
float  qz,
float  qw 
)

Sets the rotation component for this transform to the specified values.

Parameters:
qxThe quaternion x value.
qyThe quaternion y value.
qzThe quaternion z value.
qwThe quaternion w value.
void gameplay::Transform::setRotation ( const Quaternion rotation)

Sets the rotation component for this transform to the specified values.

Parameters:
rotationThe rotation as a quaternion.
void gameplay::Transform::setRotation ( const Matrix rotation)

Sets the rotation component for this transform to the specified values.

Parameters:
rotationThe rotation as a matrix.
void gameplay::Transform::setRotation ( const Vector3 axis,
float  angle 
)

Sets the rotation component for this transform to the rotation from the specified axis and angle.

Parameters:
axisThe axis of rotation.
angleThe angle of rotation (in radians).
void gameplay::Transform::setScale ( float  scale)

Sets the scale factor along all axes for this transform to the specified value.

Parameters:
scaleThe scale factor along all axes.
void gameplay::Transform::setScale ( float  sx,
float  sy,
float  sz 
)

Sets the scale component of this transform to the specified values.

Parameters:
sxThe scale factor along the x axis.
syThe scale factor along the y axis.
szThe scale factor along the z axis.
void gameplay::Transform::setScale ( const Vector3 scale)

Sets the scale component of this transform to the specified scale vector.

Parameters:
scaleThe scale vector.
void gameplay::Transform::setScaleX ( float  sx)

Sets the scale factor along the x-axis for this transform to the specified value.

Parameters:
sxThe scale factor along the x-axis.
void gameplay::Transform::setScaleY ( float  sy)

Sets the scale factor along the y-axis for this transform to the specified value.

Parameters:
syThe scale factor along the y-axis.
void gameplay::Transform::setScaleZ ( float  sz)

Sets the scale factor along the z-axis for this transform to the specified value.

Parameters:
szThe scale factor along the z-axis.
void gameplay::Transform::setTranslation ( const Vector3 translation)

Sets the translation component for this transform to the specified translation vector.

Parameters:
translationThe translation vector.
void gameplay::Transform::setTranslation ( float  tx,
float  ty,
float  tz 
)

Sets the translation component for this transform to the specified values.

Parameters:
txThe translation amount in the x direction.
tyThe translation amount in the y direction.
tzThe translation amount in the z direction.

Sets the translation factor along the x-axis for this transform to the specified value.

Parameters:
txThe translation factor along the x-axis.

Sets the translation factor along the y-axis for this transform to the specified value.

Parameters:
tyThe translation factor along the y-axis.

Sets the translation factor along the z-axis for this transform to the specified value.

Parameters:
tzThe translation factor along the z-axis.
static void gameplay::Transform::suspendTransformChange ( Transform transform) [static, protected]

Adds the specified transform to the list of transforms waiting to be notified of a change. Sets the DIRTY_NOTIFY bit on the transform.

Globally suspends all transform changed events.

virtual void gameplay::Transform::transformChanged ( ) [protected, virtual]

Called when the transform changes.

Reimplemented in gameplay::Node, and gameplay::Joint.

Transforms the specified point and stores the result in the original point.

Parameters:
pointThe point to transform.
void gameplay::Transform::transformPoint ( const Vector3 point,
Vector3 dst 
)

Transforms the specified point and stores the result in the specified destination point.

Parameters:
pointThe point to transform.
dstThe point to store the result in.

Transforms the specified vector and stores the result in the original vector.

Parameters:
vectorThe vector to transform.
void gameplay::Transform::transformVector ( const Vector3 transformVector,
Vector3 dst 
)

Transforms the specified vector and stores the result in the original vector.

Parameters:
transformVectorThe vector to transform.
dstThe vector to store the result in.
void gameplay::Transform::transformVector ( float  x,
float  y,
float  z,
float  w,
Vector3 dst 
)

Transforms the specified vector and stores the result in the specified destination vector.

Parameters:
xThe x factor to transform.
yThe y factor to transform.
zThe z factor to transform.
wThe w factor to transform.
dstThe vector to store the result in.
void gameplay::Transform::translate ( float  tx,
float  ty,
float  tz 
)

Translates this transform's translation component by the given values along each axis.

Parameters:
txThe amount to translate along the x axis.
tyThe amount to translate along the y axis.
tzThe amount to translate along the z axis.
void gameplay::Transform::translate ( const Vector3 translation)

Translates this transform's translation component by the given translation vector.

Parameters:
translationThe amount to translate.
void gameplay::Transform::translateForward ( float  amount)

Translates the camera forward by the specified amount in the z-axis.

Parameters:
amountThe amount to translate.
void gameplay::Transform::translateLeft ( float  amount)

Translates the camera left by the specified amount in the x-axis.

Parameters:
amountThe amount to translate.
void gameplay::Transform::translateSmooth ( const Vector3 target,
float  elapsedTime,
float  responseTime 
)

Translates the camera towards the given target using a smoothing function. The given response time determines the amount of smoothing (lag). A longer response time yields a smoother result and more lag. To force the camera to follow the target closely, provide a response time that is very small relative to the given elapsed time.

Parameters:
targettarget value.
elapsedTimeelapsed time between calls.
responseTimeresponse time (in the same units as elapsedTime).
void gameplay::Transform::translateUp ( float  amount)

Translates the camera up by the specified amount in the y-axis.

Parameters:
amountThe amount to translate.
void gameplay::Transform::translateX ( float  tx)

Translates this transform's translation component by the given value along the x axis.

Parameters:
txThe amount to translate along the x axis.
void gameplay::Transform::translateY ( float  ty)

Translates this transform's translation component by the given value along the y axis.

Parameters:
tyThe amount to translate along the y axis.
void gameplay::Transform::translateZ ( float  tz)

Translates this transform's translation component by the given value along the z axis.

Parameters:
tzThe amount to translate along the z axis.

Member Data Documentation

List of TransformListener's on the Transform.

Matrix gameplay::Transform::_matrix [mutable, protected]

The Matrix representation of the Transform.

char gameplay::Transform::_matrixDirtyBits [mutable, protected]

Matrix dirty bits flag.

The rotation component of the Transform.

The scale component of the Transform.

The translation component of the Transform.

const int gameplay::Transform::ANIMATE_ROTATE = 8 [static]

Rotation animation property. Data=qx,qy,qz,qw (as quaternion).

Rotation + Translation animation property (Rigid Body). Data=qx,qy,qz,qw,tx,ty,tz

const int gameplay::Transform::ANIMATE_SCALE = 1 [static]

Scale animation property. Data=sx,sy,sz

Scale + Rotation animation property. Data=sx,sy,sz,qx,qy,qz,qw

Scale, Rotation + Translation animation property. Data=sx,sy,sz,qx,qy,qz,qw,tx,ty,tz

Scale + Translation animation property. Data=sx,sy,sz,tx,ty,tz

Scale animation property. Data=scale

const int gameplay::Transform::ANIMATE_SCALE_X = 2 [static]

Scale x animation property. Data=sx

const int gameplay::Transform::ANIMATE_SCALE_Y = 3 [static]

Scale y animation property. Data=sy

const int gameplay::Transform::ANIMATE_SCALE_Z = 4 [static]

Scale z animation property. Data=sz

Translate animation property. Data=tx,ty,tz

Translate x animation property. Data=tx

Translate y animation property. Data=ty

Translate z animation property. Data=tz

 All Classes Functions Variables Typedefs Enumerations Enumerator