net.jinx.video
Class Sphere

java.lang.Object
  extended by net.jinx.video.Sphere
All Implemented Interfaces:
Visible
Direct Known Subclasses:
SkySphere

public class Sphere
extends java.lang.Object
implements Visible

Simple Visible that draws a sphere using an internally constructed Model. This uses triangles and display lists, so it should out-perform spheres constructed using GLU. However, there is a slight cost; the constructor pre-calculates everything ahead of time, so initial startup may take longer than with previous versions.

API Stability: Stable.


Constructor Summary
Sphere(double radius, int slices, int stacks)
          Deprecated. this is only here for backwards compatibility with previous versions. This simply type-casts radius to a float and calls Sphere(float,int,int).
Sphere(float radius, int slices, int stacks)
          Constructs a Sphere with the given radius, slices and stacks.
 
Method Summary
 void deinit(Context opt)
          Deinitializes this Visible, disposing of any resources that it may be using.
 void draw(Context opt)
          Renders this Visible to glDrawable.
 Coloration getColoration()
          Provides the Coloration for this Sphere.
 Material getMaterial()
          Deprecated. this class has been internally redesigned; please use the getColoration() method instead.
 java.lang.String getTexture()
          Provides the name of the texture that this Sphere should use.
 void init(Context opt)
          Initializes this Visible, preparing it for rendering.
static Model newSphereModel(float radius, int slices, int stacks)
           
 void setColoration(Coloration color)
          Sets the Coloration for this Sphere.
 void setMaterial(Material material)
          Deprecated. this class has been internally redesigned; please use the setColoration(Coloration) method instead.
 void setSmooth(boolean smooth)
           
 void setTexture(java.lang.String texture)
          Sets the name of the texture that this Sphere should use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Sphere

public Sphere(float radius,
              int slices,
              int stacks)
Constructs a Sphere with the given radius, slices and stacks.

Parameters:
radius - the radius of the sphere.
slices - the number of longitude lines.
stacks - the number of latitude lines.

Sphere

public Sphere(double radius,
              int slices,
              int stacks)
Deprecated. this is only here for backwards compatibility with previous versions. This simply type-casts radius to a float and calls Sphere(float,int,int).

Constructs a Sphere with the given radius, slices and stacks.

Parameters:
radius - the radius of the sphere.
slices - the number of longitude lines.
stacks - the number of latitude lines.
Method Detail

setSmooth

public void setSmooth(boolean smooth)

setTexture

public void setTexture(java.lang.String texture)
Sets the name of the texture that this Sphere should use.

Parameters:
texture - the name. If this is null, no texture will be used.

getTexture

public java.lang.String getTexture()
Provides the name of the texture that this Sphere should use.

Returns:
the name as a String.

setMaterial

public void setMaterial(Material material)
Deprecated. this class has been internally redesigned; please use the setColoration(Coloration) method instead.

Sets the Material for this Sphere.

Parameters:
material - the Material.

getMaterial

public Material getMaterial()
Deprecated. this class has been internally redesigned; please use the getColoration() method instead.

Provides the Material for this Sphere.

Returns:
the Material, or null if the current coloration isn't a Material.

setColoration

public void setColoration(Coloration color)
Sets the Coloration for this Sphere.

Parameters:
color - the Coloration.

getColoration

public Coloration getColoration()
Provides the Coloration for this Sphere.

Returns:
the Coloration.

init

public void init(Context opt)
Description copied from interface: Visible
Initializes this Visible, preparing it for rendering. If this Visible contains other Visibles, then their init methods MUST be called first. This is essential for DisplayList objects to function properly and efficiently.

Specified by:
init in interface Visible
Parameters:
opt - describes the rendering options that are being used.

deinit

public void deinit(Context opt)
Description copied from interface: Visible
Deinitializes this Visible, disposing of any resources that it may be using. If this Visible contains other Visibles, then their deinit methods MUST be called last. This is important for display lists.

Specified by:
deinit in interface Visible
Parameters:
opt - describes the rendering options that are being used.

draw

public void draw(Context opt)
Description copied from interface: Visible
Renders this Visible to glDrawable.

Specified by:
draw in interface Visible
Parameters:
opt - describes the rendering options that are being used.

newSphereModel

public static Model newSphereModel(float radius,
                                   int slices,
                                   int stacks)