com.threerings.opengl.model
Class CollisionMesh

java.lang.Object
  extended by com.threerings.opengl.model.CollisionMesh
All Implemented Interfaces:
Exportable

public class CollisionMesh
extends Object
implements Exportable

A mesh used for collision detection.


Nested Class Summary
protected static class CollisionMesh.CenterComparator
          Compares triangles based on one of the coordinates of their centers.
protected static class CollisionMesh.InternalNode
          An internal node containing two children.
protected static class CollisionMesh.LeafNode
          A leaf node containing a single triangle.
protected static class CollisionMesh.Node
          A node in the axis-aligned bounding box tree.
 
Field Summary
protected  CollisionMesh.Node _root
          The root node of the AABB tree.
 
Constructor Summary
CollisionMesh()
          No-arg constructor for deserialization.
CollisionMesh(Vector3f... vertices)
          Creates the mesh from an array of vertices, where each set of three vertices represents a triangle.
 
Method Summary
protected static CollisionMesh.Node createNode(Triangle[] triangles)
          Creates a node to hold the given array of triangles.
 Box getBounds()
          Returns a reference to the bounds of the mesh.
 boolean getIntersection(Ray3D ray, Vector3f result)
          Finds the intersection of the given ray with this mesh and places it in the supplied result object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_root

protected CollisionMesh.Node _root
The root node of the AABB tree.

Constructor Detail

CollisionMesh

public CollisionMesh(Vector3f... vertices)
Creates the mesh from an array of vertices, where each set of three vertices represents a triangle.


CollisionMesh

public CollisionMesh()
No-arg constructor for deserialization.

Method Detail

getBounds

public Box getBounds()
Returns a reference to the bounds of the mesh.


getIntersection

public boolean getIntersection(Ray3D ray,
                               Vector3f result)
Finds the intersection of the given ray with this mesh and places it in the supplied result object.

Returns:
true if the ray hit the mesh, in which case the result will be placed in the object supplied.

createNode

protected static CollisionMesh.Node createNode(Triangle[] triangles)
Creates a node to hold the given array of triangles.