aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ClientHamr/extantz/extantzCamera.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ClientHamr/extantz/extantzCamera.cpp77
1 files changed, 16 insertions, 61 deletions
diff --git a/ClientHamr/extantz/extantzCamera.cpp b/ClientHamr/extantz/extantzCamera.cpp
index 3c0ff7a..cab1faa 100644
--- a/ClientHamr/extantz/extantzCamera.cpp
+++ b/ClientHamr/extantz/extantzCamera.cpp
@@ -9,6 +9,9 @@
9// As such, I expect lots of Nikolaus Gebhardt's code to go away. 9// As such, I expect lots of Nikolaus Gebhardt's code to go away.
10// To be replaced by my code, which will be copyright and licensed under the same license as the rest of extantz. 10// To be replaced by my code, which will be copyright and licensed under the same license as the rest of extantz.
11 11
12// Initally I'll make it SecondLife like, coz that's what my muscle memory is used to.
13// It will get extended and made generic though.
14
12#include "extantzCamera.h" 15#include "extantzCamera.h"
13#include "IVideoDriver.h" 16#include "IVideoDriver.h"
14#include "ISceneManager.h" 17#include "ISceneManager.h"
@@ -23,14 +26,14 @@ namespace scene
23{ 26{
24 27
25// 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.
26// 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.
27ICameraSceneNode *addExtantzCamera(ISceneManager* sm, ISceneNode* parent, f32 rotateSpeed, f32 moveSpeed, s32 id, SKeyMap* keyMapArray, s32 keyMapSize, bool noVerticalMovement, f32 jumpSpeed, bool invertMouseY, bool makeActive) 30ICameraSceneNode *addExtantzCamera(ISceneManager* sm, ISceneNode* parent, f32 rotateSpeed, f32 moveSpeed, s32 id, bool noVerticalMovement, f32 jumpSpeed, bool invertMouseY, bool makeActive)
28{ 31{
29 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, makeActive);
30 if (node) 33 if (node)
31 { 34 {
32// ISceneNodeAnimator* anm = new extantzCamera(CursorControl, rotateSpeed, moveSpeed, jumpSpeed, keyMapArray, keyMapSize, noVerticalMovement, invertMouseY); 35// ISceneNodeAnimator* anm = new extantzCamera(CursorControl, rotateSpeed, moveSpeed, jumpSpeed, noVerticalMovement, invertMouseY);
33 ISceneNodeAnimator* anm = new extantzCamera(NULL, rotateSpeed, moveSpeed, jumpSpeed, keyMapArray, keyMapSize, noVerticalMovement, invertMouseY); 36 ISceneNodeAnimator* anm = new extantzCamera(NULL, rotateSpeed, moveSpeed, jumpSpeed, noVerticalMovement, invertMouseY);
34 37
35 // 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.
36 node->bindTargetAndRotation(true); 39 node->bindTargetAndRotation(true);
@@ -43,9 +46,9 @@ ICameraSceneNode *addExtantzCamera(ISceneManager* sm, ISceneNode* parent, f32 ro
43 46
44 47
45//! constructor 48//! constructor
46extantzCamera::extantzCamera(gui::ICursorControl* cursorControl, f32 rotateSpeed, f32 moveSpeed, f32 jumpSpeed, SKeyMap* keyMapArray, u32 keyMapSize, bool noVerticalMovement, bool invertY) 49extantzCamera::extantzCamera(gui::ICursorControl* cursorControl, f32 rotateSpeed, f32 moveSpeed, f32 jumpSpeed, bool noVerticalMovement, bool invertY)
47 : CursorControl(cursorControl), MaxVerticalAngle(88.0f), MoveSpeed(moveSpeed), RotateSpeed(rotateSpeed), JumpSpeed(jumpSpeed), 50 : CursorControl(cursorControl), MaxVerticalAngle(88.0f), MoveSpeed(moveSpeed), RotateSpeed(rotateSpeed), JumpSpeed(jumpSpeed),
48 MouseYDirection(invertY ? -1.0f : 1.0f), LastAnimationTime(0), firstUpdate(true), firstInput(true), NoVerticalMovement(noVerticalMovement) 51 MouseYDirection(invertY ? -1.0f : 1.0f), LastAnimationTime(0), firstUpdate(true), NoVerticalMovement(noVerticalMovement)
49{ 52{
50 #ifdef _DEBUG 53 #ifdef _DEBUG
51 setDebugName("extantzCamera"); 54 setDebugName("extantzCamera");
@@ -55,22 +58,6 @@ extantzCamera::extantzCamera(gui::ICursorControl* cursorControl, f32 rotateSpeed
55// CursorControl->grab(); 58// CursorControl->grab();
56 59
57 allKeysUp(); 60 allKeysUp();
58
59 // create key map
60 if (!keyMapArray || !keyMapSize)
61 {
62 // create default key map
63 KeyMap.push_back(SKeyMap(EKA_MOVE_FORWARD, irr::KEY_UP));
64 KeyMap.push_back(SKeyMap(EKA_MOVE_BACKWARD, irr::KEY_DOWN));
65 KeyMap.push_back(SKeyMap(EKA_STRAFE_LEFT, irr::KEY_LEFT));
66 KeyMap.push_back(SKeyMap(EKA_STRAFE_RIGHT, irr::KEY_RIGHT));
67 KeyMap.push_back(SKeyMap(EKA_JUMP_UP, irr::KEY_KEY_J));
68 }
69 else
70 {
71 // create custom key map
72 setKeyMap(keyMapArray, keyMapSize);
73 }
74} 61}
75 62
76 63
@@ -82,11 +69,9 @@ extantzCamera::~extantzCamera()
82} 69}
83 70
84 71
85//! It is possible to send mouse and key events to the camera. Most cameras 72#if 0
86//! may ignore this input, but camera scene nodes which are created for 73// TODO - get rid of this, it's an Irrlicht callback, and I'm replacing it all with EFL.
87//! example with scene::ISceneManager::addMayaCameraSceneNode or 74// Leaving it here for the moment as an example.
88//! scene::ISceneManager::addFPSCameraSceneNode, may want to get this input
89//! for changing their position, look at target or whatever.
90bool extantzCamera::OnEvent(const SEvent& evt) 75bool extantzCamera::OnEvent(const SEvent& evt)
91{ 76{
92 switch(evt.EventType) 77 switch(evt.EventType)
@@ -116,7 +101,7 @@ bool extantzCamera::OnEvent(const SEvent& evt)
116 101
117 return false; 102 return false;
118} 103}
119 104#endif
120 105
121void extantzCamera::animateNode(ISceneNode* node, u32 timeMs) 106void extantzCamera::animateNode(ISceneNode* node, u32 timeMs)
122{ 107{
@@ -142,14 +127,8 @@ void extantzCamera::animateNode(ISceneNode* node, u32 timeMs)
142 // If the camera isn't the active camera, and receiving input, then don't process it. 127 // If the camera isn't the active camera, and receiving input, then don't process it.
143 if(!camera->isInputReceiverEnabled()) 128 if(!camera->isInputReceiverEnabled())
144 { 129 {
145 firstInput = true;
146 return;
147 }
148
149 if ( firstInput )
150 {
151 allKeysUp(); 130 allKeysUp();
152 firstInput = false; 131 return;
153 } 132 }
154 133
155 scene::ISceneManager * smgr = camera->getSceneManager(); 134 scene::ISceneManager * smgr = camera->getSceneManager();
@@ -237,6 +216,7 @@ void extantzCamera::animateNode(ISceneNode* node, u32 timeMs)
237 216
238 movedir.normalize(); 217 movedir.normalize();
239 218
219 // TODO - There is no turning left or right, or the other things I'll need. So might as well create my own thing to replace this.
240 if (CursorKeys[EKA_MOVE_FORWARD]) 220 if (CursorKeys[EKA_MOVE_FORWARD])
241 pos += movedir * timeDiff * MoveSpeed; 221 pos += movedir * timeDiff * MoveSpeed;
242 222
@@ -324,30 +304,6 @@ f32 extantzCamera::getMoveSpeed() const
324} 304}
325 305
326 306
327//! Sets the keyboard mapping for this animator
328void extantzCamera::setKeyMap(SKeyMap *map, u32 count)
329{
330 // clear the keymap
331 KeyMap.clear();
332
333 // add actions
334 for (u32 i=0; i<count; ++i)
335 {
336 KeyMap.push_back(map[i]);
337 }
338}
339
340void extantzCamera::setKeyMap(const core::array<SKeyMap>& keymap)
341{
342 KeyMap=keymap;
343}
344
345const core::array<SKeyMap>& extantzCamera::getKeyMap() const
346{
347 return KeyMap;
348}
349
350
351//! Sets whether vertical movement should be allowed. 307//! Sets whether vertical movement should be allowed.
352void extantzCamera::setVerticalMovement(bool allow) 308void extantzCamera::setVerticalMovement(bool allow)
353{ 309{
@@ -367,8 +323,7 @@ void extantzCamera::setInvertMouse(bool invert)
367 323
368ISceneNodeAnimator* extantzCamera::createClone(ISceneNode* node, ISceneManager* newManager) 324ISceneNodeAnimator* extantzCamera::createClone(ISceneNode* node, ISceneManager* newManager)
369{ 325{
370 extantzCamera *newAnimator = new extantzCamera(CursorControl, RotateSpeed, MoveSpeed, JumpSpeed, 0, 0, NoVerticalMovement); 326 extantzCamera *newAnimator = new extantzCamera(CursorControl, RotateSpeed, MoveSpeed, JumpSpeed, NoVerticalMovement);
371 newAnimator->setKeyMap(KeyMap);
372 return newAnimator; 327 return newAnimator;
373} 328}
374 329