public class Triangle extends AbstractTriangle implements Savable, java.lang.Cloneable, java.io.Serializable
Triangle
defines a triangle in terms of its vertex locations,
with auxiliary storage for its centroid, normal vector, projection, and
index.Constructor and Description |
---|
Triangle()
Instantiate a zero-size Triangle at the origin.
|
Triangle(Vector3f p1,
Vector3f p2,
Vector3f p3)
Instantiate a
Triangle with the specified vertex locations. |
Modifier and Type | Method and Description |
---|---|
void |
calculateCenter()
Recalculate the stored centroid based on the current vertex locations.
|
void |
calculateNormal()
Recalculate the stored normal based on the current vertex locations.
|
Triangle |
clone()
Create a copy of this triangle.
|
static Vector3f |
computeTriangleNormal(Vector3f v1,
Vector3f v2,
Vector3f v3,
Vector3f store) |
Vector3f |
get(int i)
Access the location of the indexed vertex.
|
Vector3f |
get1()
Access the location of the first vertex.
|
Vector3f |
get2()
Access the location of the 2nd vertex.
|
Vector3f |
get3()
Access the location of the 3rd vertex.
|
Vector3f |
getCenter()
Access the stored centroid (the average of the 3 vertex locations)
calculating it if it is null.
|
int |
getIndex()
Read the index of this triangle, used to identify it in an OBBTree.
|
Vector3f |
getNormal()
Access the stored normal, updating it if it is null.
|
float |
getProjection()
Read the projection of the vertices relative to the line origin.
|
void |
read(JmeImporter e)
De-serialize this triangle from the specified importer, for example when
loading from a J3O file.
|
void |
set(int i,
float x,
float y,
float z)
Alter the location of the indexed vertex and delete the stored centroid
and normal.
|
void |
set(int i,
Vector3f point)
Alter the location of the indexed vertex and delete the stored centroid
and normal.
|
void |
set(Vector3f v1,
Vector3f v2,
Vector3f v3)
Alter the locations of all 3 vertices and delete the stored centroid and
normal.
|
void |
set1(Vector3f v)
Alter the location of the first vertex and delete the stored centroid and
normal.
|
void |
set2(Vector3f v)
Alter the location of the 2nd vertex and delete the stored centroid and
normal.
|
void |
set3(Vector3f v)
Alter the location of the 3rd vertex and delete the stored centroid and
normal.
|
void |
setCenter(Vector3f center)
Alter the stored centroid without affecting the stored normal or any
vertex locations.
|
void |
setIndex(int index)
Alter the index of this triangle, used to identify it in an OBBTree.
|
void |
setNormal(Vector3f normal)
Alter the stored normal without affecting the stored centroid or any
vertex locations.
|
void |
setProjection(float projection)
Alter the projection of the vertices relative to the line origin.
|
void |
write(JmeExporter e)
Serialize this triangle to the specified exporter, for example when
saving to a J3O file.
|
collideWith
public Triangle()
public Triangle(Vector3f p1, Vector3f p2, Vector3f p3)
Triangle
with the specified vertex locations.
Vertices should be listed in the desired winding order, typically
counter-clockwise.p1
- the location of the first vertex (not null, unaffected)p2
- the location of the 2nd vertex (not null, unaffected)p3
- the location of the 3rd vertex (not null, unaffected)public Vector3f get(int i)
i
- the index of the vertex to access (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)
i
- the index of the vertex to alter (0, 1, or 2)point
- the desired location (not null, unaffected)public void set(int i, float x, float y, float z)
i
- the index of the vertex to alter (0, 1, or 2)x
- the desired X coordinatey
- the desired Y coordinatez
- the desired Z coordinatepublic void set1(Vector3f v)
v
- the desired location (not null, unaffected)public void set2(Vector3f v)
v
- the desired location (not null, unaffected)public void set3(Vector3f v)
v
- the desired location (not null, unaffected)public void set(Vector3f v1, Vector3f v2, Vector3f v3)
set
in class AbstractTriangle
v1
- the desired location of the first vertex (not null, unaffected)v2
- the desired location of the 2nd vertex (not null, unaffected)v3
- the desired location of the 3rd vertex (not null, unaffected)public void calculateCenter()
public void calculateNormal()
public Vector3f getCenter()
public void setCenter(Vector3f center)
center
- the desired value (alias created if not null)public Vector3f getNormal()
public void setNormal(Vector3f normal)
normal
- the desired value (alias created if not null)public float getProjection()
public void setProjection(float projection)
projection
- the desired projection valuepublic int getIndex()
public void setIndex(int index)
index
- the desired indexpublic 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