org.jrabbit.base.graphics.skins.primitive
Class RegPolygonSkin

java.lang.Object
  extended by org.jrabbit.base.graphics.skins.primitive.PrimitiveSkin
      extended by org.jrabbit.base.graphics.skins.primitive.RegPolygonSkin
All Implemented Interfaces:
Renderable, Skin, Dimensioned, Vertexed

public class RegPolygonSkin
extends PrimitiveSkin

A RegPolygonSkin renders and describes an n-sided regular polygon with a base width and height of 1. It uses DisplayList acceleration to hasten rendering. NOTE: The number of sides being rendered should be greater than 2.

Author:
Chris Molini

Field Summary
protected  int dLID
          The current DisplayList ID.
protected  int numSides
          The current number of sides to the polygon.
protected  float[][] vertices
          The calculated vertex data.
 
Constructor Summary
RegPolygonSkin(int sides)
          Creates a RegPolygonSkin that renders a primitive with the indicated number of sides.
 
Method Summary
protected  void calculateVertices()
          Recalculates the vertex data.
 int numberOfSides()
          Learns the current number of sides.
 void render()
          Renders the n-sided polygon.
 void setNumberOfSides(int numSides)
          Redefines the number of sides the polygon uses.
 float[][] vertices()
          Accesses the geometry data.
 
Methods inherited from class org.jrabbit.base.graphics.skins.primitive.PrimitiveSkin
height, width
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numSides

protected int numSides
The current number of sides to the polygon.


dLID

protected int dLID
The current DisplayList ID. If this is 0, no DisplayList is currently active.


vertices

protected float[][] vertices
The calculated vertex data.

Constructor Detail

RegPolygonSkin

public RegPolygonSkin(int sides)
Creates a RegPolygonSkin that renders a primitive with the indicated number of sides.

Parameters:
sides - The number of sides for the polygon to have.
Method Detail

numberOfSides

public int numberOfSides()
Learns the current number of sides.

Returns:
The current number of sides on the regular polygon.

setNumberOfSides

public void setNumberOfSides(int numSides)
Redefines the number of sides the polygon uses. This recalculates both the DisplayList and the vertex data.

Parameters:
numSides - The new number of sides to use.

calculateVertices

protected void calculateVertices()
Recalculates the vertex data.


render

public void render()
Renders the n-sided polygon.


vertices

public float[][] vertices()
Accesses the geometry data.

Returns:
The calculated coordinates of the vertex of this object.