Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/objecthierarchy/src/orxonox/objects/worldentities/pawns/Spectator.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: 3.1 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 "Spectator.h"
31
32#include "core/CoreIncludes.h"
33#include "objects/worldentities/Model.h"
34
35namespace orxonox
36{
37    CreateFactory(Spectator);
38
39    Spectator::Spectator()
40    {
41        RegisterObject(Spectator);
42
43        this->speed_ = 100;
44        this->rotationSpeed_ = 3;
45
46        this->yaw_ = 0;
47        this->pitch_ = 0;
48        this->roll_ = 0;
49        this->setHudTemplate("spectatorhud");
50
51        this->setDestroyWhenPlayerLeft(true);
52
53        Model* temp = new Model;
54        temp->setMeshSource("assff.mesh");
55        this->attach(temp);
56    }
57
58    Spectator::~Spectator()
59    {
60    }
61
62    void Spectator::tick(float dt)
63    {
64        Vector3 velocity = this->getVelocity();
65        velocity.normalise();
66        this->setVelocity(velocity * this->speed_);
67
68        // TODO: Check why I have removed *dt (1337)
69        this->yaw(Radian(this->yaw_ * this->rotationSpeed_));
70        this->pitch(Radian(this->pitch_ * this->rotationSpeed_));
71        this->roll(Radian(this->roll_ * this->rotationSpeed_));
72
73        this->yaw_ = this->pitch_ = this->roll_ = 0;
74
75        SUPER(Spectator, tick, dt);
76
77        this->setVelocity(Vector3::ZERO);
78    }
79
80    void Spectator::setPlayer(PlayerInfo* player)
81    {
82        ControllableEntity::setPlayer(player);
83
84        this->setObjectMode(network::direction::toclient);
85    }
86
87    void Spectator::moveFrontBack(float value)
88    {
89        this->setVelocity(this->getVelocity() + value * this->speed_ * WorldEntity::FRONT);
90    }
91
92    void Spectator::moveRightLeft(float value)
93    {
94        this->setVelocity(this->getVelocity() + value * this->speed_ * WorldEntity::RIGHT);
95    }
96
97    void Spectator::moveUpDown(float value)
98    {
99        this->setVelocity(this->getVelocity() + value * this->speed_ * WorldEntity::UP);
100    }
101
102    void Spectator::rotateYaw(float value)
103    {
104        this->yaw_ = value;
105    }
106
107    void Spectator::rotatePitch(float value)
108    {
109        this->pitch_ = value;
110    }
111
112    void Spectator::rotateRoll(float value)
113    {
114        this->roll_ = value;
115    }
116
117    void Spectator::fire()
118    {
119    }
120}
Note: See TracBrowser for help on using the repository browser.