|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.java.dev.joode.geom.Geom
net.java.dev.joode.geom.TriMesh
public class TriMesh
Represents a geom as a collection of triangular facets.
Following the Xith3d and Java3d conventions, vertices are ordered counterclockwise as viewed from the front of the face.
Following the GIMPACT and ODE conventions, an oriented plane is represented
by the coordinates (a,b,c,d) such that a x + b y + c z - d = 0 is
satisfied by a point (x,y,z) on the plane, and (a,b,c) is a normal
vector pointing in the direction the plane is facing. Note that elsewhere,
the convention a x + b y + c z + d = 0 (i.e., opposite sign for d) is
sometimes used; not here. Plane coordinates a, b, c, d are stored in a
Vector4f as members x, y, z, and w, respectively.
This implementation is derived from
Copyright (c) 2006, Francisco Le�n.
All rights reserved.Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the GIMPACT nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
| Nested Class Summary | |
|---|---|
static class |
TriMesh.TriangleData
Encapsulates working information about a triangle. |
static class |
TriMesh.TrianglePlanes
Represents several planes associated with a some triangle. |
| Field Summary |
|---|
| Fields inherited from class net.java.dev.joode.geom.Geom |
|---|
aabb, AABB_MAX_X, AABB_MAX_Y, AABB_MAX_Z, AABB_MIN_X, AABB_MIN_Y, AABB_MIN_Z, body, category_bits, collide_bits, dBoxClass, dCapsuleClass, dCircle, dConvex, dCylinderClass, dFirstSpaceClass, dFirstUserClass, dGeomNumClasses, dGeomTransformClass, dHashSpaceClass, dLastSpaceClass, dLastUserClass, dMaxUserClasses, dOctTreeSpaceClass, dPlaneClass, dQuadTreeSpaceClass, dRayClass, dRectangle, dSimpleSpaceClass, dSphereClass, dTriMeshClass, GEOM_AABB_BAD, GEOM_DIRTY, GEOM_ENABLED, GEOM_PLACEABLE, gflags, lpos, parent_space, pos, R, RAY_BACKFACECULL, RAY_CLOSEST_HIT, RAY_FIRSTCONTACT, tmpq, type |
| Constructor Summary | |
|---|---|
TriMesh(Space space,
boolean placeable,
Point3f[] vertices,
int[] indices)
Constructs a TriMesh with specified sets of vertices and triangles. |
|
| Method Summary | |
|---|---|
TriMesh |
cloneState(ClonedReferences util)
deep clones the state object, any references to other SimState objects should be cloned and assigned to the clone via the ClonedReferences util object. |
void |
computeAABB()
Updates the AABB for the whole mesh. |
static boolean |
crossesPlane(Point3f[] vertices,
Vector4f plane)
Tests whether a triangle crosses a plane. |
static float |
distanceFromPlane(Point3f point,
Vector4f plane)
Computes the signed distance of a point from a plane. |
AABBSet |
getAABBSet()
Gets the set of per-triangle AABBs. |
int[] |
getIndices()
Gets the indices of the triangle vertices. |
void |
getTriangleData(int triangle,
TriMesh.TriangleData data)
Gets information about a particular triangle. |
Point3f[] |
getVertices()
Gets the array of triangle vertex coordinates. |
static boolean |
lineIntersectsPlane(Point3f s1,
Point3f s2,
Vector4f plane,
Point3f intersection)
Tests whether a line intersects a plane. |
java.lang.Iterable<Point3f[]> |
triangles()
Gets an Iterable for iterating over triangles of the mesh. |
| Methods inherited from class net.java.dev.joode.geom.Geom |
|---|
AABBTest, clonePartialGeom, destroy, getAABB, getUserData, isEnabled, recomputeAABB, setBody, setPosition, setQuaternion, setQuaternion, setRotation, setUserData |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public TriMesh(Space space,
boolean placeable,
Point3f[] vertices,
int[] indices)
TriMesh with specified sets of vertices and triangles.
space - a space to which this geom will be added,
or nullplaceable - whether the geom is to be dynamically repositioned
by means of its Geom.pos and Geom.R members.vertices - the coordinates of each triangle vertex. The triangles
themselves are identified by indices using indices into this array.indices - identifies the vertices of each triangle. Each group of
three consecutive integers in this array identifies, by index, the three
vertices in the vertices array that make up one triangle .| Method Detail |
|---|
public Point3f[] getVertices()
getIndices()public int[] getIndices()
getVertices()public java.lang.Iterable<Point3f[]> triangles()
Iterable for iterating over triangles of the mesh.
Note that the iterator returns the triangles with their original vertex
positions, not the ones as transformed by Geom.pos and Geom.R.
for (Point3f [] triangle : mesh.triangles()) {
// vertices are triangle[0], triangle1], triangle[2]
}
public AABBSet getAABBSet()
public void computeAABB()
As a side-effect, it also re-applies the translation and rotation transforms to the triangle vertices in case they have changed, and clears the cache of triangle plane information.
computeAABB in class Geom
public void getTriangleData(int triangle,
TriMesh.TriangleData data)
triangle - the index of the triangle of interest.data - a caller-supplied TriangleData object
that this method will fill with information about the triangle.
public static float distanceFromPlane(Point3f point,
Vector4f plane)
point - the pointplane - the coordinates of the plane
public static boolean crossesPlane(Point3f[] vertices,
Vector4f plane)
vertices - the triangle's three verticesplane - the coordinates of the plane
true iff vertices of the triangle lie on both
sides of the plane, or at least one vertex lies in the plane
public static boolean lineIntersectsPlane(Point3f s1,
Point3f s2,
Vector4f plane,
Point3f intersection)
s1 - one point on the lines2 - another point on the lineplane - the coordinates of the planeintersection - returns the coordinates of the point of intersection
true if the line containing the points s1 and s2
intersects the planepublic TriMesh cloneState(ClonedReferences util)
SimStatedeep clones the state object, any references to other SimState objects should be cloned and assigned to the clone via the ClonedReferences util object. The util object ensures that multiple clones of the same object are not performed during a clone operation.
util - instanciate a new one if top level cloning
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||