Top Description Inners Fields Constructors Methods
javafx.scene.shape

public Class TriangleMesh

extends Mesh
Class Inheritance
Imports
com.sun.javafx.scene.shape.ObservableFaceArrayImpl, .TriangleMeshHelper, com.sun.javafx.collections.FloatArraySyncer, .IntegerArraySyncer, com.sun.javafx.geom.BaseBounds, .BoxBounds, .PickRay, .Vec3d, com.sun.javafx.scene.input.PickResultChooser, com.sun.javafx.sg.prism.NGTriangleMesh, javafx.beans.property.ObjectProperty, .SimpleObjectProperty, javafx.collections.ArrayChangeListener, .FXCollections, .ObservableArray, .ObservableFloatArray, .ObservableIntegerArray, javafx.geometry.Point2D, .Point3D, javafx.scene.Node, javafx.scene.input.PickResult, javafx.scene.transform.Affine, .NonInvertibleTransformException, .Rotate, com.sun.javafx.logging.PlatformLogger

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

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private BaseBounds
private final ObservableFaceArray
private final ObservableIntegerArray
private final TriangleMesh.Listener<T extends ObservableArray<T>>
private final TriangleMesh.Listener<T extends ObservableArray<T>>
private boolean
private boolean
private boolean
private boolean
private final boolean
private boolean
private boolean
private final ObservableFloatArray
private final TriangleMesh.Listener<T extends ObservableArray<T>>
private NGTriangleMesh
private final ObservableFloatArray
private final TriangleMesh.Listener<T extends ObservableArray<T>>
private int
private final ObservableFloatArray
private final TriangleMesh.Listener<T extends ObservableArray<T>>
private ObjectProperty<VertexFormat>
vertexFormat

Specifies the vertex format of this TriangleMesh, one of VertexFormat.POINT_TEXCOORD or VertexFormat.POINT_NORMAL_TEXCOORD.

Constructor Summary

AccessConstructor and Description
public
TriangleMesh()

Creates a new instance of TriangleMesh class with the default VertexFormat.POINT_TEXCOORD format type.

public
TriangleMesh(VertexFormat
specifies the vertex format type.
vertexFormat
)

Creates a new instance of TriangleMesh class with the specified VertexFormat.

pack-priv
TriangleMesh(boolean isPredefinedShape)

Method Summary

Modifier and TypeMethod and Description
pack-priv BaseBounds
private Point3D

Returns:

the triangle centroid
computeCentroid
(double
x coord of first vertex of the triangle
v0x
,
double
y coord of first vertex of the triangle
v0y
,
double
z coord of first vertex of the triangle
v0z
,
double
x coord of second vertex of the triangle
v1x
,
double
y coord of second vertex of the triangle
v1y
,
double
z coord of second vertex of the triangle
v1z
,
double
x coord of third vertex of the triangle
v2x
,
double
y coord of third vertex of the triangle
v2y
,
double
z coord of third vertex of the triangle
v2z
)

Computes the centroid of the given triangle

private Point2D

Returns:

the triangle centroid
computeCentroid
(Point2D
vertex of the triangle
v0
,
Point2D
vertex of the triangle
v1
,
Point2D
vertex of the triangle
v2
)

Computes the centroid of the given triangle

private boolean

Returns:

true if the pick ray intersects with the face (regardless of whether the result has been updated)
computeIntersectsFace
(PickRay
pick ray
pickRay
,
Vec3d
pick ray's origin
origin
,
Vec3d
pick ray's direction
dir
,
int
index of the face to test
faceIndex
,
CullFace
cull face of the Node (and thus the tested face)
cullFace
,
Node
the owner node (for the possible placement to the result)
candidate
,
boolean
whether or not to report he hit face
reportFace
,
PickResultChooser
the pick result to be updated if a closer intersection is found
result
)

Computes intersection of a pick ray and a single triangle face.

pack-priv synchronized void
private boolean
doComputeIntersects(PickRay pickRay, PickResultChooser pickResult, Node candidate, CullFace cullFace, boolean reportFace)

public final int

Returns:

number of elements
getFaceElementSize
()

Returns the number of elements that represents a face.

public final ObservableFaceArray

Returns:

faces array where each face is of 3 * VertexFormat.getVertexIndexSize() integers.
getFaces
()

Gets the faces array, indices into the points, normals (optional, if it is a VertexFormat.POINT_NORMAL_TEXCOORD mesh) and texCoords arrays, of this TriangleMesh.

public final ObservableIntegerArray

Returns:

the faceSmoothingGroups array of this TriangleMesh
getFaceSmoothingGroups
()

Gets the faceSmoothingGroups array of this TriangleMesh.

public final int

Returns:

number of elements
getNormalElementSize
()

Returns the number of elements that represents a normal.

public final ObservableFloatArray

Returns:

normals array where each normal is represented by 3 float values nx, ny and nz, in that order.
getNormals
()

Gets the normals array of this TriangleMesh.

pack-priv NGTriangleMesh
pack-priv NGTriangleMesh
public final int

Returns:

number of elements
getPointElementSize
()

Returns the number of elements that represents a point.

public final ObservableFloatArray

Returns:

points array where each point is represented by 3 float values x, y and z, in that order.
getPoints
()

Gets the points array of this TriangleMesh.

pack-priv int
public final int

Returns:

number of elements
getTexCoordElementSize
()

Returns the number of elements that represents a texture coordinates.

public final ObservableFloatArray

Returns:

texCoord array where each texture coordinate is represented by 2 float values: u and v, in that order.
getTexCoords
()

Gets the texCoords array of this TriangleMesh.

public final VertexFormat
pack-priv synchronized void
pack-priv void
setDirty(boolean value)

Overrides javafx.scene.shape.Mesh.setDirty.

public final void
pack-priv void
private boolean
private boolean
private boolean
private boolean
private boolean
private boolean
public final ObjectProperty<VertexFormat>
Inherited from javafx.scene.shape.Mesh:
dirtyPropertyisDirty

Field Detail

cachedBoundsback to summary
private BaseBounds cachedBounds
facesback to summary
private final ObservableFaceArray faces
faceSmoothingGroupsback to summary
private final ObservableIntegerArray faceSmoothingGroups
faceSmoothingGroupsSyncerback to summary
private final TriangleMesh.Listener<T extends ObservableArray<T>> faceSmoothingGroupsSyncer
facesSyncerback to summary
private final TriangleMesh.Listener<T extends ObservableArray<T>> facesSyncer
isFaceSmoothingGroupValidback to summary
private boolean isFaceSmoothingGroupValid
isFacesValidback to summary
private boolean isFacesValid
isNormalsValidback to summary
private boolean isNormalsValid
isPointsValidback to summary
private boolean isPointsValid
isPredefinedShapeback to summary
private final boolean isPredefinedShape
isTexCoordsValidback to summary
private boolean isTexCoordsValid
isValidDirtyback to summary
private boolean isValidDirty
normalsback to summary
private final ObservableFloatArray normals
normalsSyncerback to summary
private final TriangleMesh.Listener<T extends ObservableArray<T>> normalsSyncer
peerback to summary
private NGTriangleMesh peer
pointsback to summary
private final ObservableFloatArray points
pointsSyncerback to summary
private final TriangleMesh.Listener<T extends ObservableArray<T>> pointsSyncer
refCountback to summary
private int refCount
texCoordsback to summary
private final ObservableFloatArray texCoords
texCoordsSyncerback to summary
private final TriangleMesh.Listener<T extends ObservableArray<T>> texCoordsSyncer
vertexFormatback to summary
private ObjectProperty<VertexFormat> vertexFormat

Specifies the vertex format of this TriangleMesh, one of VertexFormat.POINT_TEXCOORD or VertexFormat.POINT_NORMAL_TEXCOORD.

Default Value
VertexFormat.POINT_TEXCOORD
Since
JavaFX 8u40

Constructor Detail

TriangleMeshback to summary
public TriangleMesh()

Creates a new instance of TriangleMesh class with the default VertexFormat.POINT_TEXCOORD format type.

TriangleMeshback to summary
public TriangleMesh(VertexFormat vertexFormat)

Creates a new instance of TriangleMesh class with the specified VertexFormat.

Parameters
vertexFormat:VertexFormat

specifies the vertex format type.

Since
JavaFX 8u40
TriangleMeshback to summary
pack-priv TriangleMesh(boolean isPredefinedShape)

Method Detail

computeBoundsback to summary
pack-priv BaseBounds computeBounds(BaseBounds bounds)

Implements abstract javafx.scene.shape.Mesh.computeBounds.

Annotations
@Override
computeCentroidback to summary
private Point3D computeCentroid(double v0x, double v0y, double v0z, double v1x, double v1y, double v1z, double v2x, double v2y, double v2z)

Computes the centroid of the given triangle

Parameters
v0x:double

x coord of first vertex of the triangle

v0y:double

y coord of first vertex of the triangle

v0z:double

z coord of first vertex of the triangle

v1x:double

x coord of second vertex of the triangle

v1y:double

y coord of second vertex of the triangle

v1z:double

z coord of second vertex of the triangle

v2x:double

x coord of third vertex of the triangle

v2y:double

y coord of third vertex of the triangle

v2z:double

z coord of third vertex of the triangle

Returns:Point3D

the triangle centroid

computeCentroidback to summary
private Point2D computeCentroid(Point2D v0, Point2D v1, Point2D v2)

Computes the centroid of the given triangle

Parameters
v0:Point2D

vertex of the triangle

v1:Point2D

vertex of the triangle

v2:Point2D

vertex of the triangle

Returns:Point2D

the triangle centroid

computeIntersectsFaceback to summary
private boolean computeIntersectsFace(PickRay pickRay, Vec3d origin, Vec3d dir, int faceIndex, CullFace cullFace, Node candidate, boolean reportFace, PickResultChooser result)

Computes intersection of a pick ray and a single triangle face. It takes pickRay, origin and dir. The latter two can be of course obtained from the pickRay, but we need them to be converted to Point3D and don't want to do that for all faces. Therefore the conversion is done just once and passed to the method for all the faces.

Parameters
pickRay:PickRay

pick ray

origin:Vec3d

pick ray's origin

dir:Vec3d

pick ray's direction

faceIndex:int

index of the face to test

cullFace:CullFace

cull face of the Node (and thus the tested face)

candidate:Node

the owner node (for the possible placement to the result)

reportFace:boolean

whether or not to report he hit face

result:PickResultChooser

the pick result to be updated if a closer intersection is found

Returns:boolean

true if the pick ray intersects with the face (regardless of whether the result has been updated)

decRefback to summary
pack-priv synchronized void decRef()
doComputeIntersectsback to summary
private boolean doComputeIntersects(PickRay pickRay, PickResultChooser pickResult, Node candidate, CullFace cullFace, boolean reportFace)
getFaceElementSizeback to summary
public final int getFaceElementSize()

Returns the number of elements that represents a face.

Returns:int

number of elements

getFacesback to summary
public final ObservableFaceArray getFaces()

Gets the faces array, indices into the points, normals (optional, if it is a VertexFormat.POINT_NORMAL_TEXCOORD mesh) and texCoords arrays, of this TriangleMesh. All indices are in terms of elements in to the points, normals or texCoords arrays not individual floats.

Returns:ObservableFaceArray

faces array where each face is of 3 * VertexFormat.getVertexIndexSize() integers.

getFaceSmoothingGroupsback to summary
public final ObservableIntegerArray getFaceSmoothingGroups()

Gets the faceSmoothingGroups array of this TriangleMesh. Smoothing affects how a mesh is rendered but it does not effect its geometry. The face smoothing group value is used to control the smoothing between adjacent faces.

The face smoothing group value is represented by an array of bits and up to 32 unique groups is possible; (1 << 0) to (1 << 31). The face smoothing group value can range from 0 (no smoothing group) to all 32 groups. A face can belong to zero or more smoothing groups. A face is a member of group N if bit N is set, for example, groups |= (1 << N). A value of 0 implies no smoothing group or hard edges. Smoothing is applied when adjacent pair of faces shared a smoothing group. Otherwise the faces are rendered with a hard edge between them.

An empty faceSmoothingGroups implies all faces in this mesh have a smoothing group value of 1.

If faceSmoothingGroups is not empty, its size must be equal to number of faces.

This faceSmoothingGroups has no effect on its TriangleMesh if it is of VertexFormat.POINT_NORMAL_TEXCOORD format.

Returns:ObservableIntegerArray

the faceSmoothingGroups array of this TriangleMesh

getNormalElementSizeback to summary
public final int getNormalElementSize()

Returns the number of elements that represents a normal.

Returns:int

number of elements

Since
JavaFX 8u40
getNormalsback to summary
public final ObservableFloatArray getNormals()

Gets the normals array of this TriangleMesh.

Returns:ObservableFloatArray

normals array where each normal is represented by 3 float values nx, ny and nz, in that order.

Since
JavaFX 8u40
getPGMeshback to summary
pack-priv NGTriangleMesh getPGMesh()

Implements abstract javafx.scene.shape.Mesh.getPGMesh.

Annotations
@Override
getPGTriangleMeshback to summary
pack-priv NGTriangleMesh getPGTriangleMesh()
getPointElementSizeback to summary
public final int getPointElementSize()

Returns the number of elements that represents a point.

Returns:int

number of elements

getPointsback to summary
public final ObservableFloatArray getPoints()

Gets the points array of this TriangleMesh.

Returns:ObservableFloatArray

points array where each point is represented by 3 float values x, y and z, in that order.

getRefCountback to summary
pack-priv int getRefCount()
getTexCoordElementSizeback to summary
public final int getTexCoordElementSize()

Returns the number of elements that represents a texture coordinates.

Returns:int

number of elements

getTexCoordsback to summary
public final ObservableFloatArray getTexCoords()

Gets the texCoords array of this TriangleMesh. The coordinates are proportional, so texture's top-left corner is at [0, 0] and bottom-right corner is at [1, 1].

Returns:ObservableFloatArray

texCoord array where each texture coordinate is represented by 2 float values: u and v, in that order.

getVertexFormatback to summary
public final VertexFormat getVertexFormat()
incRefback to summary
pack-priv synchronized void incRef()
setDirtyback to summary
pack-priv void setDirty(boolean value)

Overrides javafx.scene.shape.Mesh.setDirty.

Annotations
@Override
setVertexFormatback to summary
public final void setVertexFormat(VertexFormat value)
updatePGback to summary
pack-priv void updatePG()

Implements abstract javafx.scene.shape.Mesh.updatePG.

Annotations
@Override
validateback to summary
private boolean validate()
validateFacesback to summary
private boolean validateFaces()
validateFaceSmoothingGroupsback to summary
private boolean validateFaceSmoothingGroups()
validateNormalsback to summary
private boolean validateNormals()
validatePointsback to summary
private boolean validatePoints()
validateTexCoordsback to summary
private boolean validateTexCoords()
vertexFormatPropertyback to summary
public final ObjectProperty<VertexFormat> vertexFormatProperty()
javafx.scene.shape back to summary

private Class TriangleMesh.Listener<T extends ObservableArray<T>>

extends Object
implements ArrayChangeListener<T extends ObservableArray<T>>, FloatArraySyncer, IntegerArraySyncer
Class Inheritance
All Implemented Interfaces
com.sun.javafx.collections.IntegerArraySyncer, com.sun.javafx.collections.FloatArraySyncer, javafx.collections.ArrayChangeListener

Field Summary

Modifier and TypeField and Description
protected final T
protected boolean
protected boolean
dirtyInFull

Array was replaced

protected int
protected int

Constructor Summary

AccessConstructor and Description
public
Listener(T array)

Method Summary

Modifier and TypeMethod and Description
protected final void
addDirtyRange(int
index of the first modified element
from
,
int
length of the modified range
length
)

Adds a dirty range

protected void
public void
onChanged(T
the array that changed
observableArray
,
boolean
indicates size of array changed
sizeChanged
,
int
A beginning (inclusive) of an interval related to the change
from
,
int
An end (exclusive) of an interval related to the change.
to
)

Implements javafx.collections.ArrayChangeListener.onChanged.

Called after a change has been made to an ObservableArray.

public final void
setDirty(boolean
if true, the whole collection is marked as dirty; if false, the whole collection is marked as not-dirty
dirty
)

public float[]
syncTo(float[]
previously synced array
array
,
int[]
an int array of 2 elements that states the start and length of elements modified.
fromAndLengthIndices
)

Implements com.sun.javafx.collections.FloatArraySyncer.syncTo.

This method is used to sync arrays on pulses.

public int[]
syncTo(int[]
previously synced array
array
,
int[]
an int array of 2 elements that states the start and length of elements modified.
fromAndLengthIndices
)

Implements com.sun.javafx.collections.IntegerArraySyncer.syncTo.

This method is used to sync arrays on pulses.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

arrayback to summary
protected final T array
dirtyback to summary
protected boolean dirty
dirtyInFullback to summary
protected boolean dirtyInFull

Array was replaced

dirtyRangeFromback to summary
protected int dirtyRangeFrom
dirtyRangeLengthback to summary
protected int dirtyRangeLength

Constructor Detail

Listenerback to summary
public Listener(T array)

Method Detail

addDirtyRangeback to summary
protected final void addDirtyRange(int from, int length)

Adds a dirty range

Parameters
from:int

index of the first modified element

length:int

length of the modified range

markDirtyback to summary
protected void markDirty()
onChangedback to summary
public void onChanged(T observableArray, boolean sizeChanged, int from, int to)

Implements javafx.collections.ArrayChangeListener.onChanged.

Doc from javafx.collections.ArrayChangeListener.onChanged.

Called after a change has been made to an ObservableArray.

Parameters
observableArray:T

the array that changed

sizeChanged:boolean

indicates size of array changed

from:int

A beginning (inclusive) of an interval related to the change

to:int

An end (exclusive) of an interval related to the change.

Annotations
@Override
setDirtyback to summary
public final void setDirty(boolean dirty)
Parameters
dirty:boolean

if true, the whole collection is marked as dirty; if false, the whole collection is marked as not-dirty

syncToback to summary
public float[] syncTo(float[] array, int[] fromAndLengthIndices)

Implements com.sun.javafx.collections.FloatArraySyncer.syncTo.

Doc from com.sun.javafx.collections.FloatArraySyncer.syncTo.

This method is used to sync arrays on pulses. This method expects the same array was synced before. The usage is similar to toArray method so always use it as following: dest = source.syncTo(dest);

Parameters
array:float[]

previously synced array

fromAndLengthIndices:int[]

an int array of 2 elements that states the start and length of elements modified.

Returns:float[]

a synced array, which is the same or new array (depending on the change).

Annotations
@Override
syncToback to summary
public int[] syncTo(int[] array, int[] fromAndLengthIndices)

Implements com.sun.javafx.collections.IntegerArraySyncer.syncTo.

Doc from com.sun.javafx.collections.IntegerArraySyncer.syncTo.

This method is used to sync arrays on pulses. This method expects the same array was synced before. The usage is similar to toArray method so always use it as following: dest = source.syncTo(dest);

Parameters
array:int[]

previously synced array

fromAndLengthIndices:int[]

an int array of 2 elements that states the start and length of elements modified.

Returns:int[]

a synced array, which is the same or new array (depending on the change).

Annotations
@Override