org.xith3d.scenegraph.primitives
Class GeomFactory

java.lang.Object
  extended by org.xith3d.scenegraph.primitives.GeomFactory

public class GeomFactory
extends java.lang.Object

Geometry Utility class.


Constructor Summary
GeomFactory()
           
 
Method Summary
protected static int calculateFeatures(org.openmali.vecmath2.Tuple3f[] coords, org.openmali.vecmath2.Vector3f[] normals, org.openmali.vecmath2.Colorf[] colors, org.openmali.vecmath2.TexCoord2f[] texCoords2, org.openmali.vecmath2.TexCoord3f[] texCoords3)
          Calculates the GeometryArray features.
static GeometryConstruct convertGeometryConstructITSA2ITA(GeometryConstruct gcITSA)
          Converts a GeometryConstruct made for IndexedTriangleStripArray to one made for IndexedTriangleArrays.
static GeometryConstruct convertGeometryConstructITSA2TA(GeometryConstruct gcITSA)
          Converts a GeometryConstruct made for IndexedTriangleStripArray to one made for TriangleArrays.
static GeometryConstruct convertGeometryConstructITSA2TSA(GeometryConstruct gcITSA)
          Converts a GeometryConstruct made for IndexedTriangleStripArray to one made for TriangleStripArrays.
protected static TriangleArray createFullFeaturedTriangleArray(GeometryConstruct[] geoms)
          Creates the full-featured TriangleArray.
static TriangleArray createFullFeaturedTriangleArray(org.openmali.vecmath2.Tuple3f[] vertices, org.openmali.vecmath2.Vector3f[] normals, org.openmali.vecmath2.Colorf[] colors, org.openmali.vecmath2.TexCoord2f[] texCoords2, int features, boolean colorAlpha, int texCoordsSize)
          Creates the full-featured TriangleArray.
static Geometry createGeometryArray(GeometryConstruct gc)
           
static IndexedTriangleArray createIndexedTriangleArray(GeometryConstruct geomConstruct)
          Creates a IndexedTriangleArray.
static IndexedTriangleArray createIndexedTriangleArray(org.openmali.vecmath2.Tuple3f[] vertices, int[] indices, org.openmali.vecmath2.Vector3f[] normals, org.openmali.vecmath2.Colorf[] colors, org.openmali.vecmath2.TexCoord2f[] texCoords2, org.openmali.vecmath2.TexCoord3f[] texCoords3)
          Creates an IndexedTriangleArray.
static IndexedTriangleStripArray createIndexedTriangleStripArray(GeometryConstruct geomConstruct)
          Creates a IndexedTriangleStripArray.
static IndexedTriangleStripArray createIndexedTriangleStripArray(org.openmali.vecmath2.Tuple3f[] vertices, int[] indices, org.openmali.vecmath2.Vector3f[] normals, org.openmali.vecmath2.Colorf[] colors, org.openmali.vecmath2.TexCoord2f[] texCoords2, org.openmali.vecmath2.TexCoord3f[] texCoords3, int[] stripLengths)
          Creates an IndexedTriangleStripArray.
static IndexedTriangleArray createITAfromITSA(GeometryConstruct gcITSA)
          Creates an IndexedTriangleArray for a Shape3D.
static TriangleArray createTAfromITSA(GeometryConstruct gcITSA)
          Creates a TriangleArray for a Shape3D.
static TriangleArray createTriangleArray(GeometryConstruct geomConstruct)
          Creates a TriangleArray.
static TriangleArray createTriangleArray(org.openmali.vecmath2.Tuple3f[] vertices, org.openmali.vecmath2.Vector3f[] normals, org.openmali.vecmath2.Colorf[] colors, org.openmali.vecmath2.TexCoord2f[] texCoords2, org.openmali.vecmath2.TexCoord3f[] texCoords3)
          Creates a TriangleArray.
static TriangleStripArray createTriangleStripArray(GeometryConstruct geomConstruct)
          Creates a TriangleStripArray.
