org.xith3d.scenegraph
Class Transform

java.lang.Object
  extended by org.xith3d.scenegraph.SceneGraphObject
      extended by org.xith3d.scenegraph.Node
          extended by org.xith3d.scenegraph.GroupNode
              extended by org.xith3d.scenegraph.Group
                  extended by org.xith3d.scenegraph.TransformGroup
                      extended by org.xith3d.scenegraph.Transform
All Implemented Interfaces:
org.jagatoo.datatypes.NamableObject, org.jagatoo.datatypes.NamedObject, org.openmali.spatial.SpatialNode, Transformable

public class Transform
extends TransformGroup

The Transform class can be used to quickly transform any object, reducing the number of lines needed (Transform3D construction, etc..) and improving readability of your code.

However, you can live without ^^


Field Summary
static Transform IDENTITY_TRANSFORM
          The identity transform (no transformation at all)
static int ROTATION
           
static int SCALE
           
static int TRANSLATION
           
 
Fields inherited from class org.xith3d.scenegraph.GroupNode
children, hostGroup, numChildren, totalNumChildren, totalNumShapes
 
Fields inherited from class org.xith3d.scenegraph.Node
bounds, boundsAutoCompute, boundsDirty, globalIgnoreBounds, instanceBoundsTypeHint, parent, transformGroup, untransformedBounds
 
Fields inherited from class org.xith3d.scenegraph.SceneGraphObject
XITH3D_USERDATAKEY_OLDUSERDATA
 
Constructor Summary
Transform()
          Creates an empty identity transform.
Transform(int mode, org.openmali.vecmath2.Tuple3f transform, Node node)
           
Transform(Node node)
           
 
Method Summary
 Transform add(Node n)
          Adds node n to this transform and returns n.
 Transform add(Transform t)
          Adds transform t to this transform and returns t.
 Transform addAxisRotation(org.openmali.vecmath2.Tuple3f rotationAxis, float angle)
          Adds rotation about an axis.
 Transform addAxisTranslation(org.openmali.vecmath2.Tuple3f translationAxis, float length)
          Sets translation about an axis with a specified length.
 Transform addRotation(float x, float y, float z)
          Adds a rotation to the current transformation.
 Transform addRotation(org.openmali.vecmath2.Matrix3f rotationMatrix)
          Adds a rotation to the current transformation.
 Transform addRotation(org.openmali.vecmath2.Tuple3f rotate)
          Adds a rotation to the current transformation.
 Transform addRotationX(float angle)
          Adds a rotation to the current transformation.
 Transform addRotationY(float angle)
          Adds a rotation to the current transformation.
 Transform addRotationZ(float angle)
          Adds a rotation to the current transformation.
 Transform addScale(float scale)
          Adds a scale transformation to the current transform.
 Transform addTranslation(float x, float y, float z)
          Adds a translation to the current transformation.
 Transform addTranslation(org.openmali.vecmath2.Tuple3f translate)
          Adds a translation to the current transformation.
 Transform clear()
          Clears all transformations (Set the identity matrix).
static Transform get(Node node)
           
 void set(Transform trans)
          Sets this transform to be equal to another one.
 Transform setAxisRotation(org.openmali.vecmath2.Tuple3f rotationAxis, float angle)
          Sets rotation about an axis.
 Transform setAxisTranslation(org.openmali.vecmath2.Tuple3f translationAxis, float length)
          Sets translation about an axis with a specified length.
 Transform setMatrix(org.openmali.vecmath2.Matrix4f matrix)
          Sets this transform to a transformation corresponding to the matrix argument.
 Transform setRotation(float x, float y, float z)
          Applies a rotation.
 Transform setRotation(org.openmali.vecmath2.Matrix3f rotationMatrix)
          Sets a rotation to the current transformation.
 Transform setRotation(org.openmali.vecmath2.Tuple3f rotate)
          Applies a rotation.
 Transform setRotationX(float angle)
          Applies a rotation.
 Transform setRotationY(float angle)
          Applies a rotation.
 Transform setRotationZ(float angle)
          Applies a rotation.
 Transform setScale(float scale)
          Applies a scale.
 Transform setScale(float x, float y, float z)
          Applies a scale.
 Transform setScale(org.openmali.vecmath2.Tuple3f scale)
          Applies a scale.
 Transform setScaleX(float scale)
          Applies a scale.
 Transform setScaleY(float scale)
          Applies a scale.
 Transform setScaleZ(float scale)
          Applies a scale.
 Transform setTransform(int mode, float x, float y, float z)
          Sets a transformation.
 Transform setTransform(int mode, org.openmali.vecmath2.Tuple3f transform)
          Sets a transformation.
 Transform setTranslation(float x, float y, float z)
          Applies a translation.
 Transform setTranslation(org.openmali.vecmath2.Tuple3f translate)
          Applies a translation.
 Transform setTranslationX(float value)
          Sets a translation.
 Transform setTranslationY(float value)
          Sets a translation.
 Transform setTranslationZ(float value)
          Sets a translation.
 void transform(org.openmali.vecmath2.Point3f input)
          Applies this transform to a Point3f.
 void transform(org.openmali.vecmath2.Vector3f input)
          Applies this transform to a Vector3f.
 
Methods inherited from class org.xith3d.scenegraph.TransformGroup
getLocalTransform, getLocalTransform, getPosition, getPosition, getTransform, getTransform, getWorldTransform, newInstance, onTransformChanged, setLocalTransform, setPosition, setPosition, setTransform, traverse, updateTransform
 
Methods inherited from class org.xith3d.scenegraph.Group
moveTo
 
Methods inherited from class org.xith3d.scenegraph.GroupNode
absorbDetails, addChild, addChild, checkChild, dump, dump, ensureCapacity, expandBounds, findAll, findAll, findFirst, findFirst, freeOpenGLResources, getChild, getChildren, getChildren, getClipper, getPickHost, getScissorRect, getTotalNumChildren, getTotalNumShapes, indexOf, isPickHost, mergeInheritedClipper, mergeInheritedNodes, mergeInheritedScissorRect, numChildren, removeAllChildren, removeChild, removeChild, setBoundsDirty, setBoundsDirtyUpward, setChild, setClipper, setPickHost, setPickHost, setScissorRect, setShowBounds, sharedCopy, sharedCopy, traverse, unmergeInheritedFog, unmergeInheritedLight, unmergeInheritedNodes, updateBounds, updateBoundsCheap
 
Methods inherited from class org.xith3d.scenegraph.Node
cloneNode, detach, duplicateNode, freeOpenGLResources, getBounds, getBoundsAutoCompute, getBoundsType, getBoundsTypeHint, getDefaultPickable, getIndentString, getInheritedNodeAttributes, getModListener, getOrderedChild, getOrderedState, getParent, getRoot, getShadowAttachment, getShowBounds, getTransformGroup, getTreeCell, getWorldBounds, getWorldTransform, isBillboard, isIgnoreBounds, isOccluder, isPickable, isRenderable, isUpdatableNode, popGlobalIgnoreBounds, printBounds, pushGlobalIgnoreBounds, setBounds, setBoundsAutoCompute, setBoundsTypeHint, setDefaultPickable, setGlobalIgnoreBounds, setIgnoreBounds, setIsOccluder, setModListener, setOrderedChild, setParent, setPickable, setPickableRecursive, setPickableRecursive, setRenderable, setShadowAttachment, setShowBounds, setTransformGroup, setTreeCell, updateOrderedChild, updateTransformGroup, updateWorldTransform
 
Methods inherited from class org.xith3d.scenegraph.SceneGraphObject
getName, getUserData, getUserData, getUserDataMap, isLive, setLive, setName, setUserData, setUserData, setUserDataRecursive, setUserDataRecursive, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.xith3d.scenegraph.Transformable
getName, setName
 

Field Detail

IDENTITY_TRANSFORM

public static final Transform IDENTITY_TRANSFORM
The identity transform (no transformation at all)


ROTATION

public static final int ROTATION
See Also:
Constant Field Values

TRANSLATION

public static final int TRANSLATION
See Also:
Constant Field Values

SCALE

public static final int SCALE
See Also:
Constant Field Values
Constructor Detail

Transform

public Transform(Node node)
Parameters:
node - The node to transform

Transform

public Transform(int mode,
                 org.openmali.vecmath2.Tuple3f transform,
                 Node node)
Parameters:
mode - Transform.ROTATION, Transform.TRANSLATION, or Transform.SCALE
transform - If rotation, euler angles (in radians), if translation or scale relevant value
node - The node to transform

Transform

public Transform()
Creates an empty identity transform.

Method Detail

setTransform

public Transform setTransform(int mode,
                              float x,
                              float y,
                              float z)
Sets a transformation.

Parameters:
mode - Transform.ROTATION, Transform.TRANSLATION, or Transform.SCALE
x - X value
y - Y value
z - Z value
Returns:
This transform, for cascade method calls

setTransform

public Transform setTransform(int mode,
                              org.openmali.vecmath2.Tuple3f transform)
Sets a transformation.

Parameters:
mode - Transform.ROTATION, Transform.TRANSLATION, or Transform.SCALE
transform - If rotation, euler angles (in radians), if translation or scale relevant value
Returns:
This transform, for cascade method calls

setTranslationX

public Transform setTranslationX(float value)
Sets a translation.

Parameters:
value - Translation
Returns:
This transform, for cascade method calls

setTranslationY

public Transform setTranslationY(float value)
Sets a translation.

Parameters:
value - Translation
Returns:
This transform, for cascade method calls

setTranslationZ

public Transform setTranslationZ(float value)
Sets a translation.

Parameters:
value -
Returns:
This transform, for cascade method calls

addTranslation

public Transform addTranslation(float x,
                                float y,
                                float z)
Adds a translation to the current transformation.

Parameters:
x - X value
y - Y value
z - Z value
Returns:
This transform, for cascade method calls

setTranslation

public Transform setTranslation(float x,
                                float y,
                                float z)
Applies a translation.

Parameters:
x - X value
y - Y value
z - Z value
Returns:
This transform, for cascade method calls

addTranslation

public Transform addTranslation(org.openmali.vecmath2.Tuple3f translate)
Adds a translation to the current transformation.

Parameters:
translate - Translation
Returns:
This transform, for cascade method calls

setTranslation

public Transform setTranslation(org.openmali.vecmath2.Tuple3f translate)
Applies a translation.

Parameters:
translate - Translation
Returns:
This transform, for cascade method calls

setRotation

public Transform setRotation(org.openmali.vecmath2.Tuple3f rotate)
Applies a rotation.

Parameters:
rotate - Euler angles, in radians
Returns:
This transform, for cascade method calls

setRotation

public Transform setRotation(float x,
                             float y,
                             float z)
Applies a rotation.

Parameters:
x - X angle, in radians
y - Y angle, in radians
z - Z angle, in radians
Returns:
This transform, for cascade method calls

addRotation

public Transform addRotation(org.openmali.vecmath2.Tuple3f rotate)
Adds a rotation to the current transformation.

Parameters:
rotate - Euler angles, in radians
Returns:
This transform, for cascade method calls

setRotation

public Transform setRotation(org.openmali.vecmath2.Matrix3f rotationMatrix)
Sets a rotation to the current transformation.

Parameters:
rotationMatrix -

addRotation

public Transform addRotation(org.openmali.vecmath2.Matrix3f rotationMatrix)
Adds a rotation to the current transformation.

Parameters:
rotationMatrix -

addRotation

public Transform addRotation(float x,
                             float y,
                             float z)
Adds a rotation to the current transformation.

Parameters:
x - X angle, in radians
y - Y angle, in radians
z - Z angle, in radians
Returns:
This transform, for cascade method calls

setRotationX

public Transform setRotationX(float angle)
Applies a rotation.

Parameters:
angle - Euler angle, in radians
Returns:
This transform, for cascade method calls

addRotationX

public Transform addRotationX(float angle)
Adds a rotation to the current transformation.

Parameters:
angle - Euler angle, in radians
Returns:
This transform, for cascade method calls

setRotationY

public Transform setRotationY(float angle)
Applies a rotation.

Parameters:
angle - Euler angle, in radians
Returns:
This transform, for cascade method calls

addRotationY

public Transform addRotationY(float angle)
Adds a rotation to the current transformation.

Parameters:
angle - Euler angle, in radians
Returns:
This transform, for cascade method calls

setRotationZ

public Transform setRotationZ(float angle)
Applies a rotation.

Parameters:
angle - Euler angle, in radians
Returns:
This transform, for cascade method calls

addRotationZ

public Transform addRotationZ(float angle)
Adds a rotation to the current transformation.

Parameters:
angle - Euler angle, in radians
Returns:
This transform, for cascade method calls

setScale

public Transform setScale(org.openmali.vecmath2.Tuple3f scale)
Applies a scale.

Parameters:
scale - X, Y, Z scale
Returns:
This transform, for cascade method calls

setScale

public Transform setScale(float x,
                          float y,
                          float z)
Applies a scale.

Parameters:
x - X scale
y - Y scale
z - Z scale
Returns:
This transform, for cascade method calls

setScaleX

public Transform setScaleX(float scale)
Applies a scale.

Parameters:
scale - X scale
Returns:
This transform, for cascade method calls

setScaleY

public Transform setScaleY(float scale)
Applies a scale.

Parameters:
scale - Y scale
Returns:
This transform, for cascade method calls

setScaleZ

public Transform setScaleZ(float scale)
Applies a scale.

Parameters:
scale - Z scale
Returns:
This transform, for cascade method calls

setScale

public Transform setScale(float scale)
Applies a scale.

Parameters:
scale - X, Y and Z scale
Returns:
This transform, for cascade method calls

addScale

public Transform addScale(float scale)
Adds a scale transformation to the current transform.

Parameters:
scale - Scale factor
Returns:
This transform, for cascade method calls

add

public Transform add(Node n)
Adds node n to this transform and returns n.

Parameters:
n - The node to add
Returns:
This transform, for cascade method calls

add

public Transform add(Transform t)
Adds transform t to this transform and returns t.

Parameters:
t - The transform to add
Returns:
The transform added

clear

public Transform clear()
Clears all transformations (Set the identity matrix).

Returns:
itself

setAxisRotation

public Transform setAxisRotation(org.openmali.vecmath2.Tuple3f rotationAxis,
                                 float angle)
Sets rotation about an axis.

Parameters:
rotationAxis - The axis to rotate about
angle - The angle to rotate of, in radians
Returns:
itself

addAxisRotation

public Transform addAxisRotation(org.openmali.vecmath2.Tuple3f rotationAxis,
                                 float angle)
Adds rotation about an axis.

Parameters:
rotationAxis - The axis to rotate about
angle - The angle to rotate of, in radians
Returns:
itself

setAxisTranslation

public Transform setAxisTranslation(org.openmali.vecmath2.Tuple3f translationAxis,
                                    float length)
Sets translation about an axis with a specified length.

Parameters:
translationAxis -
length -
Returns:
itself

addAxisTranslation

public Transform addAxisTranslation(org.openmali.vecmath2.Tuple3f translationAxis,
                                    float length)
Sets translation about an axis with a specified length.

Parameters:
translationAxis -
length -
Returns:
itself

setMatrix

public Transform setMatrix(org.openmali.vecmath2.Matrix4f matrix)
Sets this transform to a transformation corresponding to the matrix argument.

Parameters:
matrix - The transformation matrix to set this transform to
Returns:
itself

get

public static Transform get(Node node)
Parameters:
node -
Returns:
The Transform which is parent to the given node (if it's the case)

transform

public void transform(org.openmali.vecmath2.Point3f input)
Applies this transform to a Point3f. Mathematically, the matrix of this transform is multiplied with the input Tuple3f and the result is stored in it.

Parameters:
input - the Tuple3f to be applied the Transform

transform

public void transform(org.openmali.vecmath2.Vector3f input)
Applies this transform to a Vector3f. Mathematically, the matrix of this transform is multiplied with the input Tuple3f and the result is stored in it.

Parameters:
input - the Tuple3f to be applied the Transform

set

public void set(Transform trans)
Sets this transform to be equal to another one.

Parameters:
trans -