com.jme.bounding
Class OrientedBoundingBox

java.lang.Object
  extended bycom.jme.scene.Spatial
      extended bycom.jme.scene.Geometry
          extended bycom.jme.scene.TriMesh
              extended bycom.jme.scene.shape.OrientedBox
                  extended bycom.jme.bounding.OrientedBoundingBox
All Implemented Interfaces:
BoundingVolume, java.io.Serializable

public class OrientedBoundingBox
extends OrientedBox
implements BoundingVolume

Started Date: Aug 24, 2004

This class is liked BoundingBox, but can correctly rotate to fit its bounds.

Author:
Jack Lindamood
See Also:
Serialized Form

Field Summary
 int[] checkPlanes
           
 
Fields inherited from class com.jme.scene.shape.OrientedBox
center, correctCorners, extent, meshColor, normalStore, texBotLeft, texBotRight, texTopLeft, texTopRight, vectorStore, xAxis, yAxis, zAxis
 
Fields inherited from class com.jme.scene.TriMesh
indices, triangleQuantity
 
Fields inherited from class com.jme.scene.Geometry
bound, color, colorBuf, normal, normBuf, texBuf, texture, vertBuf, vertex, vertQuantity
 
Fields inherited from class com.jme.scene.Spatial
currentStates, defaultStateList, forceCull, forceView, frustrumIntersects, geometricalControllers, lightCombineMode, localRotation, localScale, localTranslation, name, parent, queueDistance, renderQueueMode, renderStateList, textureCombineMode, worldBound, worldRotation, worldScale, worldTranslation, zOrder
 
Constructor Summary
OrientedBoundingBox()
          Creates a new OrientedBounding box.
 
Method Summary
 java.lang.Object clone(BoundingVolume store)
          clone creates a new BoundingVolume object containing the same data as this one.
 void computeFromPoints(Vector3f[] points)
          computeFromPoints generates a bounding volume that encompasses a collection of points.
 float distanceTo(Vector3f point)
          Find the distance from the center of this Bounding Volume to the given point.
 Vector3f getCenter(Vector3f store)
          This function stores the approximate center of the bounding volume into the store vector.
 int getCheckPlane(int index)
          get the value for a given index in the checkplanes
 void initCheckPlanes()
          initCheckPlanes resets the checkplanes to their standard order.
 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 intersectsOBB2(OBB2 obb)
          determines if this bounding volume and a given oriented bounding box are intersecting.
 boolean intersectsOrientedBoundingBox(OrientedBoundingBox obb)
          determines if this bounding volume and a given oriented bounding box are intersecting.
 boolean intersectsSphere(BoundingSphere bs)
          determines if this bounding volume and a given bounding sphere are intersecting.
 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 recomputeMesh()
          Reconstruct a visible mesh for the bound.
 void setCheckPlane(int index, int value)
          set the value for a given index in the checkplanes
 BoundingVolume transform(Quaternion rotate, Vector3f translate, Vector3f scale)
          transform alters the location of the bounding volume by a rotation, translation and a scalar.
 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.
 int whichSide(Plane plane)
          whichSide returns the side on which the bounding volume lies on a plane.
 
Methods inherited from class com.jme.scene.shape.OrientedBox
computeCorners, computeInformation, getCenter, getExtent, getMeshColor, getxAxis, getyAxis, getzAxis, isCorrectCorners, setCenter, setExtent, setMeshColor, setxAxis, setyAxis, setzAxis
 
Methods inherited from class com.jme.scene.TriMesh
clearBuffers, draw, drawBounds, findCollisions, findTriangleCollision, findTrianglePick, findWorldRotMat, getIndexAsBuffer, getIndices, getMeshAsTriangles, getTriangle, getTriangle, getTriangleQuantity, hasCollision, hasTriangleCollision, putClone, reconstruct, setIndexBuffer, setIndices, updateCollisionTree, updateIndexBuffer
 
Methods inherited from class com.jme.scene.Geometry
applyRenderState, applyStates, copyTextureCoords, findPick, getAllTextures, getCloneID, getColorAsFloatBuffer, getColors, getModelBound, getNormalAsFloatBuffer, getNormals, getNumberOfUnits, getTextureAsFloatBuffer, getTextureAsFloatBuffer, getTextures, getTextures, getVBOColorID, getVBONormalID, getVBOTextureID, getVBOVertexID, getVerticeAsFloatBuffer, getVertices, getVertQuantity, isVBOColorEnabled, isVBONormalEnabled, isVBOTextureEnabled, isVBOVertexEnabled, randomVertice, reconstruct, setAllTextures, setColor, setColors, setFloatBuffer, setForceView, setModelBound, setNormal, setNormalBuffer, setNormals, setRandomColors, setSolidColor, setTexture, setTexture, setTextureBuffer, setTextureCoord, setTextures, setTextures, setVBOColorEnabled, setVBOColorID, setVBONormalEnabled, setVBONormalID, setVBOTextureEnabled, setVBOTextureID, setVBOVertexEnabled, setVBOVertexID, setVertex, setVertexBuffer, setVertices, updateColorBuffer, updateColorBuffer, updateModelBound, updateNormalBuffer, updateNormalBuffer, updateTextureBuffer, updateTextureBuffer, updateTextureBuffer, updateVertexBuffer, updateVertexBuffer, updateWorldBound
 
Methods inherited from class com.jme.scene.Spatial
addController, applyDefaultStates, calculateCollisions, calculatePick, clearCurrentState, clearCurrentStates, clearRenderState, getController, getControllers, getCurrentState, getLastFrustumIntersection, getLightCombineMode, getLocalRotation, getLocalScale, getLocalTranslation, getName, getParent, getRenderQueueMode, getRenderStateList, getTextureCombineMode, getWorldBound, getWorldRotation, getWorldScale, getWorldTranslation, getZOrder, isForceCulled, isForceView, onDraw, onDrawBounds, propagateBoundToRoot, propagateStatesFromRoot, removeController, removeFromParent, setForceCull, setLightCombineMode, setLocalRotation, setLocalRotation, setLocalScale, setLocalScale, setLocalTranslation, setName, setParent, setRenderQueueMode, setRenderState, setTextureCombineMode, setWorldBound, setZOrder, toString, updateGeometricState, updateRenderState, updateRenderState, updateWorldData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

checkPlanes

public int[] checkPlanes
Constructor Detail

OrientedBoundingBox

public OrientedBoundingBox()
Creates a new OrientedBounding box.

Method Detail

transform

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

Specified by:
transform in interface BoundingVolume
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 BoundingVolume transform(Quaternion rotate,
                                Vector3f translate,
                                Vector3f scale,
                                BoundingVolume store)
Description copied from interface: BoundingVolume
transform alters the location of the bounding volume by a rotation, translation and a scalar.

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

whichSide

public int whichSide(Plane plane)
Description copied from interface: 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 interface BoundingVolume
Parameters:
plane - the plane to check against this bounding volume.
Returns:
the side on which this bounding volume lies.
See Also:
Point

computeFromPoints

public void computeFromPoints(Vector3f[] points)
Description copied from interface: BoundingVolume
computeFromPoints generates a bounding volume that encompasses a collection of points.

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

merge

public BoundingVolume merge(BoundingVolume volume)
Description copied from interface: 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 interface BoundingVolume
Parameters:
volume - the volume to combine.
Returns:
the new merged bounding volume.

mergeLocal

public BoundingVolume mergeLocal(BoundingVolume volume)
Description copied from interface: 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 interface BoundingVolume
Parameters:
volume - the volume to combine.
Returns:
this

clone

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

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

initCheckPlanes

public void initCheckPlanes()
Description copied from interface: BoundingVolume
initCheckPlanes resets the checkplanes to their standard order.

Specified by:
initCheckPlanes in interface BoundingVolume

getCheckPlane

public int getCheckPlane(int index)
Description copied from interface: BoundingVolume
get the value for a given index in the checkplanes

Specified by:
getCheckPlane in interface BoundingVolume
Parameters:
index -
Returns:

setCheckPlane

public void setCheckPlane(int index,
                          int value)
Description copied from interface: BoundingVolume
set the value for a given index in the checkplanes

Specified by:
setCheckPlane in interface BoundingVolume
Parameters:
index -
value -

recomputeMesh

public void recomputeMesh()
Description copied from interface: BoundingVolume
Reconstruct a visible mesh for the bound.

Specified by:
recomputeMesh in interface BoundingVolume

distanceTo

public float distanceTo(Vector3f point)
Description copied from interface: BoundingVolume
Find the distance from the center of this Bounding Volume to the given point.

Specified by:
distanceTo in interface BoundingVolume
Parameters:
point - The point to get the distance to
Returns:
distance

getCenter

public Vector3f getCenter(Vector3f store)
Description copied from interface: BoundingVolume
This function stores the approximate center of the bounding volume into the store vector. For easy function usage, the store vector should be returned when the function is complete.

Specified by:
getCenter in interface BoundingVolume
Parameters:
store - The vector to store the center in.

intersects

public boolean intersects(BoundingVolume bv)
Description copied from interface: 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 interface 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 interface: BoundingVolume
determines if this bounding volume and a given bounding sphere are intersecting.

Specified by:
intersectsSphere in interface 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 interface: BoundingVolume
determines if this bounding volume and a given bounding box are intersecting.

Specified by:
intersectsBoundingBox in interface 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 interface: BoundingVolume
determines if this bounding volume and a given oriented bounding box are intersecting.

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

intersectsOBB2

public boolean intersectsOBB2(OBB2 obb)
Description copied from interface: BoundingVolume
determines if this bounding volume and a given oriented bounding box are intersecting.

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

intersects

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

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