com.sun.j3d.utils.geometry
Class GeometryInfo

java.lang.Object
  |
  +--com.sun.j3d.utils.geometry.GeometryInfo

public class GeometryInfo
extends java.lang.Object

The GeometryInfo object is where you put your geometry if you want to use the Java 3D utility libraries. Once you have your data in the GeometryInfo object, you can send it to any (or all) of several utilities to have operations performed on it, such as generating normals or turning it into long strips for more efficient rendering. Geometry is loaded just as it is in the Java 3D GeometryArray object, but there are fewer options for getting data into the object. GeometryInfo itself contains some simple utilities, such as calculating indices for non-indexed data ("indexifying") and getting rid of unused data in your indexed geometry information ("compacting").


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
 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 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRIANGLE_ARRAY

public static final 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

QUAD_ARRAY

public static final 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

TRIANGLE_FAN_ARRAY

public static final 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.

TRIANGLE_STRIP_ARRAY

public static final 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.

POLYGON_ARRAY

public static final int POLYGON_ARRAY
Send to the constructor to inform that the data is arranged as possibly multi-contour, possible non-planar polygons. The stripCounts array indicates how many vertices to use for each contour, and the contourCounts array indicates how many stripCounts entries to use for each polygon. The first contour is the bounding polygon, and subsequent contours are "holes." If contourCounts is left null, the default is one contour per polygon.
Constructor Detail

GeometryInfo

public GeometryInfo(int primitive)
Constructor. Creates an empty GeometryInfo object.
Parameters:
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

reset

public void reset(int primitive)
Removes all data from the GeometryInfo and resets the primitive. After a call to reset(), the GeometryInfo object will be just like it was when it was newly constructed.
Parameters:
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.

getPrimitive

public int getPrimitive()
Get the current primitive. Some of the utilities may change the primitive type of the data stored in the GeometryInfo object (for example, the stripifyer will change it to TRIANGLE_STRIP_ARRAY).

setCoordinates

public void setCoordinates(Point3f[] coordinates)
Sets the coordinates array. No data copying is done because a reference to user data is used.

setCoordinates

public void setCoordinates(Point3d[] coordinates)
Sets the coordinates array. The points are copied into the GeometryInfo object.

setCoordinates

public void setCoordinates(float[] coordinates)
Sets the coordinates array. The points are copied into the GeometryInfo object.

setCoordinates

public void setCoordinates(double[] coordinates)
Sets the coordinates array. The points are copied into the GeometryInfo object.

getCoordinates

public Point3f[] getCoordinates()
Retrieves a reference to the coordinate array.

setColors

public void setColors(Color3f[] colors)
Sets the colors array. No data copying is done because a reference to user data is used.

setColors

public void setColors(Color4f[] colors)
Sets the colors array. No data copying is done because a reference to user data is used.

setColors

public void setColors(Color3b[] colors)
Sets the colors array. The points are copied into the GeometryInfo object.

setColors

public void setColors(Color4b[] colors)
Sets the colors array. The points are copied into the GeometryInfo object.

setColors3

public void setColors3(float[] colors)
Sets the colors array. The points are copied into the GeometryInfo object, assuming 3 components (R, G, and B) per vertex.

setColors4

public void setColors4(float[] colors)
Sets the colors array. The points are copied into the GeometryInfo object, assuming 4 components (R, G, B, and A) per vertex.

setColors3

public void setColors3(byte[] colors)
Sets the colors array. The points are copied into the GeometryInfo object, assuming 3 components (R, G, and B) per vertex.

setColors4

public void setColors4(byte[] colors)
Sets the colors array. The points are copied into the GeometryInfo object, assuming 4 components (R, G, B, and A) per vertex.

getColors

public java.lang.Object[] getColors()
Retrieves a reference to the colors array. Will be either Color3f[] or Color4f[] depending on the type of the input data. Call getNumColorComponents() to find out which version is returned.

getNumColorComponents

public int getNumColorComponents()
Returns the number of color data components stored per vertex in the current GeometryInfo object (3 for RGB or 4 for RGBA). If no colors are currently defined, 0 is returned.

setNormals

public void setNormals(Vector3f[] normals)
Sets the normals array. No data copying is done because a reference to user data is used.

setNormals

public void setNormals(float[] normals)
Sets the normals array. The points are copied into the GeometryInfo object.

getNormals

public Vector3f[] getNormals()
Retrieves a reference to the normal array.

setTextureCoordinates2

public void setTextureCoordinates2(float[] texCoords)
Sets the TextureCoordinates array. The points are copied into the GeometryInfo object, assuming two numbers (S and T) ver vertex.

setTextureCoordinates3

