Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/objects/worldentities/MovableEntity.h @ 2581

Last change on this file since 2581 was 2171, checked in by landauf, 16 years ago

merged revisions 2111-2170 from objecthierarchy branch back to trunk.

  • Property svn:eol-style set to native
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 ClientConnectionListener
41    {
42        public:
43            MovableEntity(BaseObject* creator);
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::yaw;
55            using WorldEntity::pitch;
56            using WorldEntity::roll;
57            using WorldEntity::lookAt;
58            using WorldEntity::setDirection;
59
60            void setPosition(const Vector3& position);
61            void translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
62            void setOrientation(const Quaternion& orientation);
63            void rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
64            void yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
65            void pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
66            void roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
67            void lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
68            void setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
69
70            inline void setVelocity(const Vector3& velocity)
71                { this->velocity_ = velocity; }
72            inline void setVelocity(float x, float y, float z)
73                { this->velocity_.x = x; this->velocity_.y = y; this->velocity_.z = z; }
74            inline const Vector3& getVelocity() const
75                { return this->velocity_; }
76
77            inline void setAcceleration(const Vector3& acceleration)
78                { this->acceleration_ = acceleration; }
79            inline void setAcceleration(float x, float y, float z)
80                { this->acceleration_.x = x; this->acceleration_.y = y; this->acceleration_.z = z; }
81            inline const Vector3& getAcceleration() const
82                { return this->acceleration_; }
83
84            inline void setRotationAxis(const Vector3& axis)
85                { this->rotationAxis_ = axis; this->rotationAxis_.normalise(); }
86            inline void setRotationAxis(float x, float y, float z)
87                { this->rotationAxis_.x = x; this->rotationAxis_.y = y; this->rotationAxis_.z = z; rotationAxis_.normalise(); }
88            inline const Vector3& getRotationAxis() const
89                { return this->rotationAxis_; }
90
91            inline void setRotationRate(const Degree& angle)
92                { this->rotationRate_ = angle; }
93            inline void setRotationRate(const Radian& angle)
94                { this->rotationRate_ = angle; }
95            inline const Degree& getRotationRate() const
96                { return this->rotationRate_; }
97
98            inline void setMomentum(const Degree& angle)
99                { this->momentum_ = angle; }
100            inline void setMomentum(const Radian& angle)
101                { this->momentum_ = angle; }
102            inline const Degree& getMomentum() const
103                { return this->momentum_; }
104
105        private:
106            void clientConnected(unsigned int clientID);
107            void clientDisconnected(unsigned int clientID);
108            void resynchronize();
109
110            void overwritePosition();
111            void overwriteOrientation();
112
113            Vector3 velocity_;
114            Vector3 acceleration_;
115            Vector3 rotationAxis_;
116            Degree rotationRate_;
117            Degree momentum_;
118
119            Vector3 overwrite_position_;
120            Quaternion overwrite_orientation_;
121    };
122}
123
124#endif /* _MovableEntity_H__ */
Note: See TracBrowser for help on using the repository browser.