vmm.polyhedron
Class RegularPolyhedron

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

public abstract class RegularPolyhedron
extends IFS

Represents a regular polyhedron, with a parameter that allows the corners to be "truncated" by various amounts. In fact, this class can also be used for many non-regular polyhedra. The main requirement is that the algorithm that is used for truncating the corners of the polyhedron makes the following assumption: For each vertex, the opposite endpoints of the set of edges that are incident on that vertex must be co-planar (otherwise, the facets that are produced when the corners are truncated will not be planar polygons). Also, the faces should not have any colinear vertices; that is, all the vertices of each face should be real corners of that face.

This class is abstract, even though it has no abstract methods, because this class does not define any data for any polyhedron. The data must be provided by any concrete subclass, probably in the constructor of the subclass, but in any case before the computeDrawData3D() method in this class is called.


Nested Class Summary
 
Nested classes/interfaces inherited from class vmm.polyhedron.IFS
IFS.IFSView
 
Field Summary
protected  int[][] polyhedronFaces
          Data for the faces of the polyhedron.
protected  Vector3D[] polyhedronVertices
          A list of the vertices of the polyhedron.
protected  double stellationHeight
           
protected  double stellationScale
           
protected  RealParamAnimateable truncation
           
protected  ActionRadioGroup truncationSelect
          A radio group that appears in the Action menu that allows the user to select one of the standard truncations.
 
Fields inherited from class vmm.polyhedron.IFS
edgeDivisor, useBackFaceFudge
 
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 RegularPolyhedron()
          Sets up a RegularPolyhedron with default viewpoint (10,-10,10) and default xy-window (-2,2,-2,2), and adds the truncation parameter.
 
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.
 ActionList getActionsForView(View view)
          Adds truncationSelect to the actions from the superclass.
 ActionList getAdditionalAnimationsForView(View view)
          This method returns a list of ActionItem that will be added to the Animation menu of the 3dxm applicaiton.
 boolean getStellationWanted()
           
 void parameterChanged(Parameter param, java.lang.Object oldValue, java.lang.Object newValue)
          This is overridden to keep the selected item in the action group truncationSelect in sync with the value of the parameter truncation.
 void setStellationWanted(boolean stellationWanted)
           
 
Methods inherited from class vmm.polyhedron.IFS
doDraw3D, getCreateAnimation, getDefaultView, setIFSData
 
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, getAlternativeViews, getBuildAnimation, getDecorations, getDefaultBackground, getDefaultForeground, getDefaultWindow, getFramesForMorphing, getMorphingAnimation, getName, getParameterByName, getParameters, getSettingsCommandsForView, getTitle, getUseFilmstripForMorphing, getViews, 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

polyhedronVertices

protected Vector3D[] polyhedronVertices
A list of the vertices of the polyhedron. The value of this variable in this class is null. A valid vertex list must be provided by any concrete subclass. This list contains the vertices of the basic, untruncated polyhedron. The value of this variable should not be modified after the object is constructed.


polyhedronFaces

protected int[][] polyhedronFaces
Data for the faces of the polyhedron. The value of this variable in this class is null. Valid face must be provided by any concrete subclass. This list describes the faces of the basic, untruncated polyhedron. polyhedronFaces[i] is a list of the vertices of face number i, where each vertex is specified as an index into the vertex array. The vertices must be listed in counterclockwise order, when viewed from the front of the face. The value of this variable should not be modified after the object is constructed.


stellationScale

protected double stellationScale

stellationHeight

protected double stellationHeight

truncation

protected RealParamAnimateable truncation

truncationSelect

protected ActionRadioGroup truncationSelect
A radio group that appears in the Action menu that allows the user to select one of the standard truncations.

Constructor Detail

RegularPolyhedron

protected RegularPolyhedron()
Sets up a RegularPolyhedron with default viewpoint (10,-10,10) and default xy-window (-2,2,-2,2), and adds the truncation parameter.

Method Detail

getStellationWanted

public boolean getStellationWanted()

setStellationWanted

public void setStellationWanted(boolean stellationWanted)

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 IFS
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.

getActionsForView

public ActionList getActionsForView(View view)
Adds truncationSelect to the actions from the superclass.

Overrides:
getActionsForView in class IFS

parameterChanged

public void parameterChanged(Parameter param,
                             java.lang.Object oldValue,
                             java.lang.Object newValue)
This is overridden to keep the selected item in the action group truncationSelect in sync with the value of the parameter truncation.

Specified by:
parameterChanged in interface Parameterizable
Overrides:
parameterChanged in class Exhibit
Parameters:
param - The Parmeter whose value has been set.
oldValue - The previous value of the parameter.
newValue - The new, current value of the parameter. This is not necessarily guaranteed to be different from the old value (although it is for parameters definedin the VMM core).
See Also:
Exhibit.forceRedraw()

getAdditionalAnimationsForView

public ActionList getAdditionalAnimationsForView(View view)
Description copied from class: Exhibit
This method returns a list of ActionItem that will be added to the Animation menu of the 3dxm applicaiton. The values in the list should ordinarily be commands (i.e. AbstractActionVMM) that run animations (although there is no way to enforce this restriction). These animations commands are in addition to the standard "Morph" and "Cyclic Morph" commands. Note that these commands are added to those returned by View.getAdditionalAnimations().

In this top-level Exhibit class, the return value is a an empty list (but not null). In general, when overriding this method, subclasses should call "super.getAdditionalAnimationsForView()" to obtain a list of actions from the superclass. It can then add additional actions or remove or disable actions that are in the list from the superclass.

Overrides:
getAdditionalAnimationsForView in class Exhibit
Parameters:
view - The view in which the animations will be run.