Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/objecthierarchy2/src/orxonox/objects/worldentities/MovableEntity.h @ 2461

Last change on this file since 2461 was 2422, checked in by landauf, 16 years ago
  • deatheffect (explosion) of Pawns works on client and server (creator of the effects can't be the Pawn itself because it will be destroyed on the client before synchronizing the effects)
  • fixed a small initialization error in Shader
  • fixed a bug in the resynchronization of already deleted MovableEntities
  • ExplosionChunk only recalculates it's velocity on the Master
  • Property svn:eol-style set to native
File size: 5.3 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#include "tools/Timer.h"
38
39namespace orxonox
40{
41    class _OrxonoxExport MovableEntity : public WorldEntity, public Tickable, public ClientConnectionListener
42    {
43        public:
44            MovableEntity(BaseObject* creator);
45            virtual ~MovableEntity();
46
47            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
48            virtual void tick(float dt);
49            void registerVariables();
50
51            using WorldEntity::setPosition;
52            using WorldEntity::translate;
53            using WorldEntity::setOrientation;
54            using WorldEntity::rotate;
55            using WorldEntity::yaw;
56            using WorldEntity::pitch;
57            using WorldEntity::roll;
58            using WorldEntity::lookAt;
59            using WorldEntity::setDirection;
60
61            void setPosition(const Vector3& position);
62            void translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
63            void setOrientation(const Quaternion& orientation);
64            void rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
65            void yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
66            void pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
67            void roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
68            void lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
69            void setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
70
71            inline void setVelocity(const Vector3& velocity)
72                { this->velocity_ = velocity; }
73            inline void setVelocity(float x, float y, float z)
74                { this->velocity_.x = x; this->velocity_.y = y; this->velocity_.z = z; }
75            inline const Vector3& getVelocity() const
76                { return this->velocity_; }
77
78            inline void setAcceleration(const Vector3& acceleration)
79                { this->acceleration_ = acceleration; }
80            inline void setAcceleration(float x, float y, float z)
81                { this->acceleration_.x = x; this->acceleration_.y = y; this->acceleration_.z = z; }
82            inline const Vector3& getAcceleration() const
83                { return this->acceleration_; }
84
85            inline void setRotationAxis(const Vector3& axis)
86                { this->rotationAxis_ = axis; this->rotationAxis_.normalise(); }
87            inline void setRotationAxis(float x, float y, float z)
88                { this->rotationAxis_.x = x; this->rotationAxis_.y = y; this->rotationAxis_.z = z; rotationAxis_.normalise(); }
89            inline const Vector3& getRotationAxis() const
90                { return this->rotationAxis_; }
91
92            inline void setRotationRate(const Degree& angle)
93                { this->rotationRate_ = angle; }
94            inline void setRotationRate(const Radian& angle)
95                { this->rotationRate_ = angle; }
96            inline const Degree& getRotationRate() const
97                { return this->rotationRate_; }
98
99            inline void setMomentum(const Degree& angle)
100                { this->momentum_ = angle; }
101            inline void setMomentum(const Radian& angle)
102                { this->momentum_ = angle; }
103            inline const Degree& getMomentum() const
104                { return this->momentum_; }
105
106        private:
107            void clientConnected(unsigned int clientID);
108            void clientDisconnected(unsigned int clientID);
109            void resynchronize();
110
111            void overwritePosition();
112            void overwriteOrientation();
113
114            Vector3 velocity_;
115            Vector3 acceleration_;
116            Vector3 rotationAxis_;
117            Degree rotationRate_;
118            Degree momentum_;
119
120            Vector3 overwrite_position_;
121            Quaternion overwrite_orientation_;
122
123            Timer<MovableEntity> resynchronizeTimer_;
124    };
125}
126
127#endif /* _MovableEntity_H__ */
Note: See TracBrowser for help on using the repository browser.