1. Stereo Image Viewing
First, be aware that in the current release of Java 3D, stereo is only supported on Sun workstations. PCs with stereo hardware will be able to use stereo in the next release.
You've probably called
setStereoEnable()
in your Canvas3D to turn on stereo, and nothing has happened. There's actually a bit more you'll have to do to set stereo up before you can make that method call.
First, you'll need the right hardware: a pair of CrystalEyes glasses, and an emitter for a Sun workstation. There's a port on graphics card for the emitter to hook into. Once you've plugged it in, turn on the emitter.
Depending on the graphics card you have (Creator3D or Elite 3D), you'll need to use either the
ffbconfig
or
afbconfig
command. Type this command at a shell prompt:
afbconfig -prconf
This will print out the current information about your graphics card. Look
for a line that says Current resolution setting
and
write it down
. You'll want that information after you've played around with the stereo settings.
The next thing you'll need to do is kick your X server into stereo mode.
afbconfig -res stereo
and log out of your current session. The X server will reset, and you'll
be in stereo mode. It's probably a lower resolution mode than you're
already using, so don't be surprised about that.
Now you're ready to run your program. Try:
java -Dj3d.stereo=PREFERRED HelloUniverse
You should see a double image until you put your glasses on. When the glasses
and emitter sync up, you'll see the stereo image.
To return to the resolution you were working at, use the ffbconfig/afbconfig
-res
option and use your previous screen resolution as the
-res
argument.
afbconfig -res 1280
You can see all screen resoluation modes available for your system by entering
afbconfig -res \?
The following information is how to set up stereo for use in your own programs:
From Kevin Rushforth:
In order for stereo to work, the application must create a Canvas3D with a stereo-capable GraphicsConfiguration. This can be done in two ways.
1) By calling SimpleUniverse.getPreferredConfiguration
An application that wants to use stereo, if requested by the user of the app, can call the getPreferredConfiguration method in SimpleUniverse. The resulting GraphicsConfiguration should be passed to the Canvas3D constructor. The getPreferredConfiguration method reads the j3d.stereo property to control whether a stereo visual is requested. The j3d.stereo property should be set to one of "UNNECESSARY" (the default), "PREFERRED", or "REQUIRED". For example:
java -Dj3d.stereo=PREFERRED HelloUniverse
All of our shipping examples in Java 3D 1.1.2 call
getPreferredConfiguration.
2) By calling getBestConfiguration with a GraphicsConfigTemplate3D that requests stereo
An application that wants to enable the use of stereo should construct a GraphicsConfigTemplate3D and use some application-specific criteria to set the stereo flag to REQUIRED or PREFERRED as desired. For example:
GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D();
if (myApplicationWantsStereo)
template.setStereo(template.PREFERRED);
// Get the GraphicsConfiguration that best fits our needs.
GraphicsConfiguration gcfg =
GraphicsEnvironment.getLocalGraphicsEnvironment().
getDefaultScreenDevice().getBestConfiguration(template);
The resulting GraphicsConfiguration should be passed to the Canvas3D
constructor.
Now when you call
setStereoEnable(true)
from your Canvas3D, you should get a stereo image. Calling
setStereoEnable(false)
will turn it back off again.