vmm.core3D
Class View3DLit

java.lang.Object
  extended by vmm.core.View
      extended by vmm.core3D.View3D
          extended by vmm.core3D.View3DWithLightSettings
              extended by vmm.core3D.View3DLit
All Implemented Interfaces:
java.util.EventListener, javax.swing.event.ChangeListener, Decorateable, Parameterizable
Direct Known Subclasses:
IFS.IFSView, SpaceCurveParametric.SpaceCurveParametricViewAsTube, SurfaceView

public class View3DLit
extends View3DWithLightSettings


Field Summary
protected  ToggleAction dragAsSurfaceToggle
          ToggleAction for turning the dragAsSurface property on and off.
static int NO_ORIENTATION
          A constant that can be used as a parameter to setOrientation(int) to specify that surfaces have no orientation, so that both faces of a patch are treated as front faces.
static int NORMAL_ORIENTATION
          A constant that can be used as a parameter to setOrientation(int) to specify that surfaces have normal orientation, in which the normal vector points out from the front face.
static int PATCH_RENDERING
          A constant that can be used as a parameter to setRenderingStyle(int) to specify that surfaces should always be rendered as solid patches.
static int REVERSE_ORIENTATION
          A constant that can be used as a parameter to setOrientation(int) to specify that surfaces have reverse orientation, in which the normal vector points out from the back face.
protected  ActionRadioGroup selectColoredCommands
          Commands for choosing between a black and white drawing or a color drawing.
protected  ActionRadioGroup selectOrientationCommands
          Commands for selecting orientation type.
protected  ActionRadioGroup selectRenderingCommands
          Commands for selecting a rendering style.
protected  ActionRadioGroup selectShadingCommands
          Commands for choosing between phong shading and flat shading.
protected  AbstractActionVMM setTransparencyCommand
           
static int WIREFRAME_RENDERING
          A constant that can be used as a parameter to setRenderingStyle(int) to specify that surfaces should always be rendered as wireframes.
 
Fields inherited from class vmm.core3D.View3DWithLightSettings
lightingEnabledToggle, lightSettingsCommand
 
Fields inherited from class vmm.core3D.View3D
CROSS_EYE_STEREO_VIEW, leftStereographOSI, MONOCULAR_VIEW, projectionCommands, RED_GREEN_STEREO_VIEW, rightStereographOSI, set3DViewOptionsAction, setViewpointAction, stereoComposite, STEREOGRAPH_VIEW, transform3D, viewStyleCommands
 
Fields inherited from class vmm.core.View
backgroundCommands, buildAnimation, buildingImageForFilmstrip, currentGraphics, decorations, directOffscreenDrawing, fullOSI, needsRedraw, offscreenImageType, parameters, showAxesAction
 
Constructor Summary
View3DLit()
          Create a View3DLit object, using default light settings and normal orientation.
 
Method Summary
 void drawSurface(Grid3D surfaceData)
          Draws an entire surface represented in the form of a Grid3D object, taking into account current lighting and rendering settings.
 void drawSurface(Grid3D surfaceData, double startPercent, double endPercent)
          Draws all or part of a surface that is represented in the form of a Grid3D object, taking into account current lighting and rendering settings.
 void fillPolygon(Vector3D[] vertices, java.awt.Color outlineColor)
          Draws a filled-in polygon in current drawing color.
 boolean getBlackAndWhite()
          Tells whether surfaces are rendered in gray-scale rather than color.
 boolean getDragAsSurface()
          Determines how surfaces are rendered when the "fast draw" mode is in effect, such as during rotation, zooming, or dragging by the user.
 int getOrientation()
          Returns the current orientation setting for surfaces.
 boolean getPhongShading()
          Returns the current shading setting, true for Phong shading or false for flat shading.
 int getRenderingStyle()
          Returns the current rendering style.
 ActionList getSettingsCommands()
          Adds a checkbox for setting the dragAsSurface property to any settings contributed by the superclass.
 double getTransparency()
          Returns the current degree of transparency.
 ActionList getViewCommands()
          Adds commands for setting various View3DLit options to any view commands contributed by the superclass.
 void setBlackAndWhite(boolean blackAndWhite)
          Set whether surfaces should be rendered in gray-scale or in color.
 void setDragAsSurface(boolean dragAsSurface)
          Specify how surfaces are rendered when the "fast draw" mode is in effect, such as during rotation, zooming, or dragging by the user.
 void setEnableThreeD(boolean enable)
          Sets the enableThreeD property.
 void setOrientation(int orientation)
          Set how front and back faces of surface patches are determined.
 void setPhongShading(boolean phongShading)
          Select the type of shading to be used for surface patches.
 void setRenderingStyle(int style)
          Sets the rendering style that is used to draw surfaces.
 void setTransparency(double transparency)
          Set the degree of transparency for surfaces displayed in this View3DLit.
 void setViewStyle(int style)
          Overridden in this subclass to swap in the anaglyph or non-anaglph light settings, as appropriate.
 void takeExhibit(View view, boolean shareTransform)
          Set this View to view the same exhibit as another specififed view.
 
