de.rico.engine.geometry.collision
Class CollisionFinder

java.lang.Object
  extended by de.rico.engine.geometry.collision.CollisionFinder

public class CollisionFinder
extends java.lang.Object

This class can be used to find different kinds of collisions

Author:
Frank Bruns

Constructor Summary
CollisionFinder()
           
 
Method Summary
static boolean collide(BoundingBox box1, BoundingBox box2)
          Returns whethter or not a collision between the two specified bounding boxes has occured.
static boolean collide(BoundingCylinder cyl1, BoundingCylinder cyl2)
           
static boolean collide(BoundingSphere sphere1, BoundingSphere sphere2)
          Returns whethter or not a collision between the two specified bounding spheres has occured.
static Point3D getPointOfIntersection(AbstractMesh mesh, int screenX, int screenY)
          Returns the point of intersection between the specified mesh and a line that is shot from the screen coordinates into to scene.
static Point3D getPointOfIntersection(AbstractMesh mesh, Line3D line)
          Returns the point of intersection between the specified mesh and the specified line, if the mesh is set to pickable.
static Point3D getPointOfIntersection(BoundingBox box, int screenX, int screenY)
          Returns the point of intersection of a line that is shot into the world from the specified screen coordinates and the specified bounding box.
static Point3D getPointOfIntersection(BoundingBox box, Line3D line)
          Returns the point of intersection between the specified line and the specified bounding box.
static Point3D getPointOfIntersection(BoundingSphere sphere, int screenX, int screenY)
          Returns the point of intersection of a line that is shot into the world from the specified screen coordinates and the specified bounding sphere.
static Point3D getPointOfIntersection(BoundingSphere sphere, Line3D line)
          Returns the point of intersection between the specified line and the specified bounding sphere.
static Point3D getPointOfIntersection(BoundingVolumeIface vol, int screenX, int screenY)
          Returns the point of intersection of a line that is shot into the world from the specified screen coordinates and the specified bounding volume.
static Point3D getPointOfIntersection(BoundingVolumeIface vol, Line3D line)
          Returns the point of intersection between the specified line and the specified bounding volume.
static Point3D getPointOfIntersection(Triangle triangle, int screenX, int screenY)
          Returns the point of intersection of a line that is shot into the world from the specified screen coordinates and the specified triangle.
static Point3D getPointOfIntersection(Triangle triangle, Line3D line)
          Returns the point of intersection on the specified triangle with the specified line.
static boolean isPointInTriangle(Point3D p, Triangle trig)
          This method checks, if the specified point lies within the specified triangle: It does not take the triangle winding into consideration, because it doesn't make a difference between front and back faces.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CollisionFinder

public CollisionFinder()
Method Detail

collide

public static boolean collide(BoundingSphere sphere1,
                              BoundingSphere sphere2)
Returns whethter or not a collision between the two specified bounding spheres has occured.

Parameters:
sphere1 - first sphere to check for collision with second sphere
sphere2 - second sphere to check for collision with first sphere
Returns:
has collision occured? --> true=yes, false=no

collide

public static boolean collide(BoundingBox box1,
                              BoundingBox box2)
Returns whethter or not a collision between the two specified bounding boxes has occured.

Parameters:
box1 - first box to check for collision with second box
box2 - second box to check for collision with first box
Returns:
has collision occured? --> true=yes, false=no

collide

public static boolean collide(BoundingCylinder cyl1,
                              BoundingCylinder cyl2)

isPointInTriangle

public static boolean isPointInTriangle(Point3D p,
                                        Triangle trig)
This method checks, if the specified point lies within the specified triangle: It does not take the triangle winding into consideration, because it doesn't make a difference between front and back faces.

Parameters:
p - point to check
trig - triangle to check
Returns:
is point within triangle? --> true=yes, false=no

getPointOfIntersection

public static Point3D getPointOfIntersection(BoundingVolumeIface vol,
                                             int screenX,
                                             int screenY)
Returns the point of intersection of a line that is shot into the world from the specified screen coordinates and the specified bounding volume.

Parameters:
vol - bounding volume to check for intersection
screenX - x-coordinates on screen
screenY - y-coordinates on screen
Returns:
point of intersection between line and bouning volume

getPointOfIntersection

public static Point3D getPointOfIntersection(BoundingVolumeIface vol,
                                             Line3D line)
Returns the point of intersection between the specified line and the specified bounding volume.

Parameters:
vol - bounding volume to check for intersection with the line
line - line to check for intersection with the bounding volume
Returns:
point of intersection between line and bounding volume, if available, else null

getPointOfIntersection

public static Point3D getPointOfIntersection(BoundingBox box,
                                             int screenX,
                                             int screenY)
Returns the point of intersection of a line that is shot into the world from the specified screen coordinates and the specified bounding box.

Parameters:
box - bounding box to check for intersection
screenX - x-coordinates on screen
screenY - y-coordinates on screen
Returns:
point of intersection between line and box

getPointOfIntersection

public static Point3D getPointOfIntersection(BoundingBox box,
                                             Line3D line)
Returns the point of intersection between the specified line and the specified bounding box.

Parameters:
box - bounding box to check for intersection with the line
line - line to check for intersection with the box
Returns:
point of intersection between line and box, if available, else null

getPointOfIntersection

public static Point3D getPointOfIntersection(BoundingSphere sphere,
                                             int screenX,
                                             int screenY)
Returns the point of intersection of a line that is shot into the world from the specified screen coordinates and the specified bounding sphere.

Parameters:
sphere - bounding sphere to check for intersection
screenX - x-coordinates on screen
screenY - y-coordinates on screen
Returns:
point of intersection between line and sphere

getPointOfIntersection

public static Point3D getPointOfIntersection(BoundingSphere sphere,
                                             Line3D line)
Returns the point of intersection between the specified line and the specified bounding sphere.

Parameters:
sphere - sphere to check for intersection with the line
line - line to check for intersection with the sphere
Returns:
point of intersection, if available, else null

getPointOfIntersection

public static Point3D getPointOfIntersection(Triangle triangle,
                                             Line3D line)
Returns the point of intersection on the specified triangle with the specified line.

Parameters:
triangle - triangle to check for ray intersection
line - line to check for intersection with triangle
Returns:
the point of intersection between line and triangle, if there is one, else returns null.

getPointOfIntersection

public static Point3D getPointOfIntersection(Triangle triangle,
                                             int screenX,
                                             int screenY)
Returns the point of intersection of a line that is shot into the world from the specified screen coordinates and the specified triangle.

Parameters:
triangle - triangle to check for intersection
screenX - x-coordinates on screen
screenY - y-coordinates on screen
Returns:
point of intersection

getPointOfIntersection

public static Point3D getPointOfIntersection(AbstractMesh mesh,
                                             Line3D line)
Returns the point of intersection between the specified mesh and the specified line, if the mesh is set to pickable. If no such point exists the method returns null.

Parameters:
mesh - mesh to check for intersection with the line
line - line to check for intersection with the mesh
Returns:
point of intersection between the line and the mesh

getPointOfIntersection

public static Point3D getPointOfIntersection(AbstractMesh mesh,
                                             int screenX,
                                             int screenY)
Returns the point of intersection between the specified mesh and a line that is shot from the screen coordinates into to scene. If no such point exists the method returns null.

Parameters:
mesh - mesh to check for intersection with the line that gets shot from the screen coordinates into the scene
screenX - x-coordinates on screen
screenY - y-coordinates on screen
Returns:
point of intersection with the mesh