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 samer.maths.*; samer@1: import java.io.*; samer@1: import java.awt.event.*; samer@1: import javax.media.j3d.*; samer@1: import javax.vecmath.*; samer@1: samer@1: public class hello12 extends util implements Agent samer@1: { samer@1: // create universe samer@1: LocalUniverse U=new LocalUniverse(); samer@1: BranchGroup root=new BranchGroup(); samer@1: Viewer V; samer@1: samer@1: public static void main(String[] arse) throws Exception samer@1: { samer@1: init(); samer@1: samer@1: Matrix P=new Matrix("points",512,3); samer@1: VVector A=new VVector("s",512); samer@1: samer@1: P.assign( samer@1: Jama.Matrix.read( samer@1: new BufferedReader( samer@1: new FileReader(Shell.getString("filename","")) samer@1: ) samer@1: ) samer@1: ); samer@1: samer@1: new hello12(P,A); samer@1: Shell.interpret("expose"); samer@1: } samer@1: samer@1: public hello12(String vec) throws Exception samer@1: { samer@1: this( samer@1: (Matrix)Shell.get("PointsMatrix"), samer@1: (VVector)Shell.get(vec) samer@1: ); samer@1: } samer@1: samer@1: public hello12(Matrix P, VVector A) throws Exception samer@1: { samer@1: Shell.print("creating hello12"); samer@1: samer@1: // create scene samer@1: addBackground(root,new Background(new Color3f(0.26f,0.23f,0.35f))); samer@1: root.addChild( mouseRotaterGroup( samer@1: new Shape3D(new MatrixPointArray(P,A), pointy3()) samer@1: )); samer@1: samer@1: root.addChild(new Viewer("particles")); samer@1: root.addChild(new FPS(200)); 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: public void execute(String cmd, Environment env) throws Exception {} samer@1: samer@1: private static Group mouseRotaterGroup(javax.media.j3d.Node n) samer@1: { samer@1: TransformGroup tg = new TransformGroup(); samer@1: mouseRotate(tg); samer@1: mouseTranslate(tg); samer@1: mouseZoom(tg); samer@1: tg.addChild(n); samer@1: return tg; samer@1: } samer@1: samer@1: samer@1: }