org.odejava
Class GeomTriMesh

java.lang.Object
  extended by org.odejava.Geom
      extended by org.odejava.PlaceableGeom
          extended by org.odejava.GeomTriMesh
All Implemented Interfaces:
Placeable

public class GeomTriMesh
extends PlaceableGeom

A triangle mesh (TriMesh) represents an arbitrary collection of triangles. The triangle mesh collision system has the following features:

Any triangle soup can be represented i.e. the triangles are not required to have any particular strip, fan or grid structure. Triangle meshes can interact with spheres, boxes and rays. It works well for relatively large triangles. It uses temporal coherence to speed up collision tests. When a geom has its collision checked with a trimesh once, data is stored inside the trimesh. This data can be cleared with the dGeomTriMeshClearTCCache function. In the future it will be possible to disable this functionality.

Note: give index in such way that triangles are build clockwise (z is up). Created 16.12.2003 (dd.mm.yyyy)

Author:
Jani Laakso E-mail: jani.laakso@itmill.com see http://odejava.dev.java.net

Field Summary
 
Fields inherited from class org.odejava.Geom
geomId, isEncapsulated, spaceId
 
Constructor Summary
GeomTriMesh(float[] vertices, float[] normals, int numVertices)
          Convenience constructor to create a new geometry triangle mesh that is made from pure triangles without indices.
GeomTriMesh(float[] vertices, float[] normals, int[] indices)
          Create a tri mesh from a set of vertices and indices, and no name set.
GeomTriMesh(float[] vertices, int numVertices)
          Convenience constructor to create a new geometry triangle mesh that is made from pure triangles without indices.
GeomTriMesh(float[] vertices, int[] indices)
          Create a tri mesh from a set of vertices and indices, and no name set.
GeomTriMesh(String name, float[] vertices, float[] normals, int[] indices)
          Create trimesh geometry to specific space.
GeomTriMesh(String name, float[] vertices, int[] indices)
          Create trimesh geometry to specific space.
GeomTriMesh(org.openmali.vecmath2.Tuple3f[] vertices, int[] indices)
          Create a tri mesh from a set of vertices and indices, and no name set.
 
Method Summary
 int[] getIndices()
          Get the list of indices that define these triangles.
 float[] getNormals()
          Get the list of normals that contribute to the mesh.
 float[] getVertices()
          Get the list of vertices that contribute to the mesh.
 
Methods inherited from class org.odejava.PlaceableGeom
delete, fixed, getAxisAngle, getAxisAngle, getBody, getPosition, getPosition, getPosition, getQuaternion, getQuaternion, getRotation, setAxisAndAngle, setAxisAndAngle, setBody, setPosition, setPosition, setQuaternion, setQuatWXYZ, setRotation
 
Methods inherited from class org.odejava.Geom
addToSpace, finalize, getGeomFromNativeAddr, getId, getID, getName, getNativeAddr, getUserData, isEnabled, removeFromSpace, setCategoryBits, setCollideBits, setEnabled, setName, setUserData, updateNativeAddr
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.odejava.Placeable
getName
 

Constructor Detail

GeomTriMesh

public GeomTriMesh(float[] vertices,
                   int numVertices)
Convenience constructor to create a new geometry triangle mesh that is made from pure triangles without indices. Each set of 3 vertices defines a triangle to be used. Internally this will create an index array for you to make use of.

Parameters:
vertices - The collection of vertices to make the mesh from
numVertices - The number of valid vertices to use (must be a multiple of 3)

GeomTriMesh

public GeomTriMesh(float[] vertices,
                   float[] normals,
                   int numVertices)
Convenience constructor to create a new geometry triangle mesh that is made from pure triangles without indices. Each set of 3 vertices defines a triangle to be used. Internally this will create an index array for you to make use of.

Parameters:
vertices - The collection of vertices to make the mesh from
normals - The collection of face normals for each triangle
numVertices - The number of valid vertices to use (must be a multiple of 3)

GeomTriMesh

public GeomTriMesh(float[] vertices,
                   int[] indices)
Create a tri mesh from a set of vertices and indices, and no name set.

Parameters:
vertices - A list of vertices to create the geom with
indices - A list of indices to define the triangles

GeomTriMesh

public GeomTriMesh(org.openmali.vecmath2.Tuple3f[] vertices,
                   int[] indices)
Create a tri mesh from a set of vertices and indices, and no name set.

Parameters:
vertices - A list of vertices to create the geom with
indices - A list of indices to define the triangles

GeomTriMesh

public GeomTriMesh(float[] vertices,
                   float[] normals,
                   int[] indices)
Create a tri mesh from a set of vertices and indices, and no name set.

Parameters:
vertices - A list of vertices to create the geom with
normals - The collection of face normals for each triangle
indices - A list of indices to define the triangles

GeomTriMesh

public GeomTriMesh(String name,
                   float[] vertices,
                   int[] indices)
Create trimesh geometry to specific space. Vertices are defined by x,y,z groups in a single array.

Parameters:
name - An optional name to associate with this geometry
vertices - A list of vertices to create the geom with
indices - A list of indices to define the triangles

GeomTriMesh

public GeomTriMesh(String name,
                   float[] vertices,
                   float[] normals,
                   int[] indices)
Create trimesh geometry to specific space. Vertices are defined by x,y,z groups in a single array.

Parameters:
name - An optional name to associate with this geometry
vertices - A list of vertices to create the geom with
normals - The collection of face normals for each triangle
indices - A list of indices to define the triangles
Method Detail

getIndices

public int[] getIndices()
Get the list of indices that define these triangles.

Returns:
The index list

getVertices

public float[] getVertices()
Get the list of vertices that contribute to the mesh.

Returns:
The vertex list.

getNormals

public float[] getNormals()
Get the list of normals that contribute to the mesh. If no normals were defined, return null.

Returns:
The vertex list.