Main repository of MikuMikuStudio
Revision | 2d2de19e21b4ff0f5765f8fd7c4828288c1bc50d (tree) |
---|---|
Time | 2003-10-29 05:11:29 |
Author | mojomonkey <mojomonkey@75d0...> |
Commiter | mojomonkey |
actions are now framerate independant.
git-svn-id: http://jmonkeyengine.googlecode.com/svn/trunk@128 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
@@ -62,7 +62,7 @@ public class KeyLookDownAction implements InputAction { | ||
62 | 62 | */ |
63 | 63 | public void performAction(float time) { |
64 | 64 | incr.loadIdentity(); |
65 | - incr.fromAxisAngle(camera.getLeft(), speed); | |
65 | + incr.fromAxisAngle(camera.getLeft(), speed * time); | |
66 | 66 | camera.setLeft(incr.mult(camera.getLeft())); |
67 | 67 | camera.setDirection(incr.mult(camera.getDirection())); |
68 | 68 | camera.setUp(incr.mult(camera.getUp())); |
@@ -62,7 +62,7 @@ public class KeyLookUpAction implements InputAction { | ||
62 | 62 | */ |
63 | 63 | public void performAction(float time) { |
64 | 64 | incr.loadIdentity(); |
65 | - incr.fromAxisAngle(camera.getLeft(), -speed); | |
65 | + incr.fromAxisAngle(camera.getLeft(), -speed * time); | |
66 | 66 | camera.setLeft(incr.mult(camera.getLeft())); |
67 | 67 | camera.setDirection(incr.mult(camera.getDirection())); |
68 | 68 | camera.setUp(incr.mult(camera.getUp())); |
@@ -67,9 +67,9 @@ public class KeyRotateLeftAction implements InputAction { | ||
67 | 67 | public void performAction(float time) { |
68 | 68 | incr.loadIdentity(); |
69 | 69 | if(lockAxis == null) { |
70 | - incr.fromAxisAngle(camera.getUp(), speed); | |
70 | + incr.fromAxisAngle(camera.getUp(), speed * time); | |
71 | 71 | } else { |
72 | - incr.fromAxisAngle(lockAxis, speed); | |
72 | + incr.fromAxisAngle(lockAxis, speed * time); | |
73 | 73 | } |
74 | 74 | |
75 | 75 | camera.setUp(incr.mult(camera.getUp())); |
@@ -67,9 +67,9 @@ public class KeyRotateRightAction implements InputAction { | ||
67 | 67 | public void performAction(float time) { |
68 | 68 | incr.loadIdentity(); |
69 | 69 | if(lockAxis == null) { |
70 | - incr.fromAxisAngle(camera.getUp(), -speed); | |
70 | + incr.fromAxisAngle(camera.getUp(), -speed * time); | |
71 | 71 | } else { |
72 | - incr.fromAxisAngle(lockAxis, -speed); | |
72 | + incr.fromAxisAngle(lockAxis, -speed * time); | |
73 | 73 | } |
74 | 74 | camera.setUp(incr.mult(camera.getUp())); |
75 | 75 |
@@ -40,45 +40,45 @@ import com.jme.renderer.Camera; | ||
40 | 40 | * @author Mark Powell |
41 | 41 | * @version |
42 | 42 | */ |
43 | -public class MouseLook implements MouseInputAction{ | |
43 | +public class MouseLook implements MouseInputAction { | |
44 | 44 | public static final int MOUSE_BUFFER = 1; |
45 | 45 | private MouseInput mouse; |
46 | 46 | private KeyLookDownAction lookDown; |
47 | 47 | private KeyLookUpAction lookUp; |
48 | 48 | private KeyRotateLeftAction rotateLeft; |
49 | 49 | private KeyRotateRightAction rotateRight; |
50 | - | |
50 | + | |
51 | 51 | private Vector3f lockAxis; |
52 | - | |
52 | + | |
53 | 53 | private float speed; |
54 | 54 | private Camera camera; |
55 | - | |
55 | + | |
56 | 56 | public MouseLook(MouseInput mouse, Camera camera, float speed) { |
57 | 57 | this.mouse = mouse; |
58 | 58 | this.speed = speed; |
59 | 59 | this.camera = camera; |
60 | - | |
60 | + | |
61 | 61 | lookDown = new KeyLookDownAction(camera, speed); |
62 | 62 | lookUp = new KeyLookUpAction(camera, speed); |
63 | 63 | rotateLeft = new KeyRotateLeftAction(camera, speed); |
64 | 64 | rotateRight = new KeyRotateRightAction(camera, speed); |
65 | 65 | } |
66 | - | |
66 | + | |
67 | 67 | public void setLockAxis(Vector3f lockAxis) { |
68 | 68 | this.lockAxis = lockAxis; |
69 | 69 | rotateLeft.setLockAxis(lockAxis); |
70 | 70 | rotateRight.setLockAxis(lockAxis); |
71 | 71 | } |
72 | - | |
72 | + | |
73 | 73 | public void setSpeed(float speed) { |
74 | 74 | this.speed = speed; |
75 | 75 | lookDown.setSpeed(speed); |
76 | 76 | lookUp.setSpeed(speed); |
77 | 77 | rotateRight.setSpeed(speed); |
78 | 78 | rotateLeft.setSpeed(speed); |
79 | - | |
79 | + | |
80 | 80 | } |
81 | - | |
81 | + | |
82 | 82 | public float getSpeed() { |
83 | 83 | return speed; |
84 | 84 | } |
@@ -86,17 +86,21 @@ public class MouseLook implements MouseInputAction{ | ||
86 | 86 | * @see com.jme.input.action.MouseInputAction#performAction(float) |
87 | 87 | */ |
88 | 88 | public void performAction(float time) { |
89 | - if(mouse.getXDelta() > 0) { | |
90 | - rotateRight.performAction(time * ((float)mouse.getXDelta()/MOUSE_BUFFER)); | |
91 | - } else if(mouse.getXDelta() < 0) { | |
92 | - rotateLeft.performAction(time * ((float)mouse.getXDelta()/MOUSE_BUFFER)); | |
89 | + if (mouse.getXDelta() > 0) { | |
90 | + rotateRight.performAction( | |
91 | + time * ((float) mouse.getXDelta() / MOUSE_BUFFER)); | |
92 | + } else if (mouse.getXDelta() < 0) { | |
93 | + rotateLeft.performAction( | |
94 | + time * ((float) mouse.getXDelta() / MOUSE_BUFFER) * -1); | |
93 | 95 | } |
94 | - if(mouse.getYDelta() > 0) { | |
95 | - lookUp.performAction(time * ((float)mouse.getYDelta()/MOUSE_BUFFER)); | |
96 | - } else if(mouse.getYDelta() < 0) { | |
97 | - lookDown.performAction(time * ((float)mouse.getYDelta()/MOUSE_BUFFER)); | |
96 | + if (mouse.getYDelta() > 0) { | |
97 | + lookUp.performAction( | |
98 | + time * ((float) mouse.getYDelta() / MOUSE_BUFFER)); | |
99 | + } else if (mouse.getYDelta() < 0) { | |
100 | + lookDown.performAction( | |
101 | + time * ((float) mouse.getYDelta() / MOUSE_BUFFER) * -1); | |
98 | 102 | } |
99 | - | |
103 | + | |
100 | 104 | } |
101 | 105 | /* (non-Javadoc) |
102 | 106 | * @see com.jme.input.action.MouseInputAction#setMouse(com.jme.input.Mouse) |
@@ -104,6 +108,5 @@ public class MouseLook implements MouseInputAction{ | ||
104 | 108 | public void setMouse(MouseInput mouse) { |
105 | 109 | this.mouse = mouse; |
106 | 110 | } |
107 | - | |
108 | - | |
111 | + | |
109 | 112 | } |