Package jahuwaldt.j3d.geom
Class ConeGenerator
- java.lang.Object
-
- jahuwaldt.j3d.geom.GeometryGenerator
-
- jahuwaldt.j3d.geom.ConeGenerator
-
public class ConeGenerator extends GeometryGenerator
Generator of Cone raw coordinates and geometry normals.The generator is used to create cone shapes for the code. It only generates the geometry array. Internally the representation uses a triangle array and generates all the values requested - textures oordinates, normals and coordinates. Normals are always generated per vertex calculated rather than per-face.
The height of the cone is along the Y axis with the point in the positive Y direstion and starting at the origin. The radius is around the X-Z plane and is centered on the origin.
When generating strips, we create a strip for all the top and a strip for all the bottom (if used). Generating quads are a bit useless for this geometry type, but is supported non-the-less for completeness.
- Version:
- $Revision: 1.7 $
- Author:
- Justin Couch
-
-
Constructor Summary
Constructors Constructor Description ConeGenerator()
Construct a default cone of height 2 and bottom radius of 1.ConeGenerator(float height, float radius)
Create a custom cone of the given height and radius that includes the bottom faces.ConeGenerator(float height, float radius, boolean hasTop, boolean hasBottom)
Create a custom cone of the given height and radius and can toggle the use of the bottom faces.ConeGenerator(float height, float radius, int facets)
Create a custom cone of the given height and radius and can control the number of facets in the cone.ConeGenerator(float height, float radius, int facets, boolean hasTop, boolean hasBottom)
Create a custom cone of the given height and radius and can toggle the use of the bottom faces and control the number of facets in the cone.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
generate(GeometryData data)
Generate a new set of geometry items based on the passed data.float[]
getDimensions()
Get the dimensions of the cone.int
getVertexCount(GeometryData data)
Get the number of vertices that this generator will create for the shape given in the definition.boolean
hasBottom()
Check to see that this cone has a bottom in use or notvoid
setDimensions(float height, float radius, boolean hasBottom)
Change the dimensions of the cone to be generated.void
setFacetCount(int facets)
Change the number of facets used to create this cone.
-
-
-
Constructor Detail
-
ConeGenerator
public ConeGenerator()
Construct a default cone of height 2 and bottom radius of 1. It also includes the bottom faces and uses 16 segments around the base of the cone.
-
ConeGenerator
public ConeGenerator(float height, float radius)
Create a custom cone of the given height and radius that includes the bottom faces. There are 16 segments around the base of the cone.- Parameters:
height
- The height of the cone to generateradius
- The radius of the bottom of the cone
-
ConeGenerator
public ConeGenerator(float height, float radius, int facets)
Create a custom cone of the given height and radius and can control the number of facets in the cone. The cone always has a base. The minimum number of facets is 3.- Parameters:
height
- The height of the cone to generateradius
- The radius of the bottom of the conefacets
- The number of facets on the side of the cone- Throws:
java.lang.IllegalArgumentException
- The number of facets is less than 3
-
ConeGenerator
public ConeGenerator(float height, float radius, boolean hasTop, boolean hasBottom)
Create a custom cone of the given height and radius and can toggle the use of the bottom faces. There are 16 segments around the base of the cone.- Parameters:
height
- The height of the cone to generateradius
- The radius of the bottom of the conehasTop
- True if to generate faces for the tophasBottom
- True if to generate faces for the bottom
-
ConeGenerator
public ConeGenerator(float height, float radius, int facets, boolean hasTop, boolean hasBottom)
Create a custom cone of the given height and radius and can toggle the use of the bottom faces and control the number of facets in the cone. The minimum number of facets is 3.- Parameters:
height
- The height of the cone to generateradius
- The radius of the bottom of the conefacets
- The number of facets on the side of the conehasTop
- True if to generate faces for the tophasBottom
- True if to generate faces for the bottom- Throws:
java.lang.IllegalArgumentException
- The number of facets is less than 3 or the radius is not positive
-
-
Method Detail
-
getDimensions
public float[] getDimensions()
Get the dimensions of the cone. These are returned as 2 values of height and radius respectively for the array. A new array is created each time so you can do what you like with it.- Returns:
- The current size of the cone
-
hasBottom
public boolean hasBottom()
Check to see that this cone has a bottom in use or not- Returns:
- true if there is a bottom in use
-
setDimensions
public void setDimensions(float height, float radius, boolean hasBottom)
Change the dimensions of the cone to be generated. Calling this will make the points be re-calculated next time you ask for geometry or normals.- Parameters:
height
- The height of the cone to generateradius
- The radius of the bottom of the conehasBottom
- True if to generate faces for the bottom- Throws:
java.lang.IllegalArgumentException
- The radius is not positive
-
setFacetCount
public void setFacetCount(int facets)
Change the number of facets used to create this cone. This will cause the geometry to be regenerated next time they are asked for. The minimum number of facets is 3.- Parameters:
facets
- The number of facets on the side of the cone- Throws:
java.lang.IllegalArgumentException
- The number of facets is less than 3
-
getVertexCount
public int getVertexCount(GeometryData data) throws UnsupportedTypeException
Get the number of vertices that this generator will create for the shape given in the definition.- Specified by:
getVertexCount
in classGeometryGenerator
- 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 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.- Specified by:
generate
in classGeometryGenerator
- 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
-
-