samer@1: /* samer@1: hello6.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: Now has dynamically creatable views. samer@1: Have to construct views on BranchGroups so they samer@1: can be added while universe is live? samer@1: */ samer@1: samer@1: import samer.core.*; samer@1: import java.awt.event.*; samer@1: import javax.media.j3d.*; samer@1: import javax.vecmath.*; samer@1: samer@1: public class hello6 extends util implements Agent samer@1: { samer@1: // create universe samer@1: LocalUniverse U=new LocalUniverse(); samer@1: BranchGroup root=new BranchGroup(); samer@1: samer@1: public static void main(String[] arse) { init(); new hello6(); } samer@1: samer@1: public hello6() 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: root.addChild(new FPS(200)); samer@1: samer@1: root.addChild(new Viewer("view")); samer@1: root.setCapability(Group.ALLOW_CHILDREN_EXTEND); samer@1: root.setCapability(Group.ALLOW_CHILDREN_WRITE); samer@1: root.compile(); samer@1: samer@1: U.addGroup(root); samer@1: samer@1: Shell.registerAgent(this); samer@1: Shell.exposeCommands(this); samer@1: } samer@1: samer@1: public void getCommands(Agent.Registry r) { samer@1: r.add("view"); samer@1: r.setTarget(null); r.add("start").add("stop"); samer@1: } samer@1: samer@1: public void execute(String cmd, Environment env) throws Exception samer@1: { samer@1: if (cmd.equals("view")) { samer@1: root.addChild(new Viewer(X.string(env.datum("name"),"view"))); samer@1: } 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: }