org.xith3d.utility.geometry
Class GeometryCreator
java.lang.Object
org.xith3d.utility.geometry.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();
XithGeometryInfo xgi = new XithGeometryInfo();
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
for filling data.
|
Method Summary |
void |
addColor(org.openmali.vecmath2.Colorf c)
|
void |
addColor(float r,
float g,
float b)
|
void |
addColor(float r,
float g,
float b,
float a)
|
void |
addColorIndex(int i)
|
void |
addCoordinate(float x,
float y,
float z)
|
void |
addCoordinate(org.openmali.vecmath2.Point3f p)
|
void |
addCoordIndex(int i)
|
void |
addNormal(float x,
float y,
float z)
|
void |
addNormal(org.openmali.vecmath2.Vector3f v)
|
void |
addNormalIndex(int i)
|
void |
addTexCoord(float s,
float t)
|
void |
addTexCoord(org.openmali.vecmath2.TexCoord2f t)
|
void |
addTexCoords(org.openmali.vecmath2.TexCoord2f[] t)
|
void |
addTexIndex(int i)
|
void |
fillGeometryInfo(GeometryInfo gi)
|
void |
nextFace()
|
void |
setFaceSmoothingGroup(int group)
|
| 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(int textureCoordinateSets)
addCoordinate
public void addCoordinate(float x,
float y,
float z)
addCoordinate
public void addCoordinate(org.openmali.vecmath2.Point3f p)
addNormal
public void addNormal(float x,
float y,
float z)
addNormal
public void addNormal(org.openmali.vecmath2.Vector3f v)
addColor
public void addColor(float r,
float g,
float b)
addColor
public void addColor(float r,
float g,
float b,
float a)
addTexCoord
public void addTexCoord(float s,
float t)
addTexCoord
public void addTexCoord(org.openmali.vecmath2.TexCoord2f t)
addTexCoords
public void addTexCoords(org.openmali.vecmath2.TexCoord2f[] t)
addColor
public void addColor(org.openmali.vecmath2.Colorf c)
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)