Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/objecthierarchy2/src/orxonox/objects/worldentities/ControllableEntity.h @ 2478

Last change on this file since 2478 was 2478, checked in by landauf, 15 years ago
  • Readded smooth camera movement (configurable through CameraPosition), works also with camera-position-changes
  • Added free mouse look (press left control key)
  • Made strength of boost-blur configurable
  • Property svn:eol-style set to native
File size: 8.2 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 "WorldEntity.h"
35#include "objects/Tickable.h"
36
37namespace orxonox
38{
39    class _OrxonoxExport ControllableEntity : public WorldEntity, 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            void setConfigValues();
49
50            virtual void changedGametype();
51
52            virtual void setPlayer(PlayerInfo* player);
53            virtual void removePlayer();
54            inline PlayerInfo* getPlayer() const
55                { return this->player_; }
56
57            inline void setDestroyWhenPlayerLeft(bool bDestroy)
58                { this->bDestroyWhenPlayerLeft_ = bDestroy; }
59            inline bool getDestroyWhenPlayerLeft() const
60                { return this->bDestroyWhenPlayerLeft_; }
61
62            virtual void moveFrontBack(const Vector2& value) {}
63            virtual void moveRightLeft(const Vector2& value) {}
64            virtual void moveUpDown(const Vector2& value) {}
65
66            virtual void rotateYaw(const Vector2& value);
67            virtual void rotatePitch(const Vector2& value);
68            virtual void rotateRoll(const Vector2& value);
69
70            inline void moveFrontBack(float value)
71                { this->moveFrontBack(Vector2(value, 0)); }
72            inline void moveRightLeft(float value)
73                { this->moveRightLeft(Vector2(value, 0)); }
74            inline void moveUpDown(float value)
75                { this->moveUpDown(Vector2(value, 0)); }
76
77            inline void rotateYaw(float value)
78                { this->rotateYaw(Vector2(value, 0)); }
79            inline void rotatePitch(float value)
80                { this->rotatePitch(Vector2(value, 0)); }
81            inline void rotateRoll(float value)
82                { this->rotateRoll(Vector2(value, 0)); }
83
84            virtual void fire() {}
85            virtual void altFire() {}
86
87            virtual void boost() {}
88            virtual void greet() {}
89            virtual void use() {}
90            virtual void switchCamera();
91            virtual void mouseLook();
92
93            inline const Vector3& getVelocity() const
94                { return this->velocity_; }
95            inline const Vector3& getAcceleration() const
96                { return this->acceleration_; }
97            inline const std::string& getHudTemplate() const
98                { return this->hudtemplate_; }
99
100            using WorldEntity::setPosition;
101            using WorldEntity::translate;
102            using WorldEntity::setOrientation;
103            using WorldEntity::rotate;
104            using WorldEntity::yaw;
105            using WorldEntity::pitch;
106            using WorldEntity::roll;
107            using WorldEntity::lookAt;
108            using WorldEntity::setDirection;
109
110            void setPosition(const Vector3& position);
111            void translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
112            void setOrientation(const Quaternion& orientation);
113            void rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
114            void yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
115            void pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
116            void roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
117            void lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
118            void setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
119
120            void setVelocity(const Vector3& velocity);
121            inline void setVelocity(float x, float y, float z)
122                { this->velocity_.x = x; this->velocity_.y = y; this->velocity_.z = z; }
123
124            inline void setAcceleration(const Vector3& acceleration)
125                { this->acceleration_ = acceleration; }
126            inline void setAcceleration(float x, float y, float z)
127                { this->acceleration_.x = x; this->acceleration_.y = y; this->acceleration_.z = z; }
128
129            inline Camera* getCamera() const
130                { return this->camera_; }
131            inline OverlayGroup* getHUD() const
132                { return this->hud_; }
133
134            void addCameraPosition(CameraPosition* position);
135            CameraPosition* getCameraPosition(unsigned int index) const;
136            inline const std::list<CameraPosition*>& getCameraPositions() const
137                { return this->cameraPositions_; }
138
139            inline void setCameraPositionTemplate(const std::string& name)
140                { this->cameraPositionTemplate_ = name; }
141            inline const std::string& getCameraPositionTemkplate() const
142                { return this->cameraPositionTemplate_; }
143
144            inline bool hasLocalController() const
145                { return this->bHasLocalController_; }
146            inline bool hasHumanController() const
147                { return this->bHasHumanController_; }
148
149            inline const GametypeInfo* getGametypeInfo() const
150                { return this->gtinfo_; }
151
152            inline bool isInMouseLook() const
153                { return this->bMouseLook_; }
154            inline float getMouseLookSpeed() const
155                { return this->mouseLookSpeed_; }
156
157        protected:
158            virtual void startLocalHumanControl();
159            virtual void stopLocalHumanControl();
160
161            inline void setHudTemplate(const std::string& name)
162                { this->hudtemplate_ = name; }
163
164            Vector3 acceleration_;
165
166        private:
167            void overwrite();
168            void processOverwrite();
169
170            void processServerPosition();
171            void processServerVelocity();
172            void processServerOrientation();
173
174            void processClientPosition();
175            void processClientVelocity();
176            void processClientOrientation();
177
178            void networkcallback_changedplayerID();
179            void networkcallback_changedgtinfoID();
180
181            unsigned int server_overwrite_;
182            unsigned int client_overwrite_;
183
184            Vector3 velocity_;
185
186            bool bHasLocalController_;
187            bool bHasHumanController_;
188            bool bDestroyWhenPlayerLeft_;
189
190            Vector3 server_position_;
191            Vector3 client_position_;
192            Vector3 server_velocity_;
193            Vector3 client_velocity_;
194            Quaternion server_orientation_;
195            Quaternion client_orientation_;
196
197            PlayerInfo* player_;
198            unsigned int playerID_;
199
200            std::string hudtemplate_;
201            OverlayGroup* hud_;
202
203            Camera* camera_;
204            bool bMouseLook_;
205            float mouseLookSpeed_;
206            Ogre::SceneNode* cameraPositionRootNode_;
207            std::list<CameraPosition*> cameraPositions_;
208            std::string cameraPositionTemplate_;
209
210            const GametypeInfo* gtinfo_;
211            unsigned int gtinfoID_;
212    };
213}
214
215#endif /* _ControllableEntity_H__ */
Note: See TracBrowser for help on using the repository browser.