Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/objecthierarchy/src/orxonox/objects/controllers/HumanController.cc @ 2001

Last change on this file since 2001 was 2001, checked in by rgrieder, 16 years ago
  • Fixed issue with relative mouse movements.
  • Fixed bug when parsing commands in keybindings.ini
  • Fixed potential framerate dependency with relative movements
  • Simplified the use of a configured input command
  • Changed how parametrised input is handled (superposition and [-1,1]-clamp instead of average).
File size: 4.9 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "OrxonoxStableHeaders.h"
30#include "HumanController.h"
31
32#include "core/CoreIncludes.h"
33#include "core/ConsoleCommand.h"
34#include "objects/worldentities/ControllableEntity.h"
35
36namespace orxonox
37{
38    SetConsoleCommand(HumanController, moveFrontBack, true).setAsInputCommand();
39    SetConsoleCommand(HumanController, moveRightLeft, true).setAsInputCommand();
40    SetConsoleCommand(HumanController, moveUpDown,    true).setAsInputCommand();
41    SetConsoleCommand(HumanController, rotateYaw,     true).setAsInputCommand();
42    SetConsoleCommand(HumanController, rotatePitch,   true).setAsInputCommand();
43    SetConsoleCommand(HumanController, rotateRoll,    true).setAsInputCommand();
44    SetConsoleCommand(HumanController, fire,          true).keybindMode(KeybindMode::OnHold);
45    SetConsoleCommand(HumanController, altFire,       true).keybindMode(KeybindMode::OnHold);
46    SetConsoleCommand(HumanController, greet,         true);
47    SetConsoleCommand(HumanController, use,           true);
48    SetConsoleCommand(HumanController, switchCamera,  true);
49
50    CreateUnloadableFactory(HumanController);
51
52    HumanController* HumanController::localController_s = 0;
53
54    HumanController::HumanController()
55    {
56        RegisterObject(HumanController);
57
58        HumanController::localController_s = this;
59    }
60
61    HumanController::~HumanController()
62    {
63        HumanController::localController_s = 0;
64    }
65
66    void HumanController::moveFrontBack(const Vector2& value)
67    {
68        if (HumanController::localController_s && HumanController::localController_s->pawn_)
69            HumanController::localController_s->pawn_->moveFrontBack(value.y);
70    }
71
72    void HumanController::moveRightLeft(const Vector2& value)
73    {
74        if (HumanController::localController_s && HumanController::localController_s->pawn_)
75            HumanController::localController_s->pawn_->moveRightLeft(value.y);
76    }
77
78    void HumanController::moveUpDown(const Vector2& value)
79    {
80        if (HumanController::localController_s && HumanController::localController_s->pawn_)
81            HumanController::localController_s->pawn_->moveUpDown(value.y);
82    }
83
84    void HumanController::rotateYaw(const Vector2& value)
85    {
86        if (HumanController::localController_s && HumanController::localController_s->pawn_)
87            HumanController::localController_s->pawn_->rotateYaw(value.y);
88    }
89
90    void HumanController::rotatePitch(const Vector2& value)
91    {
92        if (HumanController::localController_s && HumanController::localController_s->pawn_)
93            HumanController::localController_s->pawn_->rotatePitch(value.y);
94    }
95
96    void HumanController::rotateRoll(const Vector2& value)
97    {
98        if (HumanController::localController_s && HumanController::localController_s->pawn_)
99            HumanController::localController_s->pawn_->rotateRoll(value.y);
100    }
101
102    void HumanController::fire()
103    {
104        if (HumanController::localController_s && HumanController::localController_s->pawn_)
105            HumanController::localController_s->pawn_->fire();
106    }
107
108    void HumanController::altFire()
109    {
110        if (HumanController::localController_s && HumanController::localController_s->pawn_)
111            HumanController::localController_s->pawn_->altFire();
112    }
113
114    void HumanController::greet()
115    {
116        if (HumanController::localController_s && HumanController::localController_s->pawn_)
117            HumanController::localController_s->pawn_->greet();
118    }
119
120    void HumanController::use()
121    {
122        if (HumanController::localController_s && HumanController::localController_s->pawn_)
123            HumanController::localController_s->pawn_->use();
124    }
125
126    void HumanController::switchCamera()
127    {
128        if (HumanController::localController_s && HumanController::localController_s->pawn_)
129            HumanController::localController_s->pawn_->switchCamera();
130    }
131}
Note: See TracBrowser for help on using the repository browser.