samer@1
|
1 import samer.core.*;
|
samer@1
|
2 import javax.media.j3d.*;
|
samer@1
|
3 import javax.vecmath.*;
|
samer@1
|
4 import com.sun.j3d.utils.universe.*;
|
samer@1
|
5 import com.sun.j3d.utils.behaviors.keyboard.*;
|
samer@1
|
6
|
samer@1
|
7 public class hello4 extends util implements Agent
|
samer@1
|
8 {
|
samer@1
|
9 BranchGroup root=new BranchGroup();
|
samer@1
|
10 Canvas3D canvas=new Canvas3D(null);
|
samer@1
|
11
|
samer@1
|
12 public static void main(String[] args)
|
samer@1
|
13 {
|
samer@1
|
14 init();
|
samer@1
|
15 expose((new hello4()).canvas,"hello");
|
samer@1
|
16 }
|
samer@1
|
17
|
samer@1
|
18 public hello4()
|
samer@1
|
19 {
|
samer@1
|
20 canvas=new Canvas3D(getGraphicsConfiguration());
|
samer@1
|
21
|
samer@1
|
22 Shell.print("stereo? "+ canvas.getStereoAvailable());
|
samer@1
|
23 Shell.print("antialiasing? "+ canvas.getSceneAntialiasingAvailable());
|
samer@1
|
24 // canvas.stopRenderer();
|
samer@1
|
25
|
samer@1
|
26 SimpleUniverse U = new SimpleUniverse(canvas);
|
samer@1
|
27 TransformGroup tg = new TransformGroup();
|
samer@1
|
28
|
samer@1
|
29 addRotator(tg);
|
samer@1
|
30 addKeyNavigator(tg,U.getViewingPlatform().getViewPlatformTransform());
|
samer@1
|
31 addBackground(root,new Background(0.1f,0.2f,0.15f));
|
samer@1
|
32
|
samer@1
|
33 Transform3D shrink=new Transform3D();
|
samer@1
|
34 shrink.setScale(0.6);
|
samer@1
|
35 TransformGroup sg=new TransformGroup(shrink);
|
samer@1
|
36 tg.addChild(sg);
|
samer@1
|
37 sg.addChild(yoyoGroup());
|
samer@1
|
38 root.addChild(tg);
|
samer@1
|
39
|
samer@1
|
40 root.compile();
|
samer@1
|
41
|
samer@1
|
42 U.getViewingPlatform().setNominalViewingTransform();
|
samer@1
|
43 U.addBranchGraph(root);
|
samer@1
|
44
|
samer@1
|
45 Shell.registerAgent(this);
|
samer@1
|
46 Shell.exposeCommands(this);
|
samer@1
|
47
|
samer@1
|
48 //setViewPolicy(canvas.getView());
|
samer@1
|
49 }
|
samer@1
|
50
|
samer@1
|
51 public void getCommands(Agent.Registry r) { r.add("start").add("stop"); }
|
samer@1
|
52 public void execute(String cmd, Environment env) {
|
samer@1
|
53 if (cmd.equals("start")) { canvas.startRenderer(); }
|
samer@1
|
54 else if (cmd.equals("stop")) { canvas.stopRenderer(); }
|
samer@1
|
55 }
|
samer@1
|
56
|
samer@1
|
57 } |