vmm.polyhedron
Class IFS

java.lang.Object
  extended by vmm.core.Exhibit
      extended by vmm.core3D.Exhibit3D
          extended by vmm.polyhedron.IFS
All Implemented Interfaces:
java.util.EventListener, javax.swing.event.ChangeListener, Decorateable, Parameterizable
Direct Known Subclasses:
RegularPolyhedron

public class IFS
extends Exhibit3D

Represents a polyhedron given in the form of a indexed face set. That is, the data for the polyhedron consists of a list of vertices plus a list of data for the faces of the polyhedron. A face is specified by a list of integers, one for each vertex of the face, where each integer is an index into the list of vertices. The vertices for a face must be listed in counterclockwise order as viewed from the front of face. No public method is provided for changing the indexed face set data after the object is constructed, but subclasses can do so using the protected method setIFSData(Vector3D[], int[][]).

An IFS has a create animation that shows the faces of the polyhedron being drawn in back-to-front order using a simple painter's algorithm.


Nested Class Summary
static class IFS.IFSView
           
 
Field Summary
protected  int edgeDivisor
          When drawind the polyhedron in wireframe form, each edge is divided into this many sections.
protected  boolean useBackFaceFudge
          When this value is set to true, a modified version of the simple painter's algorithm is used.
 
Fields inherited from class vmm.core3D.Exhibit3D
defaultViewpoint, defaultViewUp, previousTransform3D
 
Fields inherited from class vmm.core.Exhibit
decorations, exhibitNeedsRedraw, isMorphing, morphingView, parameters, previousTransform
 
Constructor Summary
protected IFS()
          This protected constructor creates an IFS object with no data for the polyhedron.
  IFS(Vector3D[] vertexList, int[][] faceData)
          Create a polyhedron, using specifed lists of vertices and faces.
 
Method Summary
protected  void computeDrawData3D(View3D view, boolean exhibitNeedsRedraw, Transform3D previousTransform3D, Transform3D newTransform3D)
          Recopmputes cached data, if necessary, for a 3D rendering of this exhibit.
protected  void doDraw3D(java.awt.Graphics2D g, View3D view, Transform3D transform)
          Draws this Exhibit in a 3D view.
 ActionList getActionsForView(View view)
          Adds to the Actions a toggle to control whether thick lines are used for drawing the wireframe form of the polyhedron.
 Animation getCreateAnimation(View view)
          Returns an animation in which the faces of the polyhedron are drawn one at a time, in back-to-front order.
 View getDefaultView()
          Returns a View of type IFS.IFSView.
protected  void setIFSData(Vector3D[] vertices, int[][] faces)
          Change the data that describes the polyhedron.
 
Methods inherited from class vmm.core3D.Exhibit3D
computeDrawDataHook, doDrawHook, getDefaultTransform, getDefaultViewpoint, getDefaultViewUp, setDefaultViewpoint, setDefaultViewUp
 
Methods inherited from class vmm.core.Exhibit
addChangeListener, addDecoration, addExtraXML, addParameter, addView, clearDecorations, computeDrawData, doDraw, fireExhibitChangeEvent, forceRedraw, getAdditionalAnimationsForView, getAlternativeViews, getBuildAnimation, getDecorations, getDefaultBackground, getDefaultForeground, getDefaultWindow, getFramesForMorphing, getMorphingAnimation, getName, getParameterByName, getParameters, getSettingsCommandsForView, getTitle, getUseFilmstripForMorphing, getViews, parameterChanged, readExtraXML, removeChangeListener, removeDecoration, removeParameter, removeView, render, setDefaultBackground, setDefaultForeground, setDefaultWindow, setDefaultWindow, setFramesForMorphing, setName, setUseFilmstripForMorphing, stateChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

edgeDivisor

protected int edgeDivisor
When drawind the polyhedron in wireframe form, each edge is divided into this many sections. This prevents incorrect drawing order for the edges, which can occur (at least) in the Rhombohedron. The default value is 8; this seems to work in all cases, but the value can be changed in a subclass if necessary. Also note that dividing the edges into multiple segments in this way means that an edges can be partially clipped, since clipping is applied to segments rather than to the edge as a whole.


useBackFaceFudge

protected boolean useBackFaceFudge
When this value is set to true, a modified version of the simple painter's algorithm is used. In the modified version, all back-facing faces are drawn before any front-facing face is drawn. This prevents incorrect draw order for faces that sometimes occurs (at least) for the Rhombohedron when the unmodified painter's algorithm is used. The default value is false, but it is set to true in the Rhombohedron class.

Constructor Detail

IFS

public IFS(Vector3D[] vertexList,
           int[][] faceData)
Create a polyhedron, using specifed lists of vertices and faces. The data is not verified.

Parameters:
vertexList - an array containing the vertices of the polyhedron
faceData - describes the faces of the polyhedron. faceData[i] is a list of vertices in the i-th face, listed in counterclockwise order as seen from in front of the face, with each vertex specified as an index into the vertex array.

IFS

protected IFS()
This protected constructor creates an IFS object with no data for the polyhedron. The data must be provided by the subclass before the method computeDrawData3D(View3D, boolean, Transform3D, Transform3D) is called.

Method Detail

setIFSData

protected void setIFSData(Vector3D[] vertices,
                          int[][] faces)
Change the data that describes the polyhedron. Note that this is used by RegularPolyhedron to show the various truncated forms of the polyhedron. Each truncation has its own truncation.


computeDrawData3D

protected void computeDrawData3D(View3D view,
                                 boolean exhibitNeedsRedraw,
                                 Transform3D previousTransform3D,
                                 Transform3D newTransform3D)
Description copied from class: Exhibit3D
Recopmputes cached data, if necessary, for a 3D rendering of this exhibit. The method in the Exhibit3D class does nothing. Subclasses should override this method as appropriate. Note that this method is called only if the Exhibit is being rendered in a View3D. Exhibits that have both two and three dimensional renderings can also override Exhibit.computeDrawData(View, boolean, Transform, Transform) to say what should be drawn in a 2D view.

Overrides:
computeDrawData3D in class Exhibit3D
Parameters:
view - the 3D View where the Exhibit is about to be drawn.
exhibitNeedsRedraw - if true, then something about the Exhibit has changed that probably requires recomputation of cached data. For example, this is set to true when one of the Parameters of the Exhibit has changed since the previous redraw.
previousTransform3D - the Transform3D that was used the last time this exhibit was drawn. This can be null, if this is the first time that the Exhibit is being drawn (in 3D).
newTransform3D - the transform that will be used to draw the Exhibit during the current drawing operation. This parameter and the previousTransform3D parameter are provided so that the Exhbit can detect those rare cases where cached data exists that depends on the transform. Most Exhibits will just ignore the transform parameters.

doDraw3D

protected void doDraw3D(java.awt.Graphics2D g,
                        View3D view,
                        Transform3D transform)
Description copied from class: Exhibit3D
Draws this Exhibit in a 3D view. The method in the Exhibit3D class does nothing. Subclasses should override this method to do the actual drawing. When this method is called, Exhibit3D.computeDrawData3D(View3D, boolean, Transform3D, Transform3D) has already been called, so that any cached data should be correct. Note that this method is called only if the Exhibit is being drawn in a View3D. Exhibits that have both two and three dimensional renderings should also override Exhibit.doDraw(Graphics2D, View, Transform).

When drawing a 3D exhibit, you are strongly advised to use the drawing routines supplied by the View3D and View3DLit classes. These routines will automatically produce the correct results in stereo views -- the same is not true about direct drawing to the graphics context.

Overrides:
doDraw3D in class Exhibit3D
Parameters:
g - the graphics context where the exhibit is being drawn.
view - The View3D in which the exhibit is being drawn. In general, it is advisable to use the view for all drawing operations.
transform - The transform that is being used to draw the exhibit.

getDefaultView

public View getDefaultView()
Returns a View of type IFS.IFSView.

Overrides:
getDefaultView in class Exhibit3D

getCreateAnimation

public Animation getCreateAnimation(View view)
Returns an animation in which the faces of the polyhedron are drawn one at a time, in back-to-front order.

Overrides:
getCreateAnimation in class Exhibit
Parameters:
view - A View that is displaying this Exhibit. The animation, if any, that is returned by this method will be installed in the View's display. If the view is null, than a creation animation that can run independently of a view could be returned.
Returns:
A creation animation for the given View of this Exhibit. The return value can be null to indicate that no creation animation is to be run.

getActionsForView

public ActionList getActionsForView(View view)
Adds to the Actions a toggle to control whether thick lines are used for drawing the wireframe form of the polyhedron.

Overrides:
getActionsForView in class Exhibit