Mercurial > hg > jslab
view examples/java3d/hello12.java @ 8:5e3cbbf173aa tip
Reorganise some more
author | samer |
---|---|
date | Fri, 05 Apr 2019 22:41:58 +0100 |
parents | 5df24c91468d |
children |
line wrap: on
line source
/* hello6.java Construct universe without using SimpleUniverse utility class - this puts together the view group explicitly. Now has dynamically creatable views. Have to construct views on BranchGroups so they can be added while universe is live? */ import samer.core.*; import samer.maths.*; import java.io.*; import java.awt.event.*; import javax.media.j3d.*; import javax.vecmath.*; public class hello12 extends util implements Agent { // create universe LocalUniverse U=new LocalUniverse(); BranchGroup root=new BranchGroup(); Viewer V; public static void main(String[] arse) throws Exception { init(); Matrix P=new Matrix("points",512,3); VVector A=new VVector("s",512); P.assign( Jama.Matrix.read( new BufferedReader( new FileReader(Shell.getString("filename","")) ) ) ); new hello12(P,A); Shell.interpret("expose"); } public hello12(String vec) throws Exception { this( (Matrix)Shell.get("PointsMatrix"), (VVector)Shell.get(vec) ); } public hello12(Matrix P, VVector A) throws Exception { Shell.print("creating hello12"); // create scene addBackground(root,new Background(new Color3f(0.26f,0.23f,0.35f))); root.addChild( mouseRotaterGroup( new Shape3D(new MatrixPointArray(P,A), pointy3()) )); root.addChild(new Viewer("particles")); root.addChild(new FPS(200)); root.setCapability(Group.ALLOW_CHILDREN_EXTEND); root.setCapability(Group.ALLOW_CHILDREN_WRITE); root.compile(); U.addGroup(root); Shell.registerAgent(this); Shell.exposeCommands(this); } public void getCommands(Agent.Registry r) { } public void execute(String cmd, Environment env) throws Exception {} private static Group mouseRotaterGroup(javax.media.j3d.Node n) { TransformGroup tg = new TransformGroup(); mouseRotate(tg); mouseTranslate(tg); mouseZoom(tg); tg.addChild(n); return tg; } }