public class IndexedFaceSetFactory extends AbstractIndexedFaceSetFactory
IndexedFaceSet
. See IndexedLineSetFactory
and
PointSetFactory
for functionality inherited from the superclasses.
To specify faces, first set the number of faces using setFaceCount(int)
. The faces themselves
are specified using the method setFaceIndices(int[][])
and its variants. Each element of this array is a list of
indices into the coordinate array of the underlying point set (See PointSetFactory
).
There are methods for setting the built-in face attributes normals, colors, and labels.
Texture coordinates can have fiber length 2, 3, or 4. Normals in euclidean case must have fiber length 3; otherwise they should have
length 4. Labels are represented by an array of type String[]
, and are displayed at the center of the face.
AbstractIndexedFaceSetFactory.setGenerateAABBTree(boolean)
:
The AABBTree is stored as an Attribute
within the geometry and is used to optimize picking.AbstractIndexedFaceSetFactory.setGenerateFaceLabels(boolean)
:
The face labels show the index of the face within the face array and are displayed at the midpoint of the face.AbstractIndexedFaceSetFactory.setGenerateFaceNormals(boolean)
:
The face normals are generated using the cross product of the first two edges of the face, with respect to the specified metric (see AbstractGeometryFactory.setMetric(int)
.AbstractIndexedFaceSetFactory.setGenerateVertexNormals(boolean)
:
The vertex normals are generated based on the face normals, by averaging using the combinatorial information in the face index array.AbstractIndexedFaceSetFactory.setGenerateEdgesFromFaces(boolean)
:
By default there are no edges attached to the indexed face set. Either set them explicitly using setEdgeIndices(int[])
and
its variants, or call this method with true
as argument; then the edge indices will be generated as the edges of the faces.
By default, all these values are false
.
For attributes not included in the built-in set, use the methods
setFaceAttribute(Attribute, DataList)
setFaceAttribute(Attribute, double[])
setFaceAttribute(Attribute, double[][])
A geometry in the jReality scene graph does not allow per face vertex attributes. So to unwrap a geometry e.g. to put a texture on it, one has
to introduce multiple vertices. This factory supports this as follows: set vertex coordinates for all vertices (setVertexCount()
,
setVertexCoordinates()
),
set the face indices to the wrapped faces (leave out the extra vertices) (setFaceCount()
, setFaceIndices
), and use
setUnwrapFaceIndices(int[][])
or its variants to introduce the unwrapped faces (same number of faces).
The unwrapFaceIndices
are written into the created IndexedFaceSet
. The faceIndices
are used to generate attributes, in particular to
generate correct vertex normals. The vertices that represent the same vertex are detected from correspondence in faceIndices
and unwrapFaceIndices
, and not from the vertex coordinates. There is also a
tutorial that explains the use of unwrapping.
Since the vertex count includes the extra vertices for unwrapping, one needs to multiply vertex attributes for the extra vertices.
More often than not, one needs to copy the attributes to the corresponding vertices. The correspondence may be determined from the
two sets of face indices. The method unwrapVertexAttributes()
does this for you. It has a static version (which needs
more parameters) and an instance version (which reads the corresponding parameters from the instance). It comes in many versions in
order to be directly applicable to those vertex attributes that are flat arrays of primitives.
QuadMeshFactory
,
For an example, see
this tutorial
Constructor and Description |
---|
IndexedFaceSetFactory() |
Modifier and Type | Method and Description |
---|---|
void |
setEdgeAttribute(Attribute attr,
DataList data) |
void |
setEdgeAttribute(Attribute attr,
double[] data) |
void |
setEdgeAttribute(Attribute attr,
double[][] data) |
void |
setEdgeColors(Color[] data) |
void |
setEdgeColors(DataList data) |
void |
setEdgeColors(double[] data) |
void |
setEdgeColors(double[][] data) |
void |
setEdgeCount(int count) |
void |
setEdgeIndices(int[] data) |
void |
setEdgeIndices(int[][] data) |
void |
setEdgeIndices(int[] data,
int pointCountPerLine) |
void |
setEdgeLabels(String[] data) |
void |
setEdgeRelativeRadii(double[] data) |
void |
setFaceAttribute(Attribute attr,
DataList data)
Superclass methods are protected so we override to make public
Documentation is lacking ...
|
void |
setFaceAttribute(Attribute attr,
double[] data) |
void |
setFaceAttribute(Attribute attr,
double[][] data) |
void |
setFaceAttributes(DataListSet dls) |
void |
setFaceColors(Color[] data) |
void |
setFaceColors(DataList data) |
void |
setFaceColors(double[] data) |
void |
setFaceColors(double[][] data) |
void |
setFaceCount(int count) |
void |
setFaceIndices(DataList data) |
void |
setFaceIndices(int[] data) |
void |
setFaceIndices(int[][] data) |
void |
setFaceIndices(int[] data,
int pointCountPerFace) |
void |
setFaceLabels(String[] data) |
void |
setFaceNormals(DataList data) |
void |
setFaceNormals(double[] data) |
void |
setFaceNormals(double[][] data) |
void |
setUnwrapFaceIndices(DataList data) |
void |
setUnwrapFaceIndices(int[] data) |
void |
setUnwrapFaceIndices(int[][] data) |
void |
setUnwrapFaceIndices(int[] data,
int pointCountPerFace) |
void |
setVertexAttribute(Attribute attr,
DataList data) |
void |
setVertexAttribute(Attribute attr,
double[] data) |
void |
setVertexAttribute(Attribute attr,
double[][] data) |
void |
setVertexAttributes(DataListSet dls) |
void |
setVertexColors(Color[] data) |
void |
setVertexColors(DataList data) |
void |
setVertexColors(double[] data) |
void |
setVertexColors(double[][] data) |
void |
setVertexCoordinates(DataList data) |
void |
setVertexCoordinates(double[] data) |
void |
setVertexCoordinates(double[][] data) |
void |
setVertexCount(int count) |
void |
setVertexLabels(String[] data) |
void |
setVertexNormals(DataList data) |
void |
setVertexNormals(double[] data) |
void |
setVertexNormals(double[][] data) |
void |
setVertexRelativeRadii(double[] data) |
void |
setVertexTextureCoordinates(DataList data) |
void |
setVertexTextureCoordinates(double[] data) |
void |
setVertexTextureCoordinates(double[][] data) |
boolean[] |
unwrapVertexAttributes(boolean[] data,
int entriesPerVertex) |
static boolean[] |
unwrapVertexAttributes(boolean[] data,
int entriesPerVertex,
int[][] faceIndices,
int[][] unwrapFaceIndices,
int numberOfUnwrapVertices) |
char[] |
unwrapVertexAttributes(char[] data,
int entriesPerVertex) |
static char[] |
unwrapVertexAttributes(char[] data,
int entriesPerVertex,
int[][] faceIndices,
int[][] unwrapFaceIndices,
int numberOfUnwrapVertices) |
double[] |
unwrapVertexAttributes(double[] data,
int entriesPerVertex) |
static double[] |
unwrapVertexAttributes(double[] data,
int entriesPerVertex,
int[][] faceIndices,
int[][] unwrapFaceIndices,
int numberOfUnwrapVertices) |
<E> E[] |
unwrapVertexAttributes(E[] data) |
static <E> E[] |
unwrapVertexAttributes(E[] data,
int[][] faceIndices,
int[][] unwrapFaceIndices,
int numberOfUnwrapVertices) |
float[] |
unwrapVertexAttributes(float[] data,
int entriesPerVertex) |
static float[] |
unwrapVertexAttributes(float[] data,
int entriesPerVertex,
int[][] faceIndices,
int[][] unwrapFaceIndices,
int numberOfUnwrapVertices) |
int[] |
unwrapVertexAttributes(int[] data,
int entriesPerVertex) |
static int[] |
unwrapVertexAttributes(int[] data,
int entriesPerVertex,
int[][] faceIndices,
int[][] unwrapFaceIndices,
int numberOfUnwrapVertices) |
long[] |
unwrapVertexAttributes(long[] data,
int entriesPerVertex) |
static long[] |
unwrapVertexAttributes(long[] data,
int entriesPerVertex,
int[][] faceIndices,
int[][] unwrapFaceIndices,
int numberOfUnwrapVertices) |
getIndexedFaceSet, isGenerateAABBTree, isGenerateEdgesFromFaces, isGenerateFaceLabels, isGenerateFaceNormals, isGenerateVertexNormals, setGenerateAABBTree, setGenerateEdgesFromFaces, setGenerateFaceLabels, setGenerateFaceNormals, setGenerateVertexNormals
getEdgeCount, getIndexedLineSet, getLineCount, isGenerateEdgeLabels, setGenerateEdgeLabels, setLineCount
getPointSet, getVertexCount, isGenerateVertexLabels, setGenerateVertexLabels
getGeometry, getMetric, setMetric, update
public void setVertexCount(int count)
setVertexCount
in class AbstractPointSetFactory
public void setVertexAttribute(Attribute attr, double[] data)
public void setVertexAttribute(Attribute attr, double[][] data)
setVertexAttribute
in class AbstractPointSetFactory
public void setVertexAttributes(DataListSet dls)
public void setVertexCoordinates(DataList data)
public void setVertexCoordinates(double[] data)
public void setVertexCoordinates(double[][] data)
public void setVertexNormals(DataList data)
public void setVertexNormals(double[] data)
public void setVertexNormals(double[][] data)
public void setVertexColors(DataList data)
public void setVertexColors(double[] data)
public void setVertexColors(Color[] data)
public void setVertexColors(double[][] data)
public void setVertexTextureCoordinates(DataList data)
public void setVertexTextureCoordinates(double[] data)
public void setVertexTextureCoordinates(double[][] data)
public void setVertexLabels(String[] data)
public void setVertexRelativeRadii(double[] data)
public void setEdgeCount(int count)
public void setEdgeAttribute(Attribute attr, double[] data)
public void setEdgeAttribute(Attribute attr, double[][] data)
public void setEdgeIndices(int[][] data)
public void setEdgeIndices(int[] data, int pointCountPerLine)
public void setEdgeIndices(int[] data)
public void setEdgeColors(DataList data)
public void setEdgeColors(double[] data)
public void setEdgeColors(Color[] data)
public void setEdgeColors(double[][] data)
public void setEdgeLabels(String[] data)
public void setEdgeRelativeRadii(double[] data)
public void setFaceCount(int count)
public void setFaceAttribute(Attribute attr, DataList data)
public void setFaceAttribute(Attribute attr, double[] data)
public void setFaceAttribute(Attribute attr, double[][] data)
public void setFaceAttributes(DataListSet dls)
public void setFaceIndices(DataList data)
public void setFaceIndices(int[][] data)
public void setFaceIndices(int[] data, int pointCountPerFace)
public void setFaceIndices(int[] data)
public void setUnwrapFaceIndices(DataList data)
public void setUnwrapFaceIndices(int[][] data)
public void setUnwrapFaceIndices(int[] data, int pointCountPerFace)
public void setUnwrapFaceIndices(int[] data)
public void setFaceNormals(DataList data)
public void setFaceNormals(double[] data)
public void setFaceNormals(double[][] data)
public void setFaceColors(DataList data)
public void setFaceColors(double[] data)
public void setFaceColors(Color[] data)
public void setFaceColors(double[][] data)
public void setFaceLabels(String[] data)
public boolean[] unwrapVertexAttributes(boolean[] data, int entriesPerVertex)
public static boolean[] unwrapVertexAttributes(boolean[] data, int entriesPerVertex, int[][] faceIndices, int[][] unwrapFaceIndices, int numberOfUnwrapVertices)
public char[] unwrapVertexAttributes(char[] data, int entriesPerVertex)
public static char[] unwrapVertexAttributes(char[] data, int entriesPerVertex, int[][] faceIndices, int[][] unwrapFaceIndices, int numberOfUnwrapVertices)
public double[] unwrapVertexAttributes(double[] data, int entriesPerVertex)
public static double[] unwrapVertexAttributes(double[] data, int entriesPerVertex, int[][] faceIndices, int[][] unwrapFaceIndices, int numberOfUnwrapVertices)
public <E> E[] unwrapVertexAttributes(E[] data)
public static <E> E[] unwrapVertexAttributes(E[] data, int[][] faceIndices, int[][] unwrapFaceIndices, int numberOfUnwrapVertices)
public float[] unwrapVertexAttributes(float[] data, int entriesPerVertex)
public static float[] unwrapVertexAttributes(float[] data, int entriesPerVertex, int[][] faceIndices, int[][] unwrapFaceIndices, int numberOfUnwrapVertices)
public int[] unwrapVertexAttributes(int[] data, int entriesPerVertex)
public static int[] unwrapVertexAttributes(int[] data, int entriesPerVertex, int[][] faceIndices, int[][] unwrapFaceIndices, int numberOfUnwrapVertices)
public long[] unwrapVertexAttributes(long[] data, int entriesPerVertex)
public static long[] unwrapVertexAttributes(long[] data, int entriesPerVertex, int[][] faceIndices, int[][] unwrapFaceIndices, int numberOfUnwrapVertices)