Aviatrix3D
2.1.0

org.j3d.aviatrix3d
Class BoundingBox

java.lang.Object
  extended by org.j3d.aviatrix3d.rendering.BoundingVolume
      extended by org.j3d.aviatrix3d.BoundingBox

public class BoundingBox
extends BoundingVolume

Bounds described as an axis-aligned bounding volume.

Version:
$Revision: 1.29 $
Author:
Justin Couch

Field Summary
 
Fields inherited from class org.j3d.aviatrix3d.rendering.BoundingVolume
BOX_BOUNDS, FRUSTUM_ALLIN, FRUSTUM_ALLOUT, FRUSTUM_PARTIAL, GEOMETRY_BOUNDS, NULL_BOUNDS, SPHERE_BOUNDS
 
Constructor Summary
BoundingBox()
          The default constructor with the sphere radius as one and center at the origin.
BoundingBox(float[] min, float[] max)
          Construct a bounding box with minimum and maximum positions.
 
Method Summary
 boolean checkIntersectionBox(float[] minExtents, float[] maxExtents)
          Check for the given AA box intersecting this bounds.
 boolean checkIntersectionCone(float[] vertex, float[] direction, float angle)
          Check for the given cone intersecting this bounds.
 boolean checkIntersectionCylinder(float[] center, float[] direction, float radius, float height)
          Check for the given cylinder segment intersecting this bounds.
 int checkIntersectionFrustum(javax.vecmath.Vector4f[] planes, javax.vecmath.Matrix4d mat)
          Check whether this volume intersects with the view frustum.
 int checkIntersectionFrustum(javax.vecmath.Vector4f[] planes, javax.vecmath.Matrix4f mat)
          Check whether this volume intersects with the view frustum.
 boolean checkIntersectionPoint(float[] pos)
          Check for the given point lieing inside this bounds.
 boolean checkIntersectionRay(float[] pos, float[] dir)
          Check for the given ray intersecting this bounds.
 boolean checkIntersectionSegment(float[] start, float[] end)
          Check for the given line segment intersecting this bounds.
 boolean checkIntersectionSphere(float[] center, float radius)
          Check for the given sphere intersecting this bounds.
 boolean checkIntersectionTriangle(float[] v0, float[] v1, float[] v2)
          Check for the given triangle intersecting this bounds.
 void getCenter(float[] center)
          Get the center of the bounding volume.
 void getExtents(float[] min, float[] max)
          Get the maximum extents of the bounding volume.
 void getMaximum(float[] pos)
          Get the maximum bounds position of the box.
 void getMinimum(float[] pos)
          Get the minimum bounds position of the box.
 void getSize(float[] size)
          Get the size of the bounding volume.
 int getType()
          The type of bounds this object represents.
 void setBounds(float[] min, float[] max)
          Set both of the bounds of the box.
 void setMaximum(float[] pos)
          Set the maximum bounds for the box.
 void setMaximum(float x, float y, float z)
          Set the maximum bounds for the box.
 void setMinimum(float[] pos)
          Set the minimum bounds for the box.
 void setMinimum(float x, float y, float z)
          Set the minimum bounds for the box.
 java.lang.String toString()
          Generate a string representation of this box.
 void transform(javax.vecmath.Matrix4d mat)
          Transform the current postion by the given transformation matrix.
 void transform(javax.vecmath.Matrix4f mat)
          Transform the current postion by the given transformation matrix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BoundingBox

public BoundingBox()
The default constructor with the sphere radius as one and center at the origin.


BoundingBox

public BoundingBox(float[] min,
                   float[] max)
Construct a bounding box with minimum and maximum positions.

Parameters:
min - The minimum position of the bounds
max - The maximum position of the bounds
Method Detail

getType

public int getType()
The type of bounds this object represents.

Specified by:
getType in class BoundingVolume
Returns:
One of the constant types defined

getExtents

public void getExtents(float[] min,
                       float[] max)
Get the maximum extents of the bounding volume.

Specified by:
getExtents in class BoundingVolume
Parameters:
min - The minimum position of the bounds
max - The maximum position of the bounds

getCenter

public void getCenter(float[] center)
Get the center of the bounding volume.

Specified by:
getCenter in class BoundingVolume
Parameters:
center - The center of the bounds will be copied here

getSize

public void getSize(float[] size)
Get the size of the bounding volume.

Parameters:
size - The size of the bounds will be copied here

checkIntersectionPoint

public boolean checkIntersectionPoint(float[] pos)
Check for the given point lieing inside this bounds.

Specified by:
checkIntersectionPoint in class BoundingVolume
Parameters:
pos - The location of the point to test against
Returns:
true if the point lies inside this bounds

checkIntersectionRay

public boolean checkIntersectionRay(float[] pos,
                                    float[] dir)
Check for the given ray intersecting this bounds. The line is described as a starting point and a vector direction.

Specified by:
checkIntersectionRay in class BoundingVolume
Parameters:
pos - The start location of the ray
dir - The direction vector of the ray
Returns:
true if the ray intersects this bounds

checkIntersectionSphere

public boolean checkIntersectionSphere(float[] center,
                                       float radius)
Check for the given sphere intersecting this bounds. The sphere is described by a centre location and the radius.

Specified by:
checkIntersectionSphere in class BoundingVolume
Parameters:
center - The location of the sphere's center
radius - The radius of the sphere
Returns:
true if the sphere intersects this bounds

checkIntersectionTriangle

public boolean checkIntersectionTriangle(float[] v0,
                                         float[] v1,
                                         float[] v2)
Check for the given triangle intersecting this bounds. Assumes the three coordinates of the triangle are declared in RH coordinate system.

Specified by:
checkIntersectionTriangle in class BoundingVolume
Parameters:
v0 - The first vertex of the triangle
v1 - The second vertex of the triangle
v2 - The third vertex of the triangle
Returns:
true if the sphere intersects this bounds

checkIntersectionCylinder

public boolean checkIntersectionCylinder(float[] center,
                                         float[] direction,
                                         float radius,
                                         float height)
Check for the given cylinder segment intersecting this bounds. The cylinder is described by a centre location, axial direction and the radius.

Specified by:
checkIntersectionCylinder in class BoundingVolume
Parameters:
center - The location of the cylinder's center
direction - A unit vector indicating the axial direction
radius - The radius of the cylinder
height - The half-height of the cylinder from the center point
Returns:
true if the sphere intersects this bounds

checkIntersectionCone

public boolean checkIntersectionCone(float[] vertex,
                                     float[] direction,
                                     float angle)
Check for the given cone intersecting this bounds. The cone is described by the location of the vertex, a direction vector and the spread angle of the cone.

Specified by:
checkIntersectionCone in class BoundingVolume
Parameters:
vertex - The location of the cone's vertex
direction - A unit vector indicating the axial direction
angle - The spread angle of the cone
Returns:
true if the sphere intersects this bounds

checkIntersectionBox

public boolean checkIntersectionBox(float[] minExtents,
                                    float[] maxExtents)
Check for the given AA box intersecting this bounds. The box is described by the minimum and maximum extents on each axis.

Specified by:
checkIntersectionBox in class BoundingVolume
Parameters:
minExtents - The minimum extent value on each axis
maxExtents - The maximum extent value on each axis
Returns:
true if the box intersects this bounds

checkIntersectionFrustum

public int checkIntersectionFrustum(javax.vecmath.Vector4f[] planes,
                                    javax.vecmath.Matrix4d mat)
Check whether this volume intersects with the view frustum.

Specified by:
checkIntersectionFrustum in class BoundingVolume
Parameters:
planes - The 6 planes of the frustum
mat - The vworld to local transformation matrix
Returns:
int FRUSTUM_ALLOUT, FRUSTUM_ALLIN, FRUSTUM_PARTIAL.

checkIntersectionFrustum

public int checkIntersectionFrustum(javax.vecmath.Vector4f[] planes,
                                    javax.vecmath.Matrix4f mat)
Check whether this volume intersects with the view frustum.

Specified by:
checkIntersectionFrustum in class BoundingVolume
Parameters:
planes - The 6 planes of the frustum
mat - The vworld to local transformation matrix
Returns:
int FRUSTUM_ALLOUT, FRUSTUM_ALLIN, FRUSTUM_PARTIAL.

checkIntersectionSegment

public boolean checkIntersectionSegment(float[] start,
                                        float[] end)
Check for the given line segment intersecting this bounds. The line is described as the line connecting the start and end points.

Specified by:
checkIntersectionSegment in class BoundingVolume
Parameters:
start - The start location of the segment
end - The start location of the segment
Returns:
true if the segment intersects this bounds

transform

public void transform(javax.vecmath.Matrix4d mat)
Transform the current postion by the given transformation matrix.

Specified by:
transform in class BoundingVolume
Parameters:
mat - The matrix to transform this bounds by

transform

public void transform(javax.vecmath.Matrix4f mat)
Transform the current postion by the given transformation matrix.

Specified by:
transform in class BoundingVolume
Parameters:
mat - The matrix to transform this bounds by

setBounds

public void setBounds(float[] min,
                      float[] max)
Set both of the bounds of the box.

Parameters:
min - The minimum position of the bounds
max - The maximum position of the bounds

setMinimum

public void setMinimum(float[] pos)
Set the minimum bounds for the box.

Parameters:
pos - The new position of the box to be used

setMinimum

public void setMinimum(float x,
                       float y,
                       float z)
Set the minimum bounds for the box.

Parameters:
x - The x component of the minimum position
y - The y component of the minimum position
z - The z component of the minimum position

getMinimum

public void getMinimum(float[] pos)
Get the minimum bounds position of the box.

Parameters:
pos - The position to copy the values into

setMaximum

public void setMaximum(float[] pos)
Set the maximum bounds for the box.

Parameters:
pos - The new position of the center of the sphere to be used

setMaximum

public void setMaximum(float x,
                       float y,
                       float z)
Set the maximum bounds for the box.

Parameters:
x - The x component of the minimum position
y - The y component of the minimum position
z - The z component of the minimum position

getMaximum

public void getMaximum(float[] pos)
Get the maximum bounds position of the box.

Parameters:
pos - The position to copy the values axto

toString

public java.lang.String toString()
Generate a string representation of this box.

Overrides:
toString in class java.lang.Object
Returns:
A string representing the bounds information

Aviatrix3D
2.1.0

Latest Info from http://aviatrix3d.j3d.org/
Copyright © 2003 - 2009 j3d.org