jme.geometry.primitive
Class Cylinder

java.lang.Object
  extended byjme.geometry.primitive.Primitive
      extended byjme.geometry.primitive.Quadric
          extended byjme.geometry.primitive.Cylinder
All Implemented Interfaces:
Geometry

public class Cylinder
extends Quadric

Cylinder defines a cylindrical geometry. The cylinder is defined by a base radius, top radius, height, slices and stacks. The two radii define the size of the ends of the cylinder. The top radius can be zero, creating a cone. The height defines the length of the cylinder, while the slices and stacks determine the number of vertices that make up the cylinder. The higher the slices and stacks, the better the quality of the image, but framerate will suffer.

Version:
$Id: Cylinder.java,v 1.4 2003/09/08 20:29:27 mojomonkey Exp $
Author:
Mark Powell

Field Summary
 
Fields inherited from class jme.geometry.primitive.Quadric
quadricPointer
 
Fields inherited from class jme.geometry.primitive.Primitive
alpha, blue, green, red
 
Constructor Summary
Cylinder(double baseRadius, double topRadius, double height, int slices, int stacks)
          Constructor defines the attributes of the cylinder and prepares it to be rendered via a call to initialize
 
Method Summary
 Vector[] getPoints()
          getPoints returns an array of Vectors that represents each point that makes up the piece of geometry.
 void render()
          render handles rendering the cylinder to the view context.
 void setBaseRadius(double baseRadius)
          setBaseRadius sets the base size of the cylinder.
 void setHeight(double height)
          setHeight sets the length of the cylinder.
 void setSlices(int slices)
          setSlices sets the number of slices for this cylinder.
 void setStacks(int stacks)
          setStacks sets the number of stacks for this cylinder.
 void setTopRadius(double topRadius)
          setTopRadius sets the top size of the cylinder.
 
Methods inherited from class jme.geometry.primitive.Quadric
initialize, preRender
 
Methods inherited from class jme.geometry.primitive.Primitive
clean, getTextureId, setColor, setTexture, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Cylinder

public Cylinder(double baseRadius,
                double topRadius,
                double height,
                int slices,
                int stacks)
Constructor defines the attributes of the cylinder and prepares it to be rendered via a call to initialize

Parameters:
baseRadius - size of the base.
topRadius - size of the top
height - length of the cylinder.
slices - The number of subdivisions around the z-axis.
stacks - The number of subdivisions along the z-axis.
Throws:
MonkeyRuntimeException - if any parameter other than top radius is zero or less.
Method Detail

render

public void render()
render handles rendering the cylinder to the view context.

Specified by:
render in interface Geometry
Specified by:
render in class Quadric

setBaseRadius

public void setBaseRadius(double baseRadius)
setBaseRadius sets the base size of the cylinder.

Parameters:
baseRadius - the new base size of the cylinder.
Throws:
MonkeyRuntimeException - if the baseRadius is less than or equal to zero.

setTopRadius

public void setTopRadius(double topRadius)
setTopRadius sets the top size of the cylinder. If it is set to zero, the cylinder is essentially a cone.

Parameters:
topRadius - the size of the top of the cylinder.
Throws:
MonkeyRuntimeException - if the top radius is less than zero.

setHeight

public void setHeight(double height)
setHeight sets the length of the cylinder.

Parameters:
height - the new height of the cylinder.
Throws:
MonkeyRuntimeException - if the top radius is less than or equal to zero.

setSlices

public void setSlices(int slices)
setSlices sets the number of slices for this cylinder.

Parameters:
slices - the number of slices for the cylinder.
Throws:
MonkeyRuntimeException - if slices is less than or equal to zero.

setStacks

public void setStacks(int stacks)
setStacks sets the number of stacks for this cylinder.

Parameters:
stacks - the number of stacks for the cylinder.
Throws:
MonkeyRuntimeException - if stacks is less than or equal to zero.

getPoints

public Vector[] getPoints()
Description copied from interface: Geometry
getPoints returns an array of Vectors that represents each point that makes up the piece of geometry.

Returns:
the array of vectors for the points.