Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 2306 was 2300, checked in by rgrieder, 16 years ago

Still getting physics and its implications straight:

  • Removed PositionableEntity —> StaticEntity is now the way to go. They cannot be translated in any way during physics simulation. The trick will be to remove them and add them again to Bullet. This however is not yet implemented.
  • Forgot a few consts in WorldEntity
  • Fixed a bug with infinite masses
  • WE throws exception if you try to apply physics when the SceneNode is not in the root space of the Scene.
  • Moved velocity_ to MovableEntity
  • Outside world reference of WE/ME are now always the non-physical values. getPosition() will always return node_→getPosition() and when setting it, both RigidBody and SceneNode are translated. This accounts for velocity, orientation and position.
  • Property svn:eol-style set to native
File size: 5.3 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            inline void setAcceleration(const Vector3& acceleration)
82                { this->acceleration_ = acceleration; }
83            inline void setAcceleration(float x, float y, float z)
84                { this->acceleration_.x = x; this->acceleration_.y = y; this->acceleration_.z = z; }
85
86            inline Camera* getCamera() const
87                { return this->camera_; }
88            inline OverlayGroup* getHUD() const
89                { return this->hud_; }
90
91            void addCameraPosition(CameraPosition* position);
92            CameraPosition* getCameraPosition(unsigned int index) const;
93            inline const std::list<CameraPosition*>& getCameraPositions() const
94                { return this->cameraPositions_; }
95
96            inline void setCameraPositionTemplate(const std::string& name)
97                { this->cameraPositionTemplate_ = name; }
98            inline const std::string& getCameraPositionTemkplate() const
99                { return this->cameraPositionTemplate_; }
100
101        protected:
102            virtual void startLocalControl();
103            virtual void stopLocalControl();
104
105            inline void setHudTemplate(const std::string& name)
106                { this->hudtemplate_ = name; }
107
108            inline bool isLocallyControlled() const
109                { return this->bControlled_; }
110
111            Vector3 acceleration_;
112
113        private:
114            void overwrite();
115            void processOverwrite();
116
117            void processServerPosition();
118            void processServerVelocity();
119            void processServerOrientation();
120
121            void processClientPosition();
122            void processClientVelocity();
123            void processClientOrientation();
124
125            void positionChanged();
126            void orientationChanged();
127            void velocityChanged();
128
129            void networkcallback_changedplayerID();
130
131            unsigned int server_overwrite_;
132            unsigned int client_overwrite_;
133
134            bool bControlled_;
135            Vector3 server_position_;
136            Vector3 client_position_;
137            Vector3 server_velocity_;
138            Vector3 client_velocity_;
139            Quaternion server_orientation_;
140            Quaternion client_orientation_;
141
142            PlayerInfo* player_;
143            unsigned int playerID_;
144            std::string hudtemplate_;
145            OverlayGroup* hud_;
146            Camera* camera_;
147            bool bDestroyWhenPlayerLeft_;
148
149            std::list<CameraPosition*> cameraPositions_;
150            std::string cameraPositionTemplate_;
151    };
152}
153
154#endif /* _ControllableEntity_H__ */
Note: See TracBrowser for help on using the repository browser.