public class Triangle extends AbstractTriangle implements Savable, java.lang.Cloneable, java.io.Serializable
Constructor and Description |
---|
Triangle()
Instantiate a zero-size triangle at the origin.
|
Triangle(Vector3f p1,
Vector3f p2,
Vector3f p3)
Instantiates a triangle with the specified vertex locations.
|
Modifier and Type | Method and Description |
---|---|
void |
calculateCenter()
Recalculates the stored centroid based on the current vertex locations.
|
void |
calculateNormal()
Recalculates the stored normal based on the current vertex locations.
|
Triangle |
clone()
Creates a copy of this triangle.
|
static Vector3f |
computeTriangleNormal(Vector3f v1,
Vector3f v2,
Vector3f v3,
Vector3f store) |
Vector3f |
get(int i)
Accesses the location of the indexed vertex.
|
Vector3f |
get1()
Accesses the location of the first vertex.
|
Vector3f |
get2()
Accesses the location of the 2nd vertex.
|
Vector3f |
get3()
Accesses the location of the 3rd vertex.
|
Vector3f |
getCenter()
Accesses the stored centroid (the average of the 3 vertex locations)
calculating it if it is null.
|
int |
getIndex()
Returns the index of this triangle, used to identify it in an OBBTree.
|
Vector3f |
getNormal()
Accesses the stored normal, updating it if it is null.
|
float |
getProjection()
Returns the projection of the vertices relative to the line origin.
|
void |
read(JmeImporter importer)
De-serializes this triangle from the specified importer, for example when
loading from a J3O file.
|
void |
set(int i,
float x,
float y,
float z)
Alters the location of the indexed vertex and deletes the stored centroid
and normal.
|
void |
set(int i,
Vector3f point)
Alters the location of the indexed vertex and deletes the stored centroid
and normal.
|
void |
set(Vector3f v1,
Vector3f v2,
Vector3f v3)
Alters the locations of all 3 vertices and deletes the stored centroid
and normal.
|
void |
set1(Vector3f v)
Alters the location of the first vertex and deletes the stored centroid
and normal.
|
void |
set2(Vector3f v)
Alters the location of the 2nd vertex and deletes the stored centroid and
normal.
|
void |
set3(Vector3f v)
Alters the location of the 3rd vertex and deletes the stored centroid and
normal.
|
void |
setCenter(Vector3f center)
Alters the stored centroid without affecting the stored normal or any
vertex locations.
|
void |
setIndex(int index)
Alters the index of this triangle, used to identify it in an OBBTree.
|
void |
setNormal(Vector3f normal)
Alters the stored normal without affecting the stored centroid or any
vertex locations.
|
void |
setProjection(float projection)
Alters the projection of the vertices relative to the line origin.
|
void |
write(JmeExporter e)
Serializes 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)
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 importer) throws java.io.IOException
public Triangle clone()
clone
in class java.lang.Object