Mercurial > hg > jslab
comparison examples/java3d/hello6.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 java.awt.event.*; | |
15 import javax.media.j3d.*; | |
16 import javax.vecmath.*; | |
17 | |
18 public class hello6 extends util implements Agent | |
19 { | |
20 // create universe | |
21 LocalUniverse U=new LocalUniverse(); | |
22 BranchGroup root=new BranchGroup(); | |
23 | |
24 public static void main(String[] arse) { init(); new hello6(); } | |
25 | |
26 public hello6() | |
27 { | |
28 // create scene | |
29 root.addChild(createSceneGraph()); | |
30 // addBackground(root,new Background(0.1f,0.2f,0.15f)); | |
31 // addLights(root); | |
32 root.addChild(new FPS(200)); | |
33 | |
34 root.addChild(new Viewer("view")); | |
35 root.setCapability(Group.ALLOW_CHILDREN_EXTEND); | |
36 root.setCapability(Group.ALLOW_CHILDREN_WRITE); | |
37 root.compile(); | |
38 | |
39 U.addGroup(root); | |
40 | |
41 Shell.registerAgent(this); | |
42 Shell.exposeCommands(this); | |
43 } | |
44 | |
45 public void getCommands(Agent.Registry r) { | |
46 r.add("view"); | |
47 r.setTarget(null); r.add("start").add("stop"); | |
48 } | |
49 | |
50 public void execute(String cmd, Environment env) throws Exception | |
51 { | |
52 if (cmd.equals("view")) { | |
53 root.addChild(new Viewer(X.string(env.datum("name"),"view"))); | |
54 } | |
55 } | |
56 | |
57 private static TransformGroup createSceneGraph() | |
58 { | |
59 Transform3D r=new Transform3D(); | |
60 r.rotX(Math.PI/2); | |
61 TransformGroup t2=new TransformGroup(r); | |
62 t2.addChild(yoyoGroup()); | |
63 | |
64 TransformGroup tg = new TransformGroup(); | |
65 addRotator(tg); | |
66 tg.addChild(t2); | |
67 return tg; | |
68 } | |
69 } |