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

can KeyInputCodeSegment
author sugi
date Tue, 05 Jun 2012 16:33:28 +0900
parents 33a19ca88e43
children 21e68300e205
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
88
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
1 package alice.test.topology.movement;
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
2
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
3 import java.awt.event.KeyEvent;
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
4 import java.awt.event.KeyListener;
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
5
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
6 import javax.media.j3d.Transform3D;
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
7 import javax.media.j3d.TransformGroup;
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
8 import javax.vecmath.Vector3f;
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
9
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
10
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
11 public class KeyInput implements KeyListener{
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
12
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
13 int KeyCode = 0;
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
14 Vector3f vector;
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
15 Transform3D transform;
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
16 TransformGroup transformGroup;
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
17
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
18 public KeyInput(){
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
19 transform = new Transform3D();
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
20 transformGroup= new TransformGroup();
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
21 transformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
22 vector = new Vector3f(0.0f,0.0f,0.0f);
93
6601f8854126 can KeyInputCodeSegment
sugi
parents: 88
diff changeset
23
88
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
24 }
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
25 @Override
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
26 public void keyPressed(KeyEvent event) {
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
27 // TODO Auto-generated method stub
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
28 KeyCode = event.getKeyCode();
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
29 switch(KeyCode)
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
30 {
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
31 case 37:
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
32 vector.x -= 0.1f;
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
33 break;
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
34 case 38:
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
35 vector.y += 0.1f;
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
36 break;
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
37 case 39:
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
38 vector.x += 0.1f;
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
39 break;
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
40 case 40:
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
41 vector.y -= 0.1f;
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
42 break;
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
43 }
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
44 transform.setTranslation(vector);
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
45 transformGroup.setTransform(transform);
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
46 }
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
47
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
48 @Override
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
49 public void keyReleased(KeyEvent arg0) {
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
50 // TODO Auto-generated method stub
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
51
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
52 }
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
53
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
54 @Override
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
55 public void keyTyped(KeyEvent arg0) {
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
56 // TODO Auto-generated method stub
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
57
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
58 }
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
59
33a19ca88e43 Singleton is removed .
sugi
parents:
diff changeset
60 }