Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/physics/src/orxonox/objects/worldentities/ControllableEntity.h @ 2407

Last change on this file since 2407 was 2407, checked in by rgrieder, 15 years ago
  • Removed debug output
  • Fixed a bug with parentID_ in CollisionShape
  • Reactivated overwrite mechanism in ControllableEntity
  • Build fix in WE for last commit.
  • Property svn:eol-style set to native
File size: 5.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 "MovableEntity.h"
35
36namespace orxonox
37{
38    class _OrxonoxExport ControllableEntity : public MovableEntity
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
48            virtual void setPlayer(PlayerInfo* player);
49            virtual void removePlayer();
50            inline PlayerInfo* getPlayer() const
51                { return this->player_; }
52
53            inline void setDestroyWhenPlayerLeft(bool bDestroy)
54                { this->bDestroyWhenPlayerLeft_ = bDestroy; }
55            inline bool getDestroyWhenPlayerLeft() const
56                { return this->bDestroyWhenPlayerLeft_; }
57
58            virtual void moveFrontBack(const Vector2& value) {}
59            virtual void moveRightLeft(const Vector2& value) {}
60            virtual void moveUpDown(const Vector2& value) {}
61
62            virtual void rotateYaw(const Vector2& value) {}
63            virtual void rotatePitch(const Vector2& value) {}
64            virtual void rotateRoll(const Vector2& value) {}
65
66            virtual void fire() {}
67            virtual void altFire() {}
68
69            virtual void greet() {}
70            virtual void use() {}
71            virtual void switchCamera();
72
73            inline const std::string& getHudTemplate() const
74                { return this->hudtemplate_; }
75
76            inline Camera* getCamera() const
77                { return this->camera_; }
78            inline OverlayGroup* getHUD() const
79                { return this->hud_; }
80
81            void addCameraPosition(CameraPosition* position);
82            CameraPosition* getCameraPosition(unsigned int index) const;
83            inline const std::list<CameraPosition*>& getCameraPositions() const
84                { return this->cameraPositions_; }
85
86            inline void setCameraPositionTemplate(const std::string& name)
87                { this->cameraPositionTemplate_ = name; }
88            inline const std::string& getCameraPositionTemkplate() const
89                { return this->cameraPositionTemplate_; }
90
91        protected:
92            virtual void startLocalControl();
93            virtual void stopLocalControl();
94
95            inline void setHudTemplate(const std::string& name)
96                { this->hudtemplate_ = name; }
97
98            inline bool isLocallyControlled() const
99                { return this->bControlled_; }
100
101        private:
102            void overwrite();
103            void processOverwrite();
104
105            void processServerPosition();
106            void processServerLinearVelocity();
107            void processServerOrientation();
108            void processServerAngularVelocity();
109
110            void processClientPosition();
111            void processClientLinearVelocity();
112            void processClientOrientation();
113            void processClientAngularVelocity();
114
115            void positionChanged       (bool bContinuous);
116            void orientationChanged    (bool bContinuous);
117            void linearVelocityChanged (bool bContinuous);
118            void angularVelocityChanged(bool bContinuous);
119
120            void networkcallback_changedplayerID();
121
122            unsigned int server_overwrite_;
123            unsigned int client_overwrite_;
124
125            bool bControlled_;
126            Vector3 server_position_;
127            Vector3 client_position_;
128            Vector3 server_linear_velocity_;
129            Vector3 client_linear_velocity_;
130            Quaternion server_orientation_;
131            Quaternion client_orientation_;
132            Vector3 server_angular_velocity_;
133            Vector3 client_angular_velocity_;
134
135            PlayerInfo* player_;
136            unsigned int playerID_;
137            std::string hudtemplate_;
138            OverlayGroup* hud_;
139            Camera* camera_;
140            bool bDestroyWhenPlayerLeft_;
141
142            std::list<CameraPosition*> cameraPositions_;
143            std::string cameraPositionTemplate_;
144    };
145}
146
147#endif /* _ControllableEntity_H__ */
Note: See TracBrowser for help on using the repository browser.