static TriangleStripArray createTriangleStripArray(org.openmali.vecmath2.Tuple3f[] vertices, org.openmali.vecmath2.Vector3f[] normals, org.openmali.vecmath2.Colorf[] colors, org.openmali.vecmath2.TexCoord2f[] texCoords2, org.openmali.vecmath2.TexCoord3f[] texCoords3, int[] stripLengths)
          Creates a TriangleStripArray.
static TriangleStripArray createTSAfromITSA(GeometryConstruct gcITSA)
          Creates a TriangleStripArray for a Shape3D.
static org.openmali.vecmath2.Colorf[] generateColors(boolean alpha, org.openmali.vecmath2.Tuple3f[] coords)
          Auto-generates the colors.
static org.openmali.vecmath2.Vector3f[] generateNaiveNormals(org.openmali.vecmath2.Tuple3f[] vertices)
          Auto-generates the normals.
static org.openmali.vecmath2.TexCoord2f[] generateTexCoords2(org.openmali.vecmath2.Tuple3f[] vertices)
          Auto-generates the texture coordinates.
static org.openmali.vecmath2.TexCoord3f[] generateTexCoords3(org.openmali.vecmath2.Tuple3f[] vertices)
          Auto-generates the texture coordinates.
static int getFeaturesFromAppearance(Appearance app)
          Retrieves the GeometryArray features from the Appearance, that are at least necessary to handle this Appearance.
static int getTexCoordsSize(Appearance app)
          Retrieves the GeometryArray features from the Appearance, that are at least necessary to handle this Appearance.
static void reverseWinding(Geometry ga)
          Swaps vertex 0 and 2 of each following 3.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeomFactory

public GeomFactory()
Method Detail

reverseWinding

public static void reverseWinding(Geometry ga)
Swaps vertex 0 and 2 of each following 3.

Parameters:
ga - the Geometry whose vertices are to be swapped

getFeaturesFromAppearance

public static int getFeaturesFromAppearance(Appearance app)
Retrieves the GeometryArray features from the Appearance, that are at least necessary to handle this Appearance.

Parameters:
app - the Appearance from which to retrieve the features
Returns:
the collected GometryArray features

getTexCoordsSize

public static int getTexCoordsSize(Appearance app)
Retrieves the GeometryArray features from the Appearance, that are at least necessary to handle this Appearance.

Parameters:
app - the Appearance from which to retrieve the features
Returns:
the collected GometryArray features

generateNaiveNormals

public static org.openmali.vecmath2.Vector3f[] generateNaiveNormals(org.openmali.vecmath2.Tuple3f[] vertices)
Auto-generates the normals.

Parameters:
vertices - the vertices to generate the normals from
Returns:
the normals-array

generateTexCoords2

public static org.openmali.vecmath2.TexCoord2f[] generateTexCoords2(org.openmali.vecmath2.Tuple3f[] vertices)
Auto-generates the texture coordinates.

Parameters:
vertices - the vertices from which to generate the texture coordinates
Returns:
the tex-coords-array

generateTexCoords3

public static org.openmali.vecmath2.TexCoord3f[] generateTexCoords3(org.openmali.vecmath2.Tuple3f[] vertices)
Auto-generates the texture coordinates.

Parameters:
vertices - the vertices from which to generate the texture coordinates
Returns:
the tex-coords-array

generateColors

public static org.openmali.vecmath2.Colorf[] generateColors(boolean alpha,
                                                            org.openmali.vecmath2.Tuple3f[] coords)
Auto-generates the colors.

Parameters:
alpha - the flag to indicate whether to set the alpha channel to 0
coords - the coordinates from which to generate the colors
Returns:
the colors-array

createFullFeaturedTriangleArray

public static TriangleArray createFullFeaturedTriangleArray(org.openmali.vecmath2.Tuple3f[] vertices,
                                                            org.openmali.vecmath2.Vector3f[] normals,
                                                            org.openmali.vecmath2.Colorf[] colors,
                                                            org.openmali.vecmath2.TexCoord2f[] texCoords2,
                                                            int features,
                                                            boolean colorAlpha,
                                                            int texCoordsSize)
Creates the full-featured TriangleArray.

Parameters:
vertices -
normals -
colors -
texCoords2 -
features -
colorAlpha -
texCoordsSize -
Returns:
the TriangleArray

createFullFeaturedTriangleArray

protected static TriangleArray createFullFeaturedTriangleArray(GeometryConstruct[] geoms)
Creates the full-featured TriangleArray.

Parameters:
geoms - the array of GeometryConstructs to build it from
Returns:
the TriangleArray just created

calculateFeatures

protected static int calculateFeatures(org.openmali.vecmath2.Tuple3f[] coords,
                                       org.openmali.vecmath2.Vector3f[] normals,
                                       org.openmali.vecmath2.Colorf[] colors,
                                       org.openmali.vecmath2.TexCoord2f[] texCoords2,
                                       org.openmali.vecmath2.TexCoord3f[] texCoords3)
Calculates the GeometryArray features.

Parameters:
coords - array of Tuple3f coordinates
normals - array of normals coordinates
colors - array of colors
texCoords2 - array of TexCoord2f texture coordinates
texCoords3 - array of TexCoord3f texture coordinates
Returns:
the GeometryArray features

createTriangleArray

public static TriangleArray createTriangleArray(org.openmali.vecmath2.Tuple3f[] vertices,
                                                org.openmali.vecmath2.Vector3f[] normals,
                                                org.openmali.vecmath2.Colorf[] colors,
                                                org.openmali.vecmath2.TexCoord2f[] texCoords2,
                                                org.openmali.vecmath2.TexCoord3f[] texCoords3)
Creates a TriangleArray.

Parameters:
vertices - array of Tuple3f vertices
normals - array of normals coordinates
colors - array of colors
texCoords2 - array of TexCoord2f texture coordinates
texCoords3 - array of TexCoord3f texture coordinates
Returns:
the TriangleArray

createTriangleArray

public static TriangleArray createTriangleArray(GeometryConstruct geomConstruct)
Creates a TriangleArray.

Parameters:
geomConstruct - the geometry construction data to use
Returns:
the TriangleArray

createIndexedTriangleArray

public static IndexedTriangleArray createIndexedTriangleArray(org.openmali.vecmath2.Tuple3f[] vertices,
                                                              int[] indices,
                                                              org.openmali.vecmath2.Vector3f[] normals,
                                                              org.openmali.vecmath2.Colorf[] colors,
                                                              org.openmali.vecmath2.TexCoord2f[] texCoords2,
                                                              org.openmali.vecmath2.TexCoord3f[] texCoords3)
Creates an IndexedTriangleArray.

Parameters:
vertices - array of Tuple3f vertices
indices - the indices to use
normals - array of normals coordinates
colors - array of colors
texCoords2 - array of TexCoord2f texture coordinates
texCoords3 - array of TexCoord3f texture coordinates
Returns:
the IndexedTriangleArray

createIndexedTriangleArray

public static IndexedTriangleArray createIndexedTriangleArray(GeometryConstruct geomConstruct)
Creates a IndexedTriangleArray.

Parameters:
geomConstruct - the geometry construction data to use
Returns:
the IndexedTriangleArray

createTriangleStripArray

public static TriangleStripArray createTriangleStripArray(org.openmali.vecmath2.Tuple3f[] vertices,
                                                          org.openmali.vecmath2.Vector3f[] normals,
                                                          org.openmali.vecmath2.Colorf[] colors,
                                                          org.openmali.vecmath2.TexCoord2f[] texCoords2,
                                                          org.openmali.vecmath2.TexCoord3f[] texCoords3,
                                                          int[] stripLengths)
Creates a TriangleStripArray.

Parameters:
vertices - array of Tuple3f vertices
normals - array of normals coordinates
colors - array of colors
texCoords2 - array of TexCoord2f texture coordinates
texCoords3 - array of TexCoord3f texture coordinates
stripLengths - array of strip lengths
Returns:
the TriangleStripArray

createTriangleStripArray

public static TriangleStripArray createTriangleStripArray(GeometryConstruct geomConstruct)
Creates a TriangleStripArray.

Parameters:
geomConstruct - the geometry construction data to use
Returns:
the TriangleStripArray

createIndexedTriangleStripArray

public static IndexedTriangleStripArray createIndexedTriangleStripArray(org.openmali.vecmath2.Tuple3f[] vertices,
                                                                        int[] indices,
                                                                        org.openmali.vecmath2.Vector3f[] normals,
                                                                        org.openmali.vecmath2.Colorf[] colors,
                                                                        org.openmali.vecmath2.TexCoord2f[] texCoords2,
                                                                        org.openmali.vecmath2.TexCoord3f[] texCoords3,
                                                                        int[] stripLengths)
Creates an IndexedTriangleStripArray.

Parameters:
vertices - array of Tuple3f vertices
indices - the indices to use
normals - array of normals coordinates
colors - array of colors
texCoords2 - array of TexCoord2f texture coordinates
texCoords3 - array of TexCoord3f texture coordinates
stripLengths - array of strip lengths
Returns:
the IndexedTriangleStripArray

createIndexedTriangleStripArray

public static IndexedTriangleStripArray createIndexedTriangleStripArray(GeometryConstruct geomConstruct)
Creates a IndexedTriangleStripArray.

Parameters:
geomConstruct - the geometry construction data to use
Returns:
the IndexedTriangleStripArray

createGeometryArray

public static Geometry createGeometryArray(GeometryConstruct gc)

convertGeometryConstructITSA2ITA

public static GeometryConstruct convertGeometryConstructITSA2ITA(GeometryConstruct gcITSA)
Converts a GeometryConstruct made for IndexedTriangleStripArray to one made for IndexedTriangleArrays.
The data instances will be the same for both GeometryConstructs!

Parameters:
gcITSA - the source GeometryConstruct made for IndexedTriangleStripArrays
Returns:
the new GeometryConstruct made for IndexedTriangleArrays

convertGeometryConstructITSA2TSA

public static GeometryConstruct convertGeometryConstructITSA2TSA(GeometryConstruct gcITSA)
Converts a GeometryConstruct made for IndexedTriangleStripArray to one made for TriangleStripArrays.
The data instances will be the same for both GeometryConstructs!

Parameters:
gcITSA - the source GeometryConstruct made for IndexedTriangleStripArrays
Returns:
the new GeometryConstruct made for TriangleStripArrays

convertGeometryConstructITSA2TA

public static GeometryConstruct convertGeometryConstructITSA2TA(GeometryConstruct gcITSA)
Converts a GeometryConstruct made for IndexedTriangleStripArray to one made for TriangleArrays.
The data instances will be the same for both GeometryConstructs!

Parameters:
gcITSA - the source GeometryConstruct made for IndexedTriangleStripArrays
Returns:
the new GeometryConstruct made for TriangleArrays

createITAfromITSA

public static IndexedTriangleArray createITAfromITSA(GeometryConstruct gcITSA)
Creates an IndexedTriangleArray for a Shape3D.

Parameters:
gcITSA - the GeometryConstruct to build it from

createTSAfromITSA

public static TriangleStripArray createTSAfromITSA(GeometryConstruct gcITSA)
Creates a TriangleStripArray for a Shape3D.

Parameters:
gcITSA - the GeometryConstruct to build it from

createTAfromITSA

public static TriangleArray createTAfromITSA(GeometryConstruct gcITSA)
Creates a TriangleArray for a Shape3D.

Parameters:
gcITSA - the GeometryConstruct to build it from