I have a GeForce2 GTS graphics card that has been patched to a 'Quadro2 Pro' by 
RivaTuner.
This enables quad-buffered OpenGL stereo on Win2000/XP.
On my Win2000 partition, if I type the command :   java -Dj3d.stereo=REQUIRED 
HelloUniverse
I see a stereo rotating cube when viewing with my cordless (infra-red) shutter glasses.
So, all of that works.

I simply want to display a Left.jpg and Right.jpg (slightly separated on the screen) 
and activate page-flipping.
There is very little information on this.
However, in the archives 
(http://archives.java.sun.com/cgi-bin/wa?A2=ind0202&L=java3d-interest&F=&S=&P=16400) 
the code
below was submitted by Oleg Pariser (of JPL) and Sun agreed there was a bug.
If I run the code (with the lines included that are meant to fix the bug), my left eye 
sees the Right.jpg and the right
eye does not see anything.

As 'StereoCanvas' eventually appeared in the package jpl.mipl.jade.stereo

http://www-mipl.jpl.nasa.gov/vicar/vicar250/html/javadoc/jpl/mipl/jade/stereo/package-summary.html

the problem must have been solved.

How do I properly implement displaying a pair of 2D images using page-flipping ?

(it has been done, in Andreas Petersik's 'Stereoscopic Applet' for example).

David Sykes

------------------------------------------------------------------------------------------------------------

import java.awt.*;
import java.awt.image.*;
import java.awt.color.*;
import javax.vecmath.*;
import javax.media.j3d.*;
import com.sun.j3d.utils.universe.SimpleUniverse;
import javax.swing.event.*;
import java.awt.event.*;
import javax.media.j3d.*;
import javax.media.jai.*;
import com.sun.media.jai.codec.ImageCodec;
import com.sun.j3d.utils.geometry.ColorCube;
import java.awt.image.renderable.*;
import java.io.*;
import javax.swing.*;

public class StereoCanvas extends Canvas3D {

     //Properties

     private GraphicsContext3D     _gc3D;
     private J3DGraphics2D         _j3DG2D;
     private BufferedImage         _imageLeft;
     private BufferedImage         _imageRight;

     public StereoCanvas(GraphicsConfiguration config,
                       BufferedImage imageLeft,
                       BufferedImage imageRight)
     {
       super(config);

       _imageLeft = imageLeft;
       _imageRight = imageRight;
       //Make sure that stereo is enabled
       setStereoEnable(true);
       //Stop the renderer, since we use immediate mode rendering.
       stopRenderer();
       // Create a simple scene and attach it to the virtual universe
               SimpleUniverse universe = new SimpleUniverse(this);

         // This will move the ViewPlatform back a bit so the
         // objects in the scene can be viewed.

universe.getViewingPlatform().setNominalViewingTransform();
     }

     public void paint(Graphics g)
     {
       super.paint(g);
       if(_gc3D == null || _j3DG2D == null) {

           setDoubleBufferEnable(false);

           _gc3D = getGraphicsContext3D();
           _gc3D.setBufferOverride(true);
           _gc3D.setAppearance(new Appearance());
           _gc3D.setBackground(new Background(new
Color3f(Color.black)));

       }
       _gc3D.setStereoMode(GraphicsContext3D.STEREO_BOTH);
       _j3DG2D = getGraphics2D();
       _gc3D.clear();
       _j3DG2D.flush(true);


       _gc3D.setStereoMode(GraphicsContext3D.STEREO_LEFT);
       //If the line below uncommented then this test program
       //runs correctly
       _gc3D.draw(new ColorCube(0.01));                                          // 
******** I have uncommented it !
       _j3DG2D.drawAndFlushImage(_imageLeft, 0, 0, null);
       _gc3D.setStereoMode(GraphicsContext3D.STEREO_RIGHT);
       //If the line below uncommented then this test program
       //runs correctly
       _gc3D.draw(new ColorCube(0.01));                                         // 
******** I have uncommented it !
       _j3DG2D.drawAndFlushImage(_imageRight, 0, 0, null);

       _gc3D.flush(true);

     }

     /**
      * This function simply calls paint(Graphics g) which is
different
      * from parent's implementation
      */
     public void update(Graphics g)
     {
       paint(g);
     }

     public static void main(String[] argv)
     {
       if(argv.length != 2) {
           System.out.println("Usage: java StereoCanvas imageLeftFileName 
imageRightFileName");
       }
       GraphicsConfigTemplate3D template = new
GraphicsConfigTemplate3D();
       template.setStereo(GraphicsConfigTemplate.REQUIRED) ;
       GraphicsConfiguration config
                     =
GraphicsEnvironment.getLocalGraphicsEnvironment().

getDefaultScreenDevice().getBestConfiguration(template);
       PlanarImage imageLeft = JAI.create("fileload", argv[0]);
       PlanarImage imageRight = JAI.create("fileload", argv[1]);
       StereoCanvas myCanvas3D =
           new StereoCanvas(config,
                            imageLeft.getAsBufferedImage(),
                            imageRight.getAsBufferedImage());

       JFrame jFrame = new JFrame();
       jFrame.getContentPane().setLayout(new BorderLayout());

               jFrame.getContentPane().add(myCanvas3D,
BorderLayout.CENTER);

       jFrame.pack();
       jFrame.setSize(200, 300);
       jFrame.setVisible(true);
     }
}

-----------------------------------------------------------------------------------------------------------

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to