View3D
vmm3d.core3D

Class View3D

    • Field Detail

      • MONOCULAR_VIEW

        public static final int MONOCULAR_VIEW
        One of the possible values for the viewStyle, specifying a basic non-stereo view. This is the default view style.
        See Also:
        Constant Field Values
      • RED_GREEN_STEREO_VIEW

        public static final int RED_GREEN_STEREO_VIEW
        One of the possible values for the viewStyle, specifying "anaglyph stereo". That is, left and right eye views are drawn in green and red, respectively, and the two views are composed into a single image that can be viewed with red/green or red/blue stereo glasses. In this view, the background color is forced to black.
        See Also:
        Constant Field Values
      • STEREOGRAPH_VIEW

        public static final int STEREOGRAPH_VIEW
        One of the possible values for the viewStyle, specifying a "stereograph" view. That is, the left and right eye views are drawn side-by-side. The user can view a 3D image by looking at a point in back of the images, to make the left and right eye views fuse into a single image.
        See Also:
        Constant Field Values
      • CROSS_EYE_STEREO_VIEW

        public static final int CROSS_EYE_STEREO_VIEW
        One of the possible values for the viewStyle, specifying a "stereograph" view. That is, the left and right eye views are drawn side-by-side. The user can view a 3D image by crossing his or her eyes to fuse the left ane right eye views.
        See Also:
        Constant Field Values
    • Constructor Detail

      • View3D

        public View3D()
    • Method Detail

      • getViewStyle

        public int getViewStyle()
        Returns the currently selected viewstyle.
        See Also:
        setViewStyle(int)
      • moveStereographImages

        public 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. This method is called by BasicMouseTask3D, and will probably be used rarely if ever otherwise.
        Parameters:
        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.
      • stereographLeftEyeRect

        public Rectangle stereographLeftEyeRect()
        This method is used in BasicMouseTask3D to determine the rectangle that containts the left-eye image of a stereographic view. It is also used in ODE_3D for transforming screen points to object points.
      • stereographRightEyeRect

        public Rectangle stereographRightEyeRect()
        This method is used in BasicMouseTask3D to determine the rectangle that containts the left-eye image of a stereographic view. It is also used in ODE_3D for transforming screen points to object points.
      • getEnableThreeD

        public boolean getEnableThreeD()
        Gets the value of the enableThreeD property.
        See Also:
        setEnableThreeD(boolean)
      • setEnableThreeD

        public void setEnableThreeD(boolean enable)
        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.

      • setWindowForUseWhileThreeDDisabled

        public 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). 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.
      • getOrthographicProjection

        public 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.
      • setOrthographicProjection

        public void setOrthographicProjection(boolean orthographic)
        Set to true to use an orthographic projection, and to false to use a perspective projection. The default is to use a perspective projection.
      • getViewPoint

        public Vector3D getViewPoint()
        Returns the current viewpoint for this View's transform. (In the unexpected case that this view is not using a 3D transform, returns null.)
        See Also:
        setViewPoint(Vector3D)
      • setViewPoint

        public void setViewPoint(Vector3D viewpoint)
        Sets the viewpoint for this View's transform. (Assuming that this view is using a 3D transform -- if not, nothing is done.) Note that calling this method will also adjust the imagePlaneYDirection by projecting the current imagePlaneYDirection onto the new view plane. Note that when an Exhbit is installed, the Exhibit's default Transform replaces whatever transform already exists, so there is not much use calling this when no exhibit is installed.
        See Also:
        setViewUp(Vector3D), Transform3D.setViewPoint(Vector3D)
      • getViewUp

        public Vector3D getViewUp()
        Returns the current imagePlaneYDirection for this View's transform. (In the unexpected case that this view is not using a 3D transform, returns null.)
        See Also:
        setViewUp(Vector3D)
      • setViewUp

        public void setViewUp(Vector3D viewUp)
        Sets the view up vector for this View's transform. (Assuming that this view is using a 3D transform -- if not, nothing is done.) Note that the specified viewUp vector will have to be projected onto the image plane to give the actual imagePlaneYDirection.
        See Also:
        Transform3D.setImagePlaneYDirection(Vector3D)
      • setExhibit

        public void setExhibit(Exhibit exhibit)
        Set the exhibit shown in this view. It is overridden in this class to set transform3D and to manage stereographic viewing if necessary.
        Overrides:
        setExhibit in class View
        Parameters:
        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.
        See Also:
        Display.install(View, Exhibit)
      • setTransform

        public void setTransform(Transform transform)
        Description copied from class: View
        Sets the transform for this view to a specified transform, with no error checking. This is meant mainly for use in the SaveAndRestore class.
        Overrides:
        setTransform in class View
      • setDisplay

        public void setDisplay(Display display)
        Set the display where this view draws its exhibit. This is overridden in this class to put the display into stereograpic view mode, if the view is currently set to use sterographic viewing.
        Overrides:
        setDisplay in class View
        See Also:
        Display.install(View, Exhibit)
      • finish

        public void finish()
        Called when a view is removed from its display. In this case, it restores the viewStyle to MONOCULAR_VIEW to avoid leaving the display set up for stereo viewing.
        Overrides:
        finish in class View
      • takeExhibit

        public void takeExhibit(View view,               boolean shareTransform)
        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 View
        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.
      • getTransform3D

        public Transform3D getTransform3D()
        If the transform associated with this view is a Transform3D, then that transform is returned. Otherwise, the return value is null.
      • setBackground

        public void setBackground(Color c)
        Description copied from class: View
        Set the background color that will be used for rendering this view. If the specified color is null, then the default color (white) is used. Note that the background color is automatically reset when an exhibit is installed into this View. If the exhibit is non-null, then the background color is set using 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.

        Overrides:
        setBackground in class View
      • stateChanged

        public void stateChanged(ChangeEvent evt)
        React to a change by rebuilding the offscreen bit map. This overrides the method in the View class for the following reason: If the state change comes from a Transform3D, it might be a change in the "orthographicProjection" property of a Transform3D that is shared with another view, so the setting of the projectionCommands is changed to match the setting in the Transform3D.
        Specified by:
        stateChanged in interface ChangeListener
        Overrides:
        stateChanged in class View
        See Also:
        View.forceRedraw()
      • getViewCommands

        public ActionList getViewCommands()
        Returns a list of view commands appropriate for a View3D. This method adds commands for selecting between orthographic and perspective projection and for selecting the viewStyle to the list of commands obtained from the superclass.
        Overrides:
        getViewCommands in class View
      • getSettingsCommands

        public ActionList getSettingsCommands()
        Adds a "Set Viewpoint" command to any settings commands created by the superclass.
        Overrides:
        getSettingsCommands in class View
      • addExtraXML

        public void addExtraXML(Document containingDocument,               Element viewElement)
        Overridden to add extra transform info.
        Overrides:
        addExtraXML in class View
        Parameters:
        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.
        See Also:
        View.readExtraXML(Element)
      • readExtraXML

        public void readExtraXML(Element viewInfo)                  throws IOException
        Overridden to read back the extra transform info.
        Overrides:
        readExtraXML in class View
        Parameters:
        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.
        Throws:
        IOException - If an error is found, an exception of type IOException should be thrown. This will abort the whole processing of the XML file.
      • drawPixel

        public 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. 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.
        Parameters:
        v - a non-null vector giving the coordinates of the pixel to be drawn, in world coordinates.
        See Also:
        drawPixels(Vector3D[])
      • drawDot

        public void drawDot(Vector3D pt,           double diameter)
        Draws a dot of specified diameter centered at a specified 3D point. This is done by calling the org.freehep.graphics2d.VectorGraphics fill() command for an appropriate Ellipse2D. The diameter is specified in pixels. Note that if the preserveAspectRatio is off for this View, then the dot will can be an oval rather than a circle.
      • drawPixels

        public 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. 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.
        Parameters:
        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.
      • drawLine

        public 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. 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.
        Parameters:
        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.
      • drawString

        public void drawString(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. 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.
        Parameters:
        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.
      • drawCurve

        public void drawCurve(Vector3D[] points)
        Draws a curve in three-space. This is a convenience method that just calls drawCurve(points,points.length).
        See Also:
        drawCurve(Vector3D[], int)
      • drawCurve

        public void drawCurve(Vector3D[] points,             int pointCount)
        Draws a curve in three-space. The curve is drawn by connecting points in a given array of 3D points with line segments. This method is designed to work correctly in stereo views as well as in a standard monocular view; for stereo viewing, the curve is drawn in both the left- and the right-eye view.
        Parameters:
        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.
      • drawCurve

        public void drawCurve(Vector3D[] points,             int startIndex,             int endIndex)
        Draws a curve in three-space. The curve is drawn by connecting points in a given array of 3D points with line segments. This method is designed to work correctly in stereo views as well as in a standard monocular view; for stereo viewing, the curve is drawn in both the left- and the right-eye view. This version of drawCurve makes it possible to draw any contiguous sequence of points on the curve.
        Parameters:
        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.
      • drawCollaredCurve

        public 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. The collars can be used in two ways, either reversed or not reversed. If reverse is false, then the curve is drawn in monocular views by connecting points in a given array of 3D points with line segments, except that where one part of the curve passes over another, the back segment is "broken", crossing-diagram style, to show which curve is in front. (The "break" is actually the result of drawing a wide collar around the curve in the background color.) However, this crossing diagram style is only used in a monocular view, not in stereo views; for stereo viewing, a solid curve is drawn using the 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.

        Parameters:
        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.
      • drawWireframeSurface

        public void drawWireframeSurface(Grid3D surfaceData)
        Draws a surface in wireframe. In general, surfaces should be drawn using the 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.
        Parameters:
        surfaceData - contains a grid of points on the surface
      • drawPixelDirect

        public void drawPixelDirect(Color color,                   int x,                   int y)
        Sets the pixel with pixel coordinates (x,y) to be a spelcified color. Note that this by-passes the support in the View3D class for stereo viewing (that is, x and y are used as untransformed pixel coordinates). The pixel is set in the current off-screen image, which can be either the fullOSI for monocular viewing or either the left or right OSI for stereo viewing. This method is meant mainly for use by lower level drawing methods, such as the phong lighting.
        Overrides:
        drawPixelDirect in class View
        Parameters:
        color - the color for the pixel; if null, the current drawing color is used.
        x - the horizontal pixel coordinate.
        y - the vertical pixel coordinate.
        See Also:
        drawPixel(Vector3D)
      • clip

        public final boolean clip(Vector3D objectPoint)
        This method is used to test whether a point should be clipped. It is valid only during a 3D rendering operation. It is needed in Grid3D and in IFS.

SCaVis 2.1 © jWork.ORG