annotate examples/java3d/hello12.java @ 8:5e3cbbf173aa tip

Reorganise some more
author samer
date Fri, 05 Apr 2019 22:41:58 +0100
parents 5df24c91468d
children
rev   line source
samer@1 1 /*
samer@1 2 hello6.java
samer@1 3
samer@1 4 Construct universe without using SimpleUniverse
samer@1 5 utility class - this puts together the view
samer@1 6 group explicitly.
samer@1 7
samer@1 8 Now has dynamically creatable views.
samer@1 9 Have to construct views on BranchGroups so they
samer@1 10 can be added while universe is live?
samer@1 11 */
samer@1 12
samer@1 13 import samer.core.*;
samer@1 14 import samer.maths.*;
samer@1 15 import java.io.*;
samer@1 16 import java.awt.event.*;
samer@1 17 import javax.media.j3d.*;
samer@1 18 import javax.vecmath.*;
samer@1 19
samer@1 20 public class hello12 extends util implements Agent
samer@1 21 {
samer@1 22 // create universe
samer@1 23 LocalUniverse U=new LocalUniverse();
samer@1 24 BranchGroup root=new BranchGroup();
samer@1 25 Viewer V;
samer@1 26
samer@1 27 public static void main(String[] arse) throws Exception
samer@1 28 {
samer@1 29 init();
samer@1 30
samer@1 31 Matrix P=new Matrix("points",512,3);
samer@1 32 VVector A=new VVector("s",512);
samer@1 33
samer@1 34 P.assign(
samer@1 35 Jama.Matrix.read(
samer@1 36 new BufferedReader(
samer@1 37 new FileReader(Shell.getString("filename",""))
samer@1 38 )
samer@1 39 )
samer@1 40 );
samer@1 41
samer@1 42 new hello12(P,A);
samer@1 43 Shell.interpret("expose");
samer@1 44 }
samer@1 45
samer@1 46 public hello12(String vec) throws Exception
samer@1 47 {
samer@1 48 this(
samer@1 49 (Matrix)Shell.get("PointsMatrix"),
samer@1 50 (VVector)Shell.get(vec)
samer@1 51 );
samer@1 52 }
samer@1 53
samer@1 54 public hello12(Matrix P, VVector A) throws Exception
samer@1 55 {
samer@1 56 Shell.print("creating hello12");
samer@1 57
samer@1 58 // create scene
samer@1 59 addBackground(root,new Background(new Color3f(0.26f,0.23f,0.35f)));
samer@1 60 root.addChild( mouseRotaterGroup(
samer@1 61 new Shape3D(new MatrixPointArray(P,A), pointy3())
samer@1 62 ));
samer@1 63
samer@1 64 root.addChild(new Viewer("particles"));
samer@1 65 root.addChild(new FPS(200));
samer@1 66 root.setCapability(Group.ALLOW_CHILDREN_EXTEND);
samer@1 67 root.setCapability(Group.ALLOW_CHILDREN_WRITE);
samer@1 68 root.compile();
samer@1 69
samer@1 70 U.addGroup(root);
samer@1 71
samer@1 72 Shell.registerAgent(this);
samer@1 73 Shell.exposeCommands(this);
samer@1 74 }
samer@1 75
samer@1 76 public void getCommands(Agent.Registry r) { }
samer@1 77 public void execute(String cmd, Environment env) throws Exception {}
samer@1 78
samer@1 79 private static Group mouseRotaterGroup(javax.media.j3d.Node n)
samer@1 80 {
samer@1 81 TransformGroup tg = new TransformGroup();
samer@1 82 mouseRotate(tg);
samer@1 83 mouseTranslate(tg);
samer@1 84 mouseZoom(tg);
samer@1 85 tg.addChild(n);
samer@1 86 return tg;
samer@1 87 }
samer@1 88
samer@1 89
samer@1 90 }