Class JStereoWindow

All Implemented Interfaces:
ActionListener, ComponentListener, MouseMotionListener, WindowListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, ChangeListener, RootPaneContainer, WindowConstants

Class JStereoWindow:

Creates a stereo viewing window for both ModelTriangleMesh surfaces and arbitrary Group Nodes, including the NodeVolumeTextureRender. Objects are presented on three canvases: left-eye view, right-eye view, and a anaglyph color view. The user can change the eye separation with a slider that adjusts the focal length.

The stereo rendering algorithm for creating the left and right-eye viewing transformations and anaglyph display is based on Paul Bourke's web information at http://astronomy.swin.edu.au/~pbourke/stereographics/

Author:
Alexandra Bokinsky
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Use serialVersionUID for interoperability.
      See Also:
    • m_akUniverse

      private com.sun.j3d.utils.universe.SimpleUniverse[] m_akUniverse
      Three SimpleUniverses, one for each canavas:.
    • m_dEyeSeparation

      private double m_dEyeSeparation
      Original eye separation, read from the canvas.view.physicalbody.
    • m_iCurrentUniverse

      private int m_iCurrentUniverse
      The current universe to be initialized:.
    • m_iStereoUpdateCount

      private int m_iStereoUpdateCount
      First time the stereo canvas is rendered, set to true:.
    • m_kD

      private Dimension m_kD
      BufferedImage Dimensions (power of two).
    • m_kDisplayPane

      private JSplitPane m_kDisplayPane
      The JSplitPane displaying the left and right eye views:.
    • m_kEyeSep_Slider

      private JSlider m_kEyeSep_Slider
      Focal-length, (eye separation) slider.
    • m_kLeftCanvas

      private VolumeCanvas3D m_kLeftCanvas
      Left-eye view canvas:.
    • m_kLeftImagePanel

      private JPanel m_kLeftImagePanel
      Left Image Panel, holds the canvas for the left-eye view:.
    • m_kMainPane

      private JSplitPane m_kMainPane
      The JSplitPane displaying different views and the user-interface:.
    • m_kRGStereo

      private BufferedImage m_kRGStereo
      BufferedImage containing the Anagyphy stereo image:.
    • m_kRightCanvas

      private VolumeCanvas3D m_kRightCanvas
      Right-eye view canvas:.
    • m_kRightImagePanel

      private JPanel m_kRightImagePanel
      Right Image Panel, holds the canvas for the right-eye view:.
    • m_kStereoCanvas

      private VolumeCanvas3D m_kStereoCanvas
      Stereo canvas:.
    • m_kStereoPane

      private JSplitPane m_kStereoPane
      The JSplitPane displaying the left and right eye views and the stereo view:.
    • m_kStereoPanel

      private JPanel m_kStereoPanel
      Stereo Image Panel, holds the canvas for the Anaglyph stereo view:.
    • m_kStereoShape

      private javax.media.j3d.Shape3D m_kStereoShape
      Texture-mapped polygon for displaying the Anaglyph stereo image as a texture:.
  • Constructor Details

    • JStereoWindow

      public JStereoWindow(SurfaceAttributes kSurface, javax.media.j3d.Transform3D kTransform)
      Constructs a JStereoWindow with a ModelTriangleMesh and Transform3D representing the model transformation for the surface.
      Parameters:
      kTransform - the current model transformation (rotation, scale, translation) for the surface.
      kMesh - the displayed surface
    • JStereoWindow

      public JStereoWindow(javax.media.j3d.Group kNode1, javax.media.j3d.Group kNode2, javax.media.j3d.Transform3D kTransform, SurfaceRender kSurface)
      Constructs a JStereoWindow with two nodes, one copy for each of the left and right eye views. The input nodes are identical. The Transform3D represents the model transformation for the nodes.
      Parameters:
      kNode1 - 1st copy of the displayed object (NodeVolumeTextureRender)
      kNode2 - 2nd copy of the displayed object (NodeVolumeTextureRender)
      kTransform - the current model transformation (rotation, scale, translation) for the nodes.
      kSurface - the parent window.
  • Method Details

    • actionPerformed

      public void actionPerformed(ActionEvent kEvent)
      Called when a button is pressed:
      Specified by:
      actionPerformed in interface ActionListener
      Parameters:
      kEvent - action event
    • componentHidden

      public void componentHidden(ComponentEvent e)
      componentHidden.
      Specified by:
      componentHidden in interface ComponentListener
      Parameters:
      e - ComponentEvent
    • componentMoved

      public void componentMoved(ComponentEvent e)
      componentMoved.
      Specified by:
      componentMoved in interface ComponentListener
      Parameters:
      e - ComponentEvent
    • componentResized

      public void componentResized(ComponentEvent e)
      componentResized.
      Specified by:
      componentResized in interface ComponentListener
      Parameters:
      e - ComponentEvent
    • componentShown

      public void componentShown(ComponentEvent e)
      componentShown.
      Specified by:
      componentShown in interface ComponentListener
      Parameters:
      e - ComponentEvent
    • dispose

      public void dispose()
      Deletes all local data members.
      Overrides:
      dispose in class Window
    • mouseDragged

      public void mouseDragged(MouseEvent e)
      mouseDragged.
      Specified by:
      mouseDragged in interface MouseMotionListener
      Parameters:
      e - MouseEvent
    • mouseMoved

      public void mouseMoved(MouseEvent e)
      mouseMoved.
      Specified by:
      mouseMoved in interface MouseMotionListener
      Parameters:
      e - MouseEvent
    • stateChanged

      public void stateChanged(ChangeEvent event)
      Called when the slider values have changed. Reads the new focal-length value and recalculates the viewing transformations for the left and right-eye views.
      Specified by:
      stateChanged in interface ChangeListener
      Parameters:
      event - ChangeEvent state change event.
    • windowActivated

      public void windowActivated(WindowEvent e)
      windowActivated.
      Specified by:
      windowActivated in interface WindowListener
      Parameters:
      e - WindowEvent
    • windowClosed

      public void windowClosed(WindowEvent e)
      windowClosed.
      Specified by:
      windowClosed in interface WindowListener
      Parameters:
      e - WindowEvent
    • windowClosing

      public void windowClosing(WindowEvent e)
      windowClosing Catch the windowClosing event so that the local data memebrs can be destroyed.
      Specified by:
      windowClosing in interface WindowListener
      Parameters:
      e - WindowEvent
    • windowDeactivated

      public void windowDeactivated(WindowEvent e)
      windowDeactivated.
      Specified by:
      windowDeactivated in interface WindowListener
      Parameters:
      e - WindowEvent
    • windowDeiconified

      public void windowDeiconified(WindowEvent e)
      windowDeiconified.
      Specified by:
      windowDeiconified in interface WindowListener
      Parameters:
      e - WindowEvent
    • windowIconified

      public void windowIconified(WindowEvent e)
      windowIconified.
      Specified by:
      windowIconified in interface WindowListener
      Parameters:
      e - WindowEvent
    • windowOpened

      public void windowOpened(WindowEvent e)
      windowOpened.
      Specified by:
      windowOpened in interface WindowListener
      Parameters:
      e - WindowEvent
    • addBranchGroup

      private javax.media.j3d.BranchGroup addBranchGroup(javax.media.j3d.Node kNode, javax.media.j3d.Transform3D kTransform)
      Creates a BranchGroup containing the input Node and Transform3D, and returns the BranchGroup.
      Parameters:
      kNode - the Node to add to the BranchGroup
      kTransform - the transform for the input Node
      Returns:
      the Branch of the SceneGraph containing the node and transform.
    • blendBuffers

      private void blendBuffers(BufferedImage kLeft, BufferedImage kRight)
      Blend two BufferedImages, representing the left and right-eye views into a Red-Cyan stereo anaglyph.
      Parameters:
      kLeft - the frame buffer from the left-eye rendering.
      kRight - the frame buffer from the right-eye rendering. This function does not return a value, but it sets the BufferedImage member variable m_kStereo and the Dimension member variable m_kD.
    • blendColor

      private int blendColor(int iLeftC, int iRightC)
      Blends two packed-integer colors (RGB) to create a Red-Cyan anaglyph.
      Parameters:
      iLeftC - the color from the left-eye view.
      iRightC - the color from the right-eye view.
      Returns:
      the anaglyph color (packed-int) with the red component from the left-eye view and the green and blue components from the right-eye view, creating a Red-Cyan stereo.
    • createCanvas

      private VolumeCanvas3D createCanvas(javax.media.j3d.Node kNode, JPanel kPanel)
      Creates a canvas containing the input Node object, with the input viewing transformation. The canvas is displayed in the input JPanel:
      Parameters:
      kNode - the object displayed in this canvas.
      kPanel - the window panel containing this canvas.
      Returns:
      the new canvas.
    • createTexturedPolygon

      private void createTexturedPolygon()
      Creates the texture-mapped polygon displayed in the stereo canvas. The left and right-eye views are read from the left and right-eye canvases and the images blended into a stereo view. The blended image is used as a texture and displayed on the texture-mapped polygon created in the function:
    • getFrameBuffer

      private void getFrameBuffer(BufferedImage kImage, VolumeCanvas3D kCanvas)
      Read the frame buffer from the input VolumeCanvas3D and store the result in the input BufferedImage:
      Parameters:
      kImage - the image the frame buffer is stored into.
      kCanvas - the canvas from that is read.
    • init

      private void init(javax.media.j3d.BranchGroup kNode1, javax.media.j3d.BranchGroup kNode2)
      Initialize the scene graphs and left, right, and stereo canvases for this JStereoWindow.
      Parameters:
      kNode1 - the left-eye object
      kNode2 - the right-eye object
    • setupInterface

      private void setupInterface()
      Sets up the user interface. "OK" Button and focal-length slider.
    • updateStereo

      private void updateStereo()
      Reads the left and right-eye buffers from the left and right-eye canvases and blends them into the Red-Cyan Anaglyph stereo buffer, which is then texture-mapped on the a polygon and rendered in the stereo canvas.