Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 3, 2011, 5:42:19 PM (13 years ago)
Author:
dafrick
Message:

Cleaning up in SpaceShip and Engine. Fixed several bugs.
Kicked localLinearAcceleration, primaryThrust and auxiliaryThrust out of the SpaceShip, since it wasn't used anymore.
Moved the trail lights back a bit.
Added some documentation to SpaceShip and Engine.
SpeedPickup is working again, will need some further tuning.

Location:
code/trunk/src/orxonox/items
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/items/Engine.cc

    r8706 r8727  
    2929#include "Engine.h"
    3030
    31 #include "util/Math.h"
    3231#include "core/CoreIncludes.h"
    3332#include "core/ConfigValueIncludes.h"
     33#include "core/Template.h"
    3434#include "core/XMLPort.h"
     35#include "util/Math.h"
     36
    3537#include "Scene.h"
    3638#include "worldentities/pawns/SpaceShip.h"
    37 #include "core/Template.h"
    3839
    3940namespace orxonox
     
    4142    CreateFactory(Engine);
    4243
     44    /**
     45    @brief
     46        Constructor. Registers and initializes the object.
     47    */
    4348    Engine::Engine(BaseObject* creator) : Item(creator)
    4449    {
     
    4752        this->ship_ = 0;
    4853        this->shipID_ = OBJECTID_UNKNOWN;
    49         this->relativePosition_ = Vector3(0,0,0);
    50 
    51         this->boostFactor_ = 1.5;
    52         this->speedFactor_ = 1.0;
    53 
    54         this->maxSpeedFront_ = 0.0;
    55         this->maxSpeedBack_ = 0.0;
    56         this->maxSpeedLeftRight_ = 0.0;
    57         this->maxSpeedUpDown_ = 0.0;
    58 
    59         this->accelerationFront_ = 0.0;
    60         this->accelerationBrake_ = 0.0;
    61         this->accelerationBack_ = 0.0;
    62         this->accelerationLeftRight_ = 0.0;
    63         this->accelerationUpDown_ = 0.0;
    64 
    65         this->speedAdd_ = 0.0;
    66         this->speedMultiply_ = 1.0;
     54        this->relativePosition_ = Vector3::ZERO;
     55
     56        this->boostFactor_ = 1.5f;
     57
     58        this->maxSpeedFront_ = 0.0f;
     59        this->maxSpeedBack_ = 0.0f;
     60        this->maxSpeedLeftRight_ = 0.0f;
     61        this->maxSpeedUpDown_ = 0.0f;
     62
     63        this->accelerationFront_ = 0.0f;
     64        this->accelerationBrake_ = 0.0f;
     65        this->accelerationBack_ = 0.0f;
     66        this->accelerationLeftRight_ = 0.0f;
     67        this->accelerationUpDown_ = 0.0f;
     68
     69        this->speedAdd_ = 0.0f;
     70        this->speedMultiply_ = 1.0f;
    6771
    6872        this->setConfigValues();
     
    7074    }
    7175
     76    /**
     77    @brief
     78        Destructor. Destroys the object and removes it from the SpaceShip.
     79    */
    7280    Engine::~Engine()
    7381    {
    7482        if (this->isInitialized())
    7583        {
     84            // Remove the engine from the ShapeShip.
    7685            if (this->ship_ && this->ship_->hasEngine(this))
    7786                this->ship_->removeEngine(this);
     
    108117        registerVariable(this->shipID_, VariableDirection::ToClient, new NetworkCallback<Engine>(this, &Engine::networkcallback_shipID));
    109118
    110         registerVariable(this->speedFactor_, VariableDirection::ToClient);
    111119        registerVariable(this->boostFactor_, VariableDirection::ToClient);
    112120
     
    138146    }
    139147
    140     void Engine::tick(float dt)
    141     {
    142         if (!this->ship_)
    143         {
    144             if (this->shipID_)
     148    /**
     149    @brief
     150        Run the engine for a given time interval.
     151        Is called each tick by SpaceShip.
     152    @param dt
     153        The time since last tick.
     154    */
     155    void Engine::run(float dt)
     156    {
     157        if (this->ship_ == NULL)
     158        {
     159            if (this->shipID_ != 0)
    145160            {
    146161                this->networkcallback_shipID();
    147162
    148                 if (!this->ship_)
     163                if (this->ship_ == NULL)
    149164                    return;
    150165            }
     
    156171            return;
    157172
    158         SUPER(Engine, tick, dt);
    159 
    160         Vector3 direction = this->getDirection();
    161         float directionLength = direction.length();
    162         if (directionLength > 1.0f)
    163             direction /= directionLength; // normalize
    164        
     173        // Get the desired steering direction and amount, clipped to length 1 at maximum.
     174        Vector3 steering = (this->getSteering().length() > 1.0f ? this->getSteering().normalisedCopy() : this->getSteering());
     175
     176        // Get the ships velocity.
    165177        Vector3 velocity = this->ship_->getLocalVelocity();
    166178        Vector3 acceleration = Vector3::ZERO;
    167179
    168         float factor = 1.0f / this->speedFactor_;
    169         velocity *= factor;
    170 
    171         if (direction.z < 0)
     180        // If there is forward steering action.
     181        if (steering.z < 0)
    172182        {
    173183            if (this->maxSpeedFront_ != 0)
    174184            {
    175                 float boostfactor = (this->ship_->getBoost() ? this->boostFactor_ : 1.0f);
    176                 acceleration.z = direction.z * this->accelerationFront_ * boostfactor * clamp((this->maxSpeedFront_ - -velocity.z/boostfactor) / this->maxSpeedFront_, 0.0f, 1.0f);
     185                float boostfactor = (this->ship_->isBoosting() ? this->boostFactor_ : 1.0f); // Boost factor is 1.0 if not boosting.
     186                // Boosting can lead to velocities larger the maximal forward velocity.
     187                acceleration.z = steering.z * this->accelerationFront_ * boostfactor * clamp((this->maxSpeedFront_ - -velocity.z/boostfactor) / this->maxSpeedFront_, 0.0f, 1.0f);
    177188            }
    178189        }
    179         else if (direction.z > 0)
    180         {
     190        // If there is backward steering action.
     191        else if (steering.z > 0)
     192        {
     193            // Either breaking
    181194            if (velocity.z < 0)
    182                 acceleration.z = direction.z * this->accelerationBrake_;
     195                acceleration.z = steering.z * this->accelerationBrake_;
     196            // or backward flight.
    183197            else if (this->maxSpeedBack_ != 0)
    184                 acceleration.z = direction.z * this->accelerationBack_ * clamp((this->maxSpeedBack_ - velocity.z) / this->maxSpeedBack_, 0.0f, 1.0f);
    185         }
    186 
     198                acceleration.z = steering.z * this->accelerationBack_ * clamp((this->maxSpeedBack_ - velocity.z) / this->maxSpeedBack_, 0.0f, 1.0f);
     199        }
     200        // If there is left-right steering action.
    187201        if (this->maxSpeedLeftRight_ != 0)
    188202        {
    189             if (direction.x < 0)
    190                 acceleration.x = direction.x * this->accelerationLeftRight_ * clamp((this->maxSpeedLeftRight_ - -velocity.x) / this->maxSpeedLeftRight_, 0.0f, 1.0f);
    191             else if (direction.x > 0)
    192                 acceleration.x = direction.x * this->accelerationLeftRight_ * clamp((this->maxSpeedLeftRight_ - velocity.x) / this->maxSpeedLeftRight_, 0.0f, 1.0f);
    193         }
    194 
     203            if (steering.x < 0)
     204                acceleration.x = steering.x * this->accelerationLeftRight_ * clamp((this->maxSpeedLeftRight_ - -velocity.x) / this->maxSpeedLeftRight_, 0.0f, 1.0f);
     205            else if (steering.x > 0)
     206                acceleration.x = steering.x * this->accelerationLeftRight_ * clamp((this->maxSpeedLeftRight_ - velocity.x) / this->maxSpeedLeftRight_, 0.0f, 1.0f);
     207        }
     208        // If there is up-down steering action.
    195209        if (this->maxSpeedUpDown_ != 0)
    196210        {
    197             if (direction.y < 0)
    198                 acceleration.y = direction.y * this->accelerationUpDown_ * clamp((this->maxSpeedUpDown_ - -velocity.y) / this->maxSpeedUpDown_, 0.0f, 1.0f);
    199             else if (direction.y > 0)
    200                 acceleration.y = direction.y * this->accelerationUpDown_ * clamp((this->maxSpeedUpDown_ - velocity.y) / this->maxSpeedUpDown_, 0.0f, 1.0f);
     211            if (steering.y < 0)
     212                acceleration.y = steering.y * this->accelerationUpDown_ * clamp((this->maxSpeedUpDown_ - -velocity.y) / this->maxSpeedUpDown_, 0.0f, 1.0f);
     213            else if (steering.y > 0)
     214                acceleration.y = steering.y * this->accelerationUpDown_ * clamp((this->maxSpeedUpDown_ - velocity.y) / this->maxSpeedUpDown_, 0.0f, 1.0f);
    201215        }
    202216
    203217        // NOTE: Bullet always uses global coordinates.
    204218        this->ship_->addAcceleration(this->ship_->getOrientation() * (acceleration*this->getSpeedMultiply()+Vector3(0,0,-this->getSpeedAdd())), this->ship_->getOrientation() * this->relativePosition_);
    205 
    206         // Hack to reset a temporary variable "direction"
    207         this->ship_->oneEngineTickDone();
    208         if(!this->ship_->hasEngineTicksRemaining())
    209         {
    210             this->ship_->setSteeringDirection(Vector3::ZERO);
    211             this->ship_->resetEngineTicks();
    212         }
    213     }
    214 
    215     void Engine::changedActivity()
    216     {
    217         SUPER(Engine, changedActivity);
    218     }
    219 
     219    }
     220
     221    /**
     222    @brief
     223        Adds the Engine to the input SpaceShip.
     224    @param ship
     225        A pointer to the SpaceShip to which the engine is added.
     226    */
    220227    void Engine::addToSpaceShip(SpaceShip* ship)
    221228    {
     
    230237    }
    231238
    232     const Vector3& Engine::getDirection() const
     239    /**
     240    @brief
     241        Get the direction and magnitude of the steering imposed upon the Engine.
     242    @return
     243        Returns the direction and magnitude of the steering imposed upon the Engine.
     244        Is the zero vector if the Engine doesn't belong to a ship.
     245    */
     246    const Vector3& Engine::getSteering() const
    233247    {
    234248        if (this->ship_)
     
    238252    }
    239253
    240     PickupCarrier* Engine::getCarrierParent(void) const
    241     {
    242         return this->ship_;
    243     }
    244 
    245     const Vector3& Engine::getCarrierPosition(void) const
    246     {
    247         return this->ship_->getWorldPosition();
    248     }
    249 
     254    /**
     255    @brief
     256        Load the engine template.
     257        Causes all parameters specified by the template to be applied to the Engine.
     258    */
    250259    void Engine::loadEngineTemplate()
    251260    {
     
    260269        }
    261270    }
     271
    262272}
  • code/trunk/src/orxonox/items/Engine.h

    r8706 r8727  
    3232#include "OrxonoxPrereqs.h"
    3333
    34 #include "tools/interfaces/Tickable.h"
     34#include "util/OrxAssert.h"
     35
    3536#include "Item.h"
    36 
    37 #include "interfaces/PickupCarrier.h"
    3837
    3938namespace orxonox
    4039{
    41     class _OrxonoxExport Engine : public Item, public Tickable, public PickupCarrier
     40
     41    /**
     42    @brief
     43        The Engine class provides propulsion to the SpaceShip.
     44       
     45        There are many parameters that can be specified:
     46        - The <b>relativePosition</b>, specifies the position relative to the center of the SpaceShip the Engine is mounted on.
     47        - The <b>maximal speed</b>, there are four maximal speeds that can be specified: The <b>speedfront</b>, the maximal forward speed. The <b>speedback>, the maximal backward speed. The <b>speedleftright</b>, the maximal speed in y-direction of the SpaceShip coordinate frame. The <b>speedupdown</b>, the maximal speed in z-direction of the SpaceShip coordinate frame. All maximal speeds (naturally) have to be non-negative.
     48        - The <b>acceleration</b>, there are five types of acceleration that can be specified: The <b>accelerationfront</b>, the forward acceleration. The <b>accelerationbrake</b>, the braking acceleration. The <b>accelerationback</b>, the backward acceleration. The <b>accelerationleftright</b>, the acceleration in y-direction. The <b>accelerationupdown</b>, the acceleration in z-direction. All accelerations have to be non-negative.
     49        - The <b>boostfactor</b>, specifies the factor by which boosting increases the speed. This has to be non-negative, as well. Beware that maximal speeds can be overcome through boosting.
     50        - The <b>template</b>, the name of the engine template. Allows for parameters of the Engine be set trough a template.
     51       
     52    @author
     53        Fabian 'x3n' Landau
     54    */
     55    class _OrxonoxExport Engine : public Item
    4256    {
    4357        public:
     
    4862            void setConfigValues();
    4963
    50             virtual void tick(float dt);
    51             virtual void changedActivity();
    52 
    53             virtual void addToSpaceShip(SpaceShip* ship);
     64            virtual void run(float dt); // Run the engine for a given time interval.
     65
     66            virtual void addToSpaceShip(SpaceShip* ship); // Adds the Engine to the input SpaceShip.
     67            /**
     68            @brief Get the SpaceShip this Engine is mounted on.
     69            @return Returns a pointer to the SpaceShip. NULL if it isn't mounted on any ship.
     70            */
    5471            inline SpaceShip* getShip() const
    5572                { return this->ship_; }
    5673
     74            /**
     75            @brief Set the relative position of the Engine.
     76            @param position The relative position with respect to the SpaceShip it is mounted on.
     77            */
    5778            inline void setRelativePosition(const Vector3 &position)
    5879                { this->relativePosition_ = position; }
    59             inline Vector3& getRelativePosition()
     80            /**
     81            @brief Get the relative position of the Engine.
     82            @return Returns the relative position with respect to the SpaceShip it is mounted on.
     83            */
     84            inline const Vector3& getRelativePosition() const
    6085                { return this->relativePosition_; }
    6186
     87            /**
     88            @brief Set the maximal forward speed of the Engine.
     89            @param speed The speed to be set. Must be non-negative.
     90            */
     91            //TODO: Better OrxVerify()?
     92            inline void setMaxSpeedFront(float speed)
     93                { OrxAssert(speed >= 0.0f, "The input speed must be non-negative."); this->maxSpeedFront_ = speed; }
     94            /**
     95            @brief Set the maximal backward speed of the Engine.
     96            @param speed The speed to be set. Must be non-negative.
     97            */
     98            inline void setMaxSpeedBack(float speed)
     99                { OrxAssert(speed >= 0.0f, "The input speed must be non-negative."); this->maxSpeedBack_ = speed; }
     100            /**
     101            @brief Set the maximal left-right speed of the Engine.
     102            @param speed The speed to be set. Must be non-negative.
     103            */
     104            inline void setMaxSpeedLeftRight(float speed)
     105                { OrxAssert(speed >= 0.0f, "The input speed must be non-negative."); this->maxSpeedLeftRight_ = speed; }
     106            /**
     107            @brief Set the maximal up-down speed of the Engine.
     108            @param speed The speed to be set. Must be non-negative.
     109            */
     110            inline void setMaxSpeedUpDown(float speed)
     111                { OrxAssert(speed >= 0.0f, "The input speed must be non-negative."); this->maxSpeedUpDown_ = speed; }
     112
     113            /**
     114            @brief Get the maximal forward speed of the Engine.
     115            @return Returns the maximal forward speed of the Engine. Is non-negative.
     116            */
     117            inline float getMaxSpeedFront() const
     118                { return this->maxSpeedFront_; }
     119            /**
     120            @brief Get the maximal backward speed of the Engine.
     121            @return Returns the maximal backward speed of the Engine. Is non-negative.
     122            */
     123            inline float getMaxSpeedBack() const
     124                { return this->maxSpeedBack_; }
     125            /**
     126            @brief Get the maximal left-right speed of the Engine.
     127            @return Returns the maximal left-right speed of the Engine. Is non-negative.
     128            */
     129            inline float getMaxSpeedLeftRight() const
     130                { return this->maxSpeedLeftRight_; }
     131            /**
     132            @brief Get the maximal up-down speed of the Engine.
     133            @return Returns the maximal up-down speed of the Engine. Is non-negative.
     134            */
     135            inline float getMaxSpeedUpDown() const
     136                { return this->maxSpeedUpDown_; }
     137
     138            /**
     139            @brief Set the forward acceleration produced by the Engine.
     140            @param acceleration The forward acceleration produced by the Engine. Must be non-negative.
     141            */
     142            inline void setAccelerationFront(float acceleration)
     143                { OrxAssert(acceleration >= 0.0f, "The input acceleration must be non-negative."); this->accelerationFront_ = acceleration; }
     144            /**
     145            @brief Set the breaking acceleration produced by the Engine.
     146            @param acceleration The breaking acceleration produced by the engine. Must be non-negative.
     147            */
     148            inline void setAccelerationBrake(float acceleration)
     149                { OrxAssert(acceleration >= 0.0f, "The input acceleration must be non-negative."); this->accelerationBrake_ = acceleration; }
     150            /**
     151            @brief Set the backward acceleration produced by the Engine.
     152            @param acceleration The backward acceleration produced by the Engine.
     153            */
     154            inline void setAccelerationBack(float acceleration)
     155                { OrxAssert(acceleration >= 0.0f, "The input acceleration must be non-negative."); this->accelerationBack_ = acceleration; }
     156            /**
     157            @brief Set the left-right acceleration produced by the Engine.
     158            @param acceleration The left-right acceleration produced by the Engine.
     159            */
     160            inline void setAccelerationLeftRight(float acceleration)
     161                { OrxAssert(acceleration >= 0.0f, "The input acceleration must be non-negative."); this->accelerationLeftRight_ = acceleration; }
     162            /**
     163            @brief Set the up-down acceleration produced by the Engine.
     164            @param acceleration The
     165            */
     166            inline void setAccelerationUpDown(float acceleration)
     167                { OrxAssert(acceleration >= 0.0f, "The input acceleration must be non-negative."); this->accelerationUpDown_ = acceleration; }
     168
     169            /**
     170            @brief Get the forward acceleration produced by the Engine.
     171            @return Returns the forward acceleration produced by the Engine. Is non-negative.
     172            */
     173            inline float getAccelerationFront() const
     174                { return this->accelerationFront_; }
     175            /**
     176            @brief Get the breaking acceleration produced by the Engine.
     177            @return Returns the breaking acceleration produced by the Engine. Is non-negative.
     178            */
     179            inline float getAccelerationBrake() const
     180                { return this->accelerationBrake_; }
     181            /**
     182            @brief Get the backward acceleration produced by the Engine.
     183            @return Returns the backward acceleration produced by the Engine. Is non-negative.
     184            */
     185            inline float getAccelerationBack() const
     186                { return this->accelerationBack_; }
     187            /**
     188            @brief Get the left-right acceleration produced by the Engine.
     189            @return Returns the left-right acceleration produced by the Engine. Is non-negative.
     190            */
     191            inline float getAccelerationLeftRight() const
     192                { return this->accelerationLeftRight_; }
     193            /**
     194            @brief Get the up-down acceleration produced by the Engine.
     195            @return Returns the up-down acceleration produced by the Engine. Is non-negative.
     196            */
     197            inline float getAccelerationUpDown() const
     198                { return this->accelerationUpDown_; }
     199
     200            /**
     201            @brief Set the factor by which boosting increases the forward acceleration of the Engine.
     202            @param factor The boost factor. Needs to be positive.
     203            */
    62204            inline void setBoostFactor(float factor)
    63                 { this->boostFactor_ = factor; }
     205                { OrxAssert(factor > 0.0f, "The input factor must be positive."); this->boostFactor_ = factor; }
     206            /**
     207            @brief Get the boost factor of the Engine.
     208            @return Returns the factor by which boosting increases the forward acceleration of the Engine. Is positive.
     209            */
    64210            inline float getBoostFactor() const
    65211                { return this->boostFactor_; }
    66212
    67             inline void setSpeedFactor(float factor)
    68                 { this->speedFactor_ = factor; }
    69             inline float getSpeedFactor() const
    70                 { return this->speedFactor_; }
    71 
    72             inline void setMaxSpeedFront(float speed)
    73                 { this->maxSpeedFront_ = speed; }
    74             inline void setMaxSpeedBack(float speed)
    75                 { this->maxSpeedBack_ = speed; }
    76             inline void setMaxSpeedLeftRight(float speed)
    77                 { this->maxSpeedLeftRight_ = speed; }
    78             inline void setMaxSpeedUpDown(float speed)
    79                 { this->maxSpeedUpDown_ = speed; }
    80 
    81             inline float getMaxSpeedFront() const
    82                 { return this->maxSpeedFront_; }
    83             inline float getMaxSpeedBack() const
    84                 { return this->maxSpeedBack_; }
    85             inline float getMaxSpeedLeftRight() const
    86                 { return this->maxSpeedLeftRight_; }
    87             inline float getMaxSpeedUpDown() const
    88                 { return this->maxSpeedUpDown_; }
    89 
    90             inline void setAccelerationFront(float acceleration)
    91                 { this->accelerationFront_ = acceleration; }
    92             inline void setAccelerationBrake(float acceleration)
    93                 { this->accelerationBrake_ = acceleration; }
    94             inline void setAccelerationBack(float acceleration)
    95                 { this->accelerationBack_ = acceleration; }
    96             inline void setAccelerationLeftRight(float acceleration)
    97                 { this->accelerationLeftRight_ = acceleration; }
    98             inline void setAccelerationUpDown(float acceleration)
    99                 { this->accelerationUpDown_ = acceleration; }
    100 
    101             inline float getAccelerationFront() const
    102                 { return this->accelerationFront_; }
    103             inline float getAccelerationBrake() const
    104                 { return this->accelerationBrake_; }
    105             inline float getAccelerationBack() const
    106                 { return this->accelerationBack_; }
    107             inline float getAccelerationLeftRight() const
    108                 { return this->accelerationLeftRight_; }
    109             inline float getAccelerationUpDown() const
    110                 { return this->accelerationUpDown_; }
    111 
     213            /**
     214            @brief Add to the additional forward speed factor.
     215            @param factor The speed that is added to the additional forward speed. Must be non-negative.
     216            */
     217            inline void addSpeedAdd(float speed)
     218                { this->speedAdd_ += speed; }
     219            /**
     220            @brief Add to the forward speed multiplication factor.
     221            @param factor The factor by which the forward speed multiplication factor is multiplied. Must be non-negative.
     222            */
     223            inline void addSpeedMultiply(float factor)
     224                { OrxAssert(factor >= 0.0f, "The factor must be non-negative."); this->speedMultiply_ *= factor; }
     225
     226            /**
     227            @brief Get the additional forward speed.
     228            @return Returns the additional forward speed.
     229            */
    112230            inline float getSpeedAdd(void)
    113231                { return this->speedAdd_; }
     232            /**
     233            @brief Get the forward speed multiplication factor.
     234            @return Returns the forward speed multiplication factor.
     235            */
    114236            inline float getSpeedMultiply(void)
    115237                { return this->speedMultiply_; }
    116238
    117             virtual const Vector3& getDirection() const;
    118 
    119             virtual const Vector3& getCarrierPosition(void) const;
    120 
    121             inline void setSpeedAdd(float speedAdd)
    122                 { this->speedAdd_=speedAdd; }
    123             inline void setSpeedMultiply(float speedMultiply)
    124                 { this->speedMultiply_=speedMultiply; }
    125 
    126            
     239            /**
     240            @brief Set the engine template, that specifies the parameters for the Engine.
     241            @param temp The name of the engine template.
     242            */
    127243            inline void setEngineTemplate(const std::string& temp)
    128244                { this->engineTemplate_ = temp; this->loadEngineTemplate(); }
     245            /**
     246            @brief Get the engine template, that specifies the parameters for the Engine.
     247            @return Returns the name of the engine template.
     248            */
    129249            inline const std::string& getEngineTemplate() const
    130250                { return this->engineTemplate_; }
    131251
    132252        protected:
    133             virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const
    134                 { return new std::vector<PickupCarrier*>(); }
    135             virtual PickupCarrier* getCarrierParent(void) const;
    136            
    137             void loadEngineTemplate();
     253            void loadEngineTemplate(); // Load the engine template.
     254
     255            virtual const Vector3& getSteering() const; // Get the steering direction imposed upon the Engine.
    138256
    139257        private:
     
    141259            void networkcallback_shipID();
    142260
    143             std::string engineTemplate_;
    144 
    145             SpaceShip* ship_;
    146             unsigned int shipID_;
    147             Vector3 relativePosition_;
    148 
    149             float boostFactor_;
    150             float speedFactor_;
    151 
    152             float speedAdd_;
    153             float speedMultiply_;
    154 
    155             float maxSpeedFront_;
    156             float maxSpeedBack_;
    157             float maxSpeedLeftRight_;
    158             float maxSpeedUpDown_;
    159 
    160             float accelerationFront_;
    161             float accelerationBrake_;
    162             float accelerationBack_;
    163             float accelerationLeftRight_;
    164             float accelerationUpDown_;
     261            std::string engineTemplate_; //!< The template that specifies the Engine's parameters.
     262
     263            SpaceShip* ship_; //!< A pointer to the SpaceShip the Engine is mounted on.
     264            unsigned int shipID_; //!< Object ID of the SpaceShip the Engine is mounted on.
     265            Vector3 relativePosition_; //!< The relative position of the Engine with respect to the SpaceShip it is mounted on.
     266
     267            float boostFactor_; //!< The factor by which boosting increases the forward acceleration.
     268
     269            float speedAdd_; //!< Additional forward speed. Is not bounded by the maximal forward speed.
     270            float speedMultiply_; //!< Forward speed multiplication factor. Is not bounded by the maximal forward speed.
     271
     272            float maxSpeedFront_; //!< The maximal forward speed.
     273            float maxSpeedBack_; //!< The maximal backward speed.
     274            float maxSpeedLeftRight_; //!< The maximal left-right speed.
     275            float maxSpeedUpDown_; //!< The maximal up-down speed.
     276
     277            float accelerationFront_; //!< Forward acceleration produced by the Engine.
     278            float accelerationBrake_; //!< Breaking acceleration produced by the Engine.
     279            float accelerationBack_; //!< Backward acceleration produced by the Engine.
     280            float accelerationLeftRight_; //!< Left-right acceleration produced by the Engine.
     281            float accelerationUpDown_; //!< Up-down acceleration produced by the Engine.
     282
    165283    };
    166284}
  • code/trunk/src/orxonox/items/MultiStateEngine.cc

    r6709 r8727  
    109109    }
    110110
    111     void MultiStateEngine::tick(float dt)
     111    void MultiStateEngine::run(float dt)
    112112    {
    113113        if (this->getShip())
     
    117117            if (this->getShip()->hasLocalController())
    118118            {
    119                 const Vector3& direction = this->getDirection();
     119                const Vector3& direction = this->getSteering();
    120120                bool forward = (direction.z < 0.0 && velocity.z < -FORWARD_EFFECT_VELOCITY_THRESHOLD);
    121121
    122122                this->state_ = 0;
    123                 if (this->getShip()->getBoost() && forward)
     123                if (this->getShip()->isBoosting() && forward)
    124124                    this->state_ = Boost;
    125125                else if (forward && !this->state_) // this->state_ == Boost
     
    181181        }
    182182
    183         SUPER(MultiStateEngine, tick, dt);
     183        Engine::run(dt);
    184184    }
    185185
  • code/trunk/src/orxonox/items/MultiStateEngine.h

    r7163 r8727  
    5454            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    5555
    56             virtual void tick(float dt);
     56            virtual void run(float dt);
    5757
    5858            virtual void addToSpaceShip(SpaceShip* ship);
Note: See TracChangeset for help on using the changeset viewer.