annotate src/alice/test/topology/movement/MakeFrame.java @ 93:6601f8854126 working

can KeyInputCodeSegment
author sugi
date Tue, 05 Jun 2012 16:33:28 +0900
parents 8e3c1217aad4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
81
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
1 package alice.test.topology.movement;
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
2
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
3 import java.awt.GraphicsConfiguration;
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
4
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
5 import javax.media.j3d.BoundingSphere;
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
6 import javax.media.j3d.BranchGroup;
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
7 import javax.media.j3d.Canvas3D;
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
8 import javax.media.j3d.DirectionalLight;
88
33a19ca88e43 Singleton is removed .
sugi
parents: 86
diff changeset
9
81
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
10 import javax.swing.JFrame;
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
11 import javax.swing.JPanel;
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
12 import javax.vecmath.Color3f;
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
13 import javax.vecmath.Vector3f;
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
14
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
15 import com.sun.j3d.utils.universe.SimpleUniverse;
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
16 import com.sun.j3d.utils.universe.ViewingPlatform;
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
17
88
33a19ca88e43 Singleton is removed .
sugi
parents: 86
diff changeset
18 public class MakeFrame {
81
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
19
88
33a19ca88e43 Singleton is removed .
sugi
parents: 86
diff changeset
20 int fSizeX = 800;
33a19ca88e43 Singleton is removed .
sugi
parents: 86
diff changeset
21 int fSizeY = 800;
86
f8d86641b2ec remove null
sugi
parents: 84
diff changeset
22 private Canvas3D canvas;
88
33a19ca88e43 Singleton is removed .
sugi
parents: 86
diff changeset
23 private SimpleUniverse universe;
33a19ca88e43 Singleton is removed .
sugi
parents: 86
diff changeset
24 private KeyInput key;
93
6601f8854126 can KeyInputCodeSegment
sugi
parents: 92
diff changeset
25 private KeyInputCodeSegment KIC;
81
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
26
88
33a19ca88e43 Singleton is removed .
sugi
parents: 86
diff changeset
27 public MakeFrame(){
33a19ca88e43 Singleton is removed .
sugi
parents: 86
diff changeset
28 JFrame frame = new JFrame();
33a19ca88e43 Singleton is removed .
sugi
parents: 86
diff changeset
29 frame.setSize(fSizeX,fSizeY);
33a19ca88e43 Singleton is removed .
sugi
parents: 86
diff changeset
30 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
81
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
31
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
32 JPanel cp = new JPanel();
88
33a19ca88e43 Singleton is removed .
sugi
parents: 86
diff changeset
33 cp.setLayout(null);
81
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
34 frame.add(cp);
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
35
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
36 GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
82
5cf20458b9e0 paste texture on the object
sugi
parents: 81
diff changeset
37 canvas = new Canvas3D(config);
88
33a19ca88e43 Singleton is removed .
sugi
parents: 86
diff changeset
38 canvas.setBounds(0,0,fSizeX,fSizeY);
33a19ca88e43 Singleton is removed .
sugi
parents: 86
diff changeset
39 cp.add(canvas);
82
5cf20458b9e0 paste texture on the object
sugi
parents: 81
diff changeset
40
88
33a19ca88e43 Singleton is removed .
sugi
parents: 86
diff changeset
41 universe = new SimpleUniverse(canvas);
33a19ca88e43 Singleton is removed .
sugi
parents: 86
diff changeset
42 universe.addBranchGraph(createLight());
93
6601f8854126 can KeyInputCodeSegment
sugi
parents: 92
diff changeset
43 /*
88
33a19ca88e43 Singleton is removed .
sugi
parents: 86
diff changeset
44 key = new KeyInput();
33a19ca88e43 Singleton is removed .
sugi
parents: 86
diff changeset
45 canvas.addKeyListener(key);
93
6601f8854126 can KeyInputCodeSegment
sugi
parents: 92
diff changeset
46 */
6601f8854126 can KeyInputCodeSegment
sugi
parents: 92
diff changeset
47 KIC = new KeyInputCodeSegment();
6601f8854126 can KeyInputCodeSegment
sugi
parents: 92
diff changeset
48 canvas.addKeyListener(KIC);
88
33a19ca88e43 Singleton is removed .
sugi
parents: 86
diff changeset
49 frame.setVisible(true);
81
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
50
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
51 ViewingPlatform camera = universe.getViewingPlatform();
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
52 camera.setNominalViewingTransform();
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
53 }
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
54
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
55 private BranchGroup createLight(){
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
56 BranchGroup scene = new BranchGroup();
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
57 Color3f light_color = new Color3f(1.7f,1.7f,1.7f);
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
58 Vector3f light_direction = new Vector3f(0.2f,-0.2f,-0.6f);
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
59 DirectionalLight light = new DirectionalLight(light_color,light_direction);
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
60 BoundingSphere bounds = new BoundingSphere();
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
61 light.setInfluencingBounds(bounds);
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
62 scene.addChild(light);
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
63 return scene;
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
64 }
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
65
89
e269cedd8bae Test two fish
sugi
parents: 88
diff changeset
66 public void register(MakeObject obj){
e269cedd8bae Test two fish
sugi
parents: 88
diff changeset
67 BranchGroup group = obj.createBranch();
88
33a19ca88e43 Singleton is removed .
sugi
parents: 86
diff changeset
68 this.universe.addBranchGraph(group);
33a19ca88e43 Singleton is removed .
sugi
parents: 86
diff changeset
69 }
33a19ca88e43 Singleton is removed .
sugi
parents: 86
diff changeset
70
92
8e3c1217aad4 add KeyInput
sugi
parents: 89
diff changeset
71 public void registerKObj(MakeObject obj){
8e3c1217aad4 add KeyInput
sugi
parents: 89
diff changeset
72 BranchGroup group = obj.createKeyBranch();
8e3c1217aad4 add KeyInput
sugi
parents: 89
diff changeset
73 this.universe.addBranchGraph(group);
8e3c1217aad4 add KeyInput
sugi
parents: 89
diff changeset
74 }
8e3c1217aad4 add KeyInput
sugi
parents: 89
diff changeset
75
88
33a19ca88e43 Singleton is removed .
sugi
parents: 86
diff changeset
76 public Canvas3D getCanvas(){
33a19ca88e43 Singleton is removed .
sugi
parents: 86
diff changeset
77 return this.canvas;
81
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
78 }
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
79
88
33a19ca88e43 Singleton is removed .
sugi
parents: 86
diff changeset
80 public KeyInput getKey(){
33a19ca88e43 Singleton is removed .
sugi
parents: 86
diff changeset
81 return this.key;
33a19ca88e43 Singleton is removed .
sugi
parents: 86
diff changeset
82 }
33a19ca88e43 Singleton is removed .
sugi
parents: 86
diff changeset
83
93
6601f8854126 can KeyInputCodeSegment
sugi
parents: 92
diff changeset
84 public KeyInputCodeSegment getKeySegment(){
6601f8854126 can KeyInputCodeSegment
sugi
parents: 92
diff changeset
85 return this.KIC;
81
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
86 }
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
87
02dfb6c72632 This is movement test
sugi
parents:
diff changeset
88 }