Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 24, 2008, 1:50:47 AM (16 years ago)
Author:
landauf
Message:

Update your media repository and delete keybindings.ini if you want to use boost (space).

  • Added new class "Engine" to control the speed of a SpaceShip (Engine is an Item, MultiStateEngine is a specialized version of Engine)
  • Added FadingBillboard, a billboard with the ability to fade in and out smoothly when activated/deactivated.
  • Several changes in Backlight, it's now a child of FadingBillboard
  • Some changes concerning local control in ControllableEntity
  • Fixed a bug in WorldEntity caused by different destruction order of attached objects on server and client
  • Added a "MainState" to BaseObject. An object has several states (activity, visibility, …) and one of it can be defined as "MainState" in the XML file. Other objects can change this state without knowing which state it really is (used by MultiStateEngine).
Location:
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/pawns
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy2/src/orxonox/objects/worldentities/pawns/SpaceShip.cc

    r2171 r2254  
    3232#include "core/CoreIncludes.h"
    3333#include "core/ConfigValueIncludes.h"
     34#include "core/Template.h"
    3435#include "core/XMLPort.h"
    3536#include "util/Math.h"
     37#include "objects/items/Engine.h"
    3638
    3739namespace orxonox
     
    4547        this->zeroDegree_ = 0;
    4648
    47         this->maxSpeed_ = 0;
    48         this->maxSecondarySpeed_ = 0;
     49        this->bBoost_ = false;
     50        this->steering_ = Vector3::ZERO;
     51        this->engine_ = 0;
     52
    4953        this->maxRotation_ = 0;
    50         this->translationAcceleration_ = 0;
    5154        this->rotationAcceleration_ = 0;
    5255        this->translationDamping_ = 0;
     
    6669    SpaceShip::~SpaceShip()
    6770    {
     71        if (this->isInitialized() && this->engine_)
     72            delete this->engine_;
    6873    }
    6974
     
    7277        SUPER(SpaceShip, XMLPort, xmlelement, mode);
    7378
    74         XMLPortParam(SpaceShip, "maxspeed",          setMaxSpeed,          getMaxSpeed,          xmlelement, mode);
    75         XMLPortParam(SpaceShip, "maxsecondaryspeed", setMaxSecondarySpeed, getMaxSecondarySpeed, xmlelement, mode);
     79        XMLPortParam(SpaceShip, "engine",            setEngineTemplate,    getEngineTemplate,    xmlelement, mode);
    7680        XMLPortParam(SpaceShip, "maxrotation",       setMaxRotation,       getMaxRotation,       xmlelement, mode);
    77         XMLPortParam(SpaceShip, "transacc",          setTransAcc,          getTransAcc,          xmlelement, mode);
    7881        XMLPortParam(SpaceShip, "rotacc",            setRotAcc,            getRotAcc,            xmlelement, mode);
    7982        XMLPortParam(SpaceShip, "transdamp",         setTransDamp,         getTransDamp,         xmlelement, mode);
     
    8285    void SpaceShip::registerVariables()
    8386    {
    84         REGISTERDATA(this->maxSpeed_,                direction::toclient);
    85         REGISTERDATA(this->maxSecondarySpeed_,       direction::toclient);
    8687        REGISTERDATA(this->maxRotation_,             direction::toclient);
    87         REGISTERDATA(this->translationAcceleration_, direction::toclient);
    8888        REGISTERDATA(this->rotationAcceleration_,    direction::toclient);
    8989        REGISTERDATA(this->translationDamping_,      direction::toclient);
     
    9797    void SpaceShip::tick(float dt)
    9898    {
    99         if (this->isLocallyControlled())
     99        if (this->hasLocalController())
    100100        {
    101101            // #####################################
     
    104104
    105105            Vector3 velocity = this->getVelocity();
    106             if (velocity.x > this->maxSecondarySpeed_)
    107                 velocity.x = this->maxSecondarySpeed_;
    108             if (velocity.x < -this->maxSecondarySpeed_)
    109                 velocity.x = -this->maxSecondarySpeed_;
    110             if (velocity.y > this->maxSecondarySpeed_)
    111                 velocity.y = this->maxSecondarySpeed_;
    112             if (velocity.y < -this->maxSecondarySpeed_)
    113                 velocity.y = -this->maxSecondarySpeed_;
    114             if (velocity.z > this->maxSecondarySpeed_)
    115                 velocity.z = this->maxSecondarySpeed_;
    116             if (velocity.z < -this->maxSpeed_)
    117                 velocity.z = -this->maxSpeed_;
    118106
    119107            // normalize velocity and acceleration
     
    144132
    145133
    146         if (this->isLocallyControlled())
     134        if (this->hasLocalController())
    147135        {
    148136            this->yaw(this->yawRotation_ * dt);
     
    153141            this->roll(this->rollRotation_ * dt);
    154142
    155             this->acceleration_.x = 0;
    156             this->acceleration_.y = 0;
    157             this->acceleration_.z = 0;
    158 
    159143            this->yawRotation_   = this->zeroDegree_;
    160144            this->pitchRotation_ = this->zeroDegree_;
     
    165149    void SpaceShip::moveFrontBack(const Vector2& value)
    166150    {
    167         this->acceleration_.z = -this->translationAcceleration_ * value.x;
     151        this->steering_.z = -value.x;
    168152    }
    169153
    170154    void SpaceShip::moveRightLeft(const Vector2& value)
    171155    {
    172         this->acceleration_.x = this->translationAcceleration_ * value.x;
     156        this->steering_.x = value.x;
    173157    }
    174158
    175159    void SpaceShip::moveUpDown(const Vector2& value)
    176160    {
    177         this->acceleration_.y = this->translationAcceleration_ * value.x;
     161        this->steering_.y = value.x;
    178162    }
    179163
     
    211195    {
    212196    }
     197
     198    void SpaceShip::boost()
     199    {
     200        this->bBoost_ = true;
     201    }
     202
     203    void SpaceShip::loadEngineTemplate()
     204    {
     205        if (this->enginetemplate_ != "")
     206        {
     207            Template* temp = Template::getTemplate(this->enginetemplate_);
     208
     209            if (temp)
     210            {
     211                Identifier* identifier = temp->getBaseclassIdentifier();
     212
     213                if (identifier)
     214                {
     215                    BaseObject* object = identifier->fabricate(this);
     216                    this->engine_ = dynamic_cast<Engine*>(object);
     217
     218                    if (this->engine_)
     219                    {
     220                        this->engine_->addTemplate(temp);
     221                        this->engine_->addToSpaceShip(this);
     222                    }
     223                    else
     224                    {
     225                        delete object;
     226                    }
     227                }
     228            }
     229        }
     230    }
    213231}
  • code/branches/objecthierarchy2/src/orxonox/objects/worldentities/pawns/SpaceShip.h

    r2087 r2254  
    5656
    5757            virtual void fire();
     58            virtual void boost();
    5859
    59             void setMaxSpeed(float value)
    60                 { this->maxSpeed_ = value; }
    61             void setMaxSecondarySpeed(float value)
    62                 { this->maxSecondarySpeed_ = value; }
    6360            void setMaxRotation(const Degree& value)
    6461                { this->maxRotation_ = value; }
    65             void setTransAcc(float value)
    66                 { this->translationAcceleration_ = value; }
    6762            void setRotAcc(const Degree& value)
    6863                { this->rotationAcceleration_ = value; }
     
    7065                { this->translationDamping_ = value; }
    7166
    72             inline float getMaxSpeed() const
    73                 { return this->maxSpeed_; }
    74             inline float getMaxSecondarySpeed() const
    75                 { return this->maxSecondarySpeed_; }
    7667            inline float getMaxRotation() const
    7768                { return this->maxRotation_.valueDegrees(); }
    78             inline float getTransAcc() const
    79                 { return this->translationAcceleration_; }
    8069            inline float getRotAcc() const
    8170                { return this->rotationAcceleration_.valueDegrees(); }
     
    8372                { return this->translationDamping_; }
    8473
     74            inline void setSteeringDirection(const Vector3& direction)
     75                { this->steering_ = direction; }
     76            inline const Vector3& getSteeringDirection() const
     77                { return this->steering_; }
     78
     79            inline void setBoost(bool bBoost)
     80                { this->bBoost_ = bBoost; }
     81            inline bool getBoost() const
     82                { return this->bBoost_; }
     83
     84            inline void setEngineTemplate(const std::string& temp)
     85                { this->enginetemplate_ = temp; this->loadEngineTemplate(); }
     86            inline const std::string& getEngineTemplate() const
     87                { return this->enginetemplate_; }
     88
    8589        protected:
    8690            bool bInvertYAxis_;
    8791
    88             float maxSpeed_;
    89             float maxSecondarySpeed_;
    90             float translationAcceleration_;
     92            bool bBoost_;
     93            Vector3 steering_;
    9194            float translationDamping_;
    9295
     
    98101            Degree yawRotation_;
    99102            Degree rollRotation_;
     103
     104        private:
     105            void loadEngineTemplate();
     106
     107            std::string enginetemplate_;
     108            Engine* engine_;
    100109    };
    101110}
  • code/branches/objecthierarchy2/src/orxonox/objects/worldentities/pawns/Spectator.cc

    r2171 r2254  
    106106        this->updateHUD();
    107107
    108         if (this->isLocallyControlled())
     108        if (this->hasLocalController())
    109109        {
    110110            Vector3 velocity = this->getVelocity();
     
    121121        SUPER(Spectator, tick, dt);
    122122
    123         if (this->isLocallyControlled())
     123        if (this->hasLocalController())
    124124        {
    125125            this->setVelocity(Vector3::ZERO);
     
    134134    }
    135135
    136     void Spectator::startLocalControl()
    137     {
    138         ControllableEntity::startLocalControl();
    139 //        if (this->isLocallyControlled())
     136    void Spectator::startLocalHumanControl()
     137    {
     138        ControllableEntity::startLocalHumanControl();
     139//        if (this->hasLocalController())
    140140//            this->testmesh_->setVisible(false);
    141141    }
  • code/branches/objecthierarchy2/src/orxonox/objects/worldentities/pawns/Spectator.h

    r2087 r2254  
    4646
    4747            virtual void setPlayer(PlayerInfo* player);
    48             virtual void startLocalControl();
     48            virtual void startLocalHumanControl();
    4949
    5050            virtual void moveFrontBack(const Vector2& value);
Note: See TracChangeset for help on using the changeset viewer.