Package jahuwaldt.j3d.geom
Class CylinderGenerator
- java.lang.Object
-
- jahuwaldt.j3d.geom.GeometryGenerator
-
- jahuwaldt.j3d.geom.CylinderGenerator
-
public class CylinderGenerator extends GeometryGenerator
A simple cylinder that can be configured to have end caps.The generator is used to create cylinder shaped geometry for the code. Internally we use a triangle array to generate the information as a collection of single triangles. A triangle strip would be more efficient for rendering, but that's too hard for this first cut :) The height of the cone is along the Y axis with the point in the positive Y direction. The radius is around the X-Z plane. The whole object is centered on the origin.
- Version:
- $Revision: 1.11-JAH1 $
- Author:
- Justin Couch
-
-
Constructor Summary
Constructors Constructor Description CylinderGenerator()
Construct a default cylinder with end caps.CylinderGenerator(boolean ends)
Construct a default cylinder with the option of having end caps.CylinderGenerator(float height, float radius)
Construct a cylinder of a given height and radius with ends.CylinderGenerator(float height, float radius, boolean ends, boolean side)
Construct a cylinder of a given height and radius with the option of ends.CylinderGenerator(float height, float radius, boolean top, boolean bottom, boolean side)
Construct a cylinder of a given height and radius with the option of ends.CylinderGenerator(float height, float radius, int facets)
Construct a cylinder of a given height and radius with ends and selectable number of faces around the radius.CylinderGenerator(float height, float radius, int facets, boolean ends, boolean side)
Construct a cylinder of a given height and radius with the option of ends and selectable number of faces around the radius.CylinderGenerator(float height, float radius, int facets, boolean top, boolean bottom, boolean side)
Construct a cylinder of a given height and radius with the option of ends and selectable number of faces around the radius.CylinderGenerator(int facets)
Construct a default cylinder with end caps and selectable number of faces around the radius.CylinderGenerator(int facets, boolean ends)
Construct a default cylinder with the option of having end caps and selectable number of faces around the radius.
-
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 cylinder.int
getVertexCount(GeometryData data)
Get the number of vertices that this generator will create for the shape given in the definition.boolean
hasEnds()
Check to see that this cylinder has ends in use or notvoid
setDimensions(float height, float radius, boolean ends, boolean side)
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
-
CylinderGenerator
public CylinderGenerator()
Construct a default cylinder with end caps. The default height is 2 and radius 1. There are 16 faces on around the radius.
-
CylinderGenerator
public CylinderGenerator(boolean ends)
Construct a default cylinder with the option of having end caps. The default height is 2 and radius 1. There are 16 faces on around the radius.- Parameters:
ends
- true to use end caps
-
CylinderGenerator
public CylinderGenerator(int facets)
Construct a default cylinder with end caps and selectable number of faces around the radius. The default height is 2 and radius 1. The minimum number of facets is 3.- Parameters:
facets
- The number of faces to use around the radius- Throws:
java.lang.IllegalArgumentException
- The number of facets is less than 3
-
CylinderGenerator
public CylinderGenerator(int facets, boolean ends)
Construct a default cylinder with the option of having end caps and selectable number of faces around the radius. The default height is 2 and radius 1.The minimum number of facets is 3.- Parameters:
facets
- The number of faces to use around the radiusends
- true to use end caps- Throws:
java.lang.IllegalArgumentException
- The number of facets is less than 3
-
CylinderGenerator
public CylinderGenerator(float height, float radius)
Construct a cylinder of a given height and radius with ends. There are 16 faces around the radius.- Parameters:
height
- The height of the cylinder to generateradius
- The radis of the cylinder to generate
-
CylinderGenerator
public CylinderGenerator(float height, float radius, int facets)
Construct a cylinder of a given height and radius with ends and selectable number of faces around the radius. The minimum number of facets is 3.- Parameters:
height
- The height of the cylinder to generateradius
- The radis of the cylinder to generatefacets
- The number of faces to use around the radius- Throws:
java.lang.IllegalArgumentException
- The number of facets is less than 3
-
CylinderGenerator
public CylinderGenerator(float height, float radius, boolean ends, boolean side)
Construct a cylinder of a given height and radius with the option of ends. There are 16 faces around the radius.- Parameters:
height
- The height of the cylinder to generateradius
- The radis of the cylinder to generateends
- true to use end capsside
- true to display the sides
-
CylinderGenerator
public CylinderGenerator(float height, float radius, boolean top, boolean bottom, boolean side)
Construct a cylinder of a given height and radius with the option of ends. There are 16 faces around the radius.- Parameters:
height
- The height of the cylinder to generateradius
- The radis of the cylinder to generatetop
- Whether to generate the top of the cylinderbottom
- Whether to generate the bottom of the cylinderside
- Whether to generate the side of the cylinder
-
CylinderGenerator
public CylinderGenerator(float height, float radius, int facets, boolean ends, boolean side)
Construct a cylinder of a given height and radius with the option of ends and selectable number of faces around the radius. The minimum number of facets is 3.- Parameters:
height
- The height of the cylinder to generateradius
- The radis of the cylinder to generatefacets
- The number of faces to use around the radiusends
- true to use end capsside
- true to display the side- Throws:
java.lang.IllegalArgumentException
- The number of facets is less than 3
-
CylinderGenerator
public CylinderGenerator(float height, float radius, int facets, boolean top, boolean bottom, boolean side)
Construct a cylinder of a given height and radius with the option of ends and selectable number of faces around the radius. The minimum number of facets is 3.- Parameters:
height
- The height of the cylinder to generateradius
- The radis of the cylinder to generatefacets
- The number of faces to use around the radiustop
- Whether to generate the top of the cylinderbottom
- Whether to generate the bottom of the cylinderside
- Whether to generate the side of the cylinder- Throws:
java.lang.IllegalArgumentException
- The number of facets is less than 3
-
-
Method Detail
-
hasEnds
public boolean hasEnds()
Check to see that this cylinder has ends in use or not- Returns:
- true if there is are end caps in use
-
getDimensions
public float[] getDimensions()
Get the dimensions of the cylinder. 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
-
setDimensions
public void setDimensions(float height, float radius, boolean ends, boolean side)
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 coneends
- True if to generate faces for the endsside
- true if to generate faces for the sides
-
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
-
-