|
j3d.org Code | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.j3d.geom.triangulation.GeometryInfo
public class GeometryInfo
The GeometryInfo object holds data for processing by the Java3D geometry utility tools.
The NormalGenerator adds normals to geometry without normals.Also, the GeometryCompressor can take a set of GeometryInfo objects in a CompressionSteam and generate a CompressedGeometry object from the geometry.The Stripifier combines adjacent triangles into triangle strips for more efficent rendering.
Geometry is loaded into a GeometryInfo in a manner similar to the GeometryArray methods. The constructor for the GeometryInfo takes a flag that specifies the kind of data being loaded. The vertex data is specified using methods that are similar to the GeometryArray methods, but with fewer variations.
The major difference between GeometryInfo and GeometryArray is that the number of vertices, vertex format, and other data are specified implictly, rather than as part of the constructor. The number of verticies comes from the number of coordinates passed to the setCoordinates() method. The format comes from the set of data components that are specified. For example, calling the setCoordinates(), setColors3() and setTextureCoordinatesParames(1, 2) methods implies a format of COORDINATES | COLOR_3 | TEXTURE_COORDINATE_2. Indexed representation is specified by calling the methods that specify the indices, for example setCoordinateIndices().
Stripped primitives are loaded using the TRIANGLE_FAN_ARRAY or TRIANGLE_STRIP_ARRAY flags to the constructor. The setStripCounts() method specifies the length of each strip.
A set of complex polygons is loaded using the POLYGON_ARRAY flag to the constructor. The setStripCounts() method specifies the length of each contour of the polygons. The setContourCounts() method specifies the number of countours in each polygon. For example, a triangle with a triangular hole would have strip counts [3, 3] (indicating two contours of three points) and contour counts [2] (indicating a single polygon with two contours).
GeometryInfo itelf contains some simple utilities, such as calculating indices for non-indexed data ("indexifying") and getting rid of unused data in your indexed geometry ("compacting").
The geometry utility tools modify the contents of the GeometryInfo. After processing, the resulting geometry can be extracted from the GeometryInfo by calling getGeometryArray(). If multiple tools are used, the order of processing should be: generate normals, then stripify. For example, to convert a general mesh of polygons without normals into an optimized mesh call:
GeometryInfo gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY); // initialize the geometry info here // generate normals NormalGenerator ng = new NormalGenerator(); ng.generateNormals(gi); // stripify Stripifier st = new Stripifier(); st.stripify(gi); GeometryArray result = gi.getGeometryArray();
NormalGenerator
,
Stripifier
,
com.sun.j3d.utils.compression.CompressionStream
,
com.sun.j3d.utils.compression.GeometryCompressor
,
GeometryArray
Field Summary | |
---|---|
static int |
POLYGON_ARRAY
Send to the constructor to inform that the data is arranged as possibly multi-contour, possible non-planar polygons. |
static int |
QUAD_ARRAY
Send to the constructor to inform that the data will be arranged so that each set of four vertices form an independent quad |
static int |
TRIANGLE_ARRAY
Send to the constructor to inform that the data will be arranged so that each set of three vertices form an independent triangle |
static int |
TRIANGLE_FAN_ARRAY
Send to the constructor to inform that the data will be arranged so that the stripCounts array indicates how many vertices to use for each triangle fan. |
static int |
TRIANGLE_STRIP_ARRAY
Send to the constructor to inform that the data will be arranged so that the stripCounts array indicates how many vertices to use for each triangle strip. |
Constructor Summary | |
---|---|
GeometryInfo(int primitive)
Constructor. |
Method Summary | |
---|---|
void |
compact()
Remove unused data from an indexed dataset. |
void |
convertToIndexedTriangles()
Convert the GeometryInfo object to have primitive type TRIANGLE_ARRAY and be indexed. |
int[] |
getColorIndices()
Retrieves a reference to the array of indices into the color array. |
java.lang.Object[] |
getColors()
Retrieves a reference to the colors array. |
int[] |
getContourCounts()
Retrieves a reference to the array of contourCounts. |
int[] |
getCoordinateIndices()
Retrieves a reference to the array of indices into the coordinate array. |
javax.vecmath.Point3f[] |
getCoordinates()
Retrieves a reference to the coordinate array. |
int[] |
getNormalIndices()
Retrieves a reference to the array of indices into the Normal array. |
javax.vecmath.Vector3f[] |
getNormals()
Retrieves a reference to the normal array. |
int |
getNumColorComponents()
Returns the number of color data components stored per vertex in the current GeometryInfo object (3 for RGB or 4 for RGBA). |
int |
getNumTexCoordComponents()
Returns the number of texture coordinate components that are stored per vertex. |
int |
getPrimitive()
Get the current primitive. |
int[] |
getStripCounts()
Retrieves a reference to the array of stripCounts. |
int |
getTexCoordSetCount()
Returns the number of texture coordinate sets in this GeometryInfo. |
int[] |
getTexCoordSetMap()
Returns a reference to the texture coordinate set map. |
int[] |
getTextureCoordinateIndices()
Returns a reference to texture coordinate index set 0. |
int[] |
getTextureCoordinateIndices(int texCoordSet)
Retrieves a reference to the specified array of texture coordinate indices. |
java.lang.Object[] |
getTextureCoordinates()
Retrieves a reference to texture coordinate set 0. |
java.lang.Object[] |
getTextureCoordinates(int texCoordSet)
Returns a reference to the indicated texture coordinate array. |
boolean |
getUseCoordIndexOnly()
Returns true if the data in this GeometryInfo is currently formatted in the USE_COORD_INDEX_ONLY format where a single index list is used to index into all data lists. |
void |
indexify()
|
void |
indexify(boolean useCoordIndexOnly)
Create index lists for all data lists. |
void |
recomputeIndices()
Redo indexes to guarantee connection information. |
void |
reset(int primitive)
Removes all data from the GeometryInfo and resets the primitive. |
void |
reverse()
Reverse the order of all lists. |
void |
setColorIndices(int[] colorIndices)
Sets the array of indices into the Color array. |
void |
setColors(javax.vecmath.Color3b[] colors)
Sets the colors array. |
void |
setColors(javax.vecmath.Color3f[] colors)
Sets the colors array. |
void |
setColors(javax.vecmath.Color4b[] colors)
Sets the colors array. |
void |
setColors(javax.vecmath.Color4f[] colors)
Sets the colors array. |
void |
setColors3(byte[] colors)
Sets the colors array. |
void |
setColors3(float[] colors)
Sets the colors array. |
void |
setColors4(byte[] colors)
Sets the colors array. |
void |
setColors4(float[] colors)
Sets the colors array. |
void |
setContourCounts(int[] contourCounts)
Sets the list of contour counts. |
void |
setCoordinateIndices(int[] coordinateIndices)
Sets the array of indices into the Coordinate array. |
void |
setCoordinates(double[] coordinates)
Sets the coordinates array. |
void |
setCoordinates(float[] coordinates)
Sets the coordinates array. |
void |
setCoordinates(javax.vecmath.Point3d[] coordinates)
Sets the coordinates array. |
void |
setCoordinates(javax.vecmath.Point3f[] coordinates)
Sets the coordinates array. |
void |
setNormalIndices(int[] normalIndices)
Sets the array of indices into the Normal array. |
void |
setNormals(float[] normals)
Sets the normals array. |
void |
setNormals(javax.vecmath.Vector3f[] normals)
Sets the normals array. |
void |
setStripCounts(int[] stripCounts)
Sets the array of strip counts. |
void |
setTexCoordSetMap(int[] map)
Sets the mapping between texture coordinate sets and texture units. |
void |
setTextureCoordinateIndices(int[] texIndices)
Sets the array of indices into texture coordinate set 0. |
void |
setTextureCoordinateIndices(int texCoordSet,
int[] texIndices)
Sets one of the texture coordinate index arrays. |
void |
setTextureCoordinateParams(int numSets,
int dim)
This method is used to specify the number of texture coordinate sets and the dimensionality of the texture coordinates. |
void |
setTextureCoordinates(int texCoordSet,
float[] texCoords)
Sets the texture coordinates array by copying the data into the GeometryInfo object. |
void |
setTextureCoordinates(int texCoordSet,
javax.vecmath.TexCoord2f[] texCoords)
Sets the 2D texture coordinates for the specified set. |
void |
setTextureCoordinates(int texCoordSet,
javax.vecmath.TexCoord3f[] texCoords)
Sets the texture coordinates array for the specified set. |
void |
setTextureCoordinates(int texCoordSet,
javax.vecmath.TexCoord4f[] texCoords)
Sets the texture coordinates array for the specified set. |
void |
setTextureCoordinates(javax.vecmath.Point3f[] texCoords)
Sets the TextureCoordinates array by copying the data into the GeometryInfo object. |
void |
setTextureCoordinates2(float[] texCoords)
Sets the texture coordinates array by copying the data into the GeometryInfo object, assuming two numbers (S and T) per vertex. |
void |
setTextureCoordinates3(float[] texCoords)
Sets the TextureCoordinates array by copying the data into the GeometryInfo object, assuming three numbers (S, T, & R) per vertex. |
void |
setUseCoordIndexOnly(boolean useCoordIndexOnly)
Tells the GeometryInfo that its data is formatted in the USE_COORD_INDEX_ONLY format with a single index list (the coordinate index list) that indexes into all data lists (coordinates, normals, colors, and texture coordinates). |
void |
unindexify()
Get rid of index lists by reorganizing data into an un-indexed format. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int TRIANGLE_ARRAY
public static final int QUAD_ARRAY
public static final int TRIANGLE_FAN_ARRAY
public static final int TRIANGLE_STRIP_ARRAY
public static final int POLYGON_ARRAY
Constructor Detail |
---|
public GeometryInfo(int primitive)
primitive
- Tells the GeometryInfo object the type of
primitive data to be stored
in it, so it will know the format of the data. It can be one of
TRIANGLE_ARRAY,
QUAD_ARRAY, TRIANGLE_FAN_ARRAY, TRIANGLE_STRIP_ARRAY, or POLYGON_ARRAY.Method Detail |
---|
public void reset(int primitive)
primitive
- Either TRIANGLE_ARRAY, QUAD_ARRAY,
TRIANGLE_FAN_ARRAY, TRIANGLE_STRIP_ARRAY, or POLYGON_ARRAY.
Tells the GeometryInfo object the type of primitive data to be stored
in it, so it will know the format of the data.public void convertToIndexedTriangles()
java.lang.IllegalArgumentException
- if coordinate data is missing,
if the index lists aren't all the
same length, if an index list is set and the corresponding data
list isn't set, if a data list is set and the corresponding
index list is unset (unless all index lists are unset or in
USE_COORD_INDEX_ONLY format),
if StripCounts or ContourCounts is inconsistent with the current
primitive, if the sum of the contourCounts array doesn't equal
the length of the StripCounts array, or if the number of vertices
isn't a multiple of three (for triangles) or four (for quads).public int getPrimitive()
public void setCoordinates(javax.vecmath.Point3f[] coordinates)
public void setCoordinates(javax.vecmath.Point3d[] coordinates)
public void setCoordinates(float[] coordinates)
public void setCoordinates(double[] coordinates)
public javax.vecmath.Point3f[] getCoordinates()
public void setColors(javax.vecmath.Color3f[] colors)
public void setColors(javax.vecmath.Color4f[] colors)
public void setColors(javax.vecmath.Color3b[] colors)
public void setColors(javax.vecmath.Color4b[] colors)
public void setColors3(float[] colors)
public void setColors4(float[] colors)
public void setColors3(byte[] colors)
public void setColors4(byte[] colors)
public java.lang.Object[] getColors()
Color3f[]
or Color4f[]
depending on
the type of the input data. Call
getNumColorComponents() to find out which version is returned.
public int getNumColorComponents()
public void setNormals(javax.vecmath.Vector3f[] normals)
public void setNormals(float[] normals)
public javax.vecmath.Vector3f[] getNormals()
public void setTextureCoordinateParams(int numSets, int dim)
The second call togeomInfo.setTextureCoordinateParams(2, 3); geomInfo.setTextureCoordinates(0, tex0); geomInfo.setTextureCoordinates(1, tex1); geomInfo.setTextureCoordinateParams(1, 2); geomInfo.getTexCoordSetCount();
setTextureCoordinateParams
will erase all
the texture coordinate arrays, so the subsequent call to
getTexCoordSetCount
will return 1.
numSets
- The number of texture coordinate sets that will be
specified for this GeometryInfo object.dim
- The dimensionality of the texture coordinates. Has to be 2, 3
or 4.
java.lang.IllegalArgumentException
- if the dimensionality of the texture
coordinates is not one of 2, 3 or 4.public int getTexCoordSetCount()
public int getNumTexCoordComponents()
public void setTexCoordSetMap(int[] map)
Note: If the texCoordSetMap is not set, multi-texturing is turned off. Only the texture coordinate set at index 0 (if set) will be used. Any other sets specified by the GeometryInfo.setTextureCoordinate* methods will be ignored.
public int[] getTexCoordSetMap()
public void setTextureCoordinates(int texCoordSet, javax.vecmath.TexCoord2f[] texCoords)
texCoordSet
- The texture coordinate set for which these
coordinates are being specified.texCoords
- Array of 2D texture coordinates.
java.lang.IllegalArgumentException
- if texCoordSet
< 0 or
texCoordSet >= texCoordSetCount
,
or the texture coordinate parameters were not previously set by
calling setTextureCoordinateParams(texCoordSetCount, 2)
.public void setTextureCoordinates(int texCoordSet, javax.vecmath.TexCoord3f[] texCoords)
texCoordSet
- The texture coordinate set for which these coordinates
are being specified.texCoords
- Array of 3D texture coordinates.
java.lang.IllegalArgumentException
- if texCoordSet
< 0 or
texCoordSet >= texCoordSetCount
,
or the texture coordinate parameters were not previously set by
calling setTextureCoordinateParams(texCoordSetCount, 3)
.public void setTextureCoordinates(javax.vecmath.Point3f[] texCoords)
public void setTextureCoordinates(int texCoordSet, javax.vecmath.TexCoord4f[] texCoords)
texCoordSet
- The texture coordinate set for which these coordinates
are being specified.texCoords
- Array of 4D texture coordinates.
java.lang.IllegalArgumentException
- if texCoordSet
< 0 or
texCoordSet >= texCoordSetCount
,
or the texture coordinate parameters were not previously set by
calling setTextureCoordinateParams(texCoordSetCount, 4)
.public void setTextureCoordinates(int texCoordSet, float[] texCoords)
texCoordSet
- The texture coordinate set for which these coordinates
are being specified.texCoords
- The float array of texture coordinates. For n texture
coordinates with dimensionality d, there must be d*n floats in the array.
java.lang.IllegalArgumentException
- if texCoordSet
< 0 or
texCoordSet >= texCoordSetCount
,
or the texture coordinate parameters were not previously set by
calling setTextureCoordinateParams
.public void setTextureCoordinates2(float[] texCoords)
public void setTextureCoordinates3(float[] texCoords)
public java.lang.Object[] getTextureCoordinates(int texCoordSet)
TexCoord2f[]
, TexCoord3f[]
, or TexCoord4f[]
depending on the
current dimensionality of the texture coordinates in the GeometryInfo
object. Use getNumTexCoordComponents()
to find out which
version is returned.
texCoordSet
- The index of the texture coordinate set to
retrieve.
java.lang.IllegalArgumentException
- If texCoordSet
< 0
or texCoordSet >= texCoordSetCount
public java.lang.Object[] getTextureCoordinates()
TexCoord2f[]
, TexCoord3f[]
, or TexCoord4f[]
depending on the
current dimensionality of the texture coordinates in the GeometryInfo
object. Use getNumTexCoordComponents()
to find out which
version is returned. Equivalent to getTextureCoordinates(0)
.
public void setCoordinateIndices(int[] coordinateIndices)
public int[] getCoordinateIndices()
public void setColorIndices(int[] colorIndices)
public int[] getColorIndices()
public void setNormalIndices(int[] normalIndices)
public int[] getNormalIndices()
public void setTextureCoordinateIndices(int texCoordSet, int[] texIndices)
texCoordSet
- The texture coordinate set for which these coordinate
indices are being specified.texIndices
- The integer array of indices into the specified texture
coordinate set
java.lang.IllegalArgumentException
- If texCoordSet
< 0 or
texCoordSet >= texCoordSetCount
.public void setTextureCoordinateIndices(int[] texIndices)
java.lang.IllegalArgumentException
- If texCoordSetCount > 1
.public int[] getTextureCoordinateIndices(int texCoordSet)
This method should be considered for advanced users only. Novice users should just use getGeometryArray() to retrieve their data so that the internal format of GeometryInfo is of no concern.
Depending on which of the utility routines you've called on your GeometryInfo object, the results may not be what you expect. If you've called the Stripifier, your GeometryInfo object's Primitive has been changed to indexed TRIANGLE_STRIP_ARRAY and your data will be formatted accordingly. Similarly, if you've called the Triangulator, your data is in indexed TRIANGLE_ARRAY format. Generating normals with the NormalGenerator utility will convert your data to indexed TRIANGLE_ARRAY also, but if you call getGeometryArray without calling the Stripifier or Triangulator, your data will be converted back to the original primitive type when creating the GeometryArray object to pass back. However, if your creaseAngle was not Math.PI (no creases - smooth shading), then the introduction of creases into your model may have split primitives, lengthening the StripCounts and index arrays from your original data.
texCoordSet
- The texture coordinate index set to be
retrieved.
public int[] getTextureCoordinateIndices()
getTextureCoordinateIndices(0)
.
public void setStripCounts(int[] stripCounts)
GeometryStripArray#GeometryStripArray(int, int,
int[] stripVertexCounts)
,
IndexedGeometryStripArray#IndexedGeometryStripArray(int, int, int,
int[] stripIndexCounts)
public int[] getStripCounts()
public void setContourCounts(int[] contourCounts)
public int[] getContourCounts()
public void indexify(boolean useCoordIndexOnly)
useCoordIndexOnly
- Reformat the data into the
GeometryArray.USE_COORD_INDEX_ONLY format where there is only
one index list. If the data is already in the USE_COORD_INDEX_ONLY
format, sending false (or calling indexify()) will change
it to the normal indexed format.
java.lang.IllegalArgumentException
- if coordinate data is missing,
if the index lists aren't all the
same length, if an index list is set and the corresponding data
list isn't set, if a data list is set and the corresponding
index list is unset (unless all index lists are unset or in
USE_COORD_INDEX_ONLY format),
if StripCounts or ContourCounts is inconsistent with the current
primitive, if the sum of the contourCounts array doesn't equal
the length of the StripCounts array, or if the number of vertices
isn't a multiple of three (for triangles) or four (for quads).public void indexify()
public void compact()
java.lang.IllegalArgumentException
- if coordinate data is missing,
if the index lists aren't all the
same length, if an index list is set and the corresponding data
list isn't set, if a data list is set and the corresponding
index list is unset (unless all index lists are unset or in
USE_COORD_INDEX_ONLY format),
if StripCounts or ContourCounts is inconsistent with the current
primitive, if the sum of the contourCounts array doesn't equal
the length of the StripCounts array, or if the number of vertices
isn't a multiple of three (for triangles) or four (for quads).public void unindexify()
java.lang.IllegalArgumentException
- if coordinate data is missing,
if the index lists aren't all the
same length, if an index list is set and the corresponding data
list isn't set, if a data list is set and the corresponding
index list is unset (unless all index lists are unset or in
USE_COORD_INDEX_ONLY format),
if StripCounts or ContourCounts is inconsistent with the current
primitive, if the sum of the contourCounts array doesn't equal
the length of the StripCounts array, or if the number of vertices
isn't a multiple of three (for triangles) or four (for quads).public void recomputeIndices()
java.lang.IllegalArgumentException
- if coordinate data is missing,
if the index lists aren't all the
same length, if an index list is set and the corresponding data
list isn't set, if a data list is set and the corresponding
index list is unset (unless all index lists are unset or in
USE_COORD_INDEX_ONLY format),
if StripCounts or ContourCounts is inconsistent with the current
primitive, if the sum of the contourCounts array doesn't equal
the length of the StripCounts array, or if the number of vertices
isn't a multiple of three (for triangles) or four (for quads).public void reverse()
java.lang.IllegalArgumentException
- if coordinate data is missing,
if the index lists aren't all the
same length, if an index list is set and the corresponding data
list isn't set, if a data list is set and the corresponding
index list is unset (unless all index lists are unset or in
USE_COORD_INDEX_ONLY format),
if StripCounts or ContourCounts is inconsistent with the current
primitive, if the sum of the contourCounts array doesn't equal
the length of the StripCounts array, or if the number of vertices
isn't a multiple of three (for triangles) or four (for quads).public boolean getUseCoordIndexOnly()
indexify(boolean)
,
GeometryInfo#getIndexedGeometryArray(boolean, boolean, boolean,
boolean, boolean)
public void setUseCoordIndexOnly(boolean useCoordIndexOnly)
indexify(boolean)
,
GeometryInfo#getIndexedGeometryArray(boolean, boolean, boolean,
boolean, boolean)
|
j3d.org Code | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |