org.xith3d.utility.geometry
Class GeometryUtils

java.lang.Object
  extended by org.xith3d.utility.geometry.GeometryUtils

public class GeometryUtils
extends java.lang.Object

This class provides static utility methods for Geometries.


Constructor Summary
GeometryUtils()
           
 
Method Summary
static void computeVertexNormals(Geometry geom)
          Computes smooth vertex-indices and writes them into the vertex-coord-data.
static void computeVertexNormals(Geometry geom, boolean flipNormals)
          Computes smooth vertex-indices and writes them into the vertex-coord-data.
static void computeVertexNormals(Geometry geom, int initialIndex, int indexCount)
          Computes smooth vertex-indices and writes them into the vertex-coord-data.
static void computeVertexNormals(Geometry geom, int initialIndex, int indexCount, boolean flipNormals)
          Computes smooth vertex-indices and writes them into the vertex-coord-data.
static void generateTexCoordsXY(Geometry geom, org.openmali.vecmath2.TexCoord2f[] texCoords)
          Generates (flat) TextureCoordinates from the x/y coordinates of the Geometry's vertex-coords.
static void generateTexCoordsXZ(Geometry geom, org.openmali.vecmath2.TexCoord2f[] texCoords)
          Generates (flat) TextureCoordinates from the x/z coordinates of the Geometry's vertex-coords.
static void generateTexCoordsZY(Geometry geom, org.openmali.vecmath2.TexCoord2f[] texCoords)
          Generates (flat) TextureCoordinates from the x/y coordinates of the Geometry's vertex-coords.
static org.openmali.vecmath2.Vector3f[] getNormals(Geometry geom)
          Retrieves the normals from a Geometry.
static void getNormals(Geometry geom, org.openmali.vecmath2.Vector3f[] normals)
          Retrieves the normals from a Geometry.
static org.openmali.vecmath2.Vector3f[] getNormals(Shape3D shape)
          Retrieves the normals from a Shape3D.
static org.openmali.vecmath2.Point3f[] getVertexCoords(Shape3D shape)
          Retrieves the vertices from a Shape3D.
static org.openmali.vecmath2.Point3f[] getVertexCoords(org.openmali.spatial.VertexContainer vc)
          Retrieves the vertex coordinates from a VertexContainer.
static void getVertexCoords(org.openmali.spatial.VertexContainer vc, org.openmali.vecmath2.Tuple3f[] coords)
          Retrieves the vertex coordinates from a VertexContainer.
static IndexedTriangleArray mergeGeometriesITA(Geometry... geoms)
          Merges multiple Geometries into one big IndexedTriangleArray.
static TriangleArray mergeGeometriesTA(Geometry... geoms)
          Merges multiple Geometries into one big TriangleArray.
static java.util.List<Shape3D> split(Shape3D shape, int maxFacesPerPart)
          Splits a shape into several parts.
static void subdivide(Shape3D shape, int n)
          Subdivides a Shape's Geometry into n pieces.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeometryUtils

public GeometryUtils()
Method Detail

getVertexCoords

public static final void getVertexCoords(org.openmali.spatial.VertexContainer vc,
                                         org.openmali.vecmath2.Tuple3f[] coords)
Retrieves the vertex coordinates from a VertexContainer.

Parameters:
vc - the source Geometry
coords - the coords array (must be of correct length)

getVertexCoords

public static final org.openmali.vecmath2.Point3f[] getVertexCoords(org.openmali.spatial.VertexContainer vc)
Retrieves the vertex coordinates from a VertexContainer.

Parameters:
vc - the source Geometry
Returns:
the Point3f array of vertex coords

getVertexCoords

public static final org.openmali.vecmath2.Point3f[] getVertexCoords(Shape3D shape)
Retrieves the vertices from a Shape3D.

Parameters:
shape - the source Shape3D
Returns:
the Point3f array of vertex coords

getNormals

public static final void getNormals(Geometry geom,
                                    org.openmali.vecmath2.Vector3f[] normals)
Retrieves the normals from a Geometry.

Parameters:
geom - the source Geometry
normals - the Vector3f array to store normals in

getNormals

public static final org.openmali.vecmath2.Vector3f[] getNormals(Geometry geom)
Retrieves the normals from a Geometry.

Parameters:
geom - the source Geometry
Returns:
the Vector3f array of normals

getNormals

public static final org.openmali.vecmath2.Vector3f[] getNormals(Shape3D shape)
Retrieves the normals from a Shape3D.

Parameters:
shape - the source Shape3D
Returns:
the Vector3f array of normals

mergeGeometriesTA

public static TriangleArray mergeGeometriesTA(Geometry... geoms)
Merges multiple Geometries into one big TriangleArray.

Parameters:
geoms -
Returns:
the new TriangleArray.

mergeGeometriesITA

public static IndexedTriangleArray mergeGeometriesITA(Geometry... geoms)
Merges multiple Geometries into one big IndexedTriangleArray.

Parameters:
geoms -
Returns:
the new IndexedTriangleArray.

split

public static java.util.List<Shape3D> split(Shape3D shape,
                                            int maxFacesPerPart)
Splits a shape into several parts.

Parameters:
shape -
maxFacesPerPart -
Returns:
the List of resulting Shape3Ds

subdivide

public static void subdivide(Shape3D shape,
                             int n)
Subdivides a Shape's Geometry into n pieces. Total number of faces after subdivision will be :
initial number of faces * n * number of vertices per face

Parameters:
shape - the shape to split
n - The number of times to subdivide the shape

generateTexCoordsXY

public static final void generateTexCoordsXY(Geometry geom,
                                             org.openmali.vecmath2.TexCoord2f[] texCoords)
Generates (flat) TextureCoordinates from the x/y coordinates of the Geometry's vertex-coords. The TextureCoordinates are directly applied the the Geometry.

Parameters:
geom - the Geometry to get the vertex-coords from and to store the tex-coords to
texCoords - the reference array for the texcoords. Can be null.

generateTexCoordsXZ

public static final void generateTexCoordsXZ(Geometry geom,
                                             org.openmali.vecmath2.TexCoord2f[] texCoords)
Generates (flat) TextureCoordinates from the x/z coordinates of the Geometry's vertex-coords. The TextureCoordinates are directly applied the the Geometry.

Parameters:
geom - the Geometry to get the vertex-coords from and to store the tex-coords to
texCoords - the reference array for the texcoords. Can be null.

generateTexCoordsZY

public static final void generateTexCoordsZY(Geometry geom,
                                             org.openmali.vecmath2.TexCoord2f[] texCoords)
Generates (flat) TextureCoordinates from the x/y coordinates of the Geometry's vertex-coords. The TextureCoordinates are directly applied the the Geometry.

Parameters:
geom - the Geometry to get the vertex-coords from and to store the tex-coords to
texCoords - the reference array for the texcoords. Can be null.

computeVertexNormals

public static void computeVertexNormals(Geometry geom,
                                        int initialIndex,
                                        int indexCount,
                                        boolean flipNormals)
Computes smooth vertex-indices and writes them into the vertex-coord-data. TODO: optimize!

Parameters:
geom -
initialIndex -
indexCount -
flipNormals -

computeVertexNormals

public static void computeVertexNormals(Geometry geom,
                                        int initialIndex,
                                        int indexCount)
Computes smooth vertex-indices and writes them into the vertex-coord-data.

Parameters:
geom -
initialIndex -
indexCount -

computeVertexNormals

public static void computeVertexNormals(Geometry geom,
                                        boolean flipNormals)
Computes smooth vertex-indices and writes them into the vertex-coord-data.

Parameters:
geom -
flipNormals -

computeVertexNormals

public static void computeVertexNormals(Geometry geom)
Computes smooth vertex-indices and writes them into the vertex-coord-data.

Parameters:
geom -