samer@1: /* samer@1: hello5.java samer@1: samer@1: Construct universe without using SimpleUniverse samer@1: utility class - this puts together the view samer@1: group explicitly. samer@1: samer@1: */ samer@1: samer@1: import samer.core.*; samer@1: import javax.media.j3d.*; samer@1: import javax.vecmath.*; samer@1: samer@1: public class hello5 extends util implements Agent samer@1: { samer@1: Canvas3D canvas; samer@1: samer@1: public static void main(String[] args) { init(); new hello5(); } samer@1: samer@1: public hello5() samer@1: { samer@1: // create universe samer@1: LocalUniverse U=new LocalUniverse(); samer@1: BranchGroup root=new BranchGroup(); samer@1: samer@1: // create scene samer@1: root.addChild(createSceneGraph()); samer@1: // addBackground(root,new Background(0.1f,0.2f,0.15f)); samer@1: // addLights(root); samer@1: samer@1: // create view bits samer@1: canvas=new Canvas3D(getGraphicsConfiguration()); samer@1: samer@1: TransformGroup VT=new TransformGroup(); samer@1: ViewPlatform VP=new ViewPlatform(); samer@1: View V=new View(); samer@1: samer@1: { samer@1: Transform3D t=new Transform3D(); samer@1: t.set(new Vector3d(0.0,0.0,8.0)); samer@1: VT.setTransform(t); samer@1: } samer@1: samer@1: addKeyNavigator(VT,readwrite(VT)); samer@1: VT.addChild(VP); samer@1: V.addCanvas3D(canvas); samer@1: V.attachViewPlatform(VP); samer@1: V.setPhysicalBody(new PhysicalBody()); samer@1: V.setPhysicalEnvironment(new PhysicalEnvironment()); samer@1: samer@1: root.addChild(VT); samer@1: root.compile(); samer@1: samer@1: Shell.registerAgent(this); samer@1: Shell.exposeCommands(this); samer@1: samer@1: // setViewPolicy(canvas.getView()); samer@1: expose(canvas,"hello"); samer@1: U.addGroup(root); samer@1: } samer@1: samer@1: private static TransformGroup createSceneGraph() samer@1: { samer@1: Transform3D r=new Transform3D(); samer@1: r.rotX(Math.PI/2); samer@1: TransformGroup t2=new TransformGroup(r); samer@1: t2.addChild(yoyoGroup()); samer@1: samer@1: TransformGroup tg = new TransformGroup(); samer@1: addRotator(tg); samer@1: tg.addChild(t2); samer@1: return tg; samer@1: } samer@1: samer@1: public void getCommands(Agent.Registry r) { r.add("start").add("stop"); } samer@1: public void execute(String cmd, Environment env) { samer@1: if (cmd.equals("start")) { canvas.startRenderer(); } samer@1: else if (cmd.equals("stop")) { canvas.stopRenderer(); } samer@1: } samer@1: samer@1: }