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.geometry.ColorCube;
|
samer@1
|
6
|
samer@1
|
7 public class hello2
|
samer@1
|
8 {
|
samer@1
|
9 public static void main(String[] args)
|
samer@1
|
10 {
|
samer@1
|
11 new samer.core.shells.SwingShell();
|
samer@1
|
12 run();
|
samer@1
|
13 }
|
samer@1
|
14
|
samer@1
|
15
|
samer@1
|
16 public static void run()
|
samer@1
|
17 {
|
samer@1
|
18 BranchGroup root=new BranchGroup();
|
samer@1
|
19 Transform3D xform=new Transform3D();
|
samer@1
|
20 Transform3D axis=new Transform3D();
|
samer@1
|
21
|
samer@1
|
22 axis.set(new Vector3d(0.5,0,0));
|
samer@1
|
23
|
samer@1
|
24 TransformGroup tg = new TransformGroup(xform);
|
samer@1
|
25
|
samer@1
|
26 Alpha alpha = new Alpha(-1, 4000);
|
samer@1
|
27 Behavior rotator = new RotationInterpolator(alpha, tg, axis, 0f, (float)(2*Math.PI));
|
samer@1
|
28
|
samer@1
|
29 rotator.setSchedulingBounds(new BoundingSphere());
|
samer@1
|
30 tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
|
samer@1
|
31 tg.addChild(rotator);
|
samer@1
|
32 tg.addChild(new ColorCube(0.5));
|
samer@1
|
33
|
samer@1
|
34 root.addChild(tg);
|
samer@1
|
35 root.compile();
|
samer@1
|
36
|
samer@1
|
37 Canvas3D canvas=new Canvas3D(null);
|
samer@1
|
38 SimpleUniverse U = new SimpleUniverse(canvas);
|
samer@1
|
39 U.getViewingPlatform().setNominalViewingTransform();
|
samer@1
|
40 U.addBranchGraph(root);
|
samer@1
|
41
|
samer@1
|
42 Shell.Window win;
|
samer@1
|
43 win=Shell.getWindow("hello");
|
samer@1
|
44 win.addWindowListener(Shell.exitListener());
|
samer@1
|
45 win.container().setLayout(new java.awt.BorderLayout());
|
samer@1
|
46 win.container().add(canvas);
|
samer@1
|
47 win.expose();
|
samer@1
|
48 }
|
samer@1
|
49 }
|