org.xith3d.physics.collision
Class CollideableBase

java.lang.Object
  extended by org.xith3d.physics.collision.CollideableBase
All Implemented Interfaces:
org.jagatoo.datatypes.Enableable, org.jagatoo.datatypes.NamableObject, org.jagatoo.datatypes.NamedObject, Collideable, Placeable
Direct Known Subclasses:
BoxCollideable, CapsuleCollideable, CollideableGroupBase, CylinderCollideable, PlaneCollideable, RayCollideable, SphereCollideable, TriMeshCollideable

public abstract class CollideableBase
extends java.lang.Object
implements Collideable

Common parent (abstract class) for all Collideable Objects.


Constructor Summary
CollideableBase(CollisionEngine engine)
          Creates a new CollideableBase.
 
Method Summary
protected abstract  void applyWorldPosition(org.openmali.vecmath2.Tuple3f worldPos)
          Applies the world-position to the implementation.
protected abstract  void applyWorldRotation(org.openmali.vecmath2.Matrix3f worldRot)
          Applies the world-rotation to the implementation.
 Body getBody()
          
 CollisionEngine getEngine()
          
 java.lang.String getName()
          
 CollideableGroup getParent()
          Gets the parent of this Collideable, or null if it has no parent.
 org.openmali.vecmath2.Point3f getPosition()
          
 void getPosition(org.openmali.vecmath2.Tuple3f pos)
          Writes the position of this Placeable object to the given Tuple3f, in Local coordinates (e.g. without pos/rot of parents taken into account).
 org.openmali.vecmath2.Tuple3f getRotation()
          
 void getRotation(org.openmali.vecmath2.Tuple3f rot)
          Writes the rotation (local coordinates), in Euler angles (degrees) of this Placeable object in the given Tuple3f.
 org.openmali.vecmath2.Matrix3f getRotationMatrix()
          
 void getRotationMatrix(org.openmali.vecmath2.Matrix3f mat)
          Writes the rotation, as a 3x3 rotation Matrix, of this Placeable object in the given Matrix3f.
 java.lang.Object getUserObject()
          
 org.openmali.vecmath2.Point3f getWorldPos()
          Gets position, in world coordinates, which means, taking into account all transformations from parents, and all.
 void getWorldPos(org.openmali.vecmath2.Tuple3f pos)
          Writes position to pos, in world coordinates, which means, taking into account all transformations from parents, and all.
 org.openmali.vecmath2.Tuple3f getWorldRot()
          Gets rotation, in world coordinates, which means, taking into account all transformations from parents, and all.
 void getWorldRot(org.openmali.vecmath2.Tuple3f rot)
          Writes rotation to rot, in world coordinates, which means, taking into account all transformations from parents, and all.
 org.openmali.vecmath2.Matrix3f getWorldRotMat()
          Gets rotation, in world coordinates, which means, taking into account all transformations from parents, and all.
 void getWorldRotMat(org.openmali.vecmath2.Matrix3f rot)
          Writes rotation to rot, in world coordinates, which means, taking into account all transformations from parents, and all.
 void recomputeChildrenWorldCoords(boolean applyToImplementation)
          Recompute the world coordinates of all children, if and only if this JoodeCollideable is a space.
 void recomputeWorldCoords(boolean childrenToo, boolean applyToImplementation)
          Recompute world coordinates, e.g. world position and rotation.
protected  void recomputeWorldPos(org.openmali.vecmath2.Point3f worldPos, boolean applyToImplementation)
          Recomputes the World coordinates position.
protected  void recomputeWorldRotMat(org.openmali.vecmath2.Matrix3f worldRot, boolean applyToImplementation)
          Recomputes the World coordinates rotation matrix.
 void setBody(Body body)
          Sets the Body, this Collideable is attached to.
 void setName(java.lang.String name)
          
protected  void setParent(CollideableGroup parent)
          Sets this Collideable's parent group.
 void setPosition(float x, float y, float z)
          Sets the position, in local coordinates of this Placeable object.
 void setPosition(float x, float y, float z, boolean recomputeWorldCoords)
           
 void setPosition(org.openmali.vecmath2.Tuple3f pos)
          Sets the position, in local coordinates of this Placeable object To get world coordinates, Collideable.getWorldPos().
 void setPositionX(float x)
          Sets the X position (in local coordinates) of this Collideable
 void setPositionY(float y)
          Sets the Y position (in local coordinates) of this Collideable
 void setPositionZ(float z)
          Sets the Z position (in local coordinates) of this Collideable
 void setRotation(float x, float y, float z)
          Sets the rotation (in local coordinates) of this Collideable, local coordinates.
 void setRotation(float x, float y, float z, boolean recomputeWorldCoords)
           
 void setRotation(org.openmali.vecmath2.Tuple3f rot)
          Sets the rotation of this object, in Euler angles (degrees), local coordinates.
 void setRotationMatrix(org.openmali.vecmath2.Matrix3f rot)
          Sets the rotation Matrix of this object, local coordinates.
 void setRotationMatrix(org.openmali.vecmath2.Matrix3f rot, boolean recomputeWorldCoords)
          
 void setRotationX(float x)
          Sets the X rotation (in local coordinates) of this Collideable
 void setRotationY(float y)
          Sets the Y rotation (in local coordinates) of this Collideable
 void setRotationZ(float z)
          Sets the Z rotation (in local coordinates) of this Collideable
 void setUserObject(java.lang.Object userObject)
          Sets this Collideable's user-object.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.xith3d.physics.collision.Collideable
getBaseGFX, getDebugGFX, getInfo, getType, isEnabled, setEnabled
 

Constructor Detail

CollideableBase

public CollideableBase(CollisionEngine engine)
Creates a new CollideableBase.

Method Detail

getEngine

public CollisionEngine getEngine()

Specified by:
getEngine in interface Collideable
Returns:
the collision engine of this Collideable

setName

public final void setName(java.lang.String name)

Specified by:
setName in interface org.jagatoo.datatypes.NamableObject

getName

public final java.lang.String getName()

Specified by:
getName in interface org.jagatoo.datatypes.NamedObject

setUserObject

public final void setUserObject(java.lang.Object userObject)
Sets this Collideable's user-object.

Specified by:
setUserObject in interface Collideable

getUserObject

public final java.lang.Object getUserObject()

Specified by:
getUserObject in interface Collideable
Returns:
this Collideable's user-object.

setParent

protected void setParent(CollideableGroup parent)
Sets this Collideable's parent group.

Parameters:
parent -

getParent

public final CollideableGroup getParent()
Gets the parent of this Collideable, or null if it has no parent.

Specified by:
getParent in interface Collideable
Returns:
The parent, or null

setBody

public void setBody(Body body)
Sets the Body, this Collideable is attached to.

Specified by:
setBody in interface Collideable

getBody

public final Body getBody()

Specified by:
getBody in interface Collideable
Returns:
the Body, this Collideable is attached to.

setRotation

public void setRotation(float x,
                        float y,
                        float z,
                        boolean recomputeWorldCoords)

setRotation

public final void setRotation(float x,
                              float y,
                              float z)
Sets the rotation (in local coordinates) of this Collideable, local coordinates.

Specified by:
setRotation in interface Collideable
Specified by:
setRotation in interface Placeable
Parameters:
x - The x-rotation of the Collideable
y - The y-rotation of the Collideable
z - The z-rotation of the Collideable

setRotation

public final void setRotation(org.openmali.vecmath2.Tuple3f rot)
Sets the rotation of this object, in Euler angles (degrees), local coordinates.

Specified by:
setRotation in interface Collideable
Specified by:
setRotation in interface Placeable
Parameters:
rot - The rotation, in Euler angles (degrees) of this Placeable object

setRotationX

public final void setRotationX(float x)
Sets the X rotation (in local coordinates) of this Collideable

Specified by:
setRotationX in interface Collideable

setRotationY

public final void setRotationY(float y)
Sets the Y rotation (in local coordinates) of this Collideable

