org.odejava
Class QuadTreeSpace

java.lang.Object
  extended by org.odejava.Space
      extended by org.odejava.QuadTreeSpace

public class QuadTreeSpace
extends Space

A quad-tree based space for collision detection. QuadTrees are located at a fixed point in space and cannot change after being created.

Created 16.12.2003 (dd.mm.yyyy)

Author:
Jani Laakso E-mail: jani.laakso@itmill.com see http://odejava.dev.java.net

Field Summary
protected  float[] center
          The center of the space
protected  int depth
          The depth of the quad tree to generate for this space.
protected  float[] extents
          The extents of the space
 
Fields inherited from class org.odejava.Space
deleted, geomList, geomMap, parentId, spaceId, SPACEID_ZERO
 
Constructor Summary
QuadTreeSpace(float[] center, float[] extents, int depth)
          Create a QuadTree space that does not have a parent.
QuadTreeSpace(Space parent, float[] center, float[] extents, int depth)
          Create a QuadTree space that may optionally belong to a parent space.
 
Method Summary
 void getCenter(float[] result)
          Get the center of the space and copy it into the user-provided array.
 float getDepth()
          Get the depth of the quadtree.
 void getExtents(float[] result)
          Get the extents of the space and copy it into the user-provided array.
 
Methods inherited from class org.odejava.Space
add, addBodyGeoms, addGeom, containsGeom, delete, getChildCleanupMode, getGeom, getGeomMap, getGeoms, getId, getID, getNativeAddr, getSpaceFromNativeAddr, getUserData, isEnabled, remove, renameGeom, setChildCleanupMode, setEnabled, setUserData, updateNativeAddr
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

center

protected float[] center
The center of the space


extents

protected float[] extents
The extents of the space


depth

protected int depth
The depth of the quad tree to generate for this space.

Constructor Detail

QuadTreeSpace

public QuadTreeSpace(float[] center,
                     float[] extents,
                     int depth)
Create a QuadTree space that does not have a parent. Depth should be a non-negative number.

Parameters:
center - The location of the space's center in world coords
extents - The size of the space's extents in world coords
depth - The number of subdivisions of the quad tree to make

QuadTreeSpace

public QuadTreeSpace(Space parent,
                     float[] center,
                     float[] extents,
                     int depth)
Create a QuadTree space that may optionally belong to a parent space. If the parent space reference is null, then this space is placed as a top-level space. Depth should be a non-negative number.

Parameters:
center - The location of the space's center in world coords
extents - The size of the space's extents in world coords
depth - The number of subdivisions of the quad tree to make
parent - A reference to the parent space, or null
Method Detail

getCenter

public void getCenter(float[] result)
Get the center of the space and copy it into the user-provided array.

Parameters:
result - An array to copy the center into

getExtents

public void getExtents(float[] result)
Get the extents of the space and copy it into the user-provided array.

Parameters:
result - An array to copy the center into

getDepth

public float getDepth()
Get the depth of the quadtree.

Returns:
The depth - a non-negative number