|
You will define at least 3 Java Class to display a little house in a Canvas3D and allow people to look at it from different viewpoint.
That class will contain all the 3D stuff and will receive demand from the JFrame class
That class will use a a Board3D object and 1 + 6 JButtons. A press of a button will change the viewPoint of the scene by rotating it with a parametrable angle around one of the 3 axes. A button should allow the user to go back to the default view.
The first instance of object that we will draw will be an house made with IndexedQuadArray object. Width : 6 / Depth : 7 m / Height without roof : 3 m / Roof height 2 m
Transform3D t3d = new Transform3D();
t3d.rotX(Math.PI/6);
TransformGroup tg = new TransformGroup();
tg.setTransform(t3d);
tg.addChild(new ColorCube());
racine.addChild(tg);
Remember that default java coordinate systems are not usual...
By default, Java 3D coordinate systems are right-handed, with the orientation semantics being that +y is the local gravitational up, +x is horizontal to the right, and +z is directly toward the viewer. The default units are meters.
GraphicsEnvironment local = GraphicsEnvironment.getLocalGraphicsEnvironment();
// there coulb be more than one screen
GraphicsDevice screen = local.getDefaultScreenDevice();
GraphicsConfigTemplate3D gcTemplate = new GraphicsConfigTemplate3D();
GraphicsConfiguration configuration = screen.getBestConfiguration(gcTemplate);
// Board3D extends Canvas3D and call its 'super' constructor
mainCanvas3D = new Board3D(configuration);
mainCanvas3D.setSize(200,200);
//This is the root of our view branch
viewBranch = new BranchGroup();
//The transform that will move our view
viewTransform = new Transform3D();
viewTransform.set(new Vector3f(0.0f,0.0f,5.0f));
//The transform group that will be the parent
//of our view platform elements
viewTransformGroup = new TransformGroup(viewTransform);
viewTransformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
myViewPlatform = new ViewPlatform();
//Next the physical elements are created
myBody = new PhysicalBody();
myEnvironment = new PhysicalEnvironment();
//Then we put it all together
viewTransformGroup.addChild(myViewPlatform);
viewBranch.addChild(viewTransformGroup);
myView = new View();
myView.addCanvas3D(this);
myView.attachViewPlatform(myViewPlatform);
myView.setPhysicalBody(myBody);
myView.setPhysicalEnvironment(myEnvironment);
//Create a default universe and locale
myUniverse = new VirtualUniverse();
myLocale = new Locale(myUniverse);
// Create the content Branch
contentBranch = new BranchGroup();
contentTransform = new Transform3D();
contentTransform.set(new AxisAngle4d(1.0,1.0,0.0,Math.PI/4.0));
contentTransformGroup = new TransformGroup(contentTransform);
contentBranch.addChild(contentTransformGroup);
contentTransformGroup.addChild(buildShape());
addLights(contentBranch);
//Use the functions to build the scene graph
myLocale.addBranchGraph(viewBranch);
myLocale.addBranchGraph(contentBranch);
|
| See the "Links" link above to find out the sources of the proposed informations Pascal Vuylsteker / eScience / Computer Science / ANU |
Last modified: 2/4/2002
TOC - Print |
Send your comments at : <Hugh.Fisher@anu.edu.au> |