public void setTextureCoordinates3(float[] texCoords)
Sets the TextureCoordinates array. The points are copied into the GeometryInfo object, assuming three numbers (S, T, and R) ver vertex.

setTextureCoordinates

public void setTextureCoordinates(Point2f[] texCoords)
Sets the TextureCoordinates array. No data copying is done because a reference to user data is used.

setTextureCoordinates

public void setTextureCoordinates(Point3f[] texCoords)
Sets the TextureCoordinates array. No data copying is done because a reference to user data is used.

getTextureCoordinates

public java.lang.Object[] getTextureCoordinates()
Retrieves a reference to the TextureCoordinate array. Will be either Point2f[] or Point3f[] depending on the type of the input data. Call getNumTexCoordComponents() to find out which version is returned.

getNumTexCoordComponents

public int getNumTexCoordComponents()
Returns the number of texCoord data components stored per vertex in the current GeometryInfo object (2 for ST or 3 for STR). If no texCoords are currently defined, 0 is returned.

setCoordinateIndices

public void setCoordinateIndices(int[] coordinateIndices)
Sets the array of indices into the Coordinate array.

getCoordinateIndices

public int[] getCoordinateIndices()
Retrieves a reference to the array of indices into the coordinate array.

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.

setColorIndices

public void setColorIndices(int[] colorIndices)
Sets the array of indices into the Color array.

getColorIndices

public int[] getColorIndices()
Retrieves a reference to the array of indices into the color array.

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.

setNormalIndices

public void setNormalIndices(int[] normalIndices)
Sets the array of indices into the Normal array.

getNormalIndices

public int[] getNormalIndices()
Retrieves a reference to the array of indices into the Normal array.

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.

setTextureCoordinateIndices

public void setTextureCoordinateIndices(int[] texCoordIndices)
Sets the array of indices into the TextureCoordinate array.

getTextureCoordinateIndices

public int[] getTextureCoordinateIndices()
Retrieves a reference to the array of indices into the TextureCoordinate array.

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.

setStripCounts

public void setStripCounts(int[] stripCounts)
Sets the array of strip counts. If index lists have been set for this GeomteryInfo object then the data is indexed and the stripCounts are like stripIndexCounts. If no index lists have been set then the data is non-indexed and the stripCounts are like stripVertexCounts.

getStripCounts

public int[] getStripCounts()
Retrieves a reference to the array of stripCounts.

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.

setContourCounts

public void setContourCounts(int[] contourCounts)
Sets the list of contour counts. Only used with the POLYGON_ARRAY primitive. Polygons can be made of several vertex lists called contours. The first list is the polygon, and subsequent lists are "holes" that are removed from the polygon. All of the holes must be contained entirely within the polygon.

getContourCounts

public int[] getContourCounts()
Retrieves a reference to the array of contourCounts.

recomputeIndices

public void recomputeIndices()
Redo indexes to guarantee connection information. Use this routine if your original data is in indexed format, but you don't trust that the indexing is correct. After this routine it is guaranteed that two points with the same position will have the same coordinate index (for example). Try this if you see glitches in your normals or stripification, to rule out bad indexing as the source of the problem.

reverse

public void reverse()
Reverse the order of all lists. If your data is formatted with the wrong winding rule (so you always see the back and never the front), this method will (in effect) reverse the winding of your data by inverting all of the index lists and the stripCounts and contourCounts lists.

getGeometryArray

public GeometryArray getGeometryArray()
Creates and returns a non-indexed Java 3D GeometryArray object based on the data in the GeometryInfo object. This object is suitable to be attached to a Java 3D Shape3D node for rendering. If the primitive is POLYGON_ARRAY, the polygons will be turned into triangles by the Triangulator utility before being put into the GeometryArray.

getIndexedGeometryArray

public IndexedGeometryArray getIndexedGeometryArray(boolean compact)
Creates and returns an indexed Java 3D GeometryArray object based on the data in the GeometryInfo object. This object is suitable to be attached to a Java 3D Shape3D node for rendering. If the primitive is POLYGON_ARRAY, the polygons will be turned into triangles by the Triangulator utility before being put into the GeometryArray.
Parameters:
compact - Remove Coordinates, Colors, Normals, and TextureCoordinates that aren't referenced by any indices.

getIndexedGeometryArray

public IndexedGeometryArray getIndexedGeometryArray()
Creates and returns an indexed Java 3D GeometryArray object based on the data in the GeometryInfo object. This object is suitable to be attached to a Java 3D Shape3D node for rendering. If the primitive is POLYGON_ARRAY, the polygons will be turned into triangles by the Triangulator utility before being put into the GeometryArray.