org.odejava
Class GeomTransform

java.lang.Object
  extended by org.odejava.Geom
      extended by org.odejava.PlaceableGeom
          extended by org.odejava.GeomTransform
All Implemented Interfaces:
Placeable

public class GeomTransform
extends PlaceableGeom

The GeomTransform is a geom which encapsulates a Geom, allowing the encapsulated Geom to be transformed relative to it. The GeomTransform can then be added to a Body.

Please refer to the ODE Documentation for more information. An example in ODE code exists here

It is a non-placable geometry, therefor the transform setters must not be called. However the transform getters may be called. As it is non-placable, the getters don't simply delegate the call to ODE. Rather they return the world transform of the encapsulated Geom (that is, the transform of the parent body multiplied by that of the encapsulated Geom). Subsiquently, you can bind GeomTransform objects to Display objects.

Author:
William Denniss

Field Summary
 
Fields inherited from class org.odejava.Geom
geomId, isEncapsulated, spaceId
 
Constructor Summary
GeomTransform()
          Creates a GeomTransform with no name.
GeomTransform(PlaceableGeom encapsulatedGeom)
          Creates a GeomTransform with no name.
GeomTransform(String name)
          Greats a GeomTransform with the given name
GeomTransform(String name, PlaceableGeom encapsulatedGeom)
          Greats a GeomTransform with the given name
 
Method Summary
 PlaceableGeom getEncapsulatedGeom()
          Returns the encapsulated geometry.
 org.openmali.vecmath2.Tuple3f getPosition()
          Returns the world position of the encapsulated geometry.
 org.openmali.vecmath2.Tuple3f getPosition(org.openmali.vecmath2.Tuple3f result)
          Returns the world position of the encapsulated geometry.
 org.openmali.vecmath2.Quaternion4f getQuaternion()
          Returns the world quaternion of the encapsulated geometry.
 org.openmali.vecmath2.Quaternion4f getQuaternion(org.openmali.vecmath2.Quaternion4f result)
          Returns the world quaternion of the encapsulated geometry.
 org.openmali.vecmath2.Matrix3f getRotation()
          Returns the world rotation of the encapsulated geometry.
 org.openmali.vecmath2.Matrix3f getRotation(org.openmali.vecmath2.Matrix3f result)
          Returns the world rotation of the encapsulated geometry.
 org.openmali.vecmath2.Matrix4f getTransform()
          Returns the world transform of the encapsulated geometry.
 org.openmali.vecmath2.Matrix4f getTransform(org.openmali.vecmath2.Matrix4f result)
          Returns the world transform of the encapsulated geometry.
 void removeEncapsulatedGeom()
          Removes the encapsulate Geom.
 void setEncapsulatedGeom(PlaceableGeom obj)
          Sets the encapsulated Geom.
protected  void updateCachedTransform()
          Called by the transform getters.
 
Methods inherited from class org.odejava.PlaceableGeom
delete, fixed, getAxisAngle, getAxisAngle, getBody, getPosition, setAxisAndAngle, setAxisAndAngle, setBody, setPosition, setPosition, setQuaternion, setQuatWXYZ, setRotation
 
Methods inherited from class org.odejava.Geom
addToSpace, finalize, getGeomFromNativeAddr, getId, getID, getName, getNativeAddr, getUserData, isEnabled, removeFromSpace, setCategoryBits, setCollideBits, setEnabled, setName, setUserData, updateNativeAddr
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.odejava.Placeable
getName
 

Constructor Detail

GeomTransform

public GeomTransform(String name,
                     PlaceableGeom encapsulatedGeom)
Greats a GeomTransform with the given name

Parameters:
name - the name of this Geom
encapsulatedGeom - the geom this GeomTransform encapsulates. This Geom should not be added to any Space or associated with any Body.
ODE Calls:
dCreateGeomTransform - creates the object

GeomTransform

public GeomTransform(PlaceableGeom encapsulatedGeom)
Creates a GeomTransform with no name.

Parameters:
encapsulatedGeom - the geom this GeomTransform encapsulates. This Geom should not be added to any Space or associated with any Body.
ODE Calls:
dCreateGeomTransform - creates the object

GeomTransform

public GeomTransform()
Creates a GeomTransform with no name.

ODE Calls:
dCreateGeomTransform - creates the object

GeomTransform

public GeomTransform(String name)
Greats a GeomTransform with the given name

Parameters:
name - the name of this Geom
ODE Calls:
dCreateGeomTransform - creates the object
Method Detail

setEncapsulatedGeom

public void setEncapsulatedGeom(PlaceableGeom obj)
Sets the encapsulated Geom.

Parameters:
obj - the geom this GeomTransform encapsulates. This Geom should not be added to any Space or associated with any Body.
ODE Calls:
dGeomTransformSetGeom - sets the encapsulated geom

removeEncapsulatedGeom

public void removeEncapsulatedGeom()
Removes the encapsulate Geom.

ODE Calls:
dGeomTransformSetGeom

getEncapsulatedGeom

