Mercurial > hg > jslab
diff examples/java3d/hello12.java @ 1:5df24c91468d
Oh my what a mess.
author | samer |
---|---|
date | Fri, 05 Apr 2019 16:26:00 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/java3d/hello12.java Fri Apr 05 16:26:00 2019 +0100 @@ -0,0 +1,90 @@ +/* + 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; + } + + +} \ No newline at end of file