net.java.dev.joode.geom
Class Geom

java.lang.Object
  extended by net.java.dev.joode.geom.Geom
All Implemented Interfaces:
java.io.Serializable, SimState
Direct Known Subclasses:
Box, Capsule, Circle, Cylinder, GeomTransform, Plane, Ray, Rectangle, Space, Sphere, TriMesh

public abstract class Geom
extends java.lang.Object
implements SimState

Geom is the fundamental object in the collision system. The linked lists for spaces and bodies have been removed from this class because they work in ODE by manipulating the passes in pointer to a pointer in essence the bodyAdd and spaceAdd pass the address of their link list start points and so their internal data is altered by the operations that were in the dxGeom class. This can't really be done in Java so the functionality will be replaced in the Space and Body classes

Author:
Tom Larkworthy
See Also:
Serialized Form

Field Summary
 float[] aabb
          cached AABB for this space
static int AABB_MAX_X
           
static int AABB_MAX_Y
           
static int AABB_MAX_Z
           
static int AABB_MIN_X
           
static int AABB_MIN_Y
           
static int AABB_MIN_Z
           
 Body body
          dynamics body associated with this object (if any)
 long category_bits
           
 long collide_bits
           
static int dBoxClass
           
static int dCapsuleClass
           
static int dCircle
           
static int dConvex
           
static int dCylinderClass
           
static int dFirstSpaceClass
           
static int dFirstUserClass
           
static int dGeomNumClasses
           
static int dGeomTransformClass
           
static int dHashSpaceClass
           
static int dLastSpaceClass
           
static int dLastUserClass
           
static int dMaxUserClasses
           
static int dOctTreeSpaceClass
           
static int dPlaneClass
           
static int dQuadTreeSpaceClass
           
static int dRayClass
           
static int dRectangle
           
static int dSimpleSpaceClass
           
static int dSphereClass
           
static int dTriMeshClass
           
static int GEOM_AABB_BAD
          geom's AABB is not valid
static int GEOM_DIRTY
          geom is 'dirty', i.e.
static int GEOM_ENABLED
          geom is enabled
static int GEOM_PLACEABLE
          geom is placeable
 int gflags
          flags used by geom and space
 Vector3 lpos
          geom's position vector at last time step
 Space parent_space
          the space this geom is contained in, null if none
 Vector3 pos
          geom's position vector
 Matrix3 R
          pointer to object's rotation matrix
static int RAY_BACKFACECULL
           
static int RAY_CLOSEST_HIT
           
static int RAY_FIRSTCONTACT
           
static Quaternion tmpq
           
 int type
          geom type number, set by subclass constructor
 
Constructor Summary
protected Geom()
           
  Geom(Space space, boolean isPlaceable, int type)
           
 
Method Summary
 boolean AABBTest(Geom other, float[] aabb)
          test whether the given AABB object intersects with this object, return 1=yes, 0=no.
 Geom clonePartialGeom(Geom partialClone, ClonedReferences util)
          utility method for children, sets the parents attributes of the passed in partial clone
abstract  void computeAABB()
          compute the AABB for this object and put it in aabb.
 void destroy()
          destroy a geom, removing it from any space it is in first.
 float[] getAABB()
          return in aabb an axis aligned bounding box that surrounds the given geom.
 java.lang.Object getUserData()
          get the user-defined data stored in the geom.
 boolean isEnabled()
           
 void recomputeAABB()
           
 void setBody(Body body)
          set the body associated with a placeable geom.
 void setPosition(float x, float y, float z)
           
 void setQuaternion(float x, float y, float z, float w)
           
 void setQuaternion(Quaternion q)
           
 void setRotation(Matrix3 R)
           
 void setUserData(java.lang.Object data)
          set the user-defined data stored in the geom.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.java.dev.joode.SimState
cloneState
 

Field Detail

GEOM_DIRTY

public static int GEOM_DIRTY
geom is 'dirty', i.e. position unknown


GEOM_AABB_BAD

public static int GEOM_AABB_BAD
geom's AABB is not valid


GEOM_PLACEABLE

public static int GEOM_PLACEABLE
geom is placeable


GEOM_ENABLED

public static int GEOM_ENABLED
geom is enabled


RAY_FIRSTCONTACT

public static int RAY_FIRSTCONTACT

RAY_BACKFACECULL

public static int RAY_BACKFACECULL

RAY_CLOSEST_HIT

public static int RAY_CLOSEST_HIT

dMaxUserClasses

public static final int dMaxUserClasses
See Also:
Constant Field Values

AABB_MIN_X

public static final int AABB_MIN_X
See Also:
Constant Field Values

AABB_MAX_X

public static final int AABB_MAX_X
See Also:
Constant Field Values

AABB_MIN_Y

public static final int AABB_MIN_Y
See Also:
Constant Field Values

AABB_MAX_Y

public static final int AABB_MAX_Y
See Also:
Constant Field Values

AABB_MIN_Z

public static final int AABB_MIN_Z
See Also:
Constant Field Values

AABB_MAX_Z

public static final int AABB_MAX_Z
See Also:
Constant Field Values

dSphereClass

public static final int dSphereClass
See Also:
Constant Field Values

dBoxClass

public static final int dBoxClass
See Also:
Constant Field Values

dCapsuleClass

public static final int dCapsuleClass
See Also:
Constant Field Values

dCylinderClass

public static final int dCylinderClass
See Also:
Constant Field Values

dPlaneClass

public static final int dPlaneClass
See Also:
Constant Field Values

dRayClass

public static final int dRayClass
See Also:
Constant Field Values

dGeomTransformClass

public static final int dGeomTransformClass
See Also:
Constant Field Values

dConvex

public static final int dConvex
See Also:
Constant Field Values

dTriMeshClass

public static final int dTriMeshClass
See Also:
Constant Field Values

dCircle

public static final int dCircle
See Also:
Constant Field Values

dRectangle

public static final int dRectangle
See Also:
Constant Field Values

dFirstSpaceClass

public static final int dFirstSpaceClass
See Also:
Constant Field Values

dSimpleSpaceClass

public static final int dSimpleSpaceClass
See Also:
Constant Field Values

dHashSpaceClass

public static final int dHashSpaceClass
See Also:
Constant Field Values

dOctTreeSpaceClass

public static final int dOctTreeSpaceClass
See Also:
Constant Field Values

dQuadTreeSpaceClass

public static final int dQuadTreeSpaceClass
See Also:
Constant Field Values

dLastSpaceClass

public static final int dLastSpaceClass
See Also:
Constant Field Values

dFirstUserClass

public static final int dFirstUserClass
See Also:
Constant Field Values

dLastUserClass

public static final int dLastUserClass
See Also:
Constant Field Values

dGeomNumClasses

public static final int dGeomNumClasses
See Also:
Constant Field Values

tmpq

public static final Quaternion tmpq

type

public int type
geom type number, set by subclass constructor


gflags

public int gflags
flags used by geom and space


body

public Body body
dynamics body associated with this object (if any)


pos

public Vector3 pos
geom's position vector


lpos

public Vector3 lpos
geom's position vector at last time step


R

public Matrix3 R
pointer to object's rotation matrix


parent_space

public Space parent_space
the space this geom is contained in, null if none


aabb

public float[] aabb
cached AABB for this space


category_bits

public long category_bits

collide_bits

public long collide_bits
Constructor Detail

Geom

protected Geom()

Geom

public Geom(Space space,
            boolean isPlaceable,
            int type)
Method Detail

destroy

public void destroy()
destroy a geom, removing it from any space it is in first. This one function destroys a geom of any type, but to create a geom you must call a creation function for that type.
When a space is destroyed, if its cleanup mode is true (the default) then all the geoms in that space are automatically destroyed as well.


getAABB

public float[] getAABB()
return in aabb an axis aligned bounding box that surrounds the given geom. The aabb array has elements (minx,maxx, miny, maxy, minz, maxz). If the geom is a space, a bounding box that surrounds all contained geoms is returned.
This function may return a pre-computed cached bounding box, if it can determine that the geom has not moved since the last time the bounding box was computed.


computeAABB

public abstract void computeAABB()
compute the AABB for this object and put it in aabb. this function always performs a fresh computation, it does not inspect the GEOM_AABB_BAD flag.


AABBTest

public boolean AABBTest(Geom other,
                        float[] aabb)
test whether the given AABB object intersects with this object, return 1=yes, 0=no. this is used as an early-exit test in the space collision functions. the default implementation returns 1, which is the correct behavior if no more detailed implementation can be provided. utility functions compute the AABB only if it is not current. this function manipulates the GEOM_AABB_BAD flag.


recomputeAABB

public void recomputeAABB()

getUserData

public java.lang.Object getUserData()
get the user-defined data stored in the geom.


setUserData

public void setUserData(java.lang.Object data)
set the user-defined data stored in the geom.


setBody

public void setBody(Body body)
set the body associated with a placeable geom. Setting a body on a geom automatically combines the position vector and rotation matrix of the body and geom, so that setting the position or orientation of one will set the value for both objects.
Setting a body to null gives the geom its own position and rotation, independent from any body. If the geom was previously connected to a body then its new independent position/rotation is set to the current position/rotation of the body.


setPosition

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

setRotation

public void setRotation(Matrix3 R)

setQuaternion

public void setQuaternion(float x,
                          float y,
                          float z,
                          float w)

setQuaternion

public void setQuaternion(Quaternion q)

isEnabled

public boolean isEnabled()

clonePartialGeom

public Geom clonePartialGeom(Geom partialClone,
                             ClonedReferences util)
utility method for children, sets the parents attributes of the passed in partial clone

Parameters:
partialClone -
util -
Returns: