Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentation/src/orxonox/objects/worldentities/ControllableEntity.h @ 2485

Last change on this file since 2485 was 2485, checked in by landauf, 15 years ago

Merged objecthierarchy2 into presentation branch

Couln't merge 2 lines in Gamestate.cc and a whole block of code in GSDedicated.cc (it seems like oli implemented in both branches something like a network-tick-limiter but with different approaches)

Not yet tested in network mode and with bots
The SpaceShips movement is also not yet fully adopted to the new physics (see Engine class)

  • Property svn:eol-style set to native
File size: 6.8 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 *      Reto Grieder
26 *
27 */
28
29#ifndef _ControllableEntity_H__
30#define _ControllableEntity_H__
31
32#include "OrxonoxPrereqs.h"
33
34#include "MobileEntity.h"
35
36namespace orxonox
37{
38    class _OrxonoxExport ControllableEntity : public MobileEntity
39    {
40        public:
41            ControllableEntity(BaseObject* creator);
42            virtual ~ControllableEntity();
43
44            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
45            virtual void tick(float dt);
46            void registerVariables();
47            void setConfigValues();
48
49            virtual void changedGametype();
50
51            virtual void setPlayer(PlayerInfo* player);
52            virtual void removePlayer();
53            inline PlayerInfo* getPlayer() const
54                { return this->player_; }
55
56            inline void setDestroyWhenPlayerLeft(bool bDestroy)
57                { this->bDestroyWhenPlayerLeft_ = bDestroy; }
58            inline bool getDestroyWhenPlayerLeft() const
59                { return this->bDestroyWhenPlayerLeft_; }
60
61            virtual void moveFrontBack(const Vector2& value) {}
62            virtual void moveRightLeft(const Vector2& value) {}
63            virtual void moveUpDown(const Vector2& value) {}
64
65            virtual void rotateYaw(const Vector2& value);
66            virtual void rotatePitch(const Vector2& value);
67            virtual void rotateRoll(const Vector2& value);
68
69            inline void moveFrontBack(float value)
70                { this->moveFrontBack(Vector2(value, 0)); }
71            inline void moveRightLeft(float value)
72                { this->moveRightLeft(Vector2(value, 0)); }
73            inline void moveUpDown(float value)
74                { this->moveUpDown(Vector2(value, 0)); }
75
76            inline void rotateYaw(float value)
77                { this->rotateYaw(Vector2(value, 0)); }
78            inline void rotatePitch(float value)
79                { this->rotatePitch(Vector2(value, 0)); }
80            inline void rotateRoll(float value)
81                { this->rotateRoll(Vector2(value, 0)); }
82
83            virtual void fire() {}
84            virtual void altFire() {}
85
86            virtual void boost() {}
87            virtual void greet() {}
88            virtual void use() {}
89            virtual void switchCamera();
90            virtual void mouseLook();
91
92            inline const std::string& getHudTemplate() const
93                { return this->hudtemplate_; }
94
95            inline Camera* getCamera() const
96                { return this->camera_; }
97            inline OverlayGroup* getHUD() const
98                { return this->hud_; }
99
100            void addCameraPosition(CameraPosition* position);
101            CameraPosition* getCameraPosition(unsigned int index) const;
102            inline const std::list<CameraPosition*>& getCameraPositions() const
103                { return this->cameraPositions_; }
104
105            inline void setCameraPositionTemplate(const std::string& name)
106                { this->cameraPositionTemplate_ = name; }
107            inline const std::string& getCameraPositionTemkplate() const
108                { return this->cameraPositionTemplate_; }
109
110            using WorldEntity::setPosition;
111            using WorldEntity::setOrientation;
112            using MobileEntity::setVelocity;
113            using MobileEntity::setAngularVelocity;
114
115            void setPosition(const Vector3& position);
116            void setOrientation(const Quaternion& orientation);
117            void setVelocity(const Vector3& velocity);
118            void setAngularVelocity(const Vector3& velocity);
119
120            inline bool hasLocalController() const
121                { return this->bHasLocalController_; }
122            inline bool hasHumanController() const
123                { return this->bHasHumanController_; }
124
125            inline const GametypeInfo* getGametypeInfo() const
126                { return this->gtinfo_; }
127
128            inline bool isInMouseLook() const
129                { return this->bMouseLook_; }
130            inline float getMouseLookSpeed() const
131                { return this->mouseLookSpeed_; }
132
133        protected:
134            virtual void startLocalHumanControl();
135            virtual void stopLocalHumanControl();
136
137            inline void setHudTemplate(const std::string& name)
138                { this->hudtemplate_ = name; }
139
140        private:
141            void overwrite();
142            void processOverwrite();
143
144            void processServerPosition();
145            void processServerLinearVelocity();
146            void processServerOrientation();
147            void processServerAngularVelocity();
148
149            void processClientPosition();
150            void processClientLinearVelocity();
151            void processClientOrientation();
152            void processClientAngularVelocity();
153
154            void networkcallback_changedplayerID();
155            void networkcallback_changedgtinfoID();
156
157            // Bullet btMotionState related
158            void setWorldTransform(const btTransform& worldTrans);
159
160            unsigned int server_overwrite_;
161            unsigned int client_overwrite_;
162
163            bool bHasLocalController_;
164            bool bHasHumanController_;
165            bool bDestroyWhenPlayerLeft_;
166
167            Vector3 server_position_;
168            Vector3 client_position_;
169            Vector3 server_linear_velocity_;
170            Vector3 client_linear_velocity_;
171            Quaternion server_orientation_;
172            Quaternion client_orientation_;
173            Vector3 server_angular_velocity_;
174            Vector3 client_angular_velocity_;
175
176            PlayerInfo* player_;
177            unsigned int playerID_;
178
179            std::string hudtemplate_;
180            OverlayGroup* hud_;
181
182            Camera* camera_;
183            bool bMouseLook_;
184            float mouseLookSpeed_;
185            Ogre::SceneNode* cameraPositionRootNode_;
186            std::list<CameraPosition*> cameraPositions_;
187            std::string cameraPositionTemplate_;
188
189            const GametypeInfo* gtinfo_;
190            unsigned int gtinfoID_;
191    };
192}
193
194#endif /* _ControllableEntity_H__ */
Note: See TracBrowser for help on using the repository browser.