aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ClientHamr/extantz
diff options
context:
space:
mode:
authorDavid Walter Seikel2013-01-23 05:12:02 +1000
committerDavid Walter Seikel2013-01-23 05:12:02 +1000
commit77723c64f5078bed684b906d5d1e0142945caaed (patch)
tree63287b5364dcd2dcd8c1581b8885a55327f41ebf /ClientHamr/extantz
parentClone CSceneNodeAnimatorCameraFPS so I can start to morph it into a real camera. (diff)
downloadSledjHamr-77723c64f5078bed684b906d5d1e0142945caaed.zip
SledjHamr-77723c64f5078bed684b906d5d1e0142945caaed.tar.gz
SledjHamr-77723c64f5078bed684b906d5d1e0142945caaed.tar.bz2
SledjHamr-77723c64f5078bed684b906d5d1e0142945caaed.tar.xz
Delete a bunch of the keyboard handling stuff.
Diffstat (limited to 'ClientHamr/extantz')
-rw-r--r--ClientHamr/extantz/CDemo.cpp26
-rw-r--r--ClientHamr/extantz/extantzCamera.cpp77
-rw-r--r--ClientHamr/extantz/extantzCamera.h23
3 files changed, 20 insertions, 106 deletions
diff --git a/ClientHamr/extantz/CDemo.cpp b/ClientHamr/extantz/CDemo.cpp
index 929f0db..7fc6ac1 100644
--- a/ClientHamr/extantz/CDemo.cpp
+++ b/ClientHamr/extantz/CDemo.cpp
@@ -191,31 +191,7 @@ void CDemo::switchToNextScene()
191 } 191 }
192 timeForThisScene = -1; 192 timeForThisScene = -1;
193 193
194 SKeyMap keyMap[9]; 194 camera = addExtantzCamera(sm, 0, 100.0f, .4f, -1, false, 3.f, false, true);
195 keyMap[0].Action = EKA_MOVE_FORWARD;
196 keyMap[0].KeyCode = KEY_UP;
197 keyMap[1].Action = EKA_MOVE_FORWARD;
198 keyMap[1].KeyCode = KEY_KEY_W;
199
200 keyMap[2].Action = EKA_MOVE_BACKWARD;
201 keyMap[2].KeyCode = KEY_DOWN;
202 keyMap[3].Action = EKA_MOVE_BACKWARD;
203 keyMap[3].KeyCode = KEY_KEY_S;
204
205 keyMap[4].Action = EKA_STRAFE_LEFT;
206 keyMap[4].KeyCode = KEY_LEFT;
207 keyMap[5].Action = EKA_STRAFE_LEFT;
208 keyMap[5].KeyCode = KEY_KEY_A;
209
210 keyMap[6].Action = EKA_STRAFE_RIGHT;
211 keyMap[6].KeyCode = KEY_RIGHT;
212 keyMap[7].Action = EKA_STRAFE_RIGHT;
213 keyMap[7].KeyCode = KEY_KEY_D;
214
215 keyMap[8].Action = EKA_JUMP_UP;
216 keyMap[8].KeyCode = KEY_KEY_J;
217
218 camera = addExtantzCamera(sm, 0, 100.0f, .4f, -1, keyMap, 9, false, 3.f, false, true);
219 camera->setPosition(core::vector3df(150, 170, -160)); 195 camera->setPosition(core::vector3df(150, 170, -160));
220 camera->setFarValue(5000.0f); 196 camera->setFarValue(5000.0f);
221 197
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
diff --git a/ClientHamr/extantz/extantzCamera.h b/ClientHamr/extantz/extantzCamera.h
index a81eb8a..cfd4361 100644
--- a/ClientHamr/extantz/extantzCamera.h
+++ b/ClientHamr/extantz/extantzCamera.h
@@ -24,14 +24,14 @@ namespace gui
24namespace scene 24namespace scene
25{ 25{
26 26
27 ICameraSceneNode *addExtantzCamera(ISceneManager* sm, ISceneNode* parent, f32 rotateSpeed, f32 moveSpeed, s32 id, SKeyMap* keyMapArray, s32 keyMapSize, bool noVerticalMovement, f32 jumpSpeed, bool invertMouseY, bool makeActive); 27 ICameraSceneNode *addExtantzCamera(ISceneManager* sm, ISceneNode* parent, f32 rotateSpeed, f32 moveSpeed, s32 id, bool noVerticalMovement, f32 jumpSpeed, bool invertMouseY, bool makeActive);
28 28
29 class extantzCamera : public ISceneNodeAnimator 29 class extantzCamera : public ISceneNodeAnimator
30 { 30 {
31 public: 31 public:
32 32
33 //! Constructor 33 //! Constructor
34 extantzCamera(gui::ICursorControl* cursorControl, f32 rotateSpeed = 100.0f, f32 moveSpeed = .5f, f32 jumpSpeed=0.f, SKeyMap* keyMapArray=0, u32 keyMapSize=0, bool noVerticalMovement=false, bool invertY=false); 34 extantzCamera(gui::ICursorControl* cursorControl, f32 rotateSpeed = 100.0f, f32 moveSpeed = .5f, f32 jumpSpeed=0.f, bool noVerticalMovement=false, bool invertY=false);
35 35
36 //! Destructor 36 //! Destructor
37 virtual ~extantzCamera(); 37 virtual ~extantzCamera();
@@ -39,9 +39,6 @@ namespace scene
39 //! Animates the scene node, currently only works on cameras 39 //! Animates the scene node, currently only works on cameras
40 virtual void animateNode(ISceneNode* node, u32 timeMs); 40 virtual void animateNode(ISceneNode* node, u32 timeMs);
41 41
42 //! Event receiver
43 virtual bool OnEvent(const SEvent& event);
44
45 //! Returns the speed of movement in units per second 42 //! Returns the speed of movement in units per second
46 virtual f32 getMoveSpeed() const; 43 virtual f32 getMoveSpeed() const;
47 44
@@ -54,18 +51,6 @@ namespace scene
54 //! Set the rotation speed 51 //! Set the rotation speed
55 virtual void setRotateSpeed(f32 rotateSpeed); 52 virtual void setRotateSpeed(f32 rotateSpeed);
56 53
57 //! Sets the keyboard mapping for this animator (old style)
58 //! \param keymap: an array of keyboard mappings, see SKeyMap
59 //! \param count: the size of the keyboard map array
60 virtual void setKeyMap(SKeyMap *map, u32 count);
61
62 //! Sets the keyboard mapping for this animator
63 //! \param keymap The new keymap array
64 virtual void setKeyMap(const core::array<SKeyMap>& keymap);
65
66 //! Gets the keyboard mapping for this animator
67 virtual const core::array<SKeyMap>& getKeyMap() const;
68
69 //! Sets whether vertical movement should be allowed. 54 //! Sets whether vertical movement should be allowed.
70 virtual void setVerticalMovement(bool allow); 55 virtual void setVerticalMovement(bool allow);
71 56
@@ -77,7 +62,7 @@ namespace scene
77 //! This animator will receive events when attached to the active camera 62 //! This animator will receive events when attached to the active camera
78 virtual bool isEventReceiverEnabled() const 63 virtual bool isEventReceiverEnabled() const
79 { 64 {
80 return true; 65 return false;
81 } 66 }
82 67
83 //! Returns the type of this animator 68 //! Returns the type of this animator
@@ -107,13 +92,11 @@ namespace scene
107 92
108 s32 LastAnimationTime; 93 s32 LastAnimationTime;
109 94
110 core::array<SKeyMap> KeyMap;
111 core::position2d<f32> CenterCursor, CursorPos; 95 core::position2d<f32> CenterCursor, CursorPos;
112 96
113 bool CursorKeys[EKA_COUNT]; 97 bool CursorKeys[EKA_COUNT];
114 98
115 bool firstUpdate; 99 bool firstUpdate;
116 bool firstInput;
117 bool NoVerticalMovement; 100 bool NoVerticalMovement;
118 }; 101 };
119 102