Mercurial > hg > jslab
comparison examples/java3d/hello10.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 hello10.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 picking | |
13 */ | |
14 | |
15 import samer.core.*; | |
16 import java.awt.event.*; | |
17 import javax.media.j3d.*; | |
18 import javax.vecmath.*; | |
19 | |
20 public class hello10 extends util implements Agent | |
21 { | |
22 // create universe | |
23 LocalUniverse U=new LocalUniverse(); | |
24 BranchGroup root=new BranchGroup(); | |
25 | |
26 public static void main(String[] arse) { init(); new hello10(); } | |
27 | |
28 public hello10() | |
29 { | |
30 Viewer v=new Viewer("view"); | |
31 | |
32 // v.lookFrom(new Point3d(0,0,8),new Vector3d(0,1,0)); | |
33 | |
34 // create scene | |
35 root.addChild(createSceneGraph()); | |
36 root.addChild(v); | |
37 root.setCapability(Group.ALLOW_CHILDREN_EXTEND); | |
38 root.setCapability(Group.ALLOW_CHILDREN_WRITE); | |
39 | |
40 /* | |
41 tg.setCapability(TransformGroup.ENABLE_PICK_REPORTING); | |
42 PickRotateBehavior pr=new PickRotateBehavior(objroot, canvas, bounds); | |
43 objroot.addChild(pickRotate); | |
44 */ | |
45 | |
46 root.compile(); | |
47 | |
48 U.addGroup(root); | |
49 | |
50 Shell.registerAgent(this); | |
51 Shell.exposeCommands(this); | |
52 } | |
53 | |
54 public void getCommands(Agent.Registry r) { | |
55 r.add("view"); | |
56 r.setTarget(null); r.add("start").add("stop"); | |
57 } | |
58 | |
59 public void execute(String cmd, Environment env) throws Exception | |
60 { | |
61 if (cmd.equals("view")) { | |
62 root.addChild(new Viewer(X.string(env.datum("name"),"view"))); | |
63 } | |
64 } | |
65 | |
66 private static TransformGroup createSceneGraph() | |
67 { | |
68 Transform3D r=new Transform3D(); | |
69 //r.rotX(Math.PI/2); | |
70 r.setScale(0.5); | |
71 TransformGroup t2=new TransformGroup(r); | |
72 t2.addChild( yoyoGroup( | |
73 yoyoGeometryInfo(12).getGeometryArray(), | |
74 wireframe2(), | |
75 pointy())); | |
76 | |
77 TransformGroup tg = new TransformGroup(); | |
78 // addRotator(tg); | |
79 mouseRotate(tg); | |
80 mouseTranslate(tg); | |
81 mouseZoom(tg); | |
82 tg.addChild(t2); | |
83 return tg; | |
84 } | |
85 } |