com.jme.math
Class Triangle

java.lang.Object
  extended by com.jme.math.Triangle
All Implemented Interfaces:
Savable, java.io.Serializable

public class Triangle
extends java.lang.Object
implements java.io.Serializable, Savable

Triangle defines a object for containing triangle information. The triangle is defined by a collection of three Vector3f objects.

Author:
Mark Powell, Joshua Slack
See Also:
Serialized Form

Constructor Summary
Triangle()
           
Triangle(Vector3f p1, Vector3f p2, Vector3f p3)
          Constructor instantiates a new Triangle object with the supplied vectors as the points.
 
Method Summary
 void calculateCenter()
          calculateCenter finds the average point of the triangle.
 void calculateNormal()
          calculateCenter finds the average point of the triangle.
 Triangle clone()
           
 Vector3f get(int i)
          get retrieves a point on the triangle denoted by the index supplied.
 Vector3f getCenter()
          obtains the center point of this triangle (average of the three triangles)
 java.lang.Class<? extends Triangle> getClassTag()
           
 int getIndex()
          obtains an index that this triangle represents if it is contained in a OBBTree.
 Vector3f getNormal()
          obtains the unit length normal vector of this triangle, if set or calculated
 float getProjection()
          obtains the projection of the vertices relative to the line origin.
 void read(JMEImporter e)
           
 void set(int i, Vector3f point)
          set sets one of the triangles points to that specified as a parameter.
 void setCenter(Vector3f center)
          sets the center point of this triangle (average of the three triangles)
 void setIndex(int index)
          sets an index that this triangle represents if it is contained in a OBBTree.
 void setNormal(Vector3f normal)
          sets the normal vector of this triangle (to conform, must be unit length)
 void setProjection(float projection)
          sets the projection of the vertices relative to the line origin.
 void write(JMEExporter e)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Triangle

public Triangle()

Triangle

public Triangle(Vector3f p1,
                Vector3f p2,
                Vector3f p3)
Constructor instantiates a new Triangle object with the supplied vectors as the points. It is recommended that the vertices be supplied in a counter clockwise winding to support normals for a right handed coordinate system.

Parameters:
p1 - the first point of the triangle.
p2 - the second point of the triangle.
p3 - the third point of the triangle.
Method Detail

get

public Vector3f get(int i)
get retrieves a point on the triangle denoted by the index supplied.

Parameters:
i - the index of the point.
Returns:
the point.

set

public void set(int i,
                Vector3f point)
set sets one of the triangles points to that specified as a parameter.

Parameters:
i - the index to place the point.
point - the point to set.

calculateCenter

public void calculateCenter()
calculateCenter finds the average point of the triangle.


calculateNormal

public void calculateNormal()
calculateCenter finds the average point of the triangle.


getCenter

public Vector3f getCenter()
obtains the center point of this triangle (average of the three triangles)

Returns:
the center point.

setCenter

public void setCenter(Vector3f center)
sets the center point of this triangle (average of the three triangles)

Parameters:
center - the center point.

getNormal

public Vector3f getNormal()
obtains the unit length normal vector of this triangle, if set or calculated

Returns:
the normal vector

setNormal

public void setNormal(Vector3f normal)
sets the normal vector of this triangle (to conform, must be unit length)

Parameters:
normal - the normal vector.

getProjection

public float getProjection()
obtains the projection of the vertices relative to the line origin.

Returns:
the projection of the triangle.

setProjection

public void setProjection(float projection)
sets the projection of the vertices relative to the line origin.

Parameters:
projection - the projection of the triangle.

getIndex

public int getIndex()
obtains an index that this triangle represents if it is contained in a OBBTree.

Returns:
the index in an OBBtree

setIndex

public void setIndex(int index)
sets an index that this triangle represents if it is contained in a OBBTree.

Parameters:
index - the index in an OBBtree

write

public void write(JMEExporter e)
           throws java.io.IOException
Specified by:
write in interface Savable
Throws:
java.io.IOException

read

public void read(JMEImporter e)
          throws java.io.IOException
Specified by:
read in interface Savable
Throws:
java.io.IOException

getClassTag

public java.lang.Class<? extends Triangle> getClassTag()
Specified by:
getClassTag in interface Savable

clone

public Triangle clone()
Overrides:
clone in class java.lang.Object