Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/objecthierarchy/src/orxonox/objects/worldentities/MovableEntity.h @ 1989

Last change on this file since 1989 was 1989, checked in by landauf, 15 years ago
  • added ControllableEntity, the baseclass of all players, vehicles and ships.
  • moved Template to core
  • some changes in Camera
  • added 6 constants to WorldEntity to identify relative directions
  • changed vom Radian to Degree as default angle unit
File size: 5.2 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#ifndef _MovableEntity_H__
30#define _MovableEntity_H__
31
32#include "OrxonoxPrereqs.h"
33
34#include "WorldEntity.h"
35#include "objects/Tickable.h"
36#include "network/ClientConnectionListener.h"
37
38namespace orxonox
39{
40    class _OrxonoxExport MovableEntity : public WorldEntity, public Tickable, public network::ClientConnectionListener
41    {
42        public:
43            MovableEntity();
44            virtual ~MovableEntity();
45
46            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
47            virtual void tick(float dt);
48            void registerVariables();
49
50            using WorldEntity::setPosition;
51            using WorldEntity::translate;
52            using WorldEntity::setOrientation;
53            using WorldEntity::rotate;
54            using WorldEntity::lookAt;
55            using WorldEntity::setDirection;
56
57            void setPosition(const Vector3& position);
58            void translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
59            void setOrientation(const Quaternion& orientation);
60            void rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
61            void yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
62            void pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
63            void roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
64            void lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
65            void setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
66
67            inline void setVelocity(const Vector3& velocity)
68                { this->velocity_ = velocity; }
69            inline void setVelocity(float x, float y, float z)
70                { this->velocity_.x = x; this->velocity_.y = y; this->velocity_.z = z; }
71            inline const Vector3& getVelocity() const
72                { return this->velocity_; }
73
74            inline void setAcceleration(const Vector3& acceleration)
75                { this->acceleration_ = acceleration; }
76            inline void setAcceleration(float x, float y, float z)
77                { this->acceleration_.x = x; this->acceleration_.y = y; this->acceleration_.z = z; }
78            inline const Vector3& getAcceleration() const
79                { return this->acceleration_; }
80
81            inline void setRotationAxis(const Vector3& axis)
82                { this->rotationAxis_ = axis; this->rotationAxis_.normalise(); }
83            inline void setRotationAxis(float x, float y, float z)
84                { this->rotationAxis_.x = x; this->rotationAxis_.y = y; this->rotationAxis_.z = z; rotationAxis_.normalise(); }
85            inline const Vector3& getRotationAxis() const
86                { return this->rotationAxis_; }
87
88            inline void setRotationRate(const Degree& angle)
89                { this->rotationRate_ = angle; }
90            inline void setRotationRate(const Radian& angle)
91                { this->rotationRate_ = angle; }
92            inline const Degree& getRotationRate() const
93                { return this->rotationRate_; }
94
95            inline void setMomentum(const Degree& angle)
96                { this->momentum_ = angle; }
97            inline void setMomentum(const Radian& angle)
98                { this->momentum_ = angle; }
99            inline const Degree& getMomentum() const
100                { return this->momentum_; }
101
102        private:
103            void clientConnected(unsigned int clientID);
104            void clientDisconnected(unsigned int clientID);
105            void resynchronize();
106
107            void overwritePosition();
108            void overwriteOrientation();
109
110            Vector3 velocity_;
111            Vector3 acceleration_;
112            Vector3 rotationAxis_;
113            Degree rotationRate_;
114            Degree momentum_;
115
116            Vector3 overwrite_position_;
117            Quaternion overwrite_orientation_;
118    };
119}
120
121#endif /* _MovableEntity_H__ */
Note: See TracBrowser for help on using the repository browser.