Package com.jme3.bounding
Class BoundingBox
java.lang.Object
com.jme3.bounding.BoundingVolume
com.jme3.bounding.BoundingBox
- All Implemented Interfaces:
- Collidable,- Savable,- Cloneable
BoundingBox describes a bounding volume as an axis-aligned box.
 Instances may be initialized by invoking the
containAABB method.- 
Nested Class SummaryNested classes/interfaces inherited from class com.jme3.bounding.BoundingVolumeBoundingVolume.Type
- 
Field SummaryFields inherited from class com.jme3.bounding.BoundingVolumecenter, checkPlane
- 
Constructor SummaryConstructorsConstructorDescriptionInstantiate aBoundingBoxwithout initializing it.BoundingBox(BoundingBox source) Instantiate aBoundingBoxequivalent to an existing box.BoundingBox(Vector3f c, float x, float y, float z) Instantiate aBoundingBoxwith given center and extents.BoundingBox(Vector3f min, Vector3f max) Instantiate a BoundingBox with the specified extremes.
- 
Method SummaryModifier and TypeMethodDescriptionstatic voidcheckMinMax(Vector3f min, Vector3f max, Vector3f point) clone(BoundingVolume store) clonecreates a new BoundingBox object containing the same data as this one.intcollideWith(Collidable other) intcollideWith(Collidable other, CollisionResults results) Check collision with another Collidable.voidcomputeFromPoints(FloatBuffer points) computeFromPointscreates a new Bounding Box from a given set of points.voidcomputeFromTris(int[] indices, Mesh mesh, int start, int end) voidcomputeFromTris(Triangle[] tris, int start, int end) computeFromTriscreates a new Bounding Box from a given set of triangles.voidcontainAABB(FloatBuffer points) containAABBcreates 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.booleandetermines if a given point is contained within this bounding volume.floatdistanceToEdge(Vector3f point) Find the distance from the nearest edge of this Bounding Volume to the given point.Query extent.Determine the maximum coordinate value for each axis.Determine the minimum coordinate value for each axis.getType()getType returns the type of bounding volume this is.floatfloatDetermine the X-axis distance between the center and the boundary.floatDetermine the Y-axis distance between the center and the boundary.floatDetermine the Z-axis distance between the center and the boundary.booleanintersects determines if this Bounding Box intersects with another given bounding volume.booleanintersects(Ray ray) determines if this bounding box intersects with a given ray object.booleanintersects(Vector3f point) Determines if a given point intersects (touches or is inside) this bounding volume.booleanintersects(Vector3f v1, Vector3f v2, Vector3f v3) C code ported from http://www.cs.lth.se/home/Tomas_Akenine_Moller/code/tribox3.txtbooleandetermines if this bounding box intersects a given bounding box.booleandetermines if this bounding box intersects a given bounding sphere.merge(BoundingVolume volume) mergecombines this bounding box locally with a second bounding volume.mergeLocal(BoundingVolume volume) mergeLocalcombines this bounding box locally with a second bounding volume.voidread(JmeImporter importer) voidReconfigure with the specified extremes.voidsetXExtent(float xExtent) Alter the X-axis distance between the center and the boundary.voidsetYExtent(float yExtent) Alter the Y-axis distance between the center and the boundary.voidsetZExtent(float zExtent) Alter the Z-axis distance between the center and the boundary.toString()toStringreturns the string representation of this object.transform(Matrix4f trans, BoundingVolume store) transform(Transform trans, BoundingVolume store) transformmodifies the center of the box to reflect the change made via a rotation, translation and scale.whichSidetakes a plane (typically provided by a view frustum) to determine which side this bound is on.voidwrite(JmeExporter e) Methods inherited from class com.jme3.bounding.BoundingVolumeclone, distanceSquaredTo, distanceTo, getCenter, getCenter, getCheckPlane, setCenter, setCenter, setCheckPlane, transform
- 
Constructor Details- 
BoundingBoxpublic BoundingBox()Instantiate aBoundingBoxwithout initializing it.
- 
BoundingBoxInstantiate aBoundingBoxwith given center and extents.- Parameters:
- c- the coordinates of the center of the box (not null, not altered)
- x- the X-extent of the box (0 or greater, may be +Infinity)
- y- the Y-extent of the box (0 or greater, may be +Infinity)
- z- the Z-extent of the box (0 or greater, may be +Infinity)
 
- 
BoundingBoxInstantiate aBoundingBoxequivalent to an existing box.- Parameters:
- source- the existing box (not null, not altered)
 
- 
BoundingBoxInstantiate a BoundingBox with the specified extremes.- Parameters:
- min- the desired minimum coordinate value for each axis (not null, not altered)
- max- the desired maximum coordinate value for each axis (not null, not altered)
 
 
- 
- 
Method Details- 
getTypeDescription copied from class:BoundingVolumegetType returns the type of bounding volume this is.- Specified by:
- getTypein class- BoundingVolume
- Returns:
- an enum value
 
- 
computeFromPointscomputeFromPointscreates a new Bounding Box from a given set of points. It uses thecontainAABBmethod as default.- Specified by:
- computeFromPointsin class- BoundingVolume
- Parameters:
- points- the points to contain.
 
- 
computeFromTriscomputeFromTriscreates a new Bounding Box from a given set of triangles. It is used in OBBTree calculations.- Parameters:
- tris- triangle data (unaffected)
- start- the index of the first triangle to be used
- end- the index of the triangle after the last one to be used
 
- 
computeFromTris
- 
checkMinMax
- 
containAABBcontainAABBcreates 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.
 
- 
transformtransformmodifies the center of the box to reflect the change made via a rotation, translation and scale.- Specified by:
- transformin class- BoundingVolume
- Parameters:
- trans- the transform to apply
- store- box to store result in
- Returns:
- the new bounding volume.
 
- 
transform- Specified by:
- transformin class- BoundingVolume
 
- 
whichSidewhichSidetakes a plane (typically provided by a view frustum) to determine which side this bound is on.- Specified by:
- whichSidein class- BoundingVolume
- Parameters:
- plane- the plane to check against.
- Returns:
- the side on which this bounding volume lies.
 
- 
mergemergecombines this bounding box locally with a second bounding volume. The result contains both the original box and the second volume.- Specified by:
- mergein class- BoundingVolume
- Parameters:
- volume- the bounding volume to combine with this box (or null) (not altered)
- Returns:
- this box (with its components modified) or null if the second volume is of some type other than AABB or Sphere
 
- 
mergeLocalmergeLocalcombines this bounding box locally with a second bounding volume. The result contains both the original box and the second volume.- Specified by:
- mergeLocalin class- BoundingVolume
- Parameters:
- volume- the bounding volume to combine with this box (or null) (not altered)
- Returns:
- this box (with its components modified) or null if the second volume is of some type other than AABB or Sphere
 
- 
cloneclonecreates a new BoundingBox object containing the same data as this one.- Specified by:
- clonein class- BoundingVolume
- Parameters:
- store- where to store the cloned information. if null or wrong class, a new store is created.
- Returns:
- the new BoundingBox
 
- 
toStringtoStringreturns the string representation of this object. The form is: "[Center: vector xExtent: X.XX yExtent: Y.YY zExtent: Z.ZZ]".
- 
intersectsintersects determines if this Bounding Box intersects with another given bounding volume. If so, true is returned, otherwise, false is returned.- Specified by:
- intersectsin class- BoundingVolume
- Parameters:
- bv- the second volume to test against.
- Returns:
- true if this volume intersects the given volume.
- See Also:
 
- 
intersectsSpheredetermines if this bounding box intersects a given bounding sphere.- Specified by:
- intersectsSpherein class- BoundingVolume
- Parameters:
- bs- the bounding sphere to test against.
- Returns:
- true if this volume intersects the given bounding sphere.
- See Also:
 
- 
intersectsBoundingBoxdetermines if this bounding box intersects a given bounding box. If the two boxes intersect in any way, true is returned. Otherwise, false is returned.- Specified by:
- intersectsBoundingBoxin class- BoundingVolume
- Parameters:
- bb- the bounding box to test against.
- Returns:
- true if this volume intersects the given bounding box.
- See Also:
 
- 
intersectsdetermines if this bounding box intersects with a given ray object. If an intersection has occurred, true is returned, otherwise false is returned.- Specified by:
- intersectsin class- BoundingVolume
- Parameters:
- ray- the ray to test.
- Returns:
- true if this volume is intersected by a given ray.
- See Also:
 
- 
collideWithDescription copied from interface:CollidableCheck collision with another Collidable.- Parameters:
- other- The object to check collision against
- results- Will contain the list of- CollisionResults.
- Returns:
- how many collisions were found between this and other
 
- 
collideWith- Overrides:
- collideWithin class- BoundingVolume
 
- 
intersectsC code ported from http://www.cs.lth.se/home/Tomas_Akenine_Moller/code/tribox3.txt- Parameters:
- v1- The first point in the triangle
- v2- The second point in the triangle
- v3- The third point in the triangle
- Returns:
- True if the bounding box intersects the triangle, false otherwise.
 
- 
containsDescription copied from class:BoundingVolumedetermines if a given point is contained within this bounding volume. If the point is on the edge of the bounding volume, this method will return false. Use intersects(Vector3f) to check for edge intersection.- Specified by:
- containsin class- BoundingVolume
- Parameters:
- point- the point to check
- Returns:
- true if the point lies within this bounding volume.
 
- 
intersectsDescription copied from class:BoundingVolumeDetermines if a given point intersects (touches or is inside) this bounding volume.- Specified by:
- intersectsin class- BoundingVolume
- Parameters:
- point- the point to check
- Returns:
- true if the point lies within this bounding volume.
 
- 
distanceToEdgeDescription copied from class:BoundingVolumeFind the distance from the nearest edge of this Bounding Volume to the given point.- Specified by:
- distanceToEdgein class- BoundingVolume
- Parameters:
- point- The point to get the distance to
- Returns:
- distance
 
- 
getExtentQuery extent.- Parameters:
- store- where extent gets stored - null to return a new vector
- Returns:
- store / new vector
 
- 
getXExtentpublic float getXExtent()Determine the X-axis distance between the center and the boundary.- Returns:
- the distance
 
- 
getYExtentpublic float getYExtent()Determine the Y-axis distance between the center and the boundary.- Returns:
- the distance
 
- 
getZExtentpublic float getZExtent()Determine the Z-axis distance between the center and the boundary.- Returns:
- the distance
 
- 
setXExtentpublic void setXExtent(float xExtent) Alter the X-axis distance between the center and the boundary.- Parameters:
- xExtent- the desired distance (≥0)
 
- 
setYExtentpublic void setYExtent(float yExtent) Alter the Y-axis distance between the center and the boundary.- Parameters:
- yExtent- the desired distance (≥0)
 
- 
setZExtentpublic void setZExtent(float zExtent) Alter the Z-axis distance between the center and the boundary.- Parameters:
- zExtent- the desired distance (≥0)
 
- 
getMinDetermine the minimum coordinate value for each axis.- Parameters:
- store- storage for the result (modified if not null)
- Returns:
- either storeResult or a new vector
 
- 
getMaxDetermine the maximum coordinate value for each axis.- Parameters:
- store- storage for the result (modified if not null)
- Returns:
- either storeResult or a new vector
 
- 
setMinMaxReconfigure with the specified extremes.- Parameters:
- min- the desired minimum coordinate value for each axis (not null, not altered)
- max- the desired maximum coordinate value for each axis (not null, not altered)
 
- 
write- Specified by:
- writein interface- Savable
- Overrides:
- writein class- BoundingVolume
- Throws:
- IOException
 
- 
read- Specified by:
- readin interface- Savable
- Overrides:
- readin class- BoundingVolume
- Throws:
- IOException
 
- 
getVolumepublic float getVolume()- Specified by:
- getVolumein class- BoundingVolume
 
 
-