Hello People, I recieved a couple of requests for the class, but I deleted the mails(!#) so I am posting it here instead. It is very simple. The eye separation distances are not calculated, but the values I chose work so I havent fixed them! The only method at the moment is getStereoLocale(Locale); and returns the locale object of the ViewBranch. You will need to add a root branch group to the locale to see anything.... Two frames are created, leftview and rightview, in the centre of the screen. The stereogram should be viewed with the 'Cross-eyed' method rather than the 'Focus Behind' method. To use the 'Focus Behind' method swap the frame canvasses around. (IE, add leftcanvas to left frame, right canvas to right frame, rather that left to right - right to left, you'll get it, the code is simple) I am aware that maybe I should have extended the VirtualUniverse class, but my Java isnt that good yet...... (Java3D is what has finally got me to learn Java), I know that I could probably combine some of my code into single instructions, but I'm learning Java at the same time as Java3D, with no books, just the API's and tutorials!! so I have to keep things step by step :) (I create good example / learning code though!!) It creates the following view branch structure, VirtualUniverse | Locale | BranchGroup--------: | | TransformGroup Transformgroup | | ViewPlatformleft ViewPlatformright | | leftview Rightview | | leftcanvas rightcanvas I am wondering if there is a simpler way of acomplishing the above branchgraph? Anyway, look at the code, its very simple and should be easy to improve however you like. It's just a basic framework really. I have a demo that will actually put things in the frames for you to look at, just mail me for it. (I wont delete it, I promise).. You too can have (Holographic? real-3d) images floating out of your computer screen :) Matthew Warren. ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com
import java.awt.*; import java.awt.event.*; import javax.media.j3d.*; import javax.vecmath.*; import com.sun.j3d.utils.geometry.*; import com.sun.j3d.utils.universe.*; public class StereoUniverse extends Object{ public Locale locale; StereoUniverse() { Frame leftframe = new Frame("Leftframe"); Frame rightframe = new Frame("Rightframe"); //Setup Frames leftframe.setSize(200,200); rightframe.setSize(200,200); leftframe.setBackground(Color.blue); rightframe.setBackground(Color.blue); leftframe.setLocation(312,284); rightframe.setLocation(512,284); leftframe.setVisible(true); rightframe.setVisible(true); //Create Canvases Canvas3D leftcanvas = new Canvas3D(null); leftcanvas.setBackground(Color.blue); leftcanvas.setVisible(true); Canvas3D rightcanvas = new Canvas3D(null); rightcanvas.setBackground(Color.blue); rightcanvas.setVisible(true); //Add Canvases to frame leftframe.add("Center",rightcanvas); rightframe.add("Center",leftcanvas); VirtualUniverse universe = new VirtualUniverse(); locale = new Locale(universe); BranchGroup viewbranchgroup = new BranchGroup(); Transform3D moveleftviewplatform = new Transform3D(); Transform3D moverightviewplatform = new Transform3D(); Vector3f leftvector = new Vector3f(-0.2f,0.0f,3.0f); Vector3f rightvector = new Vector3f(0.2f,0.0f,3.0f); moveleftviewplatform.setTranslation(leftvector); moverightviewplatform.setTranslation(rightvector); TransformGroup leftviewtransgroup = new TransformGroup(moveleftviewplatform); TransformGroup rightviewtransgroup = new TransformGroup(moverightviewplatform); ViewPlatform leftviewplatform = new ViewPlatform(); ViewPlatform rightviewplatform = new ViewPlatform(); View leftview = new View(); View rightview = new View(); leftview.setPhysicalBody(new PhysicalBody()); rightview.setPhysicalBody(new PhysicalBody()); leftview.setPhysicalEnvironment(new PhysicalEnvironment()); rightview.setPhysicalEnvironment(new PhysicalEnvironment()); leftview.addCanvas3D(leftcanvas); rightview.addCanvas3D(rightcanvas); //now connect the whole lot together viewbranchgroup.addChild(leftviewtransgroup); viewbranchgroup.addChild(rightviewtransgroup); leftviewtransgroup.addChild(leftviewplatform); rightviewtransgroup.addChild(rightviewplatform); leftview.attachViewPlatform(leftviewplatform); rightview.attachViewPlatform(rightviewplatform); //Compile the viewbranchgraph viewbranchgroup.compile(); //Make viewbranchgroup live locale.addBranchGraph(viewbranchgroup); } public Locale getStereoLocale() { return this.locale; } }