Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 2297 was 2292, checked in by rgrieder, 16 years ago

Finally managed to work out some physics. According to my tests, collisions with simple spheres should work with dynamic/kinematic/static objects. There are currently only a limited number of XML parameters, but we're surely going to extend that. Furthermore there is some more thinking to be done concerning changes of btRigidBody properties when it's already added to the world.

  • Property svn:eol-style set to native
File size: 5.6 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 "MovableEntity.h"
35#include "objects/Tickable.h"
36
37namespace orxonox
38{
39    class _OrxonoxExport ControllableEntity : public MovableEntity, 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 greet() {}
71            virtual void use() {}
72            virtual void switchCamera();
73
74            inline const Vector3& getVelocity() const
75                { return this->velocity_; }
76            inline const Vector3& getAcceleration() const
77                { return this->acceleration_; }
78            inline const std::string& getHudTemplate() const
79                { return this->hudtemplate_; }
80
81            void setVelocity(const Vector3& velocity);
82            inline void setVelocity(float x, float y, float z)
83                { setVelocity(Vector3(x,y,z)); }
84
85            inline void setAcceleration(const Vector3& acceleration)
86                { this->acceleration_ = acceleration; }
87            inline void setAcceleration(float x, float y, float z)
88                { this->acceleration_.x = x; this->acceleration_.y = y; this->acceleration_.z = z; }
89
90            inline Camera* getCamera() const
91                { return this->camera_; }
92            inline OverlayGroup* getHUD() const
93                { return this->hud_; }
94
95            void addCameraPosition(CameraPosition* position);
96            CameraPosition* getCameraPosition(unsigned int index) const;
97            inline const std::list<CameraPosition*>& getCameraPositions() const
98                { return this->cameraPositions_; }
99
100            inline void setCameraPositionTemplate(const std::string& name)
101                { this->cameraPositionTemplate_ = name; }
102            inline const std::string& getCameraPositionTemkplate() const
103                { return this->cameraPositionTemplate_; }
104
105        protected:
106            virtual void startLocalControl();
107            virtual void stopLocalControl();
108
109            inline void setHudTemplate(const std::string& name)
110                { this->hudtemplate_ = name; }
111
112            inline bool isLocallyControlled() const
113                { return this->bControlled_; }
114
115            Vector3 acceleration_;
116
117        private:
118            void overwrite();
119            void processOverwrite();
120
121            void processServerPosition();
122            void processServerVelocity();
123            void processServerOrientation();
124
125            void processClientPosition();
126            void processClientVelocity();
127            void processClientOrientation();
128
129            inline void internalSetVelocity(const Vector3& velocity)
130                { this->velocity_ = velocity; }
131            void positionChanged();
132            void orientationChanged();
133            void velocityChanged();
134
135            void networkcallback_changedplayerID();
136
137            unsigned int server_overwrite_;
138            unsigned int client_overwrite_;
139
140            Vector3 velocity_;
141
142            bool bControlled_;
143            Vector3 server_position_;
144            Vector3 client_position_;
145            Vector3 server_velocity_;
146            Vector3 client_velocity_;
147            Quaternion server_orientation_;
148            Quaternion client_orientation_;
149
150            PlayerInfo* player_;
151            unsigned int playerID_;
152            std::string hudtemplate_;
153            OverlayGroup* hud_;
154            Camera* camera_;
155            bool bDestroyWhenPlayerLeft_;
156
157            std::list<CameraPosition*> cameraPositions_;
158            std::string cameraPositionTemplate_;
159    };
160}
161
162#endif /* _ControllableEntity_H__ */
Note: See TracBrowser for help on using the repository browser.