Mercurial > hg > jslab
comparison examples/java3d/hello3.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 import samer.core.*; | |
2 import javax.media.j3d.*; | |
3 import javax.vecmath.*; | |
4 import com.sun.j3d.utils.universe.*; | |
5 import com.sun.j3d.utils.behaviors.keyboard.*; | |
6 | |
7 public class hello3 extends util | |
8 { | |
9 BranchGroup root=new BranchGroup(); | |
10 Bounds bounds=new BoundingSphere(); | |
11 Canvas3D canvas=new Canvas3D(null); | |
12 | |
13 public static void main(String[] args) | |
14 { | |
15 new samer.core.shells.AppShell(args); | |
16 hello3 app=new hello3(); | |
17 | |
18 Shell.Window win; | |
19 win=Shell.getWindow("hello"); | |
20 win.addWindowListener(Shell.exitListener()); | |
21 win.container().setLayout(new java.awt.BorderLayout()); | |
22 win.container().add(app.canvas); | |
23 win.expose(); | |
24 } | |
25 | |
26 public hello3() | |
27 { | |
28 SimpleUniverse U = new SimpleUniverse(canvas); | |
29 TransformGroup tg = new TransformGroup(); | |
30 | |
31 addRotator(tg); | |
32 addBackground(root,new Background(0.1f,0.2f,0.15f)); | |
33 tg.addChild(createObject()); | |
34 root.addChild(tg); | |
35 | |
36 KeyNavigatorBehavior keyNavBeh = new KeyNavigatorBehavior( | |
37 U.getViewingPlatform().getViewPlatformTransform()); | |
38 keyNavBeh.setSchedulingBounds(bounds); | |
39 root.addChild(keyNavBeh); | |
40 root.compile(); | |
41 | |
42 U.getViewingPlatform().setNominalViewingTransform(); | |
43 U.addBranchGraph(root); | |
44 } | |
45 | |
46 public static Group createObject() | |
47 { | |
48 Shape3D faces=new Shape3D(); | |
49 Shape3D edges=new Shape3D(); | |
50 Geometry geom=yoyoGeometryInfo(20).getGeometryArray(); | |
51 | |
52 faces.setGeometry(geom); | |
53 edges.setGeometry(geom); | |
54 | |
55 faces.setAppearance(translucent()); | |
56 edges.setAppearance(pointy()); | |
57 | |
58 BranchGroup bg = new BranchGroup(); | |
59 bg.addChild(faces); | |
60 bg.addChild(edges); | |
61 | |
62 return bg; | |
63 } | |
64 } |