Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 29, 2008, 12:48:11 AM (16 years ago)
Author:
landauf
Message:

bugs—
network++
endurance—
tiredness++

but it still doesn't work properly
(commit because oli is very impatient)

File:
1 edited

Legend:

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

    r2040 r2041  
    5858        this->bInvertYAxis_ = false;
    5959
     60        this->setDestroyWhenPlayerLeft(true);
     61
    6062        this->setConfigValues();
    6163        this->registerVariables();
     
    8082    void SpaceShip::registerVariables()
    8183    {
     84        REGISTERDATA(this->maxSpeed_,                network::direction::toclient);
     85        REGISTERDATA(this->maxSecondarySpeed_,       network::direction::toclient);
     86        REGISTERDATA(this->maxRotation_,             network::direction::toclient);
     87        REGISTERDATA(this->translationAcceleration_, network::direction::toclient);
     88        REGISTERDATA(this->rotationAcceleration_,    network::direction::toclient);
     89        REGISTERDATA(this->translationDamping_,      network::direction::toclient);
    8290    }
    8391
     
    8997    void SpaceShip::tick(float dt)
    9098    {
    91         // #####################################
    92         // ############# STEERING ##############
    93         // #####################################
    94 
    95         Vector3 velocity = this->getVelocity();
    96         if (velocity.x > this->maxSecondarySpeed_)
    97             velocity.x = this->maxSecondarySpeed_;
    98         if (velocity.x < -this->maxSecondarySpeed_)
    99             velocity.x = -this->maxSecondarySpeed_;
    100         if (velocity.y > this->maxSecondarySpeed_)
    101             velocity.y = this->maxSecondarySpeed_;
    102         if (velocity.y < -this->maxSecondarySpeed_)
    103             velocity.y = -this->maxSecondarySpeed_;
    104         if (velocity.z > this->maxSecondarySpeed_)
    105             velocity.z = this->maxSecondarySpeed_;
    106         if (velocity.z < -this->maxSpeed_)
    107             velocity.z = -this->maxSpeed_;
    108 
    109         // normalize velocity and acceleration
    110         for (size_t dimension = 0; dimension < 3; ++dimension)
     99        if (this->isLocallyControlled())
    111100        {
    112             if (this->acceleration_[dimension] == 0)
     101            // #####################################
     102            // ############# STEERING ##############
     103            // #####################################
     104
     105            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_;
     118
     119            // normalize velocity and acceleration
     120            for (size_t dimension = 0; dimension < 3; ++dimension)
    113121            {
    114                 if (velocity[dimension] > 0)
     122                if (this->acceleration_[dimension] == 0)
    115123                {
    116                     velocity[dimension] -= (this->translationDamping_ * dt);
    117                     if (velocity[dimension] < 0)
    118                         velocity[dimension] = 0;
    119                 }
    120                 else if (velocity[dimension] < 0)
    121                 {
    122                     velocity[dimension] += (this->translationDamping_ * dt);
    123124                    if (velocity[dimension] > 0)
    124                         velocity[dimension] = 0;
     125                    {
     126                        velocity[dimension] -= (this->translationDamping_ * dt);
     127                        if (velocity[dimension] < 0)
     128                            velocity[dimension] = 0;
     129                    }
     130                    else if (velocity[dimension] < 0)
     131                    {
     132                        velocity[dimension] += (this->translationDamping_ * dt);
     133                        if (velocity[dimension] > 0)
     134                            velocity[dimension] = 0;
     135                    }
    125136                }
    126137            }
     138
     139            this->setVelocity(velocity);
    127140        }
    128141
    129         this->setVelocity(velocity);
    130 
    131142
    132143        SUPER(SpaceShip, tick, dt);
    133144
    134145
    135         this->yaw(this->yawRotation_ * dt);
    136         if (this->bInvertYAxis_)
    137             this->pitch(Degree(-this->pitchRotation_ * dt));
    138         else
    139             this->pitch(Degree( this->pitchRotation_ * dt));
    140         this->roll(this->rollRotation_ * dt);
    141 
    142         this->acceleration_.x = 0;
    143         this->acceleration_.y = 0;
    144         this->acceleration_.z = 0;
    145 
    146         this->yawRotation_   = this->zeroDegree_;
    147         this->pitchRotation_ = this->zeroDegree_;
    148         this->rollRotation_  = this->zeroDegree_;
     146        if (this->isLocallyControlled())
     147        {
     148            this->yaw(this->yawRotation_ * dt);
     149            if (this->bInvertYAxis_)
     150                this->pitch(Degree(-this->pitchRotation_ * dt));
     151            else
     152                this->pitch(Degree( this->pitchRotation_ * dt));
     153            this->roll(this->rollRotation_ * dt);
     154
     155            this->acceleration_.x = 0;
     156            this->acceleration_.y = 0;
     157            this->acceleration_.z = 0;
     158
     159            this->yawRotation_   = this->zeroDegree_;
     160            this->pitchRotation_ = this->zeroDegree_;
     161            this->rollRotation_  = this->zeroDegree_;
     162        }
    149163    }
    150164
Note: See TracChangeset for help on using the changeset viewer.