Class GeometryGenerator
- java.lang.Object
-
- jahuwaldt.j3d.geom.GeometryGenerator
-
- Direct Known Subclasses:
ConeGenerator
,CylinderGenerator
public abstract class GeometryGenerator extends java.lang.Object
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.
- Version:
- $Revision: 1.6-JAH1 $
- Author:
- Justin Couch
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description 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.
-
-
-
Method Detail
-
getVertexCount
public abstract int getVertexCount(GeometryData data) throws UnsupportedTypeException
Get the number of vertices that this generator will create for the shape given in the definition.- Parameters:
data
- The data to base the calculations on- Returns:
- The vertex count for the object
- Throws:
UnsupportedTypeException
- The generator cannot handle the type of geometry you have requested.
-
generate
public abstract void generate(GeometryData data) throws UnsupportedTypeException, InvalidArraySizeException
Generate a new set of geometry items based on the passed data. If the data does not contain the right minimum array lengths an exception will be generated. If the array reference is null, this will create arrays of the correct length and assign them to the return value.- Parameters:
data
- The data to base the calculations on- Throws:
InvalidArraySizeException
- The array is not big enough to contain the requested geometryUnsupportedTypeException
- The generator cannot handle the type of geometry you have requested
-
-