Adds a few properties and methods to every Node for working with transformation matrices.
Category
Latest Behaviors
Author
Gavin Kistner
Difficulty
(Reference)
Time to Complete
5 Minutes
Downloads
Click Here
to download the associated files.
(This document covers version 0.9 of the 'Transform Ease' behavior, current as of 2005-Mar-21)
Description
This behavior extends every Node (Camera, Light, Group, Model, and Text objects) with three new properties and two new methods. To use, simply attach this behavior anywhere in the scene. (You have to actually attach it to add the functionality; loading it into the library for the project is not enough.)
myNode.lastLocalTransform
Like the
lastGlobalTransform
property, this property returns a transformation matrix from the previous frame.
Unlike
lastGlobalTransform
, the transformation is for the node with respect to its parent, not with respect the scene.
myNode.currentGlobalTransform
Like
lastGlobalTransform
, this property is a matrix holding the transformation matrix for the object with respect to the scene.
Unlike
lastGlobalTransform
, the transformation is for the current state of the object, not the previous frame.
Changes already made to transformations (position, scale, rotation, and pivot) on any ancestor of the object during the current frame will be reflected in this matrix, but references to the returned matrix are not automatically updated as objects are transformed. (You must assign a new variable to the property to force the matrix to be recomputed after changing the transformation on the object or its ancestors.)
WARNING
: It is computationally expensive to calculate this matrix, requiring one function call and four matrix multiplications for every ancestor of the object. If you can use
lastGlobalTransform
instead, you should.
myNode.currentLocalTransform
Like
currentGlobalTransform
, but returns the transformation matrix of the calling node with respect to the parent of that node.
WARNING
: It is computationally expensive to calculate this matrix, requiring one function call and four matrix multiplications. If you can use
lastLocalTransform
instead, you should.
myNode.lastTransformFrom(
inAncestor
,
outMatrix
)
Returns the transformation matrix for the calling node with respect to an arbitrary ancestor, using information from the last frame.
The
inAncestor
parameter should be a node that is an ancestor of the calling node. If this value is not passed (or is not a node) the return value is the
lastGlobalTransform
for the calling node.
If the
outMatrix
parameter is supplied, that matrix will be modified and returned; otherwise, a new matrix will be created and returned.
(Re-using the same matrix across successive calls to this method will result in slightly better memory performance, since a new Matrix will not be allocated each time.)
myNode.currentTransformFrom(
inAncestor
,
outMatrix
)
Returns the transformation matrix for the calling node with respect to an arbitrary ancestor, using information from the current frame.
The
inAncestor
parameter should be a node that is an ancestor of the calling node. If this value is not passed (or is not a node, or is not an ancestor of the calling node) then the return value will be the same as the
currentGlobalTransform
matrix for the calling node.
If the
outMatrix
parameter is supplied, the matrix will be modified and returned; otherwise, a new matrix will be created and returned.
(Re-using the same matrix across successive calls to this method will result in slightly better memory performance, since a new Matrix will not be allocated each time.)
WARNING
: It is computationally expensive to calculate this matrix, requiring one function call and four matrix multiplications for every below the ancestor node (including the calling node). If you can use the