Methods inherited from class vmm.core3D.View3DWithLightSettings
addExtraXML, getLightingEnabled, getLightSettings, readExtraXML, setAnaglyphLightSettings, setLightingEnabled, setLightSettings, setNonAnaglyphLightSettings
 
Methods inherited from class vmm.core3D.View3D
clearOSI, clip, createAxes, createOSI, drawCollaredCurve, drawCollaredCurve, drawCollaredCurve, drawCurve, drawCurve, drawCurve, drawDot, drawLine, drawPixel, drawPixelDirect, drawPixels, drawString, drawWireframeSurface, finish, finishOSIDraw, finishStereoView, getDefaultMouseTask, getEnableThreeD, getOrthographicProjection, getSavedAuxiliaryTransformForEnableThreeD, getTransform3D, getViewPoint, getViewStyle, getViewUp, moveStereographImages, needsNewOSI, prepareOSIForDrawing, putOSI, setBackground, setDisplay, setExhibit, setOrthographicProjection, setSavedAuxiliaryTransformForEnableThreeD, setTransform, setUpForLeftEye, setUpForRightEye, setViewPoint, setViewUp, setWindowForUseWhileThreeDDisabled, stateChanged, stereographLeftEyeRect, stereographRightEyeRect
 
Methods inherited from class vmm.core.View
addDecoration, addParameter, beginDrawToOffscreenImage, clearDecorations, doDraw, drawCurve, drawCurve, drawCurve, drawDot, drawLine, drawLine, drawLineDirect, drawPixel, drawPixel, drawPixels, drawString, drawString, endDrawToOffscreenImage, fillRectDirect, forceRedraw, getActions, getActionsForViewAndExhibit, getAdditionalAnimations, getAdditionalAnimationsForViewAndExhibit, getAntialiased, getApplyGraphics2DTransform, getBackground, getColor, getDecorations, getDisplay, getExhibit, getFastDrawing, getForeground, getImage, getName, getParameterByName, getParameters, getPreserveAspect, getRequestedWindow, getSettingsCommandsForViewAndExhibit, getShowAxes, getStatusText, getTitle, getTransform, getViewAndExhibitParameters, getWindow, parameterChanged, removeDecoration, removeParameter, render, setAntialiased, setApplyGraphics2DTransform, setColor, setFastDrawing, setFastDrawing, setForeground, setName, setPreserveAspect, setShowAxes, setStrokeSizeMultiplier, setWindow, setWindow
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WIREFRAME_RENDERING

public static final int WIREFRAME_RENDERING
A constant that can be used as a parameter to setRenderingStyle(int) to specify that surfaces should always be rendered as wireframes.

See Also:
Constant Field Values

PATCH_RENDERING

public static final int PATCH_RENDERING
A constant that can be used as a parameter to setRenderingStyle(int) to specify that surfaces should always be rendered as solid patches.

See Also:
Constant Field Values

NORMAL_ORIENTATION

public static final int NORMAL_ORIENTATION
A constant that can be used as a parameter to setOrientation(int) to specify that surfaces have normal orientation, in which the normal vector points out from the front face.

See Also:
Constant Field Values

REVERSE_ORIENTATION

public static final int REVERSE_ORIENTATION
A constant that can be used as a parameter to setOrientation(int) to specify that surfaces have reverse orientation, in which the normal vector points out from the back face.

See Also:
Constant Field Values

NO_ORIENTATION

public static final int NO_ORIENTATION
A constant that can be used as a parameter to setOrientation(int) to specify that surfaces have no orientation, so that both faces of a patch are treated as front faces.

See Also:
Constant Field Values

selectRenderingCommands

protected ActionRadioGroup selectRenderingCommands
Commands for selecting a rendering style.


selectOrientationCommands

protected ActionRadioGroup selectOrientationCommands
Commands for selecting orientation type.


selectShadingCommands

protected ActionRadioGroup selectShadingCommands
Commands for choosing between phong shading and flat shading.


selectColoredCommands

protected ActionRadioGroup selectColoredCommands
Commands for choosing between a black and white drawing or a color drawing.


dragAsSurfaceToggle

protected ToggleAction dragAsSurfaceToggle
ToggleAction for turning the dragAsSurface property on and off.

See Also:
setDragAsSurface(boolean)

setTransparencyCommand

protected AbstractActionVMM setTransparencyCommand
Constructor Detail

View3DLit

public View3DLit()
Create a View3DLit object, using default light settings and normal orientation.

Method Detail

getRenderingStyle

public int getRenderingStyle()
Returns the current rendering style.

See Also:
setRenderingStyle(int)

setRenderingStyle

public void setRenderingStyle(int style)
Sets the rendering style that is used to draw surfaces. The two available styles are WIREFRAME_RENDERING and PATCH_RENDERING. With the former, only surface grid lines are drawn. With the latter, surface patches are drawn with color determined by their intrinsic color and lighting conditions.

Parameters:
style - the new rendering style; must be one of the constants WIREFRAME_RENDERING or PATCH_RENDERING

getBlackAndWhite

public boolean getBlackAndWhite()
Tells whether surfaces are rendered in gray-scale rather than color.

See Also:
setBlackAndWhite(boolean)

setBlackAndWhite

public void setBlackAndWhite(boolean blackAndWhite)
Set whether surfaces should be rendered in gray-scale or in color. In a gray-scale image, the color is computed as usual but then only the brightness is used to determine the level of gray for drawing. Note that this setting has no effectg in anaglyph stereo views, since the drawing there is effectively always done in gray-scale.

Parameters:
blackAndWhite - true if surfaces are to be drawn in gray-scale; false if they are to be drawn in color

getOrientation

public int getOrientation()
Returns the current orientation setting for surfaces.

See Also:
setOrientation(int)

setOrientation

public void setOrientation(int orientation)
Set how front and back faces of surface patches are determined. In NORMAL_ORIENTATION, the standard normal vectorto a surface patch points out of the front face of the patch. In REVERSE_ORIENTATION, the normal vector points out of the back face. In NO_ORIENTATION, both faces are considered to be front faces.

Parameters:
orientation - the method for determining front/back faces of surface patches. Must be one of the contstants NORMAL_ORIENTATION, REVERSE_ORIENTATION, or NO_ORIENTATION.

getPhongShading

public boolean getPhongShading()
Returns the current shading setting, true for Phong shading or false for flat shading.

See Also:
getPhongShading()

setPhongShading

public void setPhongShading(boolean phongShading)
Select the type of shading to be used for surface patches. If phongShading is set to true, then the Phong shading algorithm is used to determine the color of each individual pixel in the surface patch. This gives the highest quality results, but is time consuming. If phongShading is set to false, and flat shading is used; in flat shading, the same color is used for all pixels in the patch.


getDragAsSurface

public boolean getDragAsSurface()
Determines how surfaces are rendered when the "fast draw" mode is in effect, such as during rotation, zooming, or dragging by the user.

See Also:
setDragAsSurface(boolean), View.setFastDrawing(boolean)

setDragAsSurface

public void setDragAsSurface(boolean dragAsSurface)
Specify how surfaces are rendered when the "fast draw" mode is in effect, such as during rotation, zooming, or dragging by the user. If dragAsSurface is set to false, then wireframe rendering is used for fast drawing of surface. If dragAsSurface is set to true, and the rendering method is set to PATCH_RENDERING, then "rough" surfaces are drawn during fast drawing. In a "rough" surface, flat shading is always used and all the subpatches in a patch are rendered as a single large patch. Note that when WIREFRAME_RENDERING is in effect, fast drawing will be done in wireframe mode regardless of the setting of the dragAsSurface property.


getTransparency

public double getTransparency()
Returns the current degree of transparency. The value is in the range 0.0 to 1.0.

See Also:
View3D.setTransform(vmm.core.Transform)

setTransparency

public void setTransparency(double transparency)
Set the degree of transparency for surfaces displayed in this View3DLit. The transparency degree is a number in the range 0.0 to 1.0, with 0.0 representing a fully opaque surface and 1.0 representing a fully transparent surface that will, in effect, be invisible.

Parameters:
transparency - the desired degree of transparency. The value is clamped so that it lies in the range 0 to 1, inclusive.

setEnableThreeD

public void setEnableThreeD(boolean enable)
Description copied from class: View3D
Sets the enableThreeD property. When this property is set to false, three-D related items in the Settings menu are disabled. When 3D is disabled, the view style is set to MONOCULAR, the Viewpoint is set to (1,0,0), and the projection is set to be orthographic, so any 3D drawing that is done while 3D is disabled will use a simple projection onto the yz-plane by discarding the x-coordinate. (Although in general you should not be doing any 3D drawing while 3D is disabled.) When 3D is enabled after being disabled, the view style and viewpoint settings are restored to what they were when 3D was entered unless they have been changed in the meantime.

Note that if this view has an Axes decoration, they type of Axes decoration (Axes2D or Axes3D) is set to match the new state of the enableThreeD property.

WARNING: This method does NOT do anything about mouse tasks, so you might want to change the mouse task in this View's display at the same time that you call this method.

Overrides:
setEnableThreeD in class View3D

getSettingsCommands

public ActionList getSettingsCommands()
Adds a checkbox for setting the dragAsSurface property to any settings contributed by the superclass.

Overrides:
getSettingsCommands in class View3DWithLightSettings
See Also:
View.getSettingsCommands()

setViewStyle

public void setViewStyle(int style)
Description copied from class: View3DWithLightSettings
Overridden in this subclass to swap in the anaglyph or non-anaglph light settings, as appropriate. See View3DWithLightSettings.setAnaglyphLightSettings(LightSettings) and View3DWithLightSettings.setNonAnaglyphLightSettings(LightSettings).

Overrides:
setViewStyle in class View3DWithLightSettings
Parameters:
style - the new view style. This is ignored if it is not one of the four legal options.

takeExhibit

public void takeExhibit(View view,
                        boolean shareTransform)
Description copied from class: View3D
Set this View to view the same exhibit as another specififed view. This is overridden here to copy the 3D transform from the specified view (if it has one) and to copy its viewStyle if it is a View3D and to properly handle the enableThreeD propety. Since a 3D View cannot make effective use of a 2D transform, the sharedTransform parameter is ignored if the transform in the given view is not a 3D transform.

Overrides:
takeExhibit in class View3D
Parameters:
view - The view whose Exhibit is to be copied. After the method is called, both views will be drawing the same exhibit. If null, then the exhibit of this view will also be set to null.
shareTransform - If true, the two views will share the same Transform, so that changes made to the transform in one will also result in a change in the other.

getViewCommands

public ActionList getViewCommands()
Adds commands for setting various View3DLit options to any view commands contributed by the superclass.

Overrides:
getViewCommands in class View3D
See Also:
View.getViewCommands()

drawSurface

public void drawSurface(Grid3D surfaceData)
Draws an entire surface represented in the form of a Grid3D object, taking into account current lighting and rendering settings.


drawSurface

public void drawSurface(Grid3D surfaceData,
                        double startPercent,
                        double endPercent)
Draws all or part of a surface that is represented in the form of a Grid3D object, taking into account current lighting and rendering settings. The ability to draw only part of a surface is used in surface build animations.

If fast drawing mode is in effect, the entire surface is always drawn; the startIndex and endIndex are ignored in this case. Also, if WIREFRAME_RENDERING is in effect, the entire surface is drawn in wireframe form. For normal speed rendering with patch display, the startPercent and endPercent specify a range of subpatches to draw; these numbers are given as percentages of the total number of available patches (taking into account patches that have been clipped). The subpatches are sorted into back-to-front order. (The total number of subpatches can be determined by calling Grid3D.getSubPatchCountInSurface(), but note that some of the patches might not be included in the drawing or in the calculation of percentages because ofclipping.)


fillPolygon

public void fillPolygon(Vector3D[] vertices,
                        java.awt.Color outlineColor)
Draws a filled-in polygon in current drawing color. To projection of the polygon onto the xy-plane is drawn. Note: This is used by IFS.

Parameters:
vertices - The vertices of the polygon, in object coordinates.
outlineColor - If non-null, then the polygon is outlined with this color.