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