org.openmali.spatial.bounds
Class BoundingBox

java.lang.Object
  extended by org.openmali.spatial.bodies.Body
      extended by org.openmali.spatial.bodies.Box
          extended by org.openmali.spatial.bounds.BoundingBox
All Implemented Interfaces:
java.io.Serializable, BodyInterface, Bounds

public class BoundingBox
extends Box
implements Bounds

Axis aligned bounding box volumes

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.openmali.spatial.bodies.Box
lower, upper
 
Fields inherited from class org.openmali.spatial.bodies.Body
centerX, centerY, centerZ, distComputed, maxCenterDist, maxCenterDistSquared
 
Constructor Summary
BoundingBox()
          Create a new empty bounding box
BoundingBox(Bounds bo)
          Create a new bounding box enclosing bounds bo
BoundingBox(Bounds[] bos)
          Create a new bounding box enclosing bounds bos
BoundingBox(float lowerX, float lowerY, float lowerZ, float upperX, float upperY, float upperZ)
          Creates a new Box
BoundingBox(Tuple3f lower, Tuple3f upper)
          Create a new bounding box with lower and upper corners specified
 
Method Summary
 Bounds closestIntersection(Bounds[] boundsObjects)
          Finds closest bounding object that intersects this bounding object.
 void compute(java.util.List<Tuple3f> coords)
          Computes the AABB of a set of coordinates.
 void compute(Tuple3f[] coords)
          Computes the AABB of a set of coordinates.
 void compute(VertexContainer source)
          Computes the AABB of a set of coordinates.
 BoundsType getType()
          
 boolean intersects(Bounds bo)
          Tests for intersection with another Bounds object.
 boolean intersects(Bounds[] bos)
          Tests for intersection with an array of Bounds objects.
 boolean intersects(Point3f rayOrigin, Vector3f rayDirection)
          Tests for intersection with a ray.
 boolean intersects(Point3f rayOrigin, Vector3f rayDirection, Tuple3f intersection)
          Tests for intersection with a ray.
 boolean intersects(Ray3f ray)
          Tests for intersection with a ray.
 boolean intersects(Ray3f ray, Tuple3f intersection)
          Tests for intersection with a ray.
static BoundingBox newAABB(java.util.List<Tuple3f> coords)
          Computes the AABB of a set of coordinates.
static BoundingBox newAABB(Tuple3f[] coords)
          Computes the AABB of a set of coordinates.
static BoundingBox newAABB(VertexContainer source)
          Computes the AABB of a set of coordinates.
 void set(Bounds bo)
          Sets the the value of this Bounds object to enclode the specified bounding object
 void set(Bounds[] bos)
          Sets this bounds to the comnination of all the specified bounds.
 void set(Box boundsObject)
          Sets the the value of this Bounds object to enclode the specified bounding object
 void set(Sphere boundsObject)
          Sets the the value of this Bounds object to enclode the specified bounding object
 java.lang.String toString()
          
 void transform(Bounds bounds, Matrix4f trans)
          Transforms a Bounds object so that it bounds a volume that is the result of transforming the given bounding object by the given transform.
 void transform(Matrix4f trans)
          Transforms the Bounds object by the given transform.
 
Methods inherited from class org.openmali.spatial.bodies.Box
calcCenter, combine_, combine_, combine, combine, combine, combine, combine, contains, contains, getLower, getLower, getLowerX, getLowerY, getLowerZ, getSize, getSize, getUpper, getUpper, getUpperX, getUpperY, getUpperZ, getXSpan, getYSpan, getZSpan, onBoundsChanged, set, set, setCenter, setLower, setLower, setLowerX, setLowerY, setLowerZ, setSize, setSize, setUpper, setUpper, setUpperX, setUpperY, setUpperZ
 
Methods inherited from class org.openmali.spatial.bodies.Body
getCenter, getCenterX, getCenterY, getCenterZ, getMaxCenterDistance, getMaxCenterDistanceSquared, setCenter, setMaxCenterDistanceSquared
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.openmali.spatial.bounds.Bounds
combine, combine, combine, contains, contains, getCenter, getCenterX, getCenterY, getCenterZ, getMaxCenterDistance, getMaxCenterDistanceSquared
 
Methods inherited from interface org.openmali.spatial.bodies.BodyInterface
combine, combine
 

Constructor Detail

BoundingBox

public BoundingBox()
Create a new empty bounding box


BoundingBox

public BoundingBox(float lowerX,
                   float lowerY,
                   float lowerZ,
                   float upperX,
                   float upperY,
                   float upperZ)
Creates a new Box


BoundingBox

public BoundingBox(Tuple3f lower,
                   Tuple3f upper)
Create a new bounding box with lower and upper corners specified


BoundingBox

public BoundingBox(Bounds bo)
Create a new bounding box enclosing bounds bo


BoundingBox

public BoundingBox(Bounds[] bos)
Create a new bounding box enclosing bounds bos

Method Detail

getType

public final BoundsType getType()

Specified by:
getType in interface Bounds
Returns:
the BoundsType of this Bounds instance.

intersects

public boolean intersects(Point3f rayOrigin,
                          Vector3f rayDirection,
                          Tuple3f intersection)
Tests for intersection with a ray.

Specified by:
intersects in interface Bounds

intersects

public boolean intersects(Ray3f ray,
                          Tuple3f intersection)
Tests for intersection with a ray.

Specified by:
intersects in interface Bounds

intersects

public boolean intersects(Point3f rayOrigin,
                          Vector3f rayDirection)
Tests for intersection with a ray.

Specified by:
intersects in interface Bounds

intersects

public boolean intersects(Ray3f ray)
Tests for intersection with a ray.

Specified by:
intersects in interface Bounds

intersects

public boolean intersects(Bounds bo)
Tests for intersection with another Bounds object.

Specified by:
intersects in interface Bounds

intersects

public boolean intersects(Bounds[] bos)
Tests for intersection with an array of Bounds objects.

Specified by:
intersects in interface Bounds

closestIntersection

public Bounds closestIntersection(Bounds[] boundsObjects)
Finds closest bounding object that intersects this bounding object.

Specified by:
closestIntersection in interface Bounds

transform

public void transform(Matrix4f trans)
Transforms the Bounds object by the given transform.

Specified by:
transform in interface Bounds

transform

public void transform(Bounds bounds,
                      Matrix4f trans)
Transforms a Bounds object so that it bounds a volume that is the result of transforming the given bounding object by the given transform.

Specified by:
transform in interface Bounds

set

public void set(Box boundsObject)
Sets the the value of this Bounds object to enclode the specified bounding object

Specified by:
set in interface Bounds

set

public void set(Sphere boundsObject)
Sets the the value of this Bounds object to enclode the specified bounding object

Specified by:
set in interface Bounds

set

public void set(Bounds bo)
Sets the the value of this Bounds object to enclode the specified bounding object

Specified by:
set in interface Bounds

set

public void set(Bounds[] bos)
Sets this bounds to the comnination of all the specified bounds. Any current bounds information is replaced with this new combination

Specified by:
set in interface Bounds

compute

public void compute(VertexContainer source)
Computes the AABB of a set of coordinates.

Specified by:
compute in interface Bounds
Parameters:
source - the vectex-source

compute

public void compute(java.util.List<Tuple3f> coords)
Computes the AABB of a set of coordinates.

Specified by:
compute in interface Bounds
Parameters:
coords - a List of coordinates

compute

public void compute(Tuple3f[] coords)
Computes the AABB of a set of coordinates.

Specified by:
compute in interface Bounds
Parameters:
coords - a List of coordinates

toString

public java.lang.String toString()

Overrides:
toString in class Box

newAABB

public static BoundingBox newAABB(VertexContainer source)
Computes the AABB of a set of coordinates.

Parameters:
source - the vertex source
Returns:
a Box

newAABB

public static BoundingBox newAABB(java.util.List<Tuple3f> coords)
Computes the AABB of a set of coordinates.

Parameters:
coords - a List of coordinates (Vector3fs)
Returns:
a Box

newAABB

public static BoundingBox newAABB(Tuple3f[] coords)
Computes the AABB of a set of coordinates.

Parameters:
coords - a List of coordinates (Vector3fs)
Returns:
a Box