jme.geometry.primitive
Class Sphere

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

public class Sphere
extends Quadric

Sphere defines a spherical geometry. The sphere is defined by a radius. The "quality" or tesselation of the sphere is dependant on the slices and stacks value. The slices determine how many vertices along equatorial line exist. The stacks determine how many vertices are along the polar line. The more slices and stacks the better the sphere appears. However, frame rate will drop accordingly.

Version:
$Id: Sphere.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
Sphere(double radius, int slices, int stacks)
          Constructor creates a new sphere.
 
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 sphere to the view context.
 void setRadius(double radius)
          setRadius sets the radius for the sphere.
 void setSlices(int slices)
          setSlices sets the number of slices for the sphere.
 void setStacks(int stacks)
          setStacks sets the number of stacks for the sphere.
 
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

Sphere

public Sphere(double radius,
              int slices,
              int stacks)
Constructor creates a new sphere. During instantiation the radius, slices and stacks are defined. The radius determines the size of the sphere, the slices and stacks determine how many vertices make up the sphere.

Parameters:
radius - the distance between the center of the sphere and a point on the surface.
slices - The number of subdivisions around the z-axis (similar to lines of longitude).
stacks - The number of subdivisions along the z-axis (similar to lines of latitude).
Throws:
MonkeyRuntimeException - if radius, slices or stacks are zero or less.
Method Detail

render

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

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

setRadius

public void setRadius(double radius)
setRadius sets the radius for the sphere.

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

setSlices

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

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

setStacks

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

Parameters:
stacks - the new number of stacks of the sphere.
Throws:
MonkeyRuntimeException - if the number of slices 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.