Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/objects/worldentities/ControllableEntity.h @ 2851

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

Fixed attachment of "absolute" CameraPosition-Nodes in the Network (this refers to the top-down camera in Pong)

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