|
j3d.org Code | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.j3d.geom.GeometryGenerator
public abstract class GeometryGenerator
Abstract base representation of geometry generator of box raw coordinate and geometry normals.
Curved surfaces would like to generate a smooth object most of the time. To do this, the normal values at each vertex are made to smooth the values for each set of faces that use that value (ie the effect is averaged between all the sharing faces). The typical approach to do this is to work with a value called creaseAngle. If the angle between two surfaces is less that the creaseAngle, a smoothed normal is generated. If greater, the normal is perpendicular to the face. If we are playing with different numbers of facets in an object, this gets rather annoying at times as some pieces may or may not be faceted. At the same time there is a performance hit for generating the normals as you have to check every face and build a lot of extra data before you start doing normal calculations.
This library takes a much simplified approach - let the geometry generator implementation decide. Our aim is for speed here and if we have to decide in a general fashion for every normal calculation, that could be a huge impact.
Obvious limitations to this are shapes like the cube or a near-degenerate cone that ends up as a pyramid. The smoothing of normals may be there, but no matter how hard you try, the differences between the face angles will just be too great.
Constructor Summary | |
---|---|
protected |
GeometryGenerator()
|
Method Summary | |
---|---|
protected javax.vecmath.Vector3f |
createFaceNormal(float[][] coords,
int w,
int p,
int w1,
int p1,
int w2,
int p2)
Convenience method to create a normal for the given vertex coordinates and normal array and using a 2D array of coordinate values. |
protected javax.vecmath.Vector3f |
createFaceNormal(float[] coords,
int p,
int p1,
int p2)
Convenience method to create a normal for the given vertex coordinates and normal array. |
protected javax.vecmath.Vector3f |
createRadialNormal(float[] coords,
int p)
Create a normal based on the given vertex position, assuming that it is a point in space, relative to the origin. |
protected javax.vecmath.Vector3f |
createRadialNormal(float[] coords,
int p,
float[] origin,
int originOffset)
Create a normal based on the given vertex position, assuming that it is a point in space, relative to the given point. |
abstract void |
generate(GeometryData data)
Generate a new set of geometry items based on the passed data. |
abstract int |
getVertexCount(GeometryData data)
Get the number of vertices that this generator will create for the shape given in the definition. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected GeometryGenerator()
Method Detail |
---|
public abstract int getVertexCount(GeometryData data) throws UnsupportedTypeException
data
- The data to base the calculations on
UnsupportedTypeException
- The generator cannot handle the type
of geometry you have requested.public abstract void generate(GeometryData data) throws UnsupportedTypeException, InvalidArraySizeException
data
- The data to base the calculations on
InvalidArraySizeException
- The array is not big enough to contain
the requested geometry
UnsupportedTypeException
- The generator cannot handle the type
of geometry you have requestedprotected javax.vecmath.Vector3f createFaceNormal(float[] coords, int p, int p1, int p2)
coords
- The coordinate array to read values fromp
- The index of the middle pointp1
- The index of the first pointp2
- The index of the second point
protected javax.vecmath.Vector3f createFaceNormal(float[][] coords, int w, int p, int w1, int p1, int w2, int p2)
coords
- The coordinate array to read values fromw
- The reference into the first array dimension for pp
- The index of the middle pointw1
- The reference into the first array dimension for p1p1
- The index of the first pointw2
- The reference into the first array dimension for p2p2
- The index of the second point
protected javax.vecmath.Vector3f createRadialNormal(float[] coords, int p)
coords
- The coordinate array to read values fromp
- The index of the point to calculate
protected javax.vecmath.Vector3f createRadialNormal(float[] coords, int p, float[] origin, int originOffset)
coords
- The coordinate array to read values fromp
- The index of the point to calculateorigin
- The origin to calculate relative tooriginOffset
- The offset into the origin array to use
|
j3d.org Code | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |