de.rico.engine.geometry.collision
Class BoundingBox

java.lang.Object
  extended by de.rico.engine.geometry.collision.BoundingBox
All Implemented Interfaces:
BoundingVolumeIface

public class BoundingBox
extends java.lang.Object
implements BoundingVolumeIface

This class can be used as a bounding box for a mesh. The bounding box is aligned to the original world axis and stays that way, i.e. the box will not be rotated along with the meshes rotation this axis belongs to.

Author:
Frank Bruns

Constructor Summary
BoundingBox(AbstractMesh mesh)
          Creates a bounding box for the meshes current triangle coordinates
 
Method Summary
 void draw(javax.media.opengl.GL gl)
          Draws the bounding volume
 float getBackZ()
          Returns the back z value of the bounding box.
 float getBottomY()
          Returns the bottom y-coordinate of the bounding box.
 Point3D getCenter()
          Returns the center point of the bounding volume
 float getFrontZ()
          Returns the front z-coordinate of the bounding box.
 float getHeight()
          Returns the height of the bounding box.
 float getLeftX()
          Returns the most left x-coordinate of the bounding box.
 float getLength()
          Returns the length of the bounding box.
 float getMeshBottom()
           
 float getMeshHeight()
          Returns the height of the mesh that is bounded by the bounding volume.
 float getRightX()
          Returns the most right x value of the bounding box.
 float getTopY()
          Returns the top y value of the bounding box.
 float getWidth()
          Returns the width of the bounding box.
 boolean isWithinFrustum(ViewingFrustum frustum)
          Determines whether the bounding volume is inside the viewing frustum.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BoundingBox

public BoundingBox(AbstractMesh mesh)
Creates a bounding box for the meshes current triangle coordinates

Parameters:
mesh - mesh to create a bounding box for
Method Detail

getMeshBottom

public float getMeshBottom()

getLeftX

public float getLeftX()
Returns the most left x-coordinate of the bounding box.

Returns:
most left x-coordinate of the bounding box

getRightX

public float getRightX()
Returns the most right x value of the bounding box. This is the x-coordinate at the most right side of the box.

Returns:
most right x-coordinate

getBottomY

public float getBottomY()
Returns the bottom y-coordinate of the bounding box.

Returns:
bottom y-coordinate of the bounding box

getTopY

public float getTopY()
Returns the top y value of the bounding box.

Returns:
top y-coordinate

getFrontZ

public float getFrontZ()
Returns the front z-coordinate of the bounding box.

Returns:
front z-coordinate of the bounding box

getBackZ

public float getBackZ()
Returns the back z value of the bounding box.

Returns:
maximum z-coordinate

getMeshHeight

public float getMeshHeight()
Description copied from interface: BoundingVolumeIface
Returns the height of the mesh that is bounded by the bounding volume.

Specified by:
getMeshHeight in interface BoundingVolumeIface
Returns:
height of the mesh

getWidth

public float getWidth()
Returns the width of the bounding box.

Returns:
width of the bounding box

getHeight

public float getHeight()
Returns the height of the bounding box.


getLength

public float getLength()
Returns the length of the bounding box.

Returns:
length of the bounding box

getCenter

public Point3D getCenter()
Description copied from interface: BoundingVolumeIface
Returns the center point of the bounding volume

Specified by:
getCenter in interface BoundingVolumeIface
Returns:
center point of the bounding volume

isWithinFrustum

public boolean isWithinFrustum(ViewingFrustum frustum)
Description copied from interface: BoundingVolumeIface
Determines whether the bounding volume is inside the viewing frustum. If it's not inside the viewing frustum the mesh that is bounded by this bounding volume doesn't need to be drawn anymore.

Specified by:
isWithinFrustum in interface BoundingVolumeIface
Parameters:
frustum - viewing frustum object which is coupled to the camera object

draw

public void draw(javax.media.opengl.GL gl)
Description copied from interface: BoundingVolumeIface
Draws the bounding volume

Specified by:
draw in interface BoundingVolumeIface