~baltix/+junk/irrlicht-test

« back to all changes in this revision

Viewing changes to source/Irrlicht/CSceneNodeAnimatorCameraFPS.h

  • Committer: Mantas Kriaučiūnas
  • Date: 2011-07-18 13:06:25 UTC
  • Revision ID: mantas@akl.lt-20110718130625-c5pvifp61e7kj1ol
Included whole irrlicht SVN libraries to work around launchpad recipe issue with quilt, see https://answers.launchpad.net/launchpad/+question/165193

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (C) 2002-2011 Nikolaus Gebhardt
 
2
// This file is part of the "Irrlicht Engine".
 
3
// For conditions of distribution and use, see copyright notice in irrlicht.h
 
4
 
 
5
#ifndef __C_SCENE_NODE_ANIMATOR_CAMERA_FPS_H_INCLUDED__
 
6
#define __C_SCENE_NODE_ANIMATOR_CAMERA_FPS_H_INCLUDED__
 
7
 
 
8
#include "ISceneNodeAnimatorCameraFPS.h"
 
9
#include "vector2d.h"
 
10
#include "position2d.h"
 
11
#include "SKeyMap.h"
 
12
#include "irrArray.h"
 
13
 
 
14
namespace irr
 
15
{
 
16
namespace gui
 
17
{
 
18
        class ICursorControl;
 
19
}
 
20
 
 
21
namespace scene
 
22
{
 
23
 
 
24
        //! Special scene node animator for FPS cameras
 
25
        class CSceneNodeAnimatorCameraFPS : public ISceneNodeAnimatorCameraFPS
 
26
        {
 
27
        public:
 
28
 
 
29
                //! Constructor
 
30
                CSceneNodeAnimatorCameraFPS(gui::ICursorControl* cursorControl,
 
31
                        f32 rotateSpeed = 100.0f, f32 moveSpeed = .5f, f32 jumpSpeed=0.f,
 
32
                        SKeyMap* keyMapArray=0, u32 keyMapSize=0, bool noVerticalMovement=false,
 
33
                        bool invertY=false);
 
34
 
 
35
                //! Destructor
 
36
                virtual ~CSceneNodeAnimatorCameraFPS();
 
37
 
 
38
                //! Animates the scene node, currently only works on cameras
 
39
                virtual void animateNode(ISceneNode* node, u32 timeMs);
 
40
 
 
41
                //! Event receiver
 
42
                virtual bool OnEvent(const SEvent& event);
 
43
 
 
44
                //! Returns the speed of movement in units per second
 
45
                virtual f32 getMoveSpeed() const;
 
46
 
 
47
                //! Sets the speed of movement in units per second
 
48
                virtual void setMoveSpeed(f32 moveSpeed);
 
49
 
 
50
                //! Returns the rotation speed
 
51
                virtual f32 getRotateSpeed() const;
 
52
 
 
53
                //! Set the rotation speed
 
54
                virtual void setRotateSpeed(f32 rotateSpeed);
 
55
 
 
56
                //! Sets the keyboard mapping for this animator
 
57
                //! \param keymap: an array of keyboard mappings, see SKeyMap
 
58
                //! \param count: the size of the keyboard map array
 
59
                virtual void setKeyMap(SKeyMap *map, u32 count);
 
60
 
 
61
                //! Sets whether vertical movement should be allowed.
 
62
                virtual void setVerticalMovement(bool allow);
 
63
 
 
64
                //! Sets whether the Y axis of the mouse should be inverted.
 
65
                /** If enabled then moving the mouse down will cause
 
66
                the camera to look up. It is disabled by default. */
 
67
                virtual void setInvertMouse(bool invert);
 
68
 
 
69
                //! This animator will receive events when attached to the active camera
 
70
                virtual bool isEventReceiverEnabled() const
 
71
                {
 
72
                        return true;
 
73
                }
 
74
 
 
75
                //! Returns the type of this animator
 
76
                virtual ESCENE_NODE_ANIMATOR_TYPE getType() const
 
77
                {
 
78
                        return ESNAT_CAMERA_FPS;
 
79
                }
 
80
 
 
81
                //! Creates a clone of this animator.
 
82
                /** Please note that you will have to drop
 
83
                (IReferenceCounted::drop()) the returned pointer once you're
 
84
                done with it. */
 
85
                virtual ISceneNodeAnimator* createClone(ISceneNode* node, ISceneManager* newManager=0);
 
86
 
 
87
                struct SCamKeyMap
 
88
                {
 
89
                        SCamKeyMap() {};
 
90
                        SCamKeyMap(s32 a, EKEY_CODE k) : action(a), keycode(k) {}
 
91
 
 
92
                        s32 action;
 
93
                        EKEY_CODE keycode;
 
94
                };
 
95
 
 
96
                //! Sets the keyboard mapping for this animator
 
97
                /** Helper function for the clone method.
 
98
                \param keymap the new keymap array */
 
99
                void setKeyMap(const core::array<SCamKeyMap>& keymap);
 
100
 
 
101
        private:
 
102
                void allKeysUp();
 
103
 
 
104
                gui::ICursorControl *CursorControl;
 
105
 
 
106
                f32 MaxVerticalAngle;
 
107
 
 
108
                f32 MoveSpeed;
 
109
                f32 RotateSpeed;
 
110
                f32 JumpSpeed;
 
111
                // -1.0f for inverted mouse, defaults to 1.0f
 
112
                f32 MouseYDirection;
 
113
 
 
114
                s32 LastAnimationTime;
 
115
 
 
116
                core::array<SCamKeyMap> KeyMap;
 
117
                core::position2d<f32> CenterCursor, CursorPos;
 
118
 
 
119
                bool CursorKeys[6];
 
120
 
 
121
                bool firstUpdate;
 
122
                bool NoVerticalMovement;
 
123
        };
 
124
 
 
125
} // end namespace scene
 
126
} // end namespace irr
 
127
 
 
128
#endif // __C_SCENE_NODE_ANIMATOR_CAMERA_FPS_H_INCLUDED__
 
129