Package com.ardor3d.bounding
Class BoundingBox
java.lang.Object
com.ardor3d.bounding.BoundingVolume
com.ardor3d.bounding.BoundingBox
- All Implemented Interfaces:
Savable
,Serializable
BoundingBox
defines an axis-aligned cube that defines a container for a group of vertices of a
particular piece of geometry. This box defines a center and extents from that center along the x, y and z axis. A typical usage is to allow the class define the center and radius by calling either
containAABB
or
averagePoints
. A call to computeFramePoint
in turn calls containAABB
.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.ardor3d.bounding.BoundingVolume
BoundingVolume.Type
-
Field Summary
Fields inherited from class com.ardor3d.bounding.BoundingVolume
_center, _checkPlane, _compVect1, _compVect2
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor instantiates a newBoundingBox
object.BoundingBox
(BoundingBox other) Constructor instantiates a newBoundingBox
object with given values.BoundingBox
(ReadOnlyVector3 c, double x, double y, double z) Constructor instantiates a newBoundingBox
object with given values. -
Method Summary
Modifier and TypeMethodDescriptionasType
(BoundingVolume.Type newType) Convert this bounding volume to another, given bounding type.clone
(BoundingVolume store) clone
creates a new BoundingBox object containing the same data as this one.void
computeFromPoints
(FloatBuffer points) computeFromPoints
creates a new Bounding Box from a given set of points.void
computeFromPrimitives
(MeshData data, int section, int[] indices, int start, int end) void
containAABB
(FloatBuffer points) containAABB
creates a minimum-volume axis-aligned bounding box of the points, then selects the smallest enclosing sphere of the box with the sphere centered at the boxes center.boolean
contains
(ReadOnlyVector3 point) determines if a given point is contained within this bounding volume.double
distanceToEdge
(ReadOnlyVector3 point) Find the distance from the nearest edge of this Bounding Volume to the given point.boolean
Vector3[]
getCorners
(Vector3[] store) Get our corners using the bounding center and extents.Query extent.double
getType()
getType returns the type of bounding volume this is.double
double
double
double
int
hashCode()
boolean
determines if this bounding volume and a second given volume are intersecting.boolean
intersects
(ReadOnlyRay3 ray) determines if a ray intersects this bounding volume.boolean
determines if this bounding volume and a given bounding box are intersecting.boolean
determines if this bounding volume and a given bounding box are intersecting.boolean
determines if this bounding volume and a given bounding sphere are intersecting.determines if a ray intersects this bounding volume and if so, where.merge
(BoundingVolume volume) merge
combines this sphere with a second bounding sphere.mergeLocal
(BoundingVolume volume) mergeLocal
combines this sphere with a second bounding sphere locally.void
read
(InputCapsule capsule) void
setXExtent
(double xExtent) void
setYExtent
(double yExtent) void
setZExtent
(double zExtent) toString()
toString
returns the string representation of this object.transform
(ReadOnlyTransform transform, BoundingVolume store) transform
alters the location of the bounding volume by a transform.transformRotational
(ReadOnlyTransform transform, BoundingVolume store) whichSide
(ReadOnlyPlane plane) whichSide
takes a plane (typically provided by a view frustum) to determine which side this bound is on.void
write
(OutputCapsule capsule) Methods inherited from class com.ardor3d.bounding.BoundingVolume
distanceSquaredTo, distanceTo, getCenter, getCheckPlane, getClassTag, setCenter, setCenter, setCheckPlane
-
Constructor Details
-
BoundingBox
public BoundingBox()Default constructor instantiates a newBoundingBox
object. -
BoundingBox
Constructor instantiates a newBoundingBox
object with given values.- Parameters:
other
- the other bounding box
-
BoundingBox
Constructor instantiates a newBoundingBox
object with given values.- Parameters:
c
- the centerx
- the x valuey
- the y valuez
- the z value
-
-
Method Details
-
hashCode
public int hashCode()- Overrides:
hashCode
in classBoundingVolume
-
equals
- Overrides:
equals
in classBoundingVolume
-
getType
Description copied from class:BoundingVolume
getType returns the type of bounding volume this is.- Specified by:
getType
in classBoundingVolume
- Returns:
- the type of bounding volume
-
setXExtent
public void setXExtent(double xExtent) -
getXExtent
public double getXExtent() -
setYExtent
public void setYExtent(double yExtent) -
getYExtent
public double getYExtent() -
setZExtent
public void setZExtent(double zExtent) -
getZExtent
public double getZExtent() -
getRadius
public double getRadius()- Specified by:
getRadius
in classBoundingVolume
- Returns:
- the distance from the center of this bounding volume to its further edge/corner. Similar to converting this BoundingVolume to a sphere and asking for radius.
-
transform
Description copied from class:BoundingVolume
transform
alters the location of the bounding volume by a transform.- Specified by:
transform
in classBoundingVolume
- Parameters:
transform
- the transformstore
- the bounding volume used as a store- Returns:
- the transformed bounding volume
-
transformRotational
-
computeFromPoints
computeFromPoints
creates a new Bounding Box from a given set of points. It uses thecontainAABB
method as default.- Specified by:
computeFromPoints
in classBoundingVolume
- Parameters:
points
- the points to contain.
-
computeFromPrimitives
- Specified by:
computeFromPrimitives
in classBoundingVolume
-
containAABB
containAABB
creates a minimum-volume axis-aligned bounding box of the points, then selects the smallest enclosing sphere of the box with the sphere centered at the boxes center.- Parameters:
points
- the list of points.
-
whichSide
whichSide
takes a plane (typically provided by a view frustum) to determine which side this bound is on.- Specified by:
whichSide
in classBoundingVolume
- Parameters:
plane
- the plane to check against.- Returns:
- the side on which this bounding volume lies.
-
merge
merge
combines this sphere with a second bounding sphere. This new sphere contains both bounding spheres and is returned.- Specified by:
merge
in classBoundingVolume
- Parameters:
volume
- the sphere to combine with this sphere.- Returns:
- the new sphere
-
mergeLocal
mergeLocal
combines this sphere with a second bounding sphere locally. Altering this sphere to contain both the original and the additional sphere volumes;- Specified by:
mergeLocal
in classBoundingVolume
- Parameters:
volume
- the sphere to combine with this sphere.- Returns:
- this
-
asType
Description copied from class:BoundingVolume
Convert this bounding volume to another, given bounding type.- Specified by:
asType
in classBoundingVolume
- Parameters:
newType
- the type of bounding volume to convert to.- Returns:
- a new bounding volume of the given type, containing this bounding volume.
-
clone
clone
creates a new BoundingBox object containing the same data as this one.- Specified by:
clone
in classBoundingVolume
- Parameters:
store
- where to store the cloned information. if null or wrong class, a new store is created.- Returns:
- the new BoundingBox
-
toString
toString
returns the string representation of this object. The form is: "Radius: RRR.SSSS Center: <Vector>". -
intersects
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 classBoundingVolume
- Parameters:
bv
- the second volume to test against.- Returns:
- true if this volume intersects the given volume.
-
intersectsSphere
Description copied from class:BoundingVolume
determines if this bounding volume and a given bounding sphere are intersecting.- Specified by:
intersectsSphere
in classBoundingVolume
- Parameters:
bs
- the bounding sphere to test against.- Returns:
- true if this volume intersects the given bounding sphere.
-
intersectsBoundingBox
Description copied from class:BoundingVolume
determines if this bounding volume and a given bounding box are intersecting.- Specified by:
intersectsBoundingBox
in classBoundingVolume
- Parameters:
bb
- the bounding box to test against.- Returns:
- true if this volume intersects the given bounding box.
-
intersectsOrientedBoundingBox
Description copied from class:BoundingVolume
determines if this bounding volume and a given bounding box are intersecting.- Specified by:
intersectsOrientedBoundingBox
in classBoundingVolume
- Parameters:
obb
- the bounding box to test against.- Returns:
- true if this volume intersects the given bounding box.
-
intersects
Description copied from class:BoundingVolume
determines if a ray intersects this bounding volume.- Specified by:
intersects
in classBoundingVolume
- Parameters:
ray
- the ray to test.- Returns:
- true if this volume is intersected by a given ray.
-
intersectsWhere
Description copied from class:BoundingVolume
determines if a ray intersects this bounding volume and if so, where.- Specified by:
intersectsWhere
in classBoundingVolume
- Parameters:
ray
- the ray to test.- Returns:
- an IntersectionRecord containing information about any intersections made by the given Ray with this bounding
-
contains
Description copied from class:BoundingVolume
determines if a given point is contained within this bounding volume.- Specified by:
contains
in classBoundingVolume
- Parameters:
point
- the point to check- Returns:
- true if the point lies within this bounding volume.
-
distanceToEdge
Description copied from class:BoundingVolume
Find the distance from the nearest edge of this Bounding Volume to the given point.- Specified by:
distanceToEdge
in classBoundingVolume
- Parameters:
point
- The point to get the distance to- Returns:
- distance
-
getCorners
Get our corners using the bounding center and extents.- Parameters:
store
- An optional store. Must be at least length of 8. If null, one will be created for you.- Returns:
- array filled with our corners.
- Throws:
ArrayIndexOutOfBoundsException
- if our store is length < 8.
-
getExtent
Query extent.- Parameters:
store
- where extent gets stored - null to return a new vector- Returns:
- store / new vector
-
write
- Specified by:
write
in interfaceSavable
- Overrides:
write
in classBoundingVolume
- Throws:
IOException
-
read
- Specified by:
read
in interfaceSavable
- Overrides:
read
in classBoundingVolume
- Throws:
IOException
-
getVolume
public double getVolume()- Specified by:
getVolume
in classBoundingVolume
-