Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/objecthierarchy2/src/orxonox/objects/worldentities/ControllableEntity.h @ 2274

Last change on this file since 2274 was 2254, checked in by landauf, 16 years ago

Update your media repository and delete keybindings.ini if you want to use boost (space).

  • Added new class "Engine" to control the speed of a SpaceShip (Engine is an Item, MultiStateEngine is a specialized version of Engine)
  • Added FadingBillboard, a billboard with the ability to fade in and out smoothly when activated/deactivated.
  • Several changes in Backlight, it's now a child of FadingBillboard
  • Some changes concerning local control in ControllableEntity
  • Fixed a bug in WorldEntity caused by different destruction order of attached objects on server and client
  • Added a "MainState" to BaseObject. An object has several states (activity, visibility, …) and one of it can be defined as "MainState" in the XML file. Other objects can change this state without knowing which state it really is (used by MultiStateEngine).
  • Property svn:eol-style set to native
File size: 6.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#ifndef _ControllableEntity_H__
30#define _ControllableEntity_H__
31
32#include "OrxonoxPrereqs.h"
33
34#include "WorldEntity.h"
35#include "objects/Tickable.h"
36
37namespace orxonox
38{
39    class _OrxonoxExport ControllableEntity : public WorldEntity, public Tickable
40    {
41        public:
42            ControllableEntity(BaseObject* creator);
43            virtual ~ControllableEntity();
44
45            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
46            virtual void tick(float dt);
47            void registerVariables();
48
49            virtual void setPlayer(PlayerInfo* player);
50            virtual void removePlayer();
51            inline PlayerInfo* getPlayer() const
52                { return this->player_; }
53
54            inline void setDestroyWhenPlayerLeft(bool bDestroy)
55                { this->bDestroyWhenPlayerLeft_ = bDestroy; }
56            inline bool getDestroyWhenPlayerLeft() const
57                { return this->bDestroyWhenPlayerLeft_; }
58
59            virtual void moveFrontBack(const Vector2& value) {}
60            virtual void moveRightLeft(const Vector2& value) {}
61            virtual void moveUpDown(const Vector2& value) {}
62
63            virtual void rotateYaw(const Vector2& value) {}
64            virtual void rotatePitch(const Vector2& value) {}
65            virtual void rotateRoll(const Vector2& value) {}
66
67            virtual void fire() {}
68            virtual void altFire() {}
69
70            virtual void boost() {}
71            virtual void greet() {}
72            virtual void use() {}
73            virtual void switchCamera();
74
75            inline const Vector3& getVelocity() const
76                { return this->velocity_; }
77            inline const Vector3& getAcceleration() const
78                { return this->acceleration_; }
79            inline const std::string& getHudTemplate() const
80                { return this->hudtemplate_; }
81
82            using WorldEntity::setPosition;
83            using WorldEntity::translate;
84            using WorldEntity::setOrientation;
85            using WorldEntity::rotate;
86            using WorldEntity::yaw;
87            using WorldEntity::pitch;
88            using WorldEntity::roll;
89            using WorldEntity::lookAt;
90            using WorldEntity::setDirection;
91
92            void setPosition(const Vector3& position);
93            void translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
94            void setOrientation(const Quaternion& orientation);
95            void rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
96            void yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
97            void pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
98            void roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
99            void lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
100            void setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
101
102            void setVelocity(const Vector3& velocity);
103            inline void setVelocity(float x, float y, float z)
104                { this->velocity_.x = x; this->velocity_.y = y; this->velocity_.z = z; }
105
106            inline void setAcceleration(const Vector3& acceleration)
107                { this->acceleration_ = acceleration; }
108            inline void setAcceleration(float x, float y, float z)
109                { this->acceleration_.x = x; this->acceleration_.y = y; this->acceleration_.z = z; }
110
111            inline Camera* getCamera() const
112                { return this->camera_; }
113            inline OverlayGroup* getHUD() const
114                { return this->hud_; }
115
116            void addCameraPosition(CameraPosition* position);
117            CameraPosition* getCameraPosition(unsigned int index) const;
118            inline const std::list<CameraPosition*>& getCameraPositions() const
119                { return this->cameraPositions_; }
120
121            inline void setCameraPositionTemplate(const std::string& name)
122                { this->cameraPositionTemplate_ = name; }
123            inline const std::string& getCameraPositionTemkplate() const
124                { return this->cameraPositionTemplate_; }
125
126            inline bool hasLocalController() const
127                { return this->bHasLocalController_; }
128            inline bool hasHumanController() const
129                { return this->bHasHumanController_; }
130
131        protected:
132            virtual void startLocalHumanControl();
133            virtual void stopLocalHumanControl();
134
135            inline void setHudTemplate(const std::string& name)
136                { this->hudtemplate_ = name; }
137
138            Vector3 acceleration_;
139
140        private:
141            void overwrite();
142            void processOverwrite();
143
144            void processServerPosition();
145            void processServerVelocity();
146            void processServerOrientation();
147
148            void processClientPosition();
149            void processClientVelocity();
150            void processClientOrientation();
151
152            void networkcallback_changedplayerID();
153
154            unsigned int server_overwrite_;
155            unsigned int client_overwrite_;
156
157            Vector3 velocity_;
158
159            bool bHasLocalController_;
160            bool bHasHumanController_;
161
162            Vector3 server_position_;
163            Vector3 client_position_;
164            Vector3 server_velocity_;
165            Vector3 client_velocity_;
166            Quaternion server_orientation_;
167            Quaternion client_orientation_;
168
169            PlayerInfo* player_;
170            unsigned int playerID_;
171            std::string hudtemplate_;
172            OverlayGroup* hud_;
173            Camera* camera_;
174            bool bDestroyWhenPlayerLeft_;
175
176            std::list<CameraPosition*> cameraPositions_;
177            std::string cameraPositionTemplate_;
178    };
179}
180
181#endif /* _ControllableEntity_H__ */
Note: See TracBrowser for help on using the repository browser.