aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ClientHamr/extantz/extantzCamera.cpp
diff options
context:
space:
mode:
authorDavid Walter Seikel2013-01-27 11:18:26 +1000
committerDavid Walter Seikel2013-01-27 11:18:26 +1000
commit37be70434d2d1ddd6d691863740d64ddbf0b2921 (patch)
treea1081a593ad8e4ca09440f2ddba08506b8a28627 /ClientHamr/extantz/extantzCamera.cpp
parentClean up the rest of the object files. (diff)
downloadSledjHamr-37be70434d2d1ddd6d691863740d64ddbf0b2921.zip
SledjHamr-37be70434d2d1ddd6d691863740d64ddbf0b2921.tar.gz
SledjHamr-37be70434d2d1ddd6d691863740d64ddbf0b2921.tar.bz2
SledjHamr-37be70434d2d1ddd6d691863740d64ddbf0b2921.tar.xz
Move a bunch of stuff into the new cameraMove structure, and some clean ups.
Diffstat (limited to 'ClientHamr/extantz/extantzCamera.cpp')
-rw-r--r--ClientHamr/extantz/extantzCamera.cpp88
1 files changed, 22 insertions, 66 deletions
diff --git a/ClientHamr/extantz/extantzCamera.cpp b/ClientHamr/extantz/extantzCamera.cpp
index cafc80b..f4554be 100644
--- a/ClientHamr/extantz/extantzCamera.cpp
+++ b/ClientHamr/extantz/extantzCamera.cpp
@@ -27,13 +27,13 @@ namespace scene
27 27
28// Irrlicht hard codes a reference to the original FPS camera code inside it's scene manager. This is that code extracted so we can be more flexible. 28// Irrlicht hard codes a reference to the original FPS camera code inside it's scene manager. This is that code extracted so we can be more flexible.
29// TODO - Hmmm, Where's CursorControl come from? Ah, passed to the scene manager constructor, it's a GUI thing that we need to replace with an EFL thing. 29// TODO - Hmmm, Where's CursorControl come from? Ah, passed to the scene manager constructor, it's a GUI thing that we need to replace with an EFL thing.
30ICameraSceneNode *addExtantzCamera(ISceneManager* sm, ISceneNode* parent, f32 rotateSpeed, f32 moveSpeed, s32 id, bool noVerticalMovement, f32 jumpSpeed, bool invertMouseY, bool makeActive) 30ICameraSceneNode *addExtantzCamera(ISceneManager* sm, ISceneNode* parent, s32 id)
31{ 31{
32 ICameraSceneNode* node = sm->addCameraSceneNode(parent, core::vector3df(), core::vector3df(0, 0, 100), id, makeActive); 32 ICameraSceneNode* node = sm->addCameraSceneNode(parent, core::vector3df(), core::vector3df(0, 0, 100), id, true);
33 if (node) 33 if (node)
34 { 34 {
35// ISceneNodeAnimator* anm = new extantzCamera(CursorControl, rotateSpeed, moveSpeed, jumpSpeed, noVerticalMovement, invertMouseY); 35// ISceneNodeAnimator* anm = new extantzCamera(CursorControl);
36 ISceneNodeAnimator* anm = new extantzCamera(rotateSpeed, moveSpeed, jumpSpeed, noVerticalMovement, invertMouseY); 36 ISceneNodeAnimator* anm = new extantzCamera();
37 37
38 // Bind the node's rotation to its target. This is consistent with 1.4.2 and below. 38 // Bind the node's rotation to its target. This is consistent with 1.4.2 and below.
39 node->bindTargetAndRotation(true); 39 node->bindTargetAndRotation(true);
@@ -46,16 +46,19 @@ ICameraSceneNode *addExtantzCamera(ISceneManager* sm, ISceneNode* parent, f32 ro
46 46
47 47
48//! constructor 48//! constructor
49//extantzCamera::extantzCamera(gui::ICursorControl* cursorControl, f32 rotateSpeed, f32 moveSpeed, f32 jumpSpeed, bool noVerticalMovement, bool invertY) 49//extantzCamera::extantzCamera(gui::ICursorControl* cursorControl)
50// : CursorControl(cursorControl), MaxVerticalAngle(88.0f), MoveSpeed(moveSpeed), RotateSpeed(rotateSpeed), JumpSpeed(jumpSpeed), 50// : CursorControl(cursorControl), MaxVerticalAngle(88.0f), MoveSpeed(0.4f), RotateSpeed(100.0f), JumpSpeed(3.0f),
51extantzCamera::extantzCamera(f32 rotateSpeed, f32 moveSpeed, f32 jumpSpeed, bool noVerticalMovement, bool invertY) 51extantzCamera::extantzCamera()
52 : MaxVerticalAngle(88.0f), MoveSpeed(moveSpeed), RotateSpeed(rotateSpeed), JumpSpeed(jumpSpeed), 52 : MaxVerticalAngle(88.0f), MouseYDirection(1.0f), LastAnimationTime(0), NoVerticalMovement(false)
53 MouseYDirection(invertY ? -1.0f : 1.0f), LastAnimationTime(0), firstUpdate(true), NoVerticalMovement(noVerticalMovement)
54{ 53{
55 #ifdef _DEBUG 54 #ifdef _DEBUG
56 setDebugName("extantzCamera"); 55 setDebugName("extantzCamera");
57 #endif 56 #endif
58 57
58 move.MoveSpeed = 0.1f;
59 move.RotateSpeed = 1.0f;
60 move.JumpSpeed = 3.0f;
61
59// if (CursorControl) 62// if (CursorControl)
60// CursorControl->grab(); 63// CursorControl->grab();
61} 64}
@@ -87,7 +90,7 @@ void extantzCamera::animateNode(ISceneNode* node, u32 timeMs)
87 90
88 ICameraSceneNode* camera = static_cast<ICameraSceneNode*>(node); 91 ICameraSceneNode* camera = static_cast<ICameraSceneNode*>(node);
89 92
90 if (firstUpdate) 93 if (0 == LastAnimationTime)
91 { 94 {
92 camera->updateAbsolutePosition(); 95 camera->updateAbsolutePosition();
93// if (CursorControl ) 96// if (CursorControl )
@@ -97,11 +100,10 @@ void extantzCamera::animateNode(ISceneNode* node, u32 timeMs)
97// } 100// }
98 101
99 LastAnimationTime = timeMs; 102 LastAnimationTime = timeMs;
100
101 firstUpdate = false;
102 } 103 }
103 104
104 // If the camera isn't the active camera, and receiving input, then don't process it. 105 // If the camera isn't the active camera, and receiving input, then don't process it.
106 // TODO - it never is, coz we are bypassing that, but can we replace this with something else?
105 if(!camera->isInputReceiverEnabled()) 107 if(!camera->isInputReceiverEnabled())
106 { 108 {
107// return; 109// return;
@@ -112,7 +114,7 @@ void extantzCamera::animateNode(ISceneNode* node, u32 timeMs)
112 return; 114 return;
113 115
114 // get time 116 // get time
115 f32 timeDiff = (f32) ( timeMs - LastAnimationTime ); 117 f32 timeDiff = (f32) (timeMs - LastAnimationTime);
116 LastAnimationTime = timeMs; 118 LastAnimationTime = timeMs;
117 119
118 // update position 120 // update position
@@ -127,8 +129,8 @@ void extantzCamera::animateNode(ISceneNode* node, u32 timeMs)
127 { 129 {
128 if (CursorPos != CenterCursor) 130 if (CursorPos != CenterCursor)
129 { 131 {
130 relativeRotation.Y -= (0.5f - CursorPos.X) * RotateSpeed; 132 relativeRotation.Y -= (0.5f - CursorPos.X) * move.RotateSpeed;
131 relativeRotation.X -= (0.5f - CursorPos.Y) * RotateSpeed * MouseYDirection; 133 relativeRotation.X -= (0.5f - CursorPos.Y) * move.RotateSpeed * MouseYDirection;
132 134
133 // X < MaxVerticalAngle or X > 360-MaxVerticalAngle 135 // X < MaxVerticalAngle or X > 360-MaxVerticalAngle
134 136
@@ -192,8 +194,7 @@ void extantzCamera::animateNode(ISceneNode* node, u32 timeMs)
192 194
193 movedir.normalize(); 195 movedir.normalize();
194 196
195 // TODO - There is no turning left or right, flying, or the other things I'll need. So might as well create my own thing to replace the original FPS camera. 197 pos += movedir * timeDiff * move.MoveSpeed * move.x;
196 pos += movedir * timeDiff * MoveSpeed * move.x;
197 198
198 // strafing 199 // strafing
199 core::vector3df strafevect = target; 200 core::vector3df strafevect = target;
@@ -204,7 +205,7 @@ void extantzCamera::animateNode(ISceneNode* node, u32 timeMs)
204 205
205 strafevect.normalize(); 206 strafevect.normalize();
206 207
207 pos += strafevect * timeDiff * MoveSpeed * move.y; 208 pos += strafevect * timeDiff * move.MoveSpeed * move.y;
208 209
209 // For jumping, we find the collision response animator attached to our camera 210 // For jumping, we find the collision response animator attached to our camera
210 // and if it's not falling, we tell it to jump. 211 // and if it's not falling, we tell it to jump.
@@ -220,7 +221,7 @@ void extantzCamera::animateNode(ISceneNode* node, u32 timeMs)
220 static_cast<ISceneNodeAnimatorCollisionResponse *>(*it); 221 static_cast<ISceneNodeAnimatorCollisionResponse *>(*it);
221 222
222 if(!collisionResponse->isFalling()) 223 if(!collisionResponse->isFalling())
223 collisionResponse->jump(JumpSpeed); 224 collisionResponse->jump(move.JumpSpeed);
224 } 225 }
225 226
226 it++; 227 it++;
@@ -236,55 +237,10 @@ void extantzCamera::animateNode(ISceneNode* node, u32 timeMs)
236} 237}
237 238
238 239
239//! Sets the rotation speed
240void extantzCamera::setRotateSpeed(f32 speed)
241{
242 RotateSpeed = speed;
243}
244
245
246//! Sets the movement speed
247void extantzCamera::setMoveSpeed(f32 speed)
248{
249 MoveSpeed = speed;
250}
251
252
253//! Gets the rotation speed
254f32 extantzCamera::getRotateSpeed() const
255{
256 return RotateSpeed;
257}
258
259
260// Gets the movement speed
261f32 extantzCamera::getMoveSpeed() const
262{
263 return MoveSpeed;
264}
265
266
267//! Sets whether vertical movement should be allowed.
268void extantzCamera::setVerticalMovement(bool allow)
269{
270 NoVerticalMovement = !allow;
271}
272
273
274//! Sets whether the Y axis of the mouse should be inverted.
275void extantzCamera::setInvertMouse(bool invert)
276{
277 if (invert)
278 MouseYDirection = -1.0f;
279 else
280 MouseYDirection = 1.0f;
281}
282
283
284ISceneNodeAnimator* extantzCamera::createClone(ISceneNode* node, ISceneManager* newManager) 240ISceneNodeAnimator* extantzCamera::createClone(ISceneNode* node, ISceneManager* newManager)
285{ 241{
286// extantzCamera *newAnimator = new extantzCamera(CursorControl, RotateSpeed, MoveSpeed, JumpSpeed, NoVerticalMovement); 242// extantzCamera *newAnimator = new extantzCamera(CursorControl);
287 extantzCamera *newAnimator = new extantzCamera(RotateSpeed, MoveSpeed, JumpSpeed, NoVerticalMovement); 243 extantzCamera *newAnimator = new extantzCamera();
288 return newAnimator; 244 return newAnimator;
289} 245}
290 246