Class TriangleMesh

java.lang.Object
javafx.scene.shape.Mesh
javafx.scene.shape.TriangleMesh

public class TriangleMesh extends Mesh
Defines a 3D triangle mesh that consists of its associated VertexFormat and a set of separate arrays of vertex components such as points, normals, texture coordinates, and an array of faces that define the individual triangles of the mesh.

Note that the term point, as used in the method names and method descriptions, actually refers to a 3D point (x, y, z) in space representing the position of a single vertex. The term points (plural) is used to indicate sets of 3D points for multiple vertices. Similarly, the term normal is used to indicate a 3D vector (nx, ny, nz) in space representing the direction of a single vertex. The term normals (plural) is used to indicate sets of 3D vectors for multiple vertices. The term texCoord is used to indicate a single pair of 2D texture coordinates (u, v) for a single vertex, while the term texCoords (plural) is used to indicate sets of texture coordinates for multiple vertices. Lastly, the term face is used to indicate 3 sets of interleaving points, normals (optional, depending on the associated VertexFormat) and texture coordinates that together represent the geometric topology of a single triangle, while the term faces (plural) is used to indicate sets of triangles (each represent by a face).

For example, the faces with VertexFormat.POINT_TEXCOORD that represent a single textured rectangle, using 2 triangles, have the following data order: [

p0, t0, p1, t1, p3, t3, // First triangle of a textured rectangle

p1, t1, p2, t2, p3, t3 // Second triangle of a textured rectangle

]

whereas the faces with VertexFormat.POINT_NORMAL_TEXCOORD that represent a single textured rectangle, using 2 triangles, have the following data order: [

p0, n0, t0, p1, n1, t1, p3, n3, t3, // First triangle of a textured rectangle

p1, n1, t1, p2, n2, t2, p3, n3, t3 // Second triangle of a textured rectangle

]

where p0, p1, p2 and p3 are indices into the points array, n0, n1, n2 and n3 are indices into the normals array, and t0, t1, t2 and t3 are indices into the texCoords array.

A triangle has a front and back face. The winding order of a triangle's vertices determines which side is the front face. JavaFX chooses the counter-clockwise (or right-hand rule) winding order as the front face. By default, only the front face of a triangle is rendered. See CullFace for more information.

The length of points, normals, and texCoords must be divisible by 3, 3, and 2 respectively. The length of faces must be divisible by 6 if it is of VertexFormat.POINT_TEXCOORD else it must be divisible by 9 if it is of VertexFormat.POINT_NORMAL_TEXCOORD. The values in the faces array must be within the range of the number of vertices in the points array (0 to points.length / 3 - 1) for the point indices, within the range of the number of vertices in the normals array (0 to normals.length / 3 - 1) for the normal indices, and within the range of the number of the vertices in the texCoords array (0 to texCoords.length / 2 - 1) for the texture coordinate indices.

A warning will be recorded to the logger and the mesh will not be rendered (and will have an empty bounds) if any of the array lengths are invalid or if any of the values in the faces array are out of range.

Since:
JavaFX 8.0