Specified by:
setRotationY in interface Collideable

setRotationZ

public final void setRotationZ(float z)
Sets the Z rotation (in local coordinates) of this Collideable

Specified by:
setRotationZ in interface Collideable

getRotation

public final org.openmali.vecmath2.Tuple3f getRotation()

Specified by:
getRotation in interface Collideable
Specified by:
getRotation in interface Placeable
Returns:
The rotation (local coordinates), in Euler angles (degrees) of this Placeable object To get rotation in World coordinates, Collideable.getWorldRot().

getRotation

public final void getRotation(org.openmali.vecmath2.Tuple3f rot)
Writes the rotation (local coordinates), in Euler angles (degrees) of this Placeable object in the given Tuple3f. To get rotation in World coordinates, Collideable.getWorldRot()

Specified by:
getRotation in interface Collideable
Specified by:
getRotation in interface Placeable

setRotationMatrix

public void setRotationMatrix(org.openmali.vecmath2.Matrix3f rot,
                              boolean recomputeWorldCoords)


setRotationMatrix

public final void setRotationMatrix(org.openmali.vecmath2.Matrix3f rot)
Description copied from interface: Collideable
Sets the rotation Matrix of this object, local coordinates.

Specified by:
setRotationMatrix in interface Collideable
Specified by:
setRotationMatrix in interface Placeable
Parameters:
rot - The rotation, as a 3x3 rotation Matrix, of this Placeable object

getRotationMatrix

public final org.openmali.vecmath2.Matrix3f getRotationMatrix()

Specified by:
getRotationMatrix in interface Collideable
Specified by:
getRotationMatrix in interface Placeable
Returns:
The rotation (local coordinates), as a 3x3 rotation Matrix, of this Placeable object. To get rotation matrix in World coordinates, Collideable.getWorldRotMat().

getRotationMatrix

public final void getRotationMatrix(org.openmali.vecmath2.Matrix3f mat)
Writes the rotation, as a 3x3 rotation Matrix, of this Placeable object in the given Matrix3f. To get rotation matrix in World coordinates, Collideable.getWorldRotMat().

Specified by:
getRotationMatrix in interface Collideable
Specified by:
getRotationMatrix in interface Placeable

setPosition

public void setPosition(float x,
                        float y,
                        float z,
                        boolean recomputeWorldCoords)

setPosition

public final void setPosition(float x,
                              float y,
                              float z)
Sets the position, in local coordinates of this Placeable object. to get world coordinates Collideable.getWorldPos().

Specified by:
setPosition in interface Collideable
Specified by:
setPosition in interface Placeable

setPosition

public final void setPosition(org.openmali.vecmath2.Tuple3f pos)
Sets the position, in local coordinates of this Placeable object To get world coordinates, Collideable.getWorldPos().

Specified by:
setPosition in interface Collideable
Specified by:
setPosition in interface Placeable

setPositionX

public final void setPositionX(float x)
Sets the X position (in local coordinates) of this Collideable

Specified by:
setPositionX in interface Collideable

setPositionY

public final void setPositionY(float y)
Sets the Y position (in local coordinates) of this Collideable

Specified by:
setPositionY in interface Collideable

setPositionZ

public final void setPositionZ(float z)
Sets the Z position (in local coordinates) of this Collideable

Specified by:
setPositionZ in interface Collideable

getPosition

public final org.openmali.vecmath2.Point3f getPosition()

Specified by:
getPosition in interface Collideable
Specified by:
getPosition in interface Placeable
Returns:
The position of this Collideable, in Local coordinates, (e.g. without pos/rot of parents taken into account). To get World coordinates,
See Also:
Collideable.getWorldPos()

getPosition

public final void getPosition(org.openmali.vecmath2.Tuple3f pos)
Writes the position of this Placeable object to the given Tuple3f, in Local coordinates (e.g. without pos/rot of parents taken into account). To get World coordinates, Collideable.getWorldPos().

Specified by:
getPosition in interface Collideable
Specified by:
getPosition in interface Placeable
Parameters:
pos - The Tuple3f to put the pos into

getWorldPos

public final org.openmali.vecmath2.Point3f getWorldPos()
Gets position, in world coordinates, which means, taking into account all transformations from parents, and all. Correct implementation of this method is up to the Physic Engine's developers, but it should be pretty easy anyway. Order of transformation is Translate, then Rotate. There is no scale.

Specified by:
getWorldPos in interface Collideable
Returns:
The world coordinates position.

getWorldPos

public final void getWorldPos(org.openmali.vecmath2.Tuple3f pos)
Writes position to pos, in world coordinates, which means, taking into account all transformations from parents, and all. Correct implementation of this method is up to the Physic Engine's developers, but it should be pretty easy anyway. Order of transformation is Translate, then Rotate. There is no scale.

Specified by:
getWorldPos in interface Collideable
Parameters:
pos - The Tuple3f to write in.

getWorldRot

public final org.openmali.vecmath2.Tuple3f getWorldRot()
Gets rotation, in world coordinates, which means, taking into account all transformations from parents, and all. Correct implementation of this method is up to the Physic Engine's developers, but it should be pretty easy anyway. Order of transformation is Translate, then Rotate. There is no scale.

Specified by:
getWorldRot in interface Collideable
Returns:
The world coordinates position.

getWorldRot

public final void getWorldRot(org.openmali.vecmath2.Tuple3f rot)
Writes rotation to rot, in world coordinates, which means, taking into account all transformations from parents, and all. Correct implementation of this method is up to the Physic Engine's developers, but it should be pretty easy anyway. Order of transformation is Translate, then Rotate. There is no scale.

Specified by:
getWorldRot in interface Collideable

getWorldRotMat

public final org.openmali.vecmath2.Matrix3f getWorldRotMat()
Gets rotation, in world coordinates, which means, taking into account all transformations from parents, and all. Correct implementation of this method is up to the Physic Engine's developers, but it should be pretty easy anyway. Order of transformation is Translate, then Rotate. There is no scale.

Specified by:
getWorldRotMat in interface Collideable
Returns:
The world coordinates position.

getWorldRotMat

public final void getWorldRotMat(org.openmali.vecmath2.Matrix3f rot)
Writes rotation to rot, in world coordinates, which means, taking into account all transformations from parents, and all. Correct implementation of this method is up to the Physic Engine's developers, but it should be pretty easy anyway. Order of transformation is Translate, then Rotate. There is no scale.

Specified by:
getWorldRotMat in interface Collideable

applyWorldRotation

protected abstract void applyWorldRotation(org.openmali.vecmath2.Matrix3f worldRot)
Applies the world-rotation to the implementation.

Parameters:
worldRot -

applyWorldPosition

protected abstract void applyWorldPosition(org.openmali.vecmath2.Tuple3f worldPos)
Applies the world-position to the implementation.

Parameters:
worldPos -

recomputeWorldRotMat

protected void recomputeWorldRotMat(org.openmali.vecmath2.Matrix3f worldRot,
                                    boolean applyToImplementation)
Recomputes the World coordinates rotation matrix.

Parameters:
worldRot -
applyToImplementation -

recomputeWorldPos

protected void recomputeWorldPos(org.openmali.vecmath2.Point3f worldPos,
                                 boolean applyToImplementation)
Recomputes the World coordinates position.

Parameters:
worldPos -
applyToImplementation -

recomputeChildrenWorldCoords

public void recomputeChildrenWorldCoords(boolean applyToImplementation)
Recompute the world coordinates of all children, if and only if this JoodeCollideable is a space.

Specified by:
recomputeChildrenWorldCoords in interface Collideable

recomputeWorldCoords

public void recomputeWorldCoords(boolean childrenToo,
                                 boolean applyToImplementation)
Recompute world coordinates, e.g. world position and rotation. This method should be called whenever a parent changes its local position/rotation on all its children.

Specified by:
recomputeWorldCoords in interface Collideable

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object