vmm.surface
Class Surface

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

public abstract class Surface
extends Exhibit3D

Represents a surface in three-space defined by a rectangular array of points.


Field Summary
protected  Grid3D data
          The object that holds all the data for the surface.
protected  IntegerParam uPatchCount
          The U resolution, that is, the number of patches in the u direction.
protected  IntegerParam vPatchCount
          The U resolution, that is, the number of patches in the u direction.
 
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
Surface()
          Adds uPatchCount and vPatchCount as parameters of the surface, each with a range of possible input values from 1 to 40.
 
Method Summary
protected  void computeDrawData3D(View3D view, boolean exhibitNeedsRedraw, Transform3D previousTransform, Transform3D newTransform)
          Recopmputes cached data, if necessary, for a 3D rendering of this exhibit.
protected abstract  void createData()
          Creates the data needed to represent the surface.
protected  void doDraw3D(java.awt.Graphics2D g, View3D view, Transform3D transform)
          Draws this Exhibit in a 3D view.
 Animation getBuildAnimation(View view)
          Returns a surface build animation, which shows patches being drawn bit-by-bit in back to front order.
 int getDefaultOrientation()
          Returns the default orientation setting for this surface.
 View getDefaultView()
          Returns a default view of this exhibit, a View of type SurfaceView.
 void setDefaultOrientation(int defaultOrientation)
          Set the default orientation setting for this surface.
 
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, getActionsForView, getAdditionalAnimationsForView, getAlternativeViews, getCreateAnimation, 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

data

protected Grid3D data
The object that holds all the data for the surface. This object is computed by the createData() method.


uPatchCount

protected IntegerParam uPatchCount
The U resolution, that is, the number of patches in the u direction. By convention, the number of points along the u-direction of the surface is 1 plus 6 times the value of uPatchCount, since there are 6 "subpatches" along each side of a patch. (However, the number of subpatches per patch is actually selected by a subclass when it creates the data for the surface.)


vPatchCount

protected IntegerParam vPatchCount
The U resolution, that is, the number of patches in the u direction. By convention, the number of points along the u-direction of the surface is 1 plus 6 times the value of vPatchCount.

Constructor Detail

Surface

public Surface()
Adds uPatchCount and vPatchCount as parameters of the surface, each with a range of possible input values from 1 to 40. Also calls Exhibit.setFramesForMorphing(int) to set the number of frames for morphing to 12 and calls Exhibit.setUseFilmstripForMorphing(boolean) to turn on the use of filmstrips for the morphing animation.

Method Detail

createData

protected abstract void createData()
Creates the data needed to represent the surface. This method must create a Grid3D object and assign it to the protected variable data. Note: the gridSpacing for the grid is completely managed by the top-level surface class, so subclasses do not have to concern themselves with which grid lines will be drawn. In general, subclasses only need to compute the veritces and intrinsic colors for the grid. They could also compute normal vectors.


getDefaultOrientation

public int getDefaultOrientation()
Returns the default orientation setting for this surface. This property determines which side of the surface, if any, is front-facing.

See Also:
setDefaultOrientation(int)

setDefaultOrientation

public void setDefaultOrientation(int defaultOrientation)
Set the default orientation setting for this surface. This property determines which side of the surface, if any, is front-facing. The possible settings are: View3DLit.NORMAL_ORIENTATION, View3DLit.REVERSE_ORIENTATION, and View3DLit.NO_ORIENTATION. Other values of the parameter are ignored. If it is not changed by calling this method, the default orientation is View3DLit.NORMAL_ORIENTATION.

Note that the default orientation is used only when a View is created by the getDefaultView() method.

See Also:
View3DLit.setOrientation(int)

getDefaultView

public View getDefaultView()
Returns a default view of this exhibit, a View of type SurfaceView. (Note: If a Surface is displayed in a plain View3D, it will always appear as a wireframe.)

Overrides:
getDefaultView in class Exhibit3D

getBuildAnimation

public Animation getBuildAnimation(View view)
Returns a surface build animation, which shows patches being drawn bit-by-bit in back to front order.

Overrides:
getBuildAnimation in class Exhibit
Parameters:
view - The view into which the build animation will be installed.
Returns:
The return value in this top-level Exhibit class is null.

computeDrawData3D

protected void computeDrawData3D(View3D view,
                                 boolean exhibitNeedsRedraw,
                                 Transform3D previousTransform,
                                 Transform3D newTransform)
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.
previousTransform - 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).
newTransform - 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.