public class BoundingBox extends BoundingVolume
BoundingBox
describes a bounding volume as an axis-aligned box.
containAABB
method.BoundingVolume.Type
center, checkPlane
Constructor and Description |
---|
BoundingBox()
Instantiate a
BoundingBox without initializing it. |
BoundingBox(BoundingBox source)
Instantiate a
BoundingBox equivalent to an existing box. |
BoundingBox(Vector3f c,
float x,
float y,
float z)
Instantiate a
BoundingBox with given center and extents. |
BoundingBox(Vector3f min,
Vector3f max)
Instantiate a BoundingBox with the specified extremes.
|
Modifier and Type | Method and Description |
---|---|
static void |
checkMinMax(Vector3f min,
Vector3f max,
Vector3f point) |
BoundingVolume |
clone(BoundingVolume store)
clone creates a new BoundingBox object containing the same
data as this one. |
int |
collideWith(Collidable other) |
int |
collideWith(Collidable other,
CollisionResults results)
Check collision with another Collidable.
|
void |
computeFromPoints(java.nio.FloatBuffer points)
computeFromPoints creates a new Bounding Box from a given
set of points. |
void |
computeFromTris(int[] indices,
Mesh mesh,
int start,
int end) |
void |
computeFromTris(Triangle[] tris,
int start,
int end)
computeFromTris creates a new Bounding Box from a given
set of triangles. |
void |
containAABB(java.nio.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(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(Vector3f store)
Query extent.
|
Vector3f |
getMax(Vector3f store)
Determine the maximum coordinate value for each axis.
|
Vector3f |
getMin(Vector3f store)
Determine the minimum coordinate value for each axis.
|
BoundingVolume.Type |
getType()
getType returns the type of bounding volume this is.
|
float |
getVolume() |
float |
getXExtent()
Determine the X-axis distance between the center and the boundary.
|
float |
getYExtent()
Determine the Y-axis distance between the center and the boundary.
|
float |
getZExtent()
Determine the Z-axis distance between the center and the boundary.
|
boolean |
intersects(BoundingVolume bv)
intersects determines if this Bounding Box intersects with another given
bounding volume.
|
boolean |
intersects(Ray ray)
determines if this bounding box intersects with a given ray object.
|
boolean |
intersects(Vector3f point)
Determines if a given point intersects (touches or is inside) this bounding volume.
|
boolean |
intersects(Vector3f v1,
Vector3f v2,
Vector3f v3)
C code ported from
http://www.cs.lth.se/home/Tomas_Akenine_Moller/code/tribox3.txt
|
boolean |
intersectsBoundingBox(BoundingBox bb)
determines if this bounding box intersects a given bounding box.
|
boolean |
intersectsSphere(BoundingSphere bs)
determines if this bounding box intersects a given bounding sphere.
|
BoundingVolume |
merge(BoundingVolume volume)
merge combines this bounding box locally with a second
bounding volume. |
BoundingVolume |
mergeLocal(BoundingVolume volume)
mergeLocal combines this bounding box locally with a second
bounding volume. |
void |
read(JmeImporter importer) |
void |
setMinMax(Vector3f min,
Vector3f max)
Reconfigure with the specified extremes.
|
void |
setXExtent(float xExtent)
Alter the X-axis distance between the center and the boundary.
|
void |
setYExtent(float yExtent)
Alter the Y-axis distance between the center and the boundary.
|
void |
setZExtent(float zExtent)
Alter the Z-axis distance between the center and the boundary.
|
java.lang.String |
toString()
toString returns the string representation of this object. |
BoundingVolume |
transform(Matrix4f trans,
BoundingVolume store) |
BoundingVolume |
transform(Transform trans,
BoundingVolume store)
transform modifies the center of the box to reflect the
change made via a rotation, translation and scale. |
Plane.Side |
whichSide(Plane plane)
whichSide takes a plane (typically provided by a view
frustum) to determine which side this bound is on. |
void |
write(JmeExporter e) |
clone, distanceSquaredTo, distanceTo, getCenter, getCenter, getCheckPlane, setCenter, setCenter, setCheckPlane, transform
public BoundingBox()
BoundingBox
without initializing it.public BoundingBox(Vector3f c, float x, float y, float z)
BoundingBox
with given center and extents.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)public BoundingBox(BoundingBox source)
BoundingBox
equivalent to an existing box.source
- the existing box (not null, not altered)public BoundingVolume.Type getType()
BoundingVolume
getType
in class BoundingVolume
public void computeFromPoints(java.nio.FloatBuffer points)
computeFromPoints
creates a new Bounding Box from a given
set of points. It uses the containAABB
method as default.computeFromPoints
in class BoundingVolume
points
- the points to contain.public void computeFromTris(Triangle[] tris, int start, int end)
computeFromTris
creates a new Bounding Box from a given
set of triangles. It is used in OBBTree calculations.tris
- triangle data (unaffected)start
- the index of the first triangle to be usedend
- the index of the triangle after the last one to be usedpublic void computeFromTris(int[] indices, Mesh mesh, int start, int end)
public void containAABB(java.nio.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.points
- the list of points.public BoundingVolume transform(Transform trans, BoundingVolume store)
transform
modifies the center of the box to reflect the
change made via a rotation, translation and scale.transform
in class BoundingVolume
trans
- the transform to applystore
- box to store result inpublic BoundingVolume transform(Matrix4f trans, BoundingVolume store)
transform
in class BoundingVolume
public Plane.Side whichSide(Plane plane)
whichSide
takes a plane (typically provided by a view
frustum) to determine which side this bound is on.whichSide
in class BoundingVolume
plane
- the plane to check against.public BoundingVolume merge(BoundingVolume volume)
merge
combines this bounding box locally with a second
bounding volume. The result contains both the original box and the second
volume.merge
in class BoundingVolume
volume
- the bounding volume to combine with this box (or null) (not
altered)public BoundingVolume mergeLocal(BoundingVolume volume)
mergeLocal
combines this bounding box locally with a second
bounding volume. The result contains both the original box and the second
volume.mergeLocal
in class BoundingVolume
volume
- the bounding volume to combine with this box (or null) (not
altered)public BoundingVolume clone(BoundingVolume store)
clone
creates a new BoundingBox object containing the same
data as this one.clone
in class BoundingVolume
store
- where to store the cloned information. if null or wrong class,
a new store is created.public java.lang.String toString()
toString
returns the string representation of this object.
The form is: "[Center: vector xExtent: X.XX yExtent: Y.YY zExtent:
Z.ZZ]".toString
in class java.lang.Object
public boolean intersects(BoundingVolume bv)
intersects
in class BoundingVolume
bv
- the second volume to test against.BoundingVolume.intersects(com.jme3.bounding.BoundingVolume)
public boolean intersectsSphere(BoundingSphere bs)
intersectsSphere
in class BoundingVolume
bs
- the bounding sphere to test against.BoundingVolume.intersectsSphere(com.jme3.bounding.BoundingSphere)
public boolean intersectsBoundingBox(BoundingBox bb)
intersectsBoundingBox
in class BoundingVolume
bb
- the bounding box to test against.BoundingVolume.intersectsBoundingBox(com.jme3.bounding.BoundingBox)
public boolean intersects(Ray ray)
intersects
in class BoundingVolume
ray
- the ray to test.BoundingVolume.intersects(com.jme3.math.Ray)
public int collideWith(Collidable other, CollisionResults results)
Collidable
other
- The object to check collision againstresults
- Will contain the list of CollisionResult
s.public int collideWith(Collidable other)
collideWith
in class BoundingVolume
public boolean intersects(Vector3f v1, Vector3f v2, Vector3f v3)
v1
- The first point in the trianglev2
- The second point in the trianglev3
- The third point in the trianglepublic boolean contains(Vector3f point)
BoundingVolume
contains
in class BoundingVolume
point
- the point to checkpublic boolean intersects(Vector3f point)
BoundingVolume
intersects
in class BoundingVolume
point
- the point to checkpublic float distanceToEdge(Vector3f point)
BoundingVolume
distanceToEdge
in class BoundingVolume
point
- The point to get the distance topublic Vector3f getExtent(Vector3f store)
store
- where extent gets stored - null to return a new vectorpublic float getXExtent()
public float getYExtent()
public float getZExtent()
public void setXExtent(float xExtent)
xExtent
- the desired distance (≥0)public void setYExtent(float yExtent)
yExtent
- the desired distance (≥0)public void setZExtent(float zExtent)
zExtent
- the desired distance (≥0)public Vector3f getMin(Vector3f store)
store
- storage for the result (modified if not null)public Vector3f getMax(Vector3f store)
store
- storage for the result (modified if not null)public void setMinMax(Vector3f min, Vector3f max)
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)public void write(JmeExporter e) throws java.io.IOException
write
in interface Savable
write
in class BoundingVolume
java.io.IOException
public void read(JmeImporter importer) throws java.io.IOException
read
in interface Savable
read
in class BoundingVolume
java.io.IOException
public float getVolume()
getVolume
in class BoundingVolume