com.jme.util.geom
Class GeometryCreator

java.lang.Object
  extended by com.jme.util.geom.GeometryCreator

public class GeometryCreator
extends java.lang.Object

This class supports converting per-component index data to common-index data. Some file formats allow to specify separate indices for coordinates, normals and tex coords. With this class, it is possible to convert this data for use with GeometryInfo for further processing.
In case you would like to use it for non-indexed geometry, just assign indexes incrementally, with every vertex component having it's own index.
Vertex component data can be specified at any moment - only requirement is that it needs to be specified before fillGeometryInfo method is called.
Index data needs to be specified with per-face granularity. You can specify 3 coordinates and 3 normals, or 1 coord, 1 normal, 1 coord, 1 normal, 1 coord, 1 normal, as long as 3 used components are specified for a face before nextFace is called. setFaceSmoothingGroup can be called only once per face, and it can to be called at any moment before nextFace call. Example (single triangle with same normal for each vertex)

 GeometryCreator gc = new GeometryCreator();
 gc.addNormal(0, 1, 0);
 gc.addCoordinate(0, 0, 0);
 gc.addCoordinate(1, 0, 1);
 gc.addCoordinate(0, 0, 1);
 gc.addCoordIndex(0);
 gc.addNormalIndex(0);
 gc.addCoordIndex(1);
 gc.addNormalIndex(0);
 gc.addCoordIndex(2);
 gc.addNormalIndex(0);
 gc.nextFace();
 JmeGeometryInfo xgi = new JmeGeometryInfo();
 gc.fillGeometryInfo(xgi);
 //gc is not longer important
 
 
Important - all methods in this class copy vecmath objects by reference, so please do NOT reuse them when filling data.


Constructor Summary
GeometryCreator()
          Default constructor allows for no or one texture coordinate set.
GeometryCreator(int textureCoordinateSets)
           
GeometryCreator(TriMesh mesh)
           
 
Method Summary
 void addColor(ColorRGBA c)
           
 void addColor(float r, float g, float b, float a)
           
 void addColorIndex(int i)
           
 void addCommonIndex(int i)
           
 void addCoordinate(float x, float y, float z)
           
 void addCoordinate(Vector3f p)
           
 void addCoordIndex(int i)
           
 void addNormal(float x, float y, float z)
           
 void addNormal(Vector3f v)
           
 void addNormalIndex(int i)
           
 void addTexCoord(float s, float t)
           
 void addTexCoord(Vector2f t)
           
 void addTexCoords(Vector2f[] t)
           
 void addTexIndex(int i)
           
 void fillGeometryInfo(GeometryInfo gi)
           
 void nextFace()
           
 void setFaceSmoothingGroup(int group)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeometryCreator

public GeometryCreator()
Default constructor allows for no or one texture coordinate set. For more sets, please use GeometryCreator(int textureCoordinateSets);


GeometryCreator

public GeometryCreator(TriMesh mesh)

GeometryCreator

public GeometryCreator(int textureCoordinateSets)
Method Detail

addCoordinate

public void addCoordinate(float x,
                          float y,
                          float z)

addCoordinate

public void addCoordinate(Vector3f p)

addNormal

public void addNormal(float x,
                      float y,
                      float z)

addNormal

public void addNormal(Vector3f v)

addColor

public void addColor(float r,
                     float g,
                     float b,
                     float a)

addTexCoord

public void addTexCoord(float s,
                        float t)

addTexCoord

public void addTexCoord(Vector2f t)

addTexCoords

public void addTexCoords(Vector2f[] t)

addColor

public void addColor(ColorRGBA c)

addCommonIndex

public void addCommonIndex(int i)

addCoordIndex

public void addCoordIndex(int i)

addNormalIndex

public void addNormalIndex(int i)

addColorIndex

public void addColorIndex(int i)

addTexIndex

public void addTexIndex(int i)

setFaceSmoothingGroup

public void setFaceSmoothingGroup(int group)

nextFace

public void nextFace()

fillGeometryInfo

public void fillGeometryInfo(GeometryInfo gi)