com.jme.bounding
Class OrientedBoundingBox

java.lang.Object
  extended by com.jme.bounding.BoundingVolume
      extended by com.jme.bounding.OrientedBoundingBox
All Implemented Interfaces:
Savable, java.io.Serializable

public class OrientedBoundingBox
extends BoundingVolume

Started Date: Sep 5, 2004

Version:
$Id: OrientedBoundingBox.java 4131 2009-03-19 20:15:28Z blaine.dev $
Author:
Jack Lindamood, Joshua Slack (alterations for .9)
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.jme.bounding.BoundingVolume
BoundingVolume.Type
 
Field Summary
 boolean correctCorners
          If true, the box's vectorStore array correctly represents the box's corners.
 Vector3f extent
          Extents of the box along the x,y,z axis.
 Vector3f[] vectorStore
          Vector array used to store the array of 8 corners the box has.
 Vector3f xAxis
          X axis of the Oriented Box.
 Vector3f yAxis
          Y axis of the Oriented Box.
 Vector3f zAxis
          Z axis of the Oriented Box.
 
Fields inherited from class com.jme.bounding.BoundingVolume
_compVect1, _compVect2, center, checkPlane
 
Constructor Summary
OrientedBoundingBox()
           
 
Method Summary
 BoundingVolume clone(BoundingVolume store)
          clone creates a new BoundingVolume object containing the same data as this one.
 void computeCorners()
          Sets the vectorStore information to the 8 corners of the box.
 void computeFromPoints(java.nio.FloatBuffer points)
          computeFromPoints generates a bounding volume that encompasses a collection of points.
 void computeFromTris(int[] indices, TriMesh mesh, int start, int end)
           
 void computeFromTris(Triangle[] tris, int start, int end)
           
 boolean contains(Vector3f point)
          determines if a given point is contained within this bounding volume.
 float distanceToEdge(Vector3f point)
          Find the distance from the nearest edge of this Bounding Volume to the given point.
 Vector3f getExtent()
           
 BoundingVolume.Type getType()
          getType returns the type of bounding volume this is.
 float getVolume()
           
 Vector3f getXAxis()
           
 Vector3f getYAxis()
           
 Vector3f getZAxis()
           
 boolean intersection(OrientedBoundingBox box1)
           
 boolean intersects(BoundingVolume bv)
          determines if this bounding volume and a second given volume are intersecting.
 boolean intersects(Ray ray)
          determines if a ray intersects this bounding volume.
 boolean intersectsBoundingBox(BoundingBox bb)
          determines if this bounding volume and a given bounding box are intersecting.
 boolean intersectsCapsule(BoundingCapsule bc)
          determins if this bounding volume and a given bounding capsule are intersecting.
 boolean intersectsOrientedBoundingBox(OrientedBoundingBox obb)
          determines if this bounding volume and a given bounding box are intersecting.
 boolean intersectsSphere(BoundingSphere bs)
          determines if this bounding volume and a given bounding sphere are intersecting.
 IntersectionRecord intersectsWhere(Ray ray)
          determines if a ray intersects this bounding volume and if so, where.
 BoundingVolume merge(BoundingVolume volume)
          merge combines two bounding volumes into a single bounding volume that contains both this bounding volume and the parameter volume.
 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 setExtent(Vector3f ext)
           
 void setXAxis(Vector3f axis)
           
 void setYAxis(Vector3f axis)
           
 void setZAxis(Vector3f axis)
           
 BoundingVolume transform(Matrix3f rotate, Vector3f translate, Vector3f scale, BoundingVolume store)
           
 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.
 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 com.jme.bounding.BoundingVolume
distanceSquaredTo, distanceTo, getCenter, getCenter, getCheckPlane, getClassTag, setCenter, setCheckPlane, transform
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xAxis

public final Vector3f xAxis
X axis of the Oriented Box.


yAxis

public final Vector3f yAxis
Y axis of the Oriented Box.


zAxis

public final Vector3f zAxis
Z axis of the Oriented Box.


extent

public final Vector3f extent
Extents of the box along the x,y,z axis.


vectorStore

public final Vector3f[] vectorStore
Vector array used to store the array of 8 corners the box has.


correctCorners

public boolean correctCorners
If true, the box's vectorStore array correctly represents the box's corners.

Constructor Detail

OrientedBoundingBox

public OrientedBoundingBox()
Method Detail

getType

public BoundingVolume.Type getType()
Description copied from class: BoundingVolume
getType returns the type of bounding volume this is.

Specified by:
getType in class BoundingVolume

transform

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

Specified by:
transform in class BoundingVolume
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.

transform

public BoundingVolume transform(Matrix3f rotate,
                                Vector3f translate,
                                Vector3f scale,
                                BoundingVolume store)

whichSide

public Plane.Side whichSide(Plane plane)
Description copied from class: BoundingVolume
whichSide returns the side on which the bounding volume lies on a plane. Possible values are POSITIVE_SIDE, NEGATIVE_SIDE, and NO_SIDE.

Specified by:
whichSide in class BoundingVolume
Parameters:
plane - the plane to check against this bounding volume.
Returns:
the side on which this bounding volume lies.

computeFromPoints

public void computeFromPoints(java.nio.FloatBuffer points)
Description copied from class: BoundingVolume
computeFromPoints generates a bounding volume that encompasses a collection of points.

Specified by:
computeFromPoints in class BoundingVolume
Parameters:
points - the points to contain.

merge

public BoundingVolume merge(BoundingVolume volume)
Description copied from class: BoundingVolume
merge combines two bounding volumes into a single bounding volume that contains both this bounding volume and the parameter volume.

Specified by:
merge in class BoundingVolume
Parameters:
volume - the volume to combine.
Returns:
the new merged bounding volume.

mergeLocal

public BoundingVolume mergeLocal(BoundingVolume volume)
Description copied from class: BoundingVolume
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.

Specified by:
mergeLocal in class BoundingVolume
Parameters:
volume - the volume to combine.
Returns:
this

clone

public BoundingVolume clone(BoundingVolume store)
Description copied from class: BoundingVolume
clone creates a new BoundingVolume object containing the same data as this one.

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

computeCorners

public void computeCorners()
Sets the vectorStore information to the 8 corners of the box.


computeFromTris

public void computeFromTris(int[] indices,
                            TriMesh mesh,
                            int start,
                            int end)
Specified by:
computeFromTris in class BoundingVolume

computeFromTris

public void computeFromTris(Triangle[] tris,
                            int start,
                            int end)
Specified by:
computeFromTris in class BoundingVolume

intersection

public boolean intersection(OrientedBoundingBox box1)

intersects

public boolean intersects(BoundingVolume bv)
Description copied from class: BoundingVolume
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.

Specified by:
intersects in class BoundingVolume
Parameters:
bv - the second volume to test against.
Returns:
true if this volume intersects the given volume.

intersectsSphere

public boolean intersectsSphere(BoundingSphere bs)
Description copied from class: BoundingVolume
determines if this bounding volume and a given bounding sphere are intersecting.

Specified by:
intersectsSphere in class BoundingVolume
Parameters:
bs - the bounding sphere to test against.
Returns:
true if this volume intersects the given bounding sphere.

intersectsBoundingBox

public boolean intersectsBoundingBox(BoundingBox bb)
Description copied from class: BoundingVolume
determines if this bounding volume and a given bounding box are intersecting.

Specified by:
intersectsBoundingBox in class BoundingVolume
Parameters:
bb - the bounding box to test against.
Returns:
true if this volume intersects the given bounding box.

intersectsOrientedBoundingBox

public boolean intersectsOrientedBoundingBox(OrientedBoundingBox obb)
Description copied from class: BoundingVolume
determines if this bounding volume and a given bounding box are intersecting.

Specified by:
intersectsOrientedBoundingBox in class BoundingVolume
Parameters:
obb - the bounding box to test against.
Returns:
true if this volume intersects the given bounding box.

intersectsCapsule

public boolean intersectsCapsule(BoundingCapsule bc)
Description copied from class: BoundingVolume
determins if this bounding volume and a given bounding capsule are intersecting.

Specified by:
intersectsCapsule in class BoundingVolume
Parameters:
bc - the bounding capsule to test against.
Returns:
true if this volume instersects the given bounding capsule.

intersects

public boolean intersects(Ray ray)
Description copied from class: BoundingVolume
determines if a ray intersects this bounding volume.

Specified by:
intersects in class BoundingVolume
Parameters:
ray - the ray to test.
Returns:
true if this volume is intersected by a given ray.

intersectsWhere

public IntersectionRecord intersectsWhere(Ray ray)
Description copied from class: BoundingVolume
determines if a ray intersects this bounding volume and if so, where.

Specified by:
intersectsWhere in class BoundingVolume
Parameters:
ray - the ray to test.
Returns:
an IntersectionRecord containing information about any intersections made by the given Ray with this bounding
See Also:
BoundingVolume.intersectsWhere(com.jme.math.Ray)

setXAxis

public void setXAxis(Vector3f axis)

setYAxis

public void setYAxis(Vector3f axis)

setZAxis

public void setZAxis(Vector3f axis)

setExtent

public void setExtent(Vector3f ext)

getXAxis

public Vector3f getXAxis()

getYAxis

public Vector3f getYAxis()

getZAxis

public Vector3f getZAxis()

getExtent

public Vector3f getExtent()

contains

public boolean contains(Vector3f point)
Description copied from class: BoundingVolume
determines if a given point is contained within this bounding volume.

Specified by:
contains in class BoundingVolume
Parameters:
point - the point to check
Returns:
true if the point lies within this bounding volume.

distanceToEdge

public float distanceToEdge(Vector3f point)
Description copied from class: BoundingVolume
Find the distance from the nearest edge of this Bounding Volume to the given point.

Specified by:
distanceToEdge in class BoundingVolume
Parameters:
point - The point to get the distance to
Returns:
distance

write

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

read

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

getVolume

public float getVolume()
Specified by:
getVolume in class BoundingVolume