com.jme.util.geom
Class GeometryCreator
java.lang.Object
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.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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)
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)