public class Triangle extends AbstractTriangle implements Savable, java.lang.Cloneable, java.io.Serializable
Triangle
defines an object for containing triangle information.
The triangle is defined by a collection of three Vector3f
objects.Constructor and Description |
---|
Triangle()
Instantiate a zero-size Triangle at the origin.
|
Triangle(Vector3f p1,
Vector3f p2,
Vector3f p3)
Constructor instantiates a new
Triangle object with the
supplied vectors as the points. |
Modifier and Type | Method and Description |
---|---|
void |
calculateCenter()
calculateCenter finds the average point of the triangle.
|
void |
calculateNormal()
calculateNormal generates the normal for this triangle
|
Triangle |
clone() |
static Vector3f |
computeTriangleNormal(Vector3f v1,
Vector3f v2,
Vector3f v3,
Vector3f store) |
Vector3f |
get(int i)
get retrieves a point on the triangle denoted by the index
supplied. |
Vector3f |
get1()
Access the location of the 1st point (A).
|
Vector3f |
get2()
Access the location of the 2nd point (B).
|
Vector3f |
get3()
Access the location of the 3rd point (C).
|
Vector3f |
getCenter()
obtains the center point of this triangle (average of the three triangles)
|
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,
float x,
float y,
float z)
set alters the location of one of the triangle's points. |
void |
set(int i,
Vector3f point)
set sets one of the triangle's points to that specified as a
parameter. |
void |
set(Vector3f v1,
Vector3f v2,
Vector3f v3)
set alters the locations of all 3 points. |
void |
set1(Vector3f v)
set1 alters the location of the triangle's 1st point. |
void |
set2(Vector3f v)
set2 alters the location of the triangle's 2nd point. |
void |
set3(Vector3f v)
set3 alters the location of the triangle's 3rd point. |
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) |
collideWith
public Triangle()
public Triangle(Vector3f p1, Vector3f p2, Vector3f p3)
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.p1
- the first point of the triangle.p2
- the second point of the triangle.p3
- the third point of the triangle.public Vector3f get(int i)
get
retrieves a point on the triangle denoted by the index
supplied.i
- the index of the point (0, 1, or 2)public Vector3f get1()
get1
in class AbstractTriangle
public Vector3f get2()
get2
in class AbstractTriangle
public Vector3f get3()
get3
in class AbstractTriangle
public void set(int i, Vector3f point)
set
sets one of the triangle's points to that specified as a
parameter.i
- the index to place the point (0, 1, or 2)point
- the desired location of the point (not null, unaffected)public void set(int i, float x, float y, float z)
set
alters the location of one of the triangle's points.i
- the index to place the point (0, 1, or 2)x
- the desired X-component of the point's locationy
- the desired Y-component of the point's locationz
- the desired Z-component of the point's locationpublic void set1(Vector3f v)
set1
alters the location of the triangle's 1st point.v
- the desired location (not null, unaffected)public void set2(Vector3f v)
set2
alters the location of the triangle's 2nd point.v
- the desired location (not null, unaffected)public void set3(Vector3f v)
set3
alters the location of the triangle's 3rd point.v
- the desired location (not null, unaffected)public void set(Vector3f v1, Vector3f v2, Vector3f v3)
set
alters the locations of all 3 points.set
in class AbstractTriangle
v1
- the desired location of the 1st point (not null, unaffected)v2
- the desired location of the 2nd point (not null, unaffected)v3
- the desired location of the 3rd point (not null, unaffected)public void calculateCenter()
public void calculateNormal()
public Vector3f getCenter()
public void setCenter(Vector3f center)
center
- the center point.public Vector3f getNormal()
public void setNormal(Vector3f normal)
normal
- the normal vector.public float getProjection()
public void setProjection(float projection)
projection
- the projection of the triangle.public int getIndex()
public void setIndex(int index)
index
- the index in an OBBtreepublic static Vector3f computeTriangleNormal(Vector3f v1, Vector3f v2, Vector3f v3, Vector3f store)
public void write(JmeExporter e) throws java.io.IOException
public void read(JmeImporter e) throws java.io.IOException
public Triangle clone()
clone
in class java.lang.Object