Class Canvas3D

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class Canvas3D extends Canvas
The Canvas3D class provides a drawing canvas for 3D rendering. It is used either for on-screen rendering or off-screen rendering. Canvas3D is an extension of the AWT Canvas class that users may further subclass to implement additional functionality.

The Canvas3D object extends the Canvas object to include 3D-related information such as the size of the canvas in pixels, the Canvas3D's location, also in pixels, within a Screen3D object, and whether or not the canvas has stereo enabled.

Because all Canvas3D objects contain a reference to a Screen3D object and because Screen3D objects define the size of a pixel in physical units, Java 3D can convert a Canvas3D size in pixels to a physical world size in meters. It can also determine the Canvas3D's position and orientation in the physical world.

On-screen Rendering vs. Off-screen Rendering

The Canvas3D class is used either for on-screen rendering or off-screen rendering. On-screen Canvas3Ds are added to AWT or Swing Container objects like any other canvas. Java 3D automatically and continuously renders to all on-screen canvases that are attached to an active View object. On-screen Canvas3Ds can be either single or double buffered and they can be either stereo or monoscopic.

Off-screen Canvas3Ds must not be added to any Container. Java 3D renders to off-screen canvases in response to the renderOffScreenBuffer method. Off-screen Canvas3Ds are single buffered. However, on many systems, the actual rendering is done to an off-screen hardware buffer or to a 3D library-specific buffer and only copied to the off-screen buffer of the Canvas when the rendering is complete, at "buffer swap" time. Off-screen Canvas3Ds are monoscopic.

The setOffScreenBuffer method sets the off-screen buffer for this Canvas3D. The specified image is written into by the Java 3D renderer. The size of the specified ImageComponent determines the size, in pixels, of this Canvas3D - the size inherited from Component is ignored. Note that the size, physical width, and physical height of the associated Screen3D must be set explicitly prior to rendering. Failure to do so will result in an exception.

The getOffScreenBuffer method retrieves the off-screen buffer for this Canvas3D.

The renderOffScreenBuffer method schedules the rendering of a frame into this Canvas3D's off-screen buffer. The rendering is done from the point of view of the View object to which this Canvas3D has been added. No rendering is performed if this Canvas3D object has not been added to an active View. This method does not wait for the rendering to actually happen. An application that wishes to know when the rendering is complete must either subclass Canvas3D and override the postSwap method, or call waitForOffScreenRendering.

The setOfScreenLocation methods set the location of this off-screen Canvas3D. The location is the upper-left corner of the Canvas3D relative to the upper-left corner of the corresponding off-screen Screen3D. The function of these methods is similar to that of Component.setLocation for on-screen Canvas3D objects. The default location is (0,0).

Accessing and Modifying an Eye's Image Plate Position

A Canvas3D object provides sophisticated applications with access to the eye's position information in head-tracked, room-mounted runtime environments. It also allows applications to manipulate the position of an eye relative to an image plate in non-head-tracked runtime environments.

The setLeftManualEyeInImagePlate and setRightManualEyeInImagePlate methods set the position of the manual left and right eyes in image plate coordinates. These values determine eye placement when a head tracker is not in use and the application is directly controlling the eye position in image plate coordinates. In head-tracked mode or when the windowEyepointPolicy is RELATIVE_TO_FIELD_OF_VIEW or RELATIVE_TO_COEXISTENCE, this value is ignored. When the windowEyepointPolicy is RELATIVE_TO_WINDOW, only the Z value is used.

The getLeftEyeInImagePlate, getRightEyeInImagePlate, and getCenterEyeInImagePlate methods retrieve the actual position of the left eye, right eye, and center eye in image plate coordinates and copy that value into the object provided. The center eye is the fictional eye half-way between the left and right eye. These three values are a function of the windowEyepointPolicy, the tracking enable flag, and the manual left, right, and center eye positions.

Monoscopic View Policy

The setMonoscopicViewPolicy and getMonoscopicViewPolicy methods set and retrieve the policy regarding how Java 3D generates monoscopic view. If the policy is set to View.LEFT_EYE_VIEW, the view generated corresponds to the view as seen from the left eye. If set to View.RIGHT_EYE_VIEW, the view generated corresponds to the view as seen from the right eye. If set to View.CYCLOPEAN_EYE_VIEW, the view generated corresponds to the view as seen from the "center eye," the fictional eye half-way between the left and right eye. The default monoscopic view policy is View.CYCLOPEAN_EYE_VIEW.

Immediate Mode Rendering

Pure immediate-mode rendering provides for those applications and applets that do not want Java 3D to do any automatic rendering of the scene graph. Such applications may not even wish to build a scene graph to represent their graphical data. However, they use Java 3D's attribute objects to set graphics state and Java 3D's geometric objects to render geometry.

A pure immediate mode application must create a minimal set of Java 3D objects before rendering. In addition to a Canvas3D object, the application must create a View object, with its associated PhysicalBody and PhysicalEnvironment objects, and the following scene graph elements: a VirtualUniverse object, a high-resolution Locale object, a BranchGroup node object, a TransformGroup node object with associated transform, and a ViewPlatform leaf node object that defines the position and orientation within the virtual universe that generates the view.

In immediate mode, all rendering is done completely under user control. It is necessary for the user to clear the 3D canvas, render all geometry, and swap the buffers. Additionally, rendering the right and left eye for stereo viewing becomes the sole responsibility of the application. In pure immediate mode, the user must stop the Java 3D renderer, via the Canvas3D object stopRenderer method, prior to adding the Canvas3D object to an active View object (that is, one that is attached to a live ViewPlatform object).

Other Canvas3D methods related to immediate mode rendering are:

    getGraphicsContext3D retrieves the immediate-mode 3D graphics context associated with this Canvas3D. It creates a new graphics context if one does not already exist.

    getGraphics2D retrieves the 2D graphics object associated with this Canvas3D. It creates a new 2D graphics object if one does not already exist.

    swap synchronizes and swaps buffers on a double-buffered canvas for this Canvas3D object. This method should only be called if the Java 3D renderer has been stopped. In the normal case, the renderer automatically swaps the buffer.

Mixed Mode Rendering

Mixing immediate mode and retained or compiled-retained mode requires more structure than pure immediate mode. In mixed mode, the Java 3D renderer is running continuously, rendering the scene graph into the canvas.

Canvas3D methods related to mixed mode rendering are:

    preRender called by the Java 3D rendering loop after clearing the canvas and before any rendering has been done for this frame.

    postRender called by the Java 3D rendering loop after completing all rendering to the canvas for this frame and before the buffer swap.

    postSwap called by the Java 3D rendering loop after completing all rendering to the canvas, and all other canvases associated with this view, for this frame following the buffer swap.

    renderField called by the Java 3D rendering loop during the execution of the rendering loop. It is called once for each field (i.e., once per frame on a mono system or once each for the right eye and left eye on a two-pass stereo system.

The above callback methods are called by the Java 3D rendering system and should not be called by an application directly.

The basic Java 3D stereo rendering loop, executed for each Canvas3D, is as follows:

     clear canvas (both eyes)
     call preRender()                           // user-supplied method
     set left eye view
     render opaque scene graph objects
     call renderField(FIELD_LEFT)               // user-supplied method
     render transparent scene graph objects
     set right eye view
     render opaque scene graph objects again
     call renderField(FIELD_RIGHT)              // user-supplied method
     render transparent scene graph objects again
     call postRender()                          // user-supplied method
     synchronize and swap buffers
     call postSwap()                            // user-supplied method
     

The basic Java 3D monoscopic rendering loop is as follows:

     clear canvas
     call preRender()                            // user-supplied method
     set view
     render opaque scene graph objects
     call renderField(FIELD_ALL)                 // user-supplied method
     render transparent scene graph objects
     call postRender()                           // user-supplied method
     synchronize and swap buffers
     call postSwap()                             // user-supplied method
     

In both cases, the entire loop, beginning with clearing the canvas and ending with swapping the buffers, defines a frame. The application is given the opportunity to render immediate-mode geometry at any of the clearly identified spots in the rendering loop. A user specifies his or her own rendering methods by extending the Canvas3D class and overriding the preRender, postRender, postSwap, and/or renderField methods. Updates to live Geometry, Texture, and ImageComponent objects in the scene graph are not allowed from any of these callback methods.

Serialization

Canvas3D does not support serialization. An attempt to serialize a Canvas3D object will result in an UnsupportedOperationException being thrown.

Additional Information

For more information, see the Introduction to the Java 3D API and View Model documents.

See Also:
  • Field Details

    • FIELD_LEFT

      public static final int FIELD_LEFT
      Specifies the left field of a field-sequential stereo rendering loop. A left field always precedes a right field.
      See Also:
    • FIELD_RIGHT

      public static final int FIELD_RIGHT
      Specifies the right field of a field-sequential stereo rendering loop. A right field always follows a left field.
      See Also:
    • FIELD_ALL

      public static final int FIELD_ALL
      Specifies a single-field rendering loop.
      See Also:
  • Constructor Details

    • Canvas3D

      public Canvas3D(GraphicsConfiguration graphicsConfiguration)
      Constructs and initializes a new Canvas3D object that Java 3D can render into. The following Canvas3D attributes are initialized to default values as shown:
        left manual eye in image plate : (0.142, 0.135, 0.4572)
        right manual eye in image plate : (0.208, 0.135, 0.4572)
        stereo enable : true
        double buffer enable : true
        monoscopic view policy : View.CYCLOPEAN_EYE_VIEW
        off-screen mode : false
        off-screen buffer : null
        off-screen location : (0,0)
      Parameters:
      graphicsConfiguration - a valid GraphicsConfiguration object that will be used to create the canvas. This object should not be null and should be created using a GraphicsConfigTemplate3D or the getPreferredConfiguration() method of the SimpleUniverse utility. For backward compatibility with earlier versions of Java 3D, a null or default GraphicsConfiguration will still work when used to create a Canvas3D on the default screen, but an error message will be printed. A NullPointerException or IllegalArgumentException will be thrown in a subsequent release.
      Throws:
      IllegalArgumentException - if the specified GraphicsConfiguration does not support 3D rendering
    • Canvas3D

      public Canvas3D(GraphicsConfiguration graphicsConfiguration, boolean offScreen)
      Constructs and initializes a new Canvas3D object that Java 3D can render into.
      Parameters:
      graphicsConfiguration - a valid GraphicsConfiguration object that will be used to create the canvas. This must be created either with a GraphicsConfigTemplate3D or by using the getPreferredConfiguration() method of the SimpleUniverse utility.
      offScreen - a flag that indicates whether this canvas is an off-screen 3D rendering canvas. Note that if offScreen is set to true, this Canvas3D object cannot be used for normal rendering; it should not be added to any Container object.
      Throws:
      NullPointerException - if the GraphicsConfiguration is null.
      IllegalArgumentException - if the specified GraphicsConfiguration does not support 3D rendering
      Since:
      Java 3D 1.2
  • Method Details

    • paint

      public void paint(Graphics g)
      Canvas3D uses the paint callback to track when it is possible to render into the canvas. Subclasses of Canvas3D that override this method need to call super.paint() in their paint method for Java 3D to function properly.
      Overrides:
      paint in class Canvas
      Parameters:
      g - the graphics context
    • addNotify

      public void addNotify()
      Canvas3D uses the addNotify callback to track when it is added to a container. Subclasses of Canvas3D that override this method need to call super.addNotify() in their addNotify() method for Java 3D to function properly.
      Overrides:
      addNotify in class Canvas
    • removeNotify

      public void removeNotify()
      Canvas3D uses the removeNotify callback to track when it is removed from a container. Subclasses of Canvas3D that override this method need to call super.removeNotify() in their removeNotify() method for Java 3D to function properly.
      Overrides:
      removeNotify in class Component
    • getScreen3D

      public Screen3D getScreen3D()
      Retrieve the Screen3D object that this Canvas3D is attached to. If this Canvas3D is an off-screen buffer, a new Screen3D object is created corresponding to the off-screen buffer.
      Returns:
      the 3D screen object that this Canvas3D is attached to
    • getGraphicsContext3D

      public GraphicsContext3D getGraphicsContext3D()
      Get the immediate mode 3D graphics context associated with this Canvas3D. A new graphics context object is created if one does not already exist.
      Returns:
      a GraphicsContext3D object that can be used for immediate mode rendering to this Canvas3D.
    • getGraphics2D

      public J3DGraphics2D getGraphics2D()
      Get the 2D graphics object associated with this Canvas3D. A new 2D graphics object is created if one does not already exist.
      Returns:
      a Graphics2D object that can be used for Java 2D rendering into this Canvas3D.
      Since:
      Java 3D 1.2
    • preRender

      public void preRender()
      This routine is called by the Java 3D rendering loop after clearing the canvas and before any rendering has been done for this frame. Applications that wish to perform operations in the rendering loop, prior to any actual rendering may override this function.

      Updates to live Geometry, Texture, and ImageComponent objects in the scene graph are not allowed from this method.

      NOTE: Applications should not call this method.

    • postRender

      public void postRender()
      This routine is called by the Java 3D rendering loop after completing all rendering to the canvas for this frame and before the buffer swap. Applications that wish to perform operations in the rendering loop, following any actual rendering may override this function.

      Updates to live Geometry, Texture, and ImageComponent objects in the scene graph are not allowed from this method.

      NOTE: Applications should not call this method.

    • postSwap

      public void postSwap()
      This routine is called by the Java 3D rendering loop after completing all rendering to the canvas, and all other canvases associated with this view, for this frame following the buffer swap. Applications that wish to perform operations at the very end of the rendering loop may override this function. In off-screen mode, all rendering is copied to the off-screen buffer before this method is called.

      Updates to live Geometry, Texture, and ImageComponent objects in the scene graph are not allowed from this method.

      NOTE: Applications should not call this method.

    • renderField

      public void renderField(int fieldDesc)
      This routine is called by the Java 3D rendering loop during the execution of the rendering loop. It is called once for each field (i.e., once per frame on a mono system or once each for the right eye and left eye on a two-pass stereo system. This is intended for use by applications that want to mix retained/compiled-retained mode rendering with some immediate mode rendering. Applications that wish to perform operations during the rendering loop, may override this function.

      Updates to live Geometry, Texture, and ImageComponent objects in the scene graph are not allowed from this method.

      NOTE: Applications should not call this method.

      Parameters:
      fieldDesc - field description, one of: FIELD_LEFT, FIELD_RIGHT or FIELD_ALL. Applications that wish to work correctly in stereo mode should render the same image for both FIELD_LEFT and FIELD_RIGHT calls. If Java 3D calls the renderer with FIELD_ALL then the immediate mode rendering only needs to be done once.
    • stopRenderer

      public final void stopRenderer()
      Stop the Java 3D renderer on this Canvas3D object. If the Java 3D renderer is currently running, the rendering will be synchronized before being stopped. No further rendering will be done to this canvas by Java 3D until the renderer is started again. In pure immediate mode this method should be called prior to adding this canvas to an active View object.
      Throws:
      IllegalStateException - if this Canvas3D is in off-screen mode.
    • startRenderer

      public final void startRenderer()
      Start the Java 3D renderer on this Canvas3D object. If the Java 3D renderer is not currently running, any rendering to other Canvas3D objects sharing the same View will be synchronized before this Canvas3D's renderer is (re)started. When a Canvas3D is created, it is initially marked as being started. This means that as soon as the Canvas3D is added to an active View object, the rendering loop will render the scene graph to the canvas.
    • isRendererRunning

      public final boolean isRendererRunning()
      Retrieves the state of the renderer for this Canvas3D object.
      Returns:
      the state of the renderer
      Since:
      Java 3D 1.2
    • isOffScreen

      public boolean isOffScreen()
      Retrieves a flag indicating whether this Canvas3D is an off-screen canvas.
      Returns:
      true if this Canvas3D is an off-screen canvas; false if this is an on-screen canvas.
      Since:
      Java 3D 1.2
    • setOffScreenBuffer

      public void setOffScreenBuffer(ImageComponent2D buffer)
      Sets the off-screen buffer for this Canvas3D. The specified image is written into by the Java 3D renderer. The size of the specified ImageComponent determines the size, in pixels, of this Canvas3D--the size inherited from Component is ignored.

      NOTE: the size, physical width, and physical height of the associated Screen3D must be set explicitly prior to rendering. Failure to do so will result in an exception.

      Parameters:
      buffer - the image component that will be rendered into by subsequent calls to renderOffScreenBuffer. The image component must not be part of a live scene graph, nor may it subsequently be made part of a live scene graph while being used as an off-screen buffer; an IllegalSharingException is thrown in such cases. The buffer may be null, indicating that the previous off-screen buffer is released without a new buffer being set.
      Throws:
      IllegalStateException - if this Canvas3D is not in off-screen mode.
      RestrictedAccessException - if an off-screen rendering is in process for this Canvas3D.
      IllegalSharingException - if the specified ImageComponent2D is part of a live scene graph
      IllegalSharingException - if the specified ImageComponent2D is being used by an immediate mode context, or by another Canvas3D as an off-screen buffer.
      IllegalArgumentException - if the image class of the specified ImageComponent2D is not ImageClass.BUFFERED_IMAGE.
      IllegalArgumentException - if the specified ImageComponent2D is in by-reference mode and its RenderedImage is null.
      IllegalArgumentException - if the ImageComponent2D format is not a 3-component format (e.g., FORMAT_RGB) or a 4-component format (e.g., FORMAT_RGBA).
      Since:
      Java 3D 1.2
      See Also:
    • getOffScreenBuffer

      public ImageComponent2D getOffScreenBuffer()
      Retrieves the off-screen buffer for this Canvas3D.
      Returns:
      the current off-screen buffer for this Canvas3D.
      Throws:
      IllegalStateException - if this Canvas3D is not in off-screen mode.
      Since:
      Java 3D 1.2
    • renderOffScreenBuffer

      public void renderOffScreenBuffer()
      Schedules the rendering of a frame into this Canvas3D's off-screen buffer. The rendering is done from the point of view of the View object to which this Canvas3D has been added. No rendering is performed if this Canvas3D object has not been added to an active View. This method does not wait for the rendering to actually happen. An application that wishes to know when the rendering is complete must either subclass Canvas3D and override the postSwap method, or call waitForOffScreenRendering.
      Throws:
      NullPointerException - if the off-screen buffer is null.
      IllegalStateException - if this Canvas3D is not in off-screen mode, or if either the width or the height of the associated Screen3D's size is invalid input: '<'= 0, or if the associated Screen3D's physical width or height is invalid input: '<'= 0.
      RestrictedAccessException - if an off-screen rendering is already in process for this Canvas3D or if the Java 3D renderer is stopped.
      Since:
      Java 3D 1.2
      See Also:
    • waitForOffScreenRendering

      public void waitForOffScreenRendering()
      Waits for this Canvas3D's off-screen rendering to be done. This method will wait until the postSwap method of this off-screen Canvas3D has completed. If this Canvas3D has not been added to an active view or if the renderer is stopped for this Canvas3D, then this method will return immediately. This method must not be called from a render callback method of an off-screen Canvas3D.
      Throws:
      IllegalStateException - if this Canvas3D is not in off-screen mode, or if this method is called from a render callback method of an off-screen Canvas3D.
      Since:
      Java 3D 1.2
      See Also:
    • setOffScreenLocation

      public void setOffScreenLocation(int x, int y)
      Sets the location of this off-screen Canvas3D. The location is the upper-left corner of the Canvas3D relative to the upper-left corner of the corresponding off-screen Screen3D. The function of this method is similar to that of Component.setLocation for on-screen Canvas3D objects. The default location is (0,0).
      Parameters:
      x - the x coordinate of the upper-left corner of the new location.
      y - the y coordinate of the upper-left corner of the new location.
      Throws:
      IllegalStateException - if this Canvas3D is not in off-screen mode.
      Since:
      Java 3D 1.2
    • setOffScreenLocation

      public void setOffScreenLocation(Point p)
      Sets the location of this off-screen Canvas3D. The location is the upper-left corner of the Canvas3D relative to the upper-left corner of the corresponding off-screen Screen3D. The function of this method is similar to that of Component.setLocation for on-screen Canvas3D objects. The default location is (0,0).
      Parameters:
      p - the point defining the upper-left corner of the new location.
      Throws:
      IllegalStateException - if this Canvas3D is not in off-screen mode.
      Since:
      Java 3D 1.2
    • getOffScreenLocation

      public Point getOffScreenLocation()
      Retrieves the location of this off-screen Canvas3D. The location is the upper-left corner of the Canvas3D relative to the upper-left corner of the corresponding off-screen Screen3D. The function of this method is similar to that of Component.getLocation for on-screen Canvas3D objects.
      Returns:
      a new point representing the upper-left corner of the location of this off-screen Canvas3D.
      Throws:
      IllegalStateException - if this Canvas3D is not in off-screen mode.
      Since:
      Java 3D 1.2
    • getOffScreenLocation

      public Point getOffScreenLocation(Point rv)
      Retrieves the location of this off-screen Canvas3D and stores it in the specified Point object. The location is the upper-left corner of the Canvas3D relative to the upper-left corner of the corresponding off-screen Screen3D. The function of this method is similar to that of Component.getLocation for on-screen Canvas3D objects. This version of getOffScreenLocation is useful if the caller wants to avoid allocating a new Point object on the heap.
      Parameters:
      rv - Point object into which the upper-left corner of the location of this off-screen Canvas3D is copied. If rv is null, a new Point is allocated.
      Returns:
      rv
      Throws:
      IllegalStateException - if this Canvas3D is not in off-screen mode.
      Since:
      Java 3D 1.2
    • swap

      public void swap()
      Synchronize and swap buffers on a double buffered canvas for this Canvas3D object. This method should only be called if the Java 3D renderer has been stopped. In the normal case, the renderer automatically swaps the buffer. This method calls the flush(true) methods of the associated 2D and 3D graphics contexts, if they have been allocated.
      Throws:
      RestrictedAccessException - if the Java 3D renderer is running.
      IllegalStateException - if this Canvas3D is in off-screen mode.
      See Also:
    • setLeftManualEyeInImagePlate

      public void setLeftManualEyeInImagePlate(javax.vecmath.Point3d position)
      Sets the position of the manual left eye in image-plate coordinates. This value determines eye placement when a head tracker is not in use and the application is directly controlling the eye position in image-plate coordinates. In head-tracked mode or when the windowEyePointPolicy is RELATIVE_TO_FIELD_OF_VIEW or RELATIVE_TO_COEXISTENCE, this value is ignored. When the windowEyepointPolicy is RELATIVE_TO_WINDOW only the Z value is used.
      Parameters:
      position - the new manual left eye position
    • setRightManualEyeInImagePlate

      public void setRightManualEyeInImagePlate(javax.vecmath.Point3d position)
      Sets the position of the manual right eye in image-plate coordinates. This value determines eye placement when a head tracker is not in use and the application is directly controlling the eye position in image-plate coordinates. In head-tracked mode or when the windowEyePointPolicy is RELATIVE_TO_FIELD_OF_VIEW or RELATIVE_TO_COEXISTENCE, this value is ignored. When the windowEyepointPolicy is RELATIVE_TO_WINDOW only the Z value is used.
      Parameters:
      position - the new manual right eye position
    • getLeftManualEyeInImagePlate

      public void getLeftManualEyeInImagePlate(javax.vecmath.Point3d position)
      Retrieves the position of the user-specified, manual left eye in image-plate coordinates and copies that value into the object provided.
      Parameters:
      position - the object that will receive the position
    • getRightManualEyeInImagePlate

      public void getRightManualEyeInImagePlate(javax.vecmath.Point3d position)
      Retrieves the position of the user-specified, manual right eye in image-plate coordinates and copies that value into the object provided.
      Parameters:
      position - the object that will receive the position
    • getLeftEyeInImagePlate

      public void getLeftEyeInImagePlate(javax.vecmath.Point3d position)
      Retrieves the actual position of the left eye in image-plate coordinates and copies that value into the object provided. This value is a function of the windowEyepointPolicy, the tracking enable flag, and the manual left eye position.
      Parameters:
      position - the object that will receive the position
    • getRightEyeInImagePlate

      public void getRightEyeInImagePlate(javax.vecmath.Point3d position)
      Retrieves the actual position of the right eye in image-plate coordinates and copies that value into the object provided. This value is a function of the windowEyepointPolicy, the tracking enable flag, and the manual right eye position.
      Parameters:
      position - the object that will receive the position
    • getCenterEyeInImagePlate

      public void getCenterEyeInImagePlate(javax.vecmath.Point3d position)
      Retrieves the actual position of the center eye in image-plate coordinates and copies that value into the object provided. The center eye is the fictional eye half-way between the left and right eye. This value is a function of the windowEyepointPolicy, the tracking enable flag, and the manual right and left eye positions.
      Parameters:
      position - the object that will receive the position
      See Also:
    • getImagePlateToVworld

      public void getImagePlateToVworld(Transform3D t)
      Retrieves the current ImagePlate coordinates to Virtual World coordinates transform and places it into the specified object.
      Parameters:
      t - the Transform3D object that will receive the transform
    • getPixelLocationInImagePlate

      public void getPixelLocationInImagePlate(int x, int y, javax.vecmath.Point3d imagePlatePoint)
      Computes the position of the specified AWT pixel value in image-plate coordinates and copies that value into the object provided.
      Parameters:
      x - the X coordinate of the pixel relative to the upper-left hand corner of the window.
      y - the Y coordinate of the pixel relative to the upper-left hand corner of the window.
      imagePlatePoint - the object that will receive the position in physical image plate coordinates (relative to the lower-left corner of the screen).
    • getPixelLocationInImagePlate

      public void getPixelLocationInImagePlate(javax.vecmath.Point2d pixelLocation, javax.vecmath.Point3d imagePlatePoint)
      Computes the position of the specified AWT pixel value in image-plate coordinates and copies that value into the object provided.
      Parameters:
      pixelLocation - the coordinates of the pixel relative to the upper-left hand corner of the window.
      imagePlatePoint - the object that will receive the position in physical image plate coordinates (relative to the lower-left corner of the screen).
      Since:
      Java 3D 1.2
    • getPixelLocationFromImagePlate

      public void getPixelLocationFromImagePlate(javax.vecmath.Point3d imagePlatePoint, javax.vecmath.Point2d pixelLocation)
      Projects the specified point from image plate coordinates into AWT pixel coordinates. The AWT pixel coordinates are copied into the object provided.
      Parameters:
      imagePlatePoint - the position in physical image plate coordinates (relative to the lower-left corner of the screen).
      pixelLocation - the object that will receive the coordinates of the pixel relative to the upper-left hand corner of the window.
      Since:
      Java 3D 1.2
    • getVworldProjection

      public void getVworldProjection(Transform3D leftProjection, Transform3D rightProjection)
      Copies the current Vworld projection transform for each eye into the specified Transform3D objects. This transform takes points in virtual world coordinates and projects them into clipping coordinates, which are in the range [-1,1] in X, Y, and Z after clipping and perspective division. In monoscopic mode, the same projection transform will be copied into both the right and left eye Transform3D objects.
      Parameters:
      leftProjection - the Transform3D object that will receive a copy of the current projection transform for the left eye.
      rightProjection - the Transform3D object that will receive a copy of the current projection transform for the right eye.
      Since:
      Java 3D 1.3
    • getInverseVworldProjection

      public void getInverseVworldProjection(Transform3D leftInverseProjection, Transform3D rightInverseProjection)
      Copies the inverse of the current Vworld projection transform for each eye into the specified Transform3D objects. This transform takes points in clipping coordinates, which are in the range [-1,1] in X, Y, and Z after clipping and perspective division, and transforms them into virtual world coordinates. In monoscopic mode, the same inverse projection transform will be copied into both the right and left eye Transform3D objects.
      Parameters:
      leftInverseProjection - the Transform3D object that will receive a copy of the current inverse projection transform for the left eye.
      rightInverseProjection - the Transform3D object that will receive a copy of the current inverse projection transform for the right eye.
      Since:
      Java 3D 1.3
    • getPhysicalWidth

      public double getPhysicalWidth()
      Retrieves the physical width of this canvas window in meters.
      Returns:
      the physical window width in meters.
    • getPhysicalHeight

      public double getPhysicalHeight()
      Retrieves the physical height of this canvas window in meters.
      Returns:
      the physical window height in meters.
    • getVworldToImagePlate

      public void getVworldToImagePlate(Transform3D t)
      Retrieves the current Virtual World coordinates to ImagePlate coordinates transform and places it into the specified object.
      Parameters:
      t - the Transform3D object that will receive the transform
    • getView

      public View getView()
      Gets view that points to this Canvas3D.
      Returns:
      view object that points to this Canvas3D
    • getStereoAvailable

      public boolean getStereoAvailable()
      Returns a status flag indicating whether or not stereo is available. This is equivalent to:
        ((Boolean)queryProperties(). get("stereoAvailable")). booleanValue()
      Returns:
      a flag indicating whether stereo is available
    • setStereoEnable

      public void setStereoEnable(boolean flag)
      Turns stereo on or off. Note that this attribute is used only when stereo is available. Enabling stereo on a Canvas3D that does not support stereo has no effect.
      Parameters:
      flag - enables or disables the display of stereo
      See Also:
    • getStereoEnable

      public boolean getStereoEnable()
      Returns a status flag indicating whether or not stereo is enabled.
      Returns:
      a flag indicating whether stereo is enabled
    • setMonoscopicViewPolicy

      public void setMonoscopicViewPolicy(int policy)
      Specifies how Java 3D generates monoscopic view. If set to View.LEFT_EYE_VIEW, the view generated corresponds to the view as seen from the left eye. If set to View.RIGHT_EYE_VIEW, the view generated corresponds to the view as seen from the right eye. If set to View.CYCLOPEAN_EYE_VIEW, the view generated corresponds to the view as seen from the 'center eye', the fictional eye half-way between the left and right eye. The default monoscopic view policy is View.CYCLOPEAN_EYE_VIEW.

      NOTE: for backward compatibility with Java 3D 1.1, if this attribute is set to its default value of View.CYCLOPEAN_EYE_VIEW, the monoscopic view policy in the View object will be used. An application should not use both the deprecated View method and this Canvas3D method at the same time.

      Parameters:
      policy - one of View.LEFT_EYE_VIEW, View.RIGHT_EYE_VIEW, or View.CYCLOPEAN_EYE_VIEW.
      Throws:
      IllegalStateException - if the specified policy is CYCLOPEAN_EYE_VIEW, the canvas is a stereo canvas, and the viewPolicy for the associated view is HMD_VIEW
      Since:
      Java 3D 1.2
    • getMonoscopicViewPolicy

      public int getMonoscopicViewPolicy()
      Returns policy on how Java 3D generates monoscopic view.
      Returns:
      policy one of View.LEFT_EYE_VIEW, View.RIGHT_EYE_VIEW or View.CYCLOPEAN_EYE_VIEW.
      Since:
      Java 3D 1.2
    • getDoubleBufferAvailable

      public boolean getDoubleBufferAvailable()
      Returns a status flag indicating whether or not double buffering is available. This is equivalent to:
        ((Boolean)queryProperties(). get("doubleBufferAvailable")). booleanValue()
      Returns:
      a flag indicating whether double buffering is available.
    • setDoubleBufferEnable

      public void setDoubleBufferEnable(boolean flag)
      Turns double buffering on or off. If double buffering is off, all drawing is to the front buffer and no buffer swap is done between frames. It should be stressed that running Java 3D with double buffering disabled is not recommended. Enabling double buffering on a Canvas3D that does not support double buffering has no effect.
      Parameters:
      flag - enables or disables double buffering.
      See Also:
    • getDoubleBufferEnable

      public boolean getDoubleBufferEnable()
      Returns a status flag indicating whether or not double buffering is enabled.
      Returns:
      a flag indicating if double buffering is enabled.
    • getSceneAntialiasingAvailable

      public boolean getSceneAntialiasingAvailable()
      Returns a status flag indicating whether or not scene antialiasing is available. This is equivalent to:
        ((Boolean)queryProperties(). get("sceneAntialiasingAvailable")). booleanValue()
      Returns:
      a flag indicating whether scene antialiasing is available.
    • isShadingLanguageSupported

      public boolean isShadingLanguageSupported(int shadingLanguage)
      Returns a flag indicating whether or not the specified shading language is supported. A ShaderError will be generated if an unsupported shading language is used.
      Parameters:
      shadingLanguage - the shading language being queried, one of: Shader.SHADING_LANGUAGE_GLSL or Shader.SHADING_LANGUAGE_CG.
      Returns:
      true if the specified shading language is supported, false otherwise.
      Since:
      Java 3D 1.4
    • queryProperties

      public final Map queryProperties()
      Returns a read-only Map object containing key-value pairs that define various properties for this Canvas3D. All of the keys are String objects. The values are key-specific, but most will be Boolean, Integer, Float, Double, or String objects.

      The currently defined keys are:

        Key (String) Value Type
        shadingLanguageCg Boolean
        shadingLanguageGLSL Boolean
        doubleBufferAvailable Boolean
        stereoAvailable Boolean
        sceneAntialiasingAvailable Boolean
        sceneAntialiasingNumPasses Integer
        stencilSize Integer
        texture3DAvailable Boolean
        textureColorTableSize Integer
        textureLodRangeAvailable Boolean
        textureLodOffsetAvailable Boolean
        textureWidthMax Integer
        textureHeightMax Integer
        textureBoundaryWidthMax Integer
        textureEnvCombineAvailable Boolean
        textureCombineDot3Available Boolean
        textureCombineSubtractAvailable Boolean
        textureCoordSetsMax Integer
        textureUnitStateMax Integer
        textureImageUnitsMax Integer
        textureImageUnitsVertexMax Integer
        textureImageUnitsCombinedMax Integer
        textureCubeMapAvailable Boolean
        textureDetailAvailable Boolean
        textureSharpenAvailable Boolean
        textureFilter4Available Boolean
        textureAnisotropicFilterDegreeMax Float
        textureNonPowerOfTwoAvailable Boolean
        vertexAttrsMax Integer
        compressedGeometry.majorVersionNumber Integer
        compressedGeometry.minorVersionNumber Integer
        compressedGeometry.minorMinorVersionNumber Integer
        native.version String

      The descriptions of the values returned for each key are as follows:

      • shadingLanguageCg
          A Boolean indicating whether or not Cg shading Language is available for this Canvas3D.
      • shadingLanguageGLSL
          A Boolean indicating whether or not GLSL shading Language is available for this Canvas3D.
      • doubleBufferAvailable
          A Boolean indicating whether or not double buffering is available for this Canvas3D. This is equivalent to the getDoubleBufferAvailable method. If this flag is false, the Canvas3D will be rendered in single buffer mode; requests to enable double buffering will be ignored.
      • stereoAvailable
          A Boolean indicating whether or not stereo is available for this Canvas3D. This is equivalent to the getStereoAvailable method. If this flag is false, the Canvas3D will be rendered in monoscopic mode; requests to enable stereo will be ignored.
      • sceneAntialiasingAvailable
          A Boolean indicating whether or not scene antialiasing is available for this Canvas3D. This is equivalent to the getSceneAntialiasingAvailable method. If this flag is false, requests to enable scene antialiasing will be ignored.
      • sceneAntialiasingNumPasses
          An Integer indicating the number of passes scene antialiasing requires to render a single frame for this Canvas3D. If this value is zero, scene antialiasing is not supported. If this value is one, multisampling antialiasing is used. Otherwise, the number indicates the number of rendering passes needed.
      • stencilSize
          An Integer indicating the number of stencil bits that are available for this Canvas3D.
      • texture3DAvailable
          A Boolean indicating whether or not 3D Texture mapping is available for this Canvas3D. If this flag is false, 3D texture mapping is either not supported by the underlying rendering layer or is otherwise unavailable for this particular Canvas3D. All use of 3D texture mapping will be ignored in this case.
      • textureColorTableSize
          An Integer indicating the maximum size of the texture color table for this Canvas3D. If the size is 0, the texture color table is either not supported by the underlying rendering layer or is otherwise unavailable for this particular Canvas3D. An attempt to use a texture color table larger than textureColorTableSize will be ignored; no color lookup will be performed.
      • textureLodRangeAvailable
          A Boolean indicating whether or not setting only a subset of mipmap levels and setting a range of texture LOD are available for this Canvas3D. If it indicates false, setting a subset of mipmap levels and setting a texture LOD range are not supported by the underlying rendering layer, and an attempt to set base level, or maximum level, or minimum LOD, or maximum LOD will be ignored. In this case, images for all mipmap levels must be defined for the texture to be valid.
      • textureLodOffsetAvailable
          A Boolean indicating whether or not setting texture LOD offset is available for this Canvas3D. If it indicates false, setting texture LOD offset is not supported by the underlying rendering layer, and an attempt to set the texture LOD offset will be ignored.
      • textureWidthMax
          An Integer indicating the maximum texture width supported by this Canvas3D. If the width of a texture exceeds the maximum texture width for a Canvas3D, then the texture will be effectively disabled for that Canvas3D.
      • textureHeightMax
          An Integer indicating the maximum texture height supported by this Canvas3D. If the height of a texture exceeds the maximum texture height for a Canvas3D, then the texture will be effectively disabled for that Canvas3D.
      • textureBoundaryWidthMax
          An Integer indicating the maximum texture boundary width supported by the underlying rendering layer for this Canvas3D. If the maximum supported texture boundary width is 0, then texture boundary is not supported by the underlying rendering layer. An attempt to specify a texture boundary width > the textureBoundaryWidthMax will effectively disable the texture.
      • textureEnvCombineAvailable
          A Boolean indicating whether or not texture environment combine operation is supported for this Canvas3D. If it indicates false, then texture environment combine is not supported by the underlying rendering layer, and an attempt to specify COMBINE as the texture mode will be ignored. The texture mode in effect will be REPLACE.
      • textureCombineDot3Available
          A Boolean indicating whether or not texture combine mode COMBINE_DOT3 is supported for this Canvas3D. If it indicates false, then texture combine mode COMBINE_DOT3 is not supported by the underlying rendering layer, and an attempt to specify COMBINE_DOT3 as the texture combine mode will be ignored. The texture combine mode in effect will be COMBINE_REPLACE.
      • textureCombineSubtractAvailable
          A Boolean indicating whether or not texture combine mode COMBINE_SUBTRACT is supported for this Canvas3D. If it indicates false, then texture combine mode COMBINE_SUBTRACT is not supported by the underlying rendering layer, and an attempt to specify COMBINE_SUBTRACT as the texture combine mode will be ignored. The texture combine mode in effect will be COMBINE_REPLACE.
      • textureCoordSetsMax
          An Integer indicating the maximum number of texture coordinate sets supported by the underlying rendering layer.
      • textureUnitStateMax
          An Integer indicating the maximum number of fixed-function texture units supported by the underlying rendering layer. If the number of application-sepcified texture unit states exceeds the maximum number for a Canvas3D, and the fixed-function rendering pipeline is used, then the texture will be effectively disabled for that Canvas3D.
      • textureImageUnitsMax
          An Integer indicating the maximum number of texture image units that can be accessed by the fragment shader when programmable shaders are used.
      • textureImageUnitsVertexMax
          An Integer indicating the maximum number of texture image units that can be accessed by the vertex shader when programmable shaders are used.
      • textureImageUnitsCombinedMax
          An Integer indicating the combined maximum number of texture image units that can be accessed by the vertex shader and the fragment shader when programmable shaders are used.
      • textureCubeMapAvailable
          A Boolean indicating whether or not texture cube map is supported for this Canvas3D. If it indicates false, then texture cube map is not supported by the underlying rendering layer, and an attempt to specify NORMAL_MAP or REFLECTION_MAP as the texture generation mode will be ignored. The texture generation mode in effect will be SPHERE_MAP.
      • textureDetailAvailable
          A Boolean indicating whether or not detail texture is supported for this Canvas3D. If it indicates false, then detail texture is not supported by the underlying rendering layer, and an attempt to specify LINEAR_DETAIL, LINEAR_DETAIL_ALPHA or LINEAR_DETAIL_RGB as the texture magnification filter mode will be ignored. The texture magnification filter mode in effect will be BASE_LEVEL_LINEAR. As of Java 3D 1.5, this property is always false.
      • textureSharpenAvailable
          A Boolean indicating whether or not sharpen texture is supported for this Canvas3D. If it indicates false, then sharpen texture is not supported by the underlying rendering layer, and an attempt to specify LINEAR_SHARPEN, LINEAR_SHARPEN_ALPHA or LINEAR_SHARPEN_RGB as the texture magnification filter mode will be ignored. The texture magnification filter mode in effect will be BASE_LEVEL_LINEAR.
      • textureFilter4Available
          A Boolean indicating whether or not filter4 is supported for this Canvas3D. If it indicates flase, then filter4 is not supported by the underlying rendering layer, and an attempt to specify FILTER_4 as the texture minification filter mode or texture magnification filter mode will be ignored. The texture filter mode in effect will be BASE_LEVEL_LINEAR.
      • textureAnisotropicFilterDegreeMax
          A Float indicating the maximum degree of anisotropic filter available for this Canvas3D. If it indicates 1.0, setting anisotropic filter is not supported by the underlying rendering layer, and an attempt to set anisotropic filter degree will be ignored.
      • textureNonPowerOfTwoAvailable
          A Boolean indicating whether or not texture dimensions that are not powers of two are supported for for this Canvas3D. If it indicates false, then textures with non power of two sizes will be ignored. Set the property j3d.textureEnforcePowerOfTwo to revert to the pre-1.5 behavior of throwing exceptions for non power of two textures.
      • vertexAttrsMax
          An Integer indicating the maximum number of vertex attributes supported by the underlying rendering layer. This is in addition to the vertex coordinate (position), color, normal, and so forth.
      • compressedGeometry.majorVersionNumber
        compressedGeometry.minorVersionNumber
        compressedGeometry.minorMinorVersionNumber
          Integers indicating the major, minor, and minor-minor version numbers, respectively, of the version of compressed geometry supported by this version of Java 3D.
      • native.version
          A String indicating the version number of the native graphics library. The format of this string is defined by the native library.
      Returns:
      the properties of this Canavs3D
      Since:
      Java 3D 1.2
    • getSize

      public Dimension getSize()
      Overrides:
      getSize in class Component
    • getSize

      public Dimension getSize(Dimension rv)
      Overrides:
      getSize in class Component
    • getLocationOnScreen

      public Point getLocationOnScreen()
      Overrides:
      getLocationOnScreen in class Component
    • getX

      public int getX()
      Overrides:
      getX in class Component
    • getY

      public int getY()
      Overrides:
      getY in class Component
    • getWidth

      public int getWidth()
      Overrides:
      getWidth in class Component
    • getHeight

      public int getHeight()
      Overrides:
      getHeight in class Component
    • getLocation

      public Point getLocation(Point rv)
      Overrides:
      getLocation in class Component
    • getLocation

      public Point getLocation()
      Overrides:
      getLocation in class Component
    • getBounds

      public Rectangle getBounds()
      Overrides:
      getBounds in class Component
    • getBounds

      public Rectangle getBounds(Rectangle rv)
      Overrides:
      getBounds in class Component