Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/bigships/src/orxonox/worldentities/pawns/SpaceShip.h @ 8426

Last change on this file since 8426 was 8426, checked in by decryphe, 13 years ago
  • Moved handling of blur effect from Engine.cc to SpaceShip.cc.
  • Implemented handling of multiple engines per SpaceShip, so that in future it would be possible to turn single engines on/off individually (for example if one gets destroyed on a big ship).
  • Updated some pointers accessing the single Engine of a SpaceShip to ask the SpaceShip itself instead for data.
  • Property svn:eol-style set to native
File size: 4.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 *      ...
26 *
27 */
28
29#ifndef _SpaceShip_H__
30#define _SpaceShip_H__
31
32#include "OrxonoxPrereqs.h"
33
34#include <string>
35#include <LinearMath/btVector3.h>
36#include "tools/Timer.h"
37#include "util/Math.h"
38#include "Pawn.h"
39
40namespace orxonox
41{
42    class _OrxonoxExport SpaceShip : public Pawn
43    {
44        public:
45            SpaceShip(BaseObject* creator);
46            virtual ~SpaceShip();
47
48            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
49            virtual void tick(float dt);
50            void setConfigValues();
51
52            virtual void moveFrontBack(const Vector2& value);
53            virtual void moveRightLeft(const Vector2& value);
54            virtual void moveUpDown(const Vector2& value);
55
56            virtual void rotateYaw(const Vector2& value);
57            virtual void rotatePitch(const Vector2& value);
58            virtual void rotateRoll(const Vector2& value);
59
60            virtual void fire();
61            virtual void boost(bool bBoost); // Starts or stops boosting.
62
63                        void addEngine(Engine* engine);
64                        bool hasEngine(Engine* engine);
65                        Engine* getEngine(unsigned int i); // This one's for XMLPort
66                        inline const std::vector<Engine*>& getEngineList()
67                                { return this->engineList_; }
68                        void removeAllEngines();
69
70                        void setSpeedFactor(float factor);
71                        float getSpeedFactor(); // Gets mean speed factor
72                        float getMaxSpeedFront(); // gets largest speed forward
73                        float getBoostFactor(); // gets mean boost factor
74
75            inline void setSteeringDirection(const Vector3& direction)
76                { this->steering_ = direction; }
77            inline const Vector3& getSteeringDirection() const
78                { return this->steering_; }
79                        inline void resetEngineTicks()
80                                { this->engineTicksNotDone = this->engineList_.size(); }
81                        inline void oneEngineTickDone()
82                                { this->engineTicksNotDone--; }
83                        inline const bool hasEngineTicksRemaining()
84                                { return (this->engineTicksNotDone>0); }
85
86            inline bool getBoost() const
87                { return this->bBoost_; }
88
89        protected:
90            virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const;
91            bool bInvertYAxis_;
92
93            bool bBoost_;
94            bool bBoostCooldown_;
95            float boostPower_;
96            float initialBoostPower_;
97            float boostRate_;
98            float boostPowerRate_;
99            float boostCooldownDuration_;
100            Vector3 steering_;
101            float primaryThrust_;
102            float auxilaryThrust_;
103            float rotationThrust_;
104            btVector3 localLinearAcceleration_;
105            btVector3 localAngularAcceleration_;
106
107        private:
108            void registerVariables();
109            virtual bool isCollisionTypeLegal(WorldEntity::CollisionType type) const;
110           
111                        //All things booster
112                        void changedEnableMotionBlur();
113            void boostCooledDown(void);
114
115                        Shader* boostBlur_;
116            float blurStrength_;
117            bool bEnableMotionBlur_;
118
119                        std::vector<Engine*> engineList_;
120                        int engineTicksNotDone; // Used for knowing when to reset temporary variables.
121            Timer timer_;
122    };
123}
124
125#endif /* _SpaceShip_H__ */
Note: See TracBrowser for help on using the repository browser.