public PlaceableGeom getEncapsulatedGeom()
Returns the encapsulated geometry.

Returns:
the encapsulated geometry.

getPosition

public org.openmali.vecmath2.Tuple3f getPosition()
Returns the world position of the encapsulated geometry. This is calcualted by multiplying the transform matrix of the parent body with the offset transform of the encapsulated geom. To get the offset of the encapsulated geom - call getPosition on it.

Specified by:
getPosition in interface Placeable
Overrides:
getPosition in class PlaceableGeom
Returns:
the world position of the encapsulated geometry
Throws:
IllegalOdejavaOperation - if this GeomTransform doesn't have a parent body or doesn't have an encapsulated Geom
See Also:
updateCachedTransform()

getPosition

public org.openmali.vecmath2.Tuple3f getPosition(org.openmali.vecmath2.Tuple3f result)
Returns the world position of the encapsulated geometry. This is calcualted by multiplying the transform matrix of the parent body with the offset transform of the encapsulated geom. To get the offset of the encapsulated geom - call getPosition on it.

Specified by:
getPosition in interface Placeable
Overrides:
getPosition in class PlaceableGeom
Parameters:
result - Vector3f to write the result to
Returns:
the world position of the encapsulated geometry
Throws:
IllegalOdejavaOperation - if this GeomTransform doesn't have a parent body or doesn't have an encapsulated Geom
See Also:
updateCachedTransform()

getQuaternion

public org.openmali.vecmath2.Quaternion4f getQuaternion()
Returns the world quaternion of the encapsulated geometry. This is calcualted by multiplying the transform matrix of the parent body with the offset transform of the encapsulated geom. To get the offset of the encapsulated geom - call getQuaternion on it.

Specified by:
getQuaternion in interface Placeable
Overrides:
getQuaternion in class PlaceableGeom
Returns:
the world quaternion of the encapsulated geometry
Throws:
IllegalOdejavaOperation - if this GeomTransform doesn't have a parent body or doesn't have an encapsulated Geom
See Also:
updateCachedTransform()

getQuaternion

public org.openmali.vecmath2.Quaternion4f getQuaternion(org.openmali.vecmath2.Quaternion4f result)
Returns the world quaternion of the encapsulated geometry. This is calcualted by multiplying the transform matrix of the parent body with the offset transform of the encapsulated geom. To get the offset of the encapsulated geom - call getQuaternion on it.

Specified by:
getQuaternion in interface Placeable
Overrides:
getQuaternion in class PlaceableGeom
Parameters:
result - the result Quad4f.
Returns:
the world quaternion of the encapsulated geometry
Throws:
IllegalOdejavaOperation - if this GeomTransform doesn't have a parent body or doesn't have an encapsulated Geom
See Also:
updateCachedTransform()

getRotation

public org.openmali.vecmath2.Matrix3f getRotation()
Returns the world rotation of the encapsulated geometry. This is calcualted by multiplying the transform matrix of the parent body with the offset transform of the encapsulated geom. To get the offset of the encapsulated geom - call getQuaternion on it.

Specified by:
getRotation in interface Placeable
Overrides:
getRotation in class PlaceableGeom
Returns:
the world rotation of the encapsulated geometry
Throws:
IllegalOdejavaOperation - if this GeomTransform doesn't have a parent body or doesn't have an encapsulated Geom * @see updateCachedTransform

getRotation

public org.openmali.vecmath2.Matrix3f getRotation(org.openmali.vecmath2.Matrix3f result)
Returns the world rotation of the encapsulated geometry. This is calcualted by multiplying the transform matrix of the parent body with the offset transform of the encapsulated geom. To get the offset of the encapsulated geom - call getQuaternion on it.

Parameters:
result - Matrix3f to write the result to
Returns:
the world rotation of the encapsulated geometry
Throws:
IllegalOdejavaOperation - if this GeomTransform doesn't have a parent body or doesn't have an encapsulated Geom
See Also:
updateCachedTransform()

updateCachedTransform

protected void updateCachedTransform()
Called by the transform getters. Gets the transform of the parent Body and multiplies it by the transform of the encapsulated Geom. The result is stored in the field cachedBodyTransform.

Throws:
IllegalOdejavaOperation - if this GeomTransform doesn't have a parent body or doesn't have an encapsulated Geom

getTransform

public org.openmali.vecmath2.Matrix4f getTransform()
Returns the world transform of the encapsulated geometry. This is calcualted by multiplying the transform matrix of the parent body with the offset transform of the encapsulated geom. To get the offset of the encapsulated geom - call getQuaternion on it.

Returns:
the world transform of the encapsulated geometry

getTransform

public org.openmali.vecmath2.Matrix4f getTransform(org.openmali.vecmath2.Matrix4f result)
Returns the world transform of the encapsulated geometry. This is calcualted by multiplying the transform matrix of the parent body with the offset transform of the encapsulated geom. To get the offset of the encapsulated geom - call getQuaternion on it.

Parameters:
result - Matrix4f to write the result to
Returns:
the world transform of the encapsulated geometry