|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sun.j3d.utils.geometry.GeometryInfo
The GeometryInfo object holds data for processing by the Java3D geometry utility tools:
The Triangulator converts complex polygons (possibly with holes) into trianglesAlso, the GeometryCompressor can take a set of GeometryInfo objects in a CompressionSteam and generate a CompressedGeometry object from the geometry.The NormalGenerator adds normals to geometry without normals.
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 setTextureCoordinates2() 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: triangluate, generate normals, stripify. For example, to convert a general mesh of polygons without normals into an optimized mesh initialize the GeometryInfo and then call:
Note: Only one set of texture coordinates can be managed by a GeometryInfo.GeometryInfo gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY); // initialize the geometry info here // triangluate Trianglulator tri = new Trianglulator(); tri.triangluate(gi); // generate normals NormalGenerator ng = new NormalGenerator(); ng.generateNormals(gi); // stripify Stripifier st = new Stripifier(); st.stripify(gi); GeometryArray result = gi.getGeometryArray();
Triangulator
,
NormalGenerator
,
Stripifier
,
CompressionStream
,
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. |
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. |
Point3f[] |
getCoordinates()
Retrieves a reference to the coordinate array. |
GeometryArray |
getGeometryArray()
Creates and returns a non-indexed Java 3D GeometryArray object based on the data in the GeometryInfo object. |
IndexedGeometryArray |
getIndexedGeometryArray()
Creates and returns an indexed Java 3D GeometryArray object based on the data in the GeometryInfo object. |
IndexedGeometryArray |
getIndexedGeometryArray(boolean compact)
Creates and returns an indexed Java 3D GeometryArray object based on the data in the GeometryInfo object. |
int[] |
getNormalIndices()
Retrieves a reference to the array of indices into the Normal array. |
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 texCoord data components stored per vertex in the current GeometryInfo object (2 for ST or 3 for STR). |
int |
getPrimitive()
Get the current primitive. |
int[] |
getStripCounts()
Retrieves a reference to the array of stripCounts. |
int[] |
getTextureCoordinateIndices()
Retrieves a reference to the array of indices into the TextureCoordinate array. |
java.lang.Object[] |
getTextureCoordinates()
Retrieves a reference to the TextureCoordinate array. |
void |
indexify()
Create indices for non-indexed data. |
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(Color3b[] colors)
Sets the colors array. |
void |
setColors(Color3f[] colors)
Sets the colors array. |
void |
setColors(Color4b[] colors)
Sets the colors array. |
void |
setColors(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(Point3d[] coordinates)
Sets the coordinates array. |
void |
setCoordinates(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(Vector3f[] normals)
Sets the normals array. |
void |
setStripCounts(int[] stripCounts)
Sets the array of strip counts. |
void |
setTextureCoordinateIndices(int[] texCoordIndices)
Sets the array of indices into the TextureCoordinate array. |
void |
setTextureCoordinates(Point2f[] texCoords)
Sets the TextureCoordinates array. |
void |
setTextureCoordinates(Point3f[] texCoords)
Sets the TextureCoordinates array. |
void |
setTextureCoordinates2(float[] texCoords)
Sets the TextureCoordinates array. |
void |
setTextureCoordinates3(float[] texCoords)
Sets the TextureCoordinates array. |
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
- 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.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()
public int getPrimitive()
public void setCoordinates(Point3f[] coordinates)
public void setCoordinates(Point3d[] coordinates)
public void setCoordinates(float[] coordinates)
public void setCoordinates(double[] coordinates)
public Point3f[] getCoordinates()
public void setColors(Color3f[] colors)
public void setColors(Color4f[] colors)
public void setColors(Color3b[] colors)
public void setColors(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()
public int getNumColorComponents()
public void setNormals(Vector3f[] normals)
public void setNormals(float[] normals)
public Vector3f[] getNormals()
public void setTextureCoordinates2(float[] texCoords)
public void setTextureCoordinates3(float[] texCoords)
public void setTextureCoordinates(Point2f[] texCoords)
public void setTextureCoordinates(Point3f[] texCoords)
public java.lang.Object[] getTextureCoordinates()
public int getNumTexCoordComponents()
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[] texCoordIndices)
public int[] getTextureCoordinateIndices()
public void setStripCounts(int[] stripCounts)
public int[] getStripCounts()
public void setContourCounts(int[] contourCounts)
public int[] getContourCounts()
public void indexify()
public void compact()
public void unindexify()
public void recomputeIndices()
public void reverse()
public GeometryArray getGeometryArray()
public IndexedGeometryArray getIndexedGeometryArray(boolean compact)
compact
- Remove Coordinates, Colors, Normals, and
TextureCoordinates that aren't referenced by any indices.public IndexedGeometryArray getIndexedGeometryArray()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |