com.jme.bounding
Class BoundingVolume

java.lang.Object
  extended by com.jme.bounding.BoundingVolume
All Implemented Interfaces:
Savable, java.io.Serializable
Direct Known Subclasses:
BoundingBox, BoundingCapsule, BoundingSphere, LineBoundingBox, OrientedBoundingBox, OrthogonalBoundingBox

public abstract class BoundingVolume
extends java.lang.Object
implements java.io.Serializable, Savable

BoundingVolume defines an interface for dealing with containment of a collection of points.

Version:
$Id: BoundingVolume.java 4131 2009-03-19 20:15:28Z blaine.dev $
Author:
Mark Powell
See Also:
Serialized Form

Nested Class Summary
static class BoundingVolume.Type
           
 
Field Summary
protected static Vector3f _compVect1
           
protected static Vector3f _compVect2
           
protected static Vector3f _compVect3
           
protected  Vector3f center
           
protected  int checkPlane
           
 
Constructor Summary
BoundingVolume()
           
BoundingVolume(Vector3f center)
           
 
Method Summary
abstract  BoundingVolume clone(BoundingVolume store)
          clone creates a new BoundingVolume object containing the same data as this one.
abstract  void computeFromPoints(java.nio.FloatBuffer points)
          computeFromPoints generates a bounding volume that encompasses a collection of points.
abstract  void computeFromTris(int[] triIndex, TriMesh mesh, int start, int end)
           
abstract  void computeFromTris(Triangle[] tris, int start, int end)
           
abstract  boolean contains(Vector3f point)
          determines if a given point is contained within this bounding volume.
 float distanceSquaredTo(Vector3f point)
          Find the squared distance from the center of this Bounding Volume to the given point.
 float distanceTo(Vector3f point)
          Find the distance from the center of this Bounding Volume to the given point.
abstract  float distanceToEdge(Vector3f point)
          Find the distance from the nearest edge of this Bounding Volume to the given point.
 Vector3f getCenter()
           
 Vector3f getCenter(Vector3f store)
           
 int getCheckPlane()
          Grabs the checkplane we should check first.
 java.lang.Class getClassTag()
           
abstract  BoundingVolume.Type getType()
          getType returns the type of bounding volume this is.
abstract  float getVolume()
           
abstract  boolean intersects(BoundingVolume bv)
          determines if this bounding volume and a second given volume are intersecting.
abstract  boolean intersects(Ray ray)
          determines if a ray intersects this bounding volume.
abstract  boolean intersectsBoundingBox(BoundingBox bb)
          determines if this bounding volume and a given bounding box are intersecting.
abstract  boolean intersectsCapsule(BoundingCapsule bc)
          determins if this bounding volume and a given bounding capsule are intersecting.
abstract  boolean intersectsOrientedBoundingBox(OrientedBoundingBox bb)
          determines if this bounding volume and a given bounding box are intersecting.
abstract  boolean intersectsSphere(BoundingSphere bs)
          determines if this bounding volume and a given bounding sphere are intersecting.
abstract  IntersectionRecord intersectsWhere(Ray ray)
          determines if a ray intersects this bounding volume and if so, where.
abstract  BoundingVolume merge(BoundingVolume volume)
          merge combines two bounding volumes into a single bounding volume that contains both this bounding volume and the parameter volume.
abstract  BoundingVolume mergeLocal(BoundingVolume volume)
          mergeLocal combines two bounding volumes into a single bounding volume that contains both this bounding volume and the parameter volume.
 void read(JMEImporter e)
           
 void setCenter(Vector3f newCenter)
           
 void setCheckPlane(int value)
          Sets the index of the plane that should be first checked during rendering.
 BoundingVolume transform(Quaternion rotate, Vector3f translate, Vector3f scale)
          transform alters the location of the bounding volume by a rotation, translation and a scalar.
abstract  BoundingVolume transform(Quaternion rotate, Vector3f translate, Vector3f scale, BoundingVolume store)
          transform alters the location of the bounding volume by a rotation, translation and a scalar.
abstract  Plane.Side whichSide(Plane plane)
          whichSide returns the side on which the bounding volume lies on a plane.
 void write(JMEExporter e)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

checkPlane

protected int checkPlane

center

protected Vector3f center

_compVect1

protected static final transient Vector3f _compVect1

_compVect2

protected static final transient Vector3f _compVect2

_compVect3

protected static final transient Vector3f _compVect3
Constructor Detail

BoundingVolume

public BoundingVolume()

BoundingVolume

public BoundingVolume(Vector3f center)
Method Detail

getCheckPlane

public int getCheckPlane()
Grabs the checkplane we should check first.


setCheckPlane

public final void setCheckPlane(int value)
Sets the index of the plane that should be first checked during rendering.

Parameters:
value -

getType

public abstract BoundingVolume.Type getType()
getType returns the type of bounding volume this is.


transform

public final BoundingVolume transform(Quaternion rotate,
                                      Vector3f translate,
                                      Vector3f scale)
transform alters the location of the bounding volume by a rotation, translation and a scalar.

Parameters:
rotate - the rotation to affect the bound.
translate - the translation to affect the bound.
scale - the scale to resize the bound.
Returns:
the new bounding volume.

transform

public abstract BoundingVolume transform(Quaternion rotate,
                                         Vector3f translate,
                                         Vector3f scale,
                                         BoundingVolume store)
transform alters the location of the bounding volume by a rotation, translation and a scalar.

Parameters:
rotate - the rotation to affect the bound.
translate - the translation to affect the bound.
scale - the scale to resize the bound.
store - sphere to store result in
Returns:
the new bounding volume.

whichSide

public abstract Plane.Side whichSide(Plane plane)
whichSide returns the side on which the bounding volume lies on a plane. Possible values are POSITIVE_SIDE, NEGATIVE_SIDE, and NO_SIDE.

Parameters:
plane - the plane to check against this bounding volume.
Returns:
the side on which this bounding volume lies.

computeFromPoints

public abstract void computeFromPoints(java.nio.FloatBuffer points)
computeFromPoints generates a bounding volume that encompasses a collection of points.

Parameters:
points - the points to contain.

merge

public abstract BoundingVolume merge(BoundingVolume volume)
merge combines two bounding volumes into a single bounding volume that contains both this bounding volume and the parameter volume.

Parameters:
volume - the volume to combine.
Returns:
the new merged bounding volume.

mergeLocal

public abstract BoundingVolume mergeLocal(BoundingVolume volume)
mergeLocal combines two bounding volumes into a single bounding volume that contains both this bounding volume and the parameter volume. The result is stored locally.

Parameters:
volume - the volume to combine.
Returns:
this

clone

public abstract BoundingVolume clone(BoundingVolume store)
clone creates a new BoundingVolume object containing the same data as this one.

Parameters:
store - where to store the cloned information. if null or wrong class, a new store is created.
Returns:
the new BoundingVolume

getCenter

public final Vector3f getCenter()

getCenter

public final Vector3f getCenter(Vector3f store)

setCenter

public final void setCenter(Vector3f newCenter)

distanceTo

public final float distanceTo(Vector3f point)
Find the distance from the center of this Bounding Volume to the given point.

Parameters:
point - The point to get the distance to
Returns:
distance

distanceSquaredTo

public final float distanceSquaredTo(Vector3f point)
Find the squared distance from the center of this Bounding Volume to the given point.

Parameters:
point - The point to get the distance to
Returns:
distance

distanceToEdge

public abstract float distanceToEdge(Vector3f point)
Find the distance from the nearest edge of this Bounding Volume to the given point.

Parameters:
point - The point to get the distance to
Returns:
distance

intersects

public abstract boolean intersects(BoundingVolume bv)
determines if this bounding volume and a second given volume are intersecting. Intersecting being: one volume contains another, one volume overlaps another or one volume touches another.

Parameters:
bv - the second volume to test against.
Returns:
true if this volume intersects the given volume.

intersects

public abstract boolean intersects(Ray ray)
determines if a ray intersects this bounding volume.

Parameters:
ray - the ray to test.
Returns:
true if this volume is intersected by a given ray.

intersectsWhere

public abstract IntersectionRecord intersectsWhere(Ray ray)
determines if a ray intersects this bounding volume and if so, where.

Parameters:
ray - the ray to test.
Returns:
an IntersectionRecord containing information about any intersections made by the given Ray with this bounding

intersectsSphere

public abstract boolean intersectsSphere(BoundingSphere bs)
determines if this bounding volume and a given bounding sphere are intersecting.

Parameters:
bs - the bounding sphere to test against.
Returns:
true if this volume intersects the given bounding sphere.

intersectsBoundingBox

public abstract boolean intersectsBoundingBox(BoundingBox bb)
determines if this bounding volume and a given bounding box are intersecting.

Parameters:
bb - the bounding box to test against.
Returns:
true if this volume intersects the given bounding box.

intersectsOrientedBoundingBox

public abstract boolean intersectsOrientedBoundingBox(OrientedBoundingBox bb)
determines if this bounding volume and a given bounding box are intersecting.

Parameters:
bb - the bounding box to test against.
Returns:
true if this volume intersects the given bounding box.

intersectsCapsule

public abstract boolean intersectsCapsule(BoundingCapsule bc)
determins if this bounding volume and a given bounding capsule are intersecting.

Parameters:
bc - the bounding capsule to test against.
Returns:
true if this volume instersects the given bounding capsule.

contains

public abstract boolean contains(Vector3f point)
determines if a given point is contained within this bounding volume.

Parameters:
point - the point to check
Returns:
true if the point lies within this bounding volume.

write

public void write(JMEExporter e)
           throws java.io.IOException
Specified by:
write in interface Savable
Throws:
java.io.IOException

read

public void read(JMEImporter e)
          throws java.io.IOException
Specified by:
read in interface Savable
Throws:
java.io.IOException

getClassTag

public java.lang.Class getClassTag()
Specified by:
getClassTag in interface Savable

computeFromTris

public abstract void computeFromTris(int[] triIndex,
                                     TriMesh mesh,
                                     int start,
                                     int end)

computeFromTris

public abstract void computeFromTris(Triangle[] tris,
                                     int start,
                                     int end)

getVolume

public abstract float getVolume()