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 hello3 extends util
|
samer@1
|
8 {
|
samer@1
|
9 BranchGroup root=new BranchGroup();
|
samer@1
|
10 Bounds bounds=new BoundingSphere();
|
samer@1
|
11 Canvas3D canvas=new Canvas3D(null);
|
samer@1
|
12
|
samer@1
|
13 public static void main(String[] args)
|
samer@1
|
14 {
|
samer@1
|
15 new samer.core.shells.AppShell(args);
|
samer@1
|
16 hello3 app=new hello3();
|
samer@1
|
17
|
samer@1
|
18 Shell.Window win;
|
samer@1
|
19 win=Shell.getWindow("hello");
|
samer@1
|
20 win.addWindowListener(Shell.exitListener());
|
samer@1
|
21 win.container().setLayout(new java.awt.BorderLayout());
|
samer@1
|
22 win.container().add(app.canvas);
|
samer@1
|
23 win.expose();
|
samer@1
|
24 }
|
samer@1
|
25
|
samer@1
|
26 public hello3()
|
samer@1
|
27 {
|
samer@1
|
28 SimpleUniverse U = new SimpleUniverse(canvas);
|
samer@1
|
29 TransformGroup tg = new TransformGroup();
|
samer@1
|
30
|
samer@1
|
31 addRotator(tg);
|
samer@1
|
32 addBackground(root,new Background(0.1f,0.2f,0.15f));
|
samer@1
|
33 tg.addChild(createObject());
|
samer@1
|
34 root.addChild(tg);
|
samer@1
|
35
|
samer@1
|
36 KeyNavigatorBehavior keyNavBeh = new KeyNavigatorBehavior(
|
samer@1
|
37 U.getViewingPlatform().getViewPlatformTransform());
|
samer@1
|
38 keyNavBeh.setSchedulingBounds(bounds);
|
samer@1
|
39 root.addChild(keyNavBeh);
|
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
|
samer@1
|
46 public static Group createObject()
|
samer@1
|
47 {
|
samer@1
|
48 Shape3D faces=new Shape3D();
|
samer@1
|
49 Shape3D edges=new Shape3D();
|
samer@1
|
50 Geometry geom=yoyoGeometryInfo(20).getGeometryArray();
|
samer@1
|
51
|
samer@1
|
52 faces.setGeometry(geom);
|
samer@1
|
53 edges.setGeometry(geom);
|
samer@1
|
54
|
samer@1
|
55 faces.setAppearance(translucent());
|
samer@1
|
56 edges.setAppearance(pointy());
|
samer@1
|
57
|
samer@1
|
58 BranchGroup bg = new BranchGroup();
|
samer@1
|
59 bg.addChild(faces);
|
samer@1
|
60 bg.addChild(edges);
|
samer@1
|
61
|
samer@1
|
62 return bg;
|
samer@1
|
63 }
|
samer@1
|
64 } |