samer@1: /* samer@1: hello10.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: picking 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 hello10 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 hello10(); } samer@1: samer@1: public hello10() samer@1: { samer@1: Viewer v=new Viewer("view"); samer@1: samer@1: // v.lookFrom(new Point3d(0,0,8),new Vector3d(0,1,0)); samer@1: samer@1: // create scene samer@1: root.addChild(createSceneGraph()); samer@1: root.addChild(v); samer@1: root.setCapability(Group.ALLOW_CHILDREN_EXTEND); samer@1: root.setCapability(Group.ALLOW_CHILDREN_WRITE); samer@1: samer@1: /* samer@1: tg.setCapability(TransformGroup.ENABLE_PICK_REPORTING); samer@1: PickRotateBehavior pr=new PickRotateBehavior(objroot, canvas, bounds); samer@1: objroot.addChild(pickRotate); samer@1: */ samer@1: 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: r.setScale(0.5); samer@1: TransformGroup t2=new TransformGroup(r); samer@1: t2.addChild( yoyoGroup( samer@1: yoyoGeometryInfo(12).getGeometryArray(), samer@1: wireframe2(), samer@1: pointy())); samer@1: samer@1: TransformGroup tg = new TransformGroup(); samer@1: // addRotator(tg); samer@1: mouseRotate(tg); samer@1: mouseTranslate(tg); samer@1: mouseZoom(tg); samer@1: tg.addChild(t2); samer@1: return tg; samer@1: } samer@1: }