|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object vmm.core.View vmm.core3D.View3D
public class View3D
Extends the View class to support three-dimensional viewing.
Field Summary | |
---|---|
static int |
CROSS_EYE_STEREO_VIEW
One of the possible values for the viewStyle, specifying a "stereograph" view. |
protected java.awt.image.BufferedImage |
leftStereographOSI
Left and right offscreen images, used during stereograph viewing. |
static int |
MONOCULAR_VIEW
One of the possible values for the viewStyle, specifying a basic non-stereo view. |
protected ActionRadioGroup |
projectionCommands
A set of two radio items for selecting between orthograhic and prespective projection. |
static int |
RED_GREEN_STEREO_VIEW
One of the possible values for the viewStyle, specifying "anaglyph stereo". |
protected java.awt.image.BufferedImage |
rightStereographOSI
Left and right offscreen images, used during stereograph viewing. |
protected AbstractActionVMM |
set3DViewOptionsAction
A menu item that will show a Set Eye Separation Multiplier dialog box. |
protected AbstractActionVMM |
setViewpointAction
A menu item that will show a Set Viewpoint dialog box. |
protected StereoComposite |
stereoComposite
Used when the view style is RED_GREEN_STEREO_VIEW. |
static int |
STEREOGRAPH_VIEW
One of the possible values for the viewStyle, specifying a "stereograph" view. |
protected Transform3D |
transform3D
The current transform of this view, if it is a Transform3D. |
protected ActionRadioGroup |
viewStyleCommands
A menu item for selecting one of the four possible view styles. |
Fields inherited from class vmm.core.View |
---|
backgroundCommands, buildAnimation, buildingImageForFilmstrip, currentGraphics, decorations, directOffscreenDrawing, fullOSI, needsRedraw, offscreenImageType, parameters, showAxesAction |
Constructor Summary | |
---|---|
View3D()
|
Method Summary | |
---|---|
void |
addExtraXML(org.w3c.dom.Document containingDocument,
org.w3c.dom.Element viewElement)
Overridden to add extra transform info. |
protected void |
clearOSI()
Fills the offscreen image with the background color of this View. |
boolean |
clip(Vector3D objectPoint)
This method is used to test whether a point should be clipped. |
protected Axes2D |
createAxes()
Returns an Axes decoration that is appropriate for this view. |
protected void |
createOSI(int width,
int height)
Create an offscreen image for drawing. |
void |
drawCollaredCurve(Vector3D[] points,
boolean reversed)
A convenience method that simply calls drawCollardCurve(points,0,points.length-1,reversed) . |
void |
drawCollaredCurve(Vector3D[] points,
int pointCount,
boolean reversed)
A convenience method that simply calls drawCollardCurve(points,0,pointCount-1,reversed) . |
void |
drawCollaredCurve(Vector3D[] points,
int startIndex,
int endIndex,
boolean reversed)
Draws a curve in three-space, possibley using "collars" to produce a more three-dimensional effect. |
void |
drawCurve(Vector3D[] points)
Draws a curve in three-space. |
void |
drawCurve(Vector3D[] points,
int pointCount)
Draws a curve in three-space. |
void |
drawCurve(Vector3D[] points,
int startIndex,
int endIndex)
Draws a curve in three-space. |
void |
drawDot(Vector3D pt,
double diameter)
Draws a dot of specified diameter centered at a specified 3D point. |
void |
drawLine(Vector3D v1,
Vector3D v2)
This method can be called during a drawing operation, such as in Exhibit3D.doDraw3D(Graphics2D, View3D, Transform3D) ,
to draw a line segment. |
void |
drawPixel(Vector3D v)
This method can be called during a drawing operation, such as in Exhibit3D.doDraw3D(Graphics2D, View3D, Transform3D) ,
to draw a single pixel. |
void |
drawPixelDirect(java.awt.Color color,
int x,
int y)
Sets the pixel with pixel coordinates (x,y) to be a spelcified color. |
void |
drawPixels(Vector3D[] vlist)
This method can be called during a drawing operation, such as in Exhibit3D.doDraw3D(Graphics2D, View3D, Transform3D) ,
to draw a list of pixels. |
void |
drawString(java.lang.String str,
Vector3D basepoint)
This method can be called during a drawing operation, such as in Exhibit3D.doDraw3D(Graphics2D, View3D, Transform3D) ,
to draw a string. |
void |
drawWireframeSurface(Grid3D surfaceData)
Draws a surface in wireframe. |
void |
finish()
Called when a view is removed from its display. |
protected void |
finishOSIDraw()
This is called by methods in the View class to clean up after drawing to the off-screen image. |
protected void |
finishStereoView()
To be used with setUpForLeftEye() and setUpForRightEye() to support
3D rendering. |
MouseTask |
getDefaultMouseTask()
Returns a MouseTase of type BasicMouseTask3D , which is approriate for most 3D views. |
boolean |
getEnableThreeD()
Gets the value of the enableThreeD property. |
boolean |
getOrthographicProjection()
Returns true if this view is currently set to use an orthographic projection, and false if it is set to use a perspective projection. |
protected Transform |
getSavedAuxiliaryTransformForEnableThreeD()
If 3D is enabled, this returns the saved transform that is used when 3D is disabled; if 3D is disabled, this returns the saved transform that is used when 3D is enabled. |
ActionList |
getSettingsCommands()
Adds a "Set Viewpoint" command to any settings commands created by the superclass. |
Transform3D |
getTransform3D()
If the transform associated with this view is a Transform3D , then that transform is returned. |
ActionList |
getViewCommands()
Returns a list of view commands appropriate for a View3D. |
Vector3D |
getViewPoint()
Returns the current viewpoint for this View's transform. |
int |
getViewStyle()
Returns the currently selected viewstyle. |
Vector3D |
getViewUp()
Returns the current imagePlaneYDirection for this View's transform. |
void |
moveStereographImages(int offset)
This method moves the left- and right-eye views of the exhibit closer together or farther apart, within the limits of available space. |
protected boolean |
needsNewOSI(int width,
int height)
This is called by render to check whether a new offscreen image needs to be
created, given the specified width and height of the drawing area. |
protected java.awt.Graphics2D |
prepareOSIForDrawing()
This is called by methods in the View class to prepare the off-screen image for drawing. |
protected void |
putOSI(java.awt.Graphics2D g,
int width,
int height)
This is called by render to copy the offscreen image to the screen. |
void |
readExtraXML(org.w3c.dom.Element viewInfo)
Overridden to read back the extra transform info. |
void |
setBackground(java.awt.Color c)
Set the background color that will be used for rendering this view. |
void |
setDisplay(Display display)
Set the display where this view draws its exhibit. |
void |
setEnableThreeD(boolean enable)
Sets the enableThreeD property. |
void |
setExhibit(Exhibit exhibit)
Set the exhibit shown in this view. |
void |
setOrthographicProjection(boolean orthographic)
Set to true to use an orthographic projection, and to false to use a perspective projection. |
protected void |
setSavedAuxiliaryTransformForEnableThreeD(Transform transform)
If 3D is enabled this sets the saved transform that is used when 3D is disabled; if 3D is disabled, this sets the saved transform that is used when 3D is enabled. |
void |
setTransform(Transform transform)
Sets the transform for this view to a specified transform, with no error checking. |
protected void |
setUpForLeftEye()
To be used with the setUpForLeftEye and finishStereoView methods to support
3D rendering. |
protected void |
setUpForRightEye()
To be used with setUpForLeftEye() and finishStereoView to support
3D rendering. |
void |
setViewPoint(Vector3D viewpoint)
Sets the viewpoint for this View's transform. |
void |
setViewStyle(int style)
Set the current view styles. |
void |
setViewUp(Vector3D viewUp)
Sets the view up vector for this View's transform. |
void |
setWindowForUseWhileThreeDDisabled(double xmin,
double xmax,
double ymin,
double ymax)
Set the x and y ranges to be used when 3D has been disabled by setEnableThreeD(boolean) . |
void |
stateChanged(javax.swing.event.ChangeEvent evt)
React to a change by rebuilding the offscreen bit map. |
java.awt.Rectangle |
stereographLeftEyeRect()
This method is used in BasicMouseTask3D to determine the rectangle that containts the left-eye image of a stereographic view. |
java.awt.Rectangle |
stereographRightEyeRect()
This method is used in BasicMouseTask3D to determine the rectangle that containts the left-eye image of a stereographic view. |
void |
takeExhibit(View view,
boolean shareTransform)
Set this View to view the same exhibit as another specififed view. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MONOCULAR_VIEW
public static final int RED_GREEN_STEREO_VIEW
public static final int STEREOGRAPH_VIEW
public static final int CROSS_EYE_STEREO_VIEW
protected Transform3D transform3D
View.getTransform()
, and is here for convenience only.
protected StereoComposite stereoComposite
protected java.awt.image.BufferedImage leftStereographOSI
protected java.awt.image.BufferedImage rightStereographOSI
protected ActionRadioGroup viewStyleCommands
getViewCommands()
.
protected ActionRadioGroup projectionCommands
protected AbstractActionVMM setViewpointAction
getSettingsCommands()
protected AbstractActionVMM set3DViewOptionsAction
getSettingsCommands()
Constructor Detail |
---|
public View3D()
Method Detail |
---|
public int getViewStyle()
setViewStyle(int)
public void setViewStyle(int style)
MONOCULAR_VIEW
, RED_GREEN_STEREO_VIEW
, CROSS_EYE_STEREO_VIEW
,
or STEREOGRAPH_VIEW
.
style
- the new view style. This is ignored if it is not one of the four legal options.public void moveStereographImages(int offset)
BasicMouseTask3D
, and
will probably be used rarely if ever otherwise.
offset
- The number of pixels to move the images. A positive value moves them closer
together. A negative value moves them farther apart. However, they can't be moved closer together
than when they are touching or farther apart than the border of the window permits.public java.awt.Rectangle stereographLeftEyeRect()
ODE_3D
for transforming screen points to object points.
public java.awt.Rectangle stereographRightEyeRect()
ODE_3D
for transforming screen points to object points.
public boolean getEnableThreeD()
setEnableThreeD(boolean)
public void setEnableThreeD(boolean enable)
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.
public void setWindowForUseWhileThreeDDisabled(double xmin, double xmax, double ymin, double ymax)
setEnableThreeD(boolean)
.
This method can be called at any time, even while 3D is enabled -- if it is, the specified
ranges only come in to effect the next time 3D is disabled.
protected Transform getSavedAuxiliaryTransformForEnableThreeD()
SaveAndRestore
and will probably not
be used otehrwise.
protected void setSavedAuxiliaryTransformForEnableThreeD(Transform transform)
SaveAndRestore
and will probably not be
used otherwise.
public boolean getOrthographicProjection()
public void setOrthographicProjection(boolean orthographic)
public Vector3D getViewPoint()
setViewPoint(Vector3D)
public void setViewPoint(Vector3D viewpoint)
setViewUp(Vector3D)
,
Transform3D.setViewPoint(Vector3D)
public Vector3D getViewUp()
setViewUp(Vector3D)
public void setViewUp(Vector3D viewUp)
Transform3D.setImagePlaneYDirection(Vector3D)
public void setExhibit(Exhibit exhibit)
transform3D
and to manage stereographic viewing if necessary.
setExhibit
in class View
exhibit
- The exhibit to be installed in this View. The value can be null.
In that case, no Exhibit will be associated with the View after the method executes.
If exhibit is already installed in this View, then no changes are made.Display.install(View, Exhibit)
public void setTransform(Transform transform)
View
SaveAndRestore
class.
setTransform
in class View
public void setDisplay(Display display)
setDisplay
in class View
Display.install(View, Exhibit)
public void finish()
finish
in class View
public void takeExhibit(View view, boolean shareTransform)
takeExhibit
in class View
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.public Transform3D getTransform3D()
Transform3D
, then that transform is returned.
Otherwise, the return value is null.
protected Axes2D createAxes()
Axes3D
and returns
an Axes2D
if 3D is disabled.
createAxes
in class View
setEnableThreeD(boolean)
public MouseTask getDefaultMouseTask()
BasicMouseTask3D
, which is approriate for most 3D views.
getDefaultMouseTask
in class View
BasicMouseTask2D
, which allows
dragging and zooming of the 2D window.MouseTask
public void setBackground(java.awt.Color c)
View
Exhibit.getDefaultBackground()
; if a null exhibit is installed, the background color
is set to white. So, this method is only for adjusting the background color while an exhibit is displayed.
Changing the background color will cause a redraw.
In addition to setting the background color, this method will set the foreground color to either black or white, depending on whehter the background color is light or dark. It is possible to change the foreground color to something else after setting the background.
setBackground
in class View
public void stateChanged(javax.swing.event.ChangeEvent evt)
stateChanged
in interface javax.swing.event.ChangeListener
stateChanged
in class View
View.forceRedraw()
public ActionList getViewCommands()
getViewCommands
in class View
public ActionList getSettingsCommands()
getSettingsCommands
in class View
protected boolean needsNewOSI(int width, int height)
render
to check whether a new offscreen image needs to be
created, given the specified width and height of the drawing area.
needsNewOSI
in class View
protected void putOSI(java.awt.Graphics2D g, int width, int height)
render
to copy the offscreen image to the screen.
The width and height of the drawing area are given as parameters, since they
are needed in the case of stereograph views.
putOSI
in class View
protected void createOSI(int width, int height)
createOSI
in class View
protected void clearOSI()
clearOSI
in class View
protected java.awt.Graphics2D prepareOSIForDrawing()
prepareOSIForDrawing
in class View
protected void finishOSIDraw()
finishOSIDraw
in class View
public void addExtraXML(org.w3c.dom.Document containingDocument, org.w3c.dom.Element viewElement)
addExtraXML
in class View
containingDocument
- The overall XML document that contains the view Element that is being created.
This parameter is necessary because it is needed to create any nested subelements that are to be added
to the view element.viewElement
- The XML element that is being constructed. This element already exists; the
purpose of this method to add any extra information that would be needed to reconstruct this view
object from the XML represenation.View.readExtraXML(Element)
public void readExtraXML(org.w3c.dom.Element viewInfo) throws java.io.IOException
readExtraXML
in class View
viewInfo
- The <view> element from the XML file that contains the information about this
view. Some methods from the SaveAndRestore
class might be useful for getting the data.
java.io.IOException
- If an error is found, an exception of type IOException should be thrown.
This will abort the whole processing of the XML file.public void drawPixel(Vector3D v)
Exhibit3D.doDraw3D(Graphics2D, View3D, Transform3D)
,
to draw a single pixel. This method is designed to work correctly in stereo views as well as in a standard monocular
view; for stereo viewing, the pixel is drawn in both the left- and the right-eye view.
v
- a non-null vector giving the coordinates of the pixel to be drawn, in world coordinates.drawPixels(Vector3D[])
public void drawDot(Vector3D pt, double diameter)
public void drawPixels(Vector3D[] vlist)
Exhibit3D.doDraw3D(Graphics2D, View3D, Transform3D)
,
to draw a list of pixels. This method is designed to work correctly in stereo views as well as in a standard monocular
view; for stereo viewing, each pixel is drawn in both the left- and the right-eye view. This method is more efficient
than drawing each pixel individually when drawing in stereo.
vlist
- a non-null array of vectors, where each vector contains the coordinates of the pixel to be drawn, in world coordinates.
The individual vectors in the list can be null; null values in the array are ignored.public void drawLine(Vector3D v1, Vector3D v2)
Exhibit3D.doDraw3D(Graphics2D, View3D, Transform3D)
,
to draw a line segment. This method is designed to work correctly in stereo views as well as in a standard monocular
view; for stereo viewing, the line segment is drawn in both the left- and the right-eye view.
v1
- a non-null vector giving the coordinates of one endpoint of the line segment, in world coordinates.v2
- a non-null vector giving the coordinates of a second endpoint of the line segment, in world coordinates.public void drawString(java.lang.String str, Vector3D basepoint)
Exhibit3D.doDraw3D(Graphics2D, View3D, Transform3D)
,
to draw a string. Only the basepoint of the string undergoes transformation and projection. The string itself
is always drawn flat on the screen, as if it is located in the view plane.
This method is designed to work correctly in stereo views as well as in a standard monocular
view; for stereo viewing, the string is drawn in both the left- and the right-eye view.
str
- the non-null string that is to be drawn.basepoint
- a non-null vector giving the coordinates of the basepoing of the string to be drawn, in world coordinates.public void drawCurve(Vector3D[] points)
drawCurve(points,points.length)
.
drawCurve(Vector3D[], int)
public void drawCurve(Vector3D[] points, int pointCount)
points
- A non-null array containing the points on the curve. Null values are allowed in this array.
A null value is treated as a missing point on the curve -- no connecting line segment is drawn from the missing
point to the points on either side. This makes it possible for a single array to define multiple disconnected
curve segments.pointCount
- The number of points on the curve. Only the points in positions 0 through pointCount-1 in
the array are used when drawing the curve.public void drawCurve(Vector3D[] points, int startIndex, int endIndex)
points
- A non-null array containing the points on the curve. Null values are allowed in this array.
A null value is treated as a missing point on the curve -- no connecting line segment is drawn from the missing
point to the points on either side. This makes it possible for a single array to define multiple disconnected
curve segments.startIndex
- The number of points in the array that should be used for the curve. A curve is drawn
though points[startIndex], point[startIndex+1], ..., points[endIndex]. The value of startIndex
is clamped to lie in the range 0 to points.length-1.endIndex
- The number of points in the array that should be used for the curve. A curve is drawn
though points[startIndex], point[startIndex+1], ..., points[endIndex]. The value of endIndex
is clamped to lie in the range 0 to points.length-1. If startIndex is less than or equal to endIndex,
nothing is drawn.public void drawCollaredCurve(Vector3D[] points, boolean reversed)
drawCollardCurve(points,0,points.length-1,reversed)
.
drawCollaredCurve(Vector3D[], int, int, boolean)
public void drawCollaredCurve(Vector3D[] points, int pointCount, boolean reversed)
drawCollardCurve(points,0,pointCount-1,reversed)
.
drawCollaredCurve(Vector3D[], int, int, boolean)
public void drawCollaredCurve(Vector3D[] points, int startIndex, int endIndex, boolean reversed)
drawCurve(Vector3D[], int)
method.
If "reversed" is true, then the curve is drawn with reversed collars in both monocular and stereo views. For a reversed collar, the curve itself is drawn in the background color, and the collar is drawn in the foreground color. This gives a nice 3D effect.
points
- A non-null array containing the points on the curve. Null values are allowed in this array.
A null value is treated as a missing point on the curve -- no connecting line segment is drawn from the missing
point to the points on either side. This makes it possible for a single array to define multiple disconnected
curve segments.startIndex
- The number of points in the array that should be used for the curve. A curve is drawn
though points[startIndex], point[startIndex+1], ..., points[endIndex]. The value of startIndex
is clamped to lie in the range 0 to points.length-1.endIndex
- The number of points in the array that should be used for the curve. A curve is drawn
though points[startIndex], point[startIndex+1], ..., points[endIndex]. The value of endIndex
is clamped to lie in the range 0 to points.length-1. If startIndex is less than or equal to endIndex,
nothing is drawn.reversed
- tells whether or not to used reversed colors for drawing the collar.public void drawWireframeSurface(Grid3D surfaceData)
View3DLit.drawSurface(Grid3D)
and View3DLit.drawSurface(Grid3D, double, double)
methods, which will render the surface either as wireframe or as patches, as appropriate for the settings
in a View3DLit
. However,
this drawWireframeSurface
method can be used to render a wireframe surface in a plain View3D
or to draw a surface grid that really is intrinsically a wireframe in any 3D view.
surfaceData
- contains a grid of points on the surfacepublic void drawPixelDirect(java.awt.Color color, int x, int y)
drawPixelDirect
in class View
color
- the color for the pixel; if null, the current drawing color is used.x
- the horizontal pixel coordinate.y
- the vertical pixel coordinate.drawPixel(Vector3D)
protected void setUpForLeftEye()
setUpForLeftEye
and finishStereoView
methods to support
3D rendering. When rendering in one of the three stereo view styles, the image needs to be rendered
twice, once for the left eye and once for the right eye. The setUpForLeftEye
methods
should be called first; this sets up the transform and current graphics context for rendering from
the viewpoint of the left eye into the left eye image. Next comes the code for drawing the object.
then setUpForRightEye
, followed by a repeat of the code for drawing the object.
Finally, calling finshStereoView
must be called to restore the original drawing
context. These three methods must always be used in this way. Note that most programmers will not
have to worry about this -- these methods will only be used when writing methods for rendering
new graphics primitives such as lines and surfaces in this class and its subclasses.
protected void setUpForRightEye()
setUpForLeftEye()
and finishStereoView
to support
3D rendering.
protected void finishStereoView()
setUpForLeftEye()
and setUpForRightEye()
to support
3D rendering.
public final boolean clip(Vector3D objectPoint)
Grid3D
and in
IFS
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |