Package com.jme3.math
Class Triangle
java.lang.Object
com.jme3.math.Triangle
Describes a triangle in terms of its vertex locations, with auxiliary storage
for its normal vector.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Recalculates the stored normal based on the current vertex locations.get
(int i) Accesses the location of the indexed vertex.get1()
Accesses the location of the first vertex.get2()
Accesses the location of the 2nd vertex.get3()
Accesses the location of the 3rd vertex.Accesses the stored normal, updating it if it is null.void
Alters the location of the indexed vertex and deletes the stored normal.void
Alters the locations of all 3 vertices and deletes the stored normal.void
Alters the location of the first vertex and deletes the stored normal.void
Alters the location of the 2nd vertex and deletes the stored normal.void
Alters the location of the 3rd vertex and deletes the stored normal.
-
Constructor Details
-
Triangle
public Triangle()Instantiate a zero-size triangle at the origin. -
Triangle
Instantiates a triangle with the specified vertex locations. Vertices should be listed in the desired winding order, typically counter-clockwise.- Parameters:
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)
-
-
Method Details
-
get
Accesses the location of the indexed vertex.- Parameters:
i
- the index of the vertex to access (0, 1, or 2)- Returns:
- a pre-existing location vector, or null if the index is invalid
-
get1
Accesses the location of the first vertex.- Returns:
- the pre-existing location vector (not null)
-
get2
Accesses the location of the 2nd vertex.- Returns:
- the pre-existing location vector (not null)
-
get3
Accesses the location of the 3rd vertex.- Returns:
- the pre-existing location vector (not null)
-
set
Alters the location of the indexed vertex and deletes the stored normal.- Parameters:
i
- the index of the vertex to alter (0, 1, or 2)point
- the desired location (not null, unaffected)
-
set1
Alters the location of the first vertex and deletes the stored normal.- Parameters:
v
- the desired location (not null, unaffected)
-
set2
Alters the location of the 2nd vertex and deletes the stored normal.- Parameters:
v
- the desired location (not null, unaffected)
-
set3
Alters the location of the 3rd vertex and deletes the stored normal.- Parameters:
v
- the desired location (not null, unaffected)
-
set
Alters the locations of all 3 vertices and deletes the stored normal.- Parameters:
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)
-
calculateNormal
public void calculateNormal()Recalculates the stored normal based on the current vertex locations. -
getNormal
Accesses the stored normal, updating it if it is null.- Returns:
- unit normal vector (an internal vector subject to re-use)
-