Here is the example which was posted, although i tried it and it didn,t seem to work. If you can get it to work tell me how as well. On Thu, 2 Dec 1999, Gregory Hopkins wrote: > Hi, > > There seem to have been some good examples posted. I was wondering if anyone could >explain the > math involved in using the difficult universe accurately. > > I want to do an effect like throwing a knife into the viewers eye, but I'm not sure >how all the > settings of canvas size, viewpoint etc. interact together. > > Does anyone know how to calculate the correct settings for example, for a user >viewing the > screen from 50cm with a window 40cm wide with some stereo objects in it. > > Also is it possible to adjust for lenses/mirrors between the user and the screen? > > From, > > Greg. > > > > > > > > Can someone give me an example, or point me to one, of how to set up the > > view in Java3D without using simple universe. All of the examples that I > > have seen use this. I have an image but I want to be able to look at my > > world in different directions. > > > > Thank You, > > Casey R > > > > =========================================================================== > 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". >
/** * Example01 illustrates the basics of Java 3D. We construct * the simplest possible view branch and insert it into our * scene graph. We do not specify any content for the content * branch of our scene graph, so Java 3D renders an empty * universe. * <P> * This example is designed so that we can swap out the * content of our constructView(), constructViewBranch(), * and constructContentBranch() methods to change our physical * viewing parameters, view branch portion of our scene graph, * or content portion of the scene graph independently from each * other. * <P> * This version is compliant with Java 1.2 Beta 4 and * Java 3D 1.1 Beta 2, Nov 1998. Please refer to: <BR> * http://www.javaworld.com/javaworld/jw-12-1998/jw-12-media.html * <P> * @author Bill Day <[EMAIL PROTECTED]> * @version 1.0 * @see javax.media.j3d.BranchGroup * @see javax.media.j3d.Canvas3D * @see javax.media.j3d.Locale * @see javax.media.j3d.PhysicalBody * @see javax.media.j3d.PhysicalEnvironment * @see javax.media.j3d.TransformGroup * @see javax.media.j3d.View * @see javax.media.j3d.ViewPlatform * @see javax.media.j3d.VirtualUniverse **/ import java.awt.*; import java.awt.event.*; import javax.media.j3d.*; public class Example01 extends Frame { /** * Instantiates an Example01 object. **/ public static void main(String args[]) { new Example01(); } /** * The Example01 constructor sets the frame's size, adds the * visual components, and then makes them visible to the user. * <P> * We place a Canvas3D object into the Frame so that Java 3D * has the heavyweight component it needs to render 3D * graphics into. We then call methods to construct the * View and Content branches of our scene graph. **/ public Example01() { //Title our frame and set its size. super("Java 3D Example01"); setSize(400,300); //Here is our first Java 3d-specific code. We add a //Canvas3D to our Frame so that we can render our 3D //graphics. Java 3D requires a heavyweight component //Canvas3D into which to render. Canvas3D myCanvas3D = new Canvas3D(null); add("Center",myCanvas3D); //Turn on the visibility of our frame. setVisible(true); //We want to be sure we properly dispose of resources //this frame is using when the window is closed. We use //an anonymous inner class adapter for this. addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) {dispose(); System.exit(0);} } ); //Now that we have our Frame and Canvas3D, we are ready //to start building our scene graph. We need to construct //both a view branch and a content branch. In order to //actually use our view branch, we also need to construct //a View and connect it to our view branch's ViewPlatform. View myView = constructView(myCanvas3D); Locale myLocale = constructViewBranch(myView); constructContentBranch(myLocale); } /** * constructView() takes a Canvas3D reference and constructs * a View to display in that Canvas3D. It uses the default * PhysicalBody and PhysicalEnvironment (both required to be * set or else the 3D runtime will throw exceptions). The * returned View is used by constructViewBranch() to attach * the scene graph's ViewPlatform to a Canvas3D for rendering. * * @see constructViewBranch(View) **/ private View constructView(Canvas3D myCanvas3D) { View myView = new View(); myView.addCanvas3D(myCanvas3D); myView.setPhysicalBody(new PhysicalBody()); myView.setPhysicalEnvironment(new PhysicalEnvironment()); return(myView); } /** * constructViewBranch() takes as input a View which we * attached to our Canvas3D in constructView(). It constructs * a default view branch for the scene graph, attaches * the View to the ViewPlatform, and returns a reference to * our Locale for use by constructContentBranch() * in creating content for our scene graph. * * @see constructView(Canvas3D) * @see constructContentBranch(Locale) **/ private Locale constructViewBranch(View myView) { //First, we create the necessary coordinate systems //(VirtualUniverse, Locale), container nodes //(BranchGroup, TransformGroup), and platform which //determines our viewing position and direction (ViewPlatform). VirtualUniverse myUniverse = new VirtualUniverse(); Locale myLocale = new Locale(myUniverse); BranchGroup myBranchGroup = new BranchGroup(); TransformGroup myTransformGroup = new TransformGroup(); ViewPlatform myViewPlatform = new ViewPlatform(); //Next, we insert the platform into the transform group, //the transform group into the branch group, and the branch //group into the locale's branch graph portion of the //scene graph. myTransformGroup.addChild(myViewPlatform); myBranchGroup.addChild(myTransformGroup); myLocale.addBranchGraph(myBranchGroup); //Finally, we attach our view to the view platform and we //return a reference to our new universe. We are ready to //render 3D content! myView.attachViewPlatform(myViewPlatform); return(myLocale); } /** * constructContentBranch() is where we specify the 3D graphics * content to be rendered into the Locale referenced * in the passed parameter. Nothing is currently specified, so we * render an empty universe. * * @see constructViewBranch(View) **/ private void constructContentBranch(Locale myLocale) { //Insert content to be rendered here. } }
