Aviatrix3D
2.1.0

org.j3d.aviatrix3d.rendering
Class BoundingVolume

java.lang.Object
  extended by org.j3d.aviatrix3d.rendering.BoundingVolume
Direct Known Subclasses:
BoundingBox, BoundingGeometry, BoundingSphere, BoundingVoid

public abstract class BoundingVolume
extends java.lang.Object

Base representation of a class that can representing bound information.

Bounds describe a 3D volume, and various abstract intersection methods are defined. All methods must be implemented as various methods may be called during different parts of the rendering cycle. All bounds and rays are assumed to be represented in the same local coordinate space.

All intersection tests assume that the incoming picking details have been transformed to the local coordinate space that this volume exists in. The one exception to this rule is the view frustum intersection tests. The reason for this is performance - transforming 6 planes of the view matrix requires 6 matrix-vector multiplications, whereas by providing the reverse we only need to perform 2 matrix-vector mulitplications. Since view frustum culling is such a performance critical path of the rendering system we have decided to optimise for speed here rather than consistent API coding.

Version:
$Revision: 2.3 $
Author:
Justin Couch

Field Summary
static int BOX_BOUNDS
          The bounding volume type is sphere
static int FRUSTUM_ALLIN
          The frustum check revealed all points inside the frustum
static int FRUSTUM_ALLOUT
          The frustum check revealed all points outside the frustum
static int FRUSTUM_PARTIAL
          The frustum check revealed some points inside the frustum
static int GEOMETRY_BOUNDS
          The bounding volume type is user provided geometry
static int NULL_BOUNDS
          The bounding volume type is not valid (ie it has no bounds)
static int SPHERE_BOUNDS
          The bounding volume type is sphere
 
Constructor Summary
protected BoundingVolume()
          The default constructor.
 
Method Summary
abstract  boolean checkIntersectionBox(float[] minExtents, float[] maxExtents)
          Check for the given AA box intersecting this bounds.
abstract  boolean checkIntersectionCone(float[] vertex, float[] direction, float angle)
          Check for the given cone intersecting this bounds.
abstract  boolean checkIntersectionCylinder(float[] center, float[] direction, float radius, float height)
          Check for the given cylinder segment intersecting this bounds.
abstract  int checkIntersectionFrustum(javax.vecmath.Vector4f[] planes, javax.vecmath.Matrix4d mat)
          Check whether this volume intersects with the view frustum.
abstract  int checkIntersectionFrustum(javax.vecmath.Vector4f[] planes, javax.vecmath.Matrix4f mat)
          Check whether this volume intersects with the view frustum.
abstract  boolean checkIntersectionPoint(float[] pos)
          Check for the given point lieing inside this bounds.
abstract  boolean checkIntersectionRay(float[] pos, float[] dir)
          Check for the given ray intersecting this bounds.
abstract  boolean checkIntersectionSegment(float[] start, float[] end)
          Check for the given line segment intersecting this bounds.
abstract  boolean checkIntersectionSphere(float[] center, float radius)
          Check for the given sphere intersecting this bounds.
abstract  boolean checkIntersectionTriangle(float[] v0, float[] v1, float[] v2)
          Check for the given triangle intersecting this bounds.
abstract  void getCenter(float[] center)
          Get the center of the bounding volume.
abstract  void getExtents(float[] min, float[] max)
          Get the maximum extents of the bounding volume.
abstract  int getType()
          The type of bounds this object represents.
abstract  void transform(javax.vecmath.Matrix4d mat)
          Transform the current postion by the given transformation matrix.
abstract  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, toString, wait, wait, wait
 

Field Detail

NULL_BOUNDS

public static final int NULL_BOUNDS
The bounding volume type is not valid (ie it has no bounds)

See Also:
Constant Field Values

SPHERE_BOUNDS

public static final int SPHERE_BOUNDS
The bounding volume type is sphere

See Also:
Constant Field Values

BOX_BOUNDS

public static final int BOX_BOUNDS
The bounding volume type is sphere

See Also:
Constant Field Values

GEOMETRY_BOUNDS

public static final int GEOMETRY_BOUNDS
The bounding volume type is user provided geometry

See Also:
Constant Field Values

FRUSTUM_ALLOUT

public static final int FRUSTUM_ALLOUT
The frustum check revealed all points outside the frustum

See Also:
Constant Field Values

FRUSTUM_ALLIN

public static final int FRUSTUM_ALLIN
The frustum check revealed all points inside the frustum

See Also:
Constant Field Values

FRUSTUM_PARTIAL

public static final int FRUSTUM_PARTIAL
The frustum check revealed some points inside the frustum

See Also:
Constant Field Values
Constructor Detail

BoundingVolume

protected BoundingVolume()
The default constructor.

Method Detail

getType

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

Returns:
One of the constant types defined

getExtents

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

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

getCenter

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

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

checkIntersectionPoint

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

Parameters:
pos - The location of the point to test against
Returns:
true if the point lies inside this bounds

checkIntersectionRay

public abstract 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.

Parameters:
pos - The start location of the ray
dir - The direction vector of the ray
Returns:
true if the ray intersects this bounds

checkIntersectionSegment

public abstract 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.

Parameters:
start - The start location of the segment
end - The start location of the segment
Returns:
true if the segment intersects this bounds

checkIntersectionSphere

public abstract 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.

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 abstract 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.

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 abstract 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.

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 abstract 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. The cone is considered to be infinite in length.

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 abstract 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.

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 abstract int checkIntersectionFrustum(javax.vecmath.Vector4f[] planes,
                                             javax.vecmath.Matrix4d mat)
Check whether this volume intersects with the view frustum.

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 abstract int checkIntersectionFrustum(javax.vecmath.Vector4f[] planes,
                                             javax.vecmath.Matrix4f mat)
Check whether this volume intersects with the view frustum.

Parameters:
planes - The 6 planes of the frustum
mat - The vworld to local transformation matrix
Returns:
int FRUSTUM_ALLOUT, FRUSTUM_ALLIN, FRUSTUM_PARTIAL.

transform

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

Parameters:
mat - The matrix to transform this bounds by

transform

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

Parameters:
mat - The matrix to transform this bounds by

Aviatrix3D
2.1.0

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