Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 10, 2008, 1:38:17 PM (15 years ago)
Author:
rgrieder
Message:

Trying to synchronise phyiscs over the network.

  • Removed derivation of CollisionShape from WorldEntity (BaseObject instead).
File:
1 edited

Legend:

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

    r2314 r2374  
    4040namespace orxonox
    4141{
     42    const float orientationGain = 100;
    4243    CreateFactory(SpaceShip);
    4344
     
    8485        if (this->physicalBody_)
    8586        {
    86             this->physicalBody_->setDamping(0.8, 0.9);
    87             this->physicalBody_->setActivationState(DISABLE_DEACTIVATION);
     87            this->physicalBody_->setDamping(0.7, 0.3);
    8888        }
    8989    }
     
    106106    void SpaceShip::tick(float dt)
    107107    {
    108         if (this->isLocallyControlled())
    109         {
    110             // #####################################
    111             // ############# STEERING ##############
    112             // #####################################
    113 
    114             //Vector3 velocity = this->getVelocity();
    115             //if (velocity.x > this->maxSecondarySpeed_)
    116             //    velocity.x = this->maxSecondarySpeed_;
    117             //if (velocity.x < -this->maxSecondarySpeed_)
    118             //    velocity.x = -this->maxSecondarySpeed_;
    119             //if (velocity.y > this->maxSecondarySpeed_)
    120             //    velocity.y = this->maxSecondarySpeed_;
    121             //if (velocity.y < -this->maxSecondarySpeed_)
    122             //    velocity.y = -this->maxSecondarySpeed_;
    123             //if (velocity.z > this->maxSecondarySpeed_)
    124             //    velocity.z = this->maxSecondarySpeed_;
    125             //if (velocity.z < -this->maxSpeed_)
    126             //    velocity.z = -this->maxSpeed_;
    127 
    128             // normalize velocity and acceleration
    129             //for (size_t dimension = 0; dimension < 3; ++dimension)
    130             //{
    131             //    if (this->acceleration_[dimension] == 0)
    132             //    {
    133             //        if (velocity[dimension] > 0)
    134             //        {
    135             //            velocity[dimension] -= (this->translationDamping_ * dt);
    136             //            if (velocity[dimension] < 0)
    137             //                velocity[dimension] = 0;
    138             //        }
    139             //        else if (velocity[dimension] < 0)
    140             //        {
    141             //            velocity[dimension] += (this->translationDamping_ * dt);
    142             //            if (velocity[dimension] > 0)
    143             //                velocity[dimension] = 0;
    144             //        }
    145             //    }
    146             //}
    147 
    148             //this->setVelocity(velocity);
    149         }
    150 
    151 
    152108        SUPER(SpaceShip, tick, dt);
    153 
    154 
    155         //if (this->isLocallyControlled())
    156         //{
    157         //    this->yaw(this->yawRotation_ * dt);
    158         //    if (this->bInvertYAxis_)
    159         //        this->pitch(Degree(-this->pitchRotation_ * dt));
    160         //    else
    161         //        this->pitch(Degree( this->pitchRotation_ * dt));
    162         //    this->roll(this->rollRotation_ * dt);
    163 
    164         //    this->acceleration_.x = 0;
    165         //    this->acceleration_.y = 0;
    166         //    this->acceleration_.z = 0;
    167 
    168         //    this->yawRotation_   = this->zeroDegree_;
    169         //    this->pitchRotation_ = this->zeroDegree_;
    170         //    this->rollRotation_  = this->zeroDegree_;
    171         //}
    172109    }
    173110
     
    176113        assert(this->physicalBody_);
    177114        this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * btVector3(0.0f, 0.0f, -getMass() * value.x * 100));
    178 //        this->acceleration_.z = -this->translationAcceleration_ * value.x;
    179115    }
    180116
     
    182118    {
    183119        this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * btVector3(getMass() * value.x * 100, 0.0f, 0.0f));
    184 //        this->acceleration_.x = this->translationAcceleration_ * value.x;
    185120    }
    186121
     
    188123    {
    189124        this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * btVector3(0.0f, getMass() * value.x * 100, 0.0f));
    190 //        this->acceleration_.y = this->translationAcceleration_ * value.x;
    191125    }
    192126
    193127    void SpaceShip::rotateYaw(const Vector2& value)
    194128    {
    195         this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * btVector3(0.0f, getMass() * value.x * 10000, 0.0f));
    196         //Degree temp = value.x * value.x * sgn(value.x) * this->rotationAcceleration_;
    197         //if (temp > this->maxRotation_)
    198         //    temp = this->maxRotation_;
    199         //if (temp < -this->maxRotation_)
    200         //    temp = -this->maxRotation_;
    201         //this->yawRotation_ = Degree(temp);
     129        this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * btVector3(0.0f, 1 / this->physicalBody_->getInvInertiaDiagLocal().y() * value.y * orientationGain, 0.0f));
    202130    }
    203131
    204132    void SpaceShip::rotatePitch(const Vector2& value)
    205133    {
    206         this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * btVector3(getMass() * value.x * 10000, 0.0f, 0.0f));
    207         //Degree temp = value.x * value.x * sgn(value.x) * this->rotationAcceleration_;
    208         //if (temp > this->maxRotation_)
    209         //    temp = this->maxRotation_;
    210         //if (temp < -this->maxRotation_)
    211         //    temp = -this->maxRotation_;
    212         //this->pitchRotation_ = Degree(temp);
     134        this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * btVector3(1 / this->physicalBody_->getInvInertiaDiagLocal().x() * value.y * orientationGain, 0.0f, 0.0f));
    213135    }
    214136
    215137    void SpaceShip::rotateRoll(const Vector2& value)
    216138    {
    217         this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * btVector3(0.0f, 0.0f, -getMass() * value.x * 10000));
    218         //Degree temp = value.x * value.x * sgn(value.x) * this->rotationAcceleration_;
    219         //if (temp > this->maxRotation_)
    220         //    temp = this->maxRotation_;
    221         //if (temp < -this->maxRotation_)
    222         //    temp = -this->maxRotation_;
    223         //this->rollRotation_ = Degree(temp);
     139        this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * btVector3(0.0f, 0.0f, -1 / this->physicalBody_->getInvInertiaDiagLocal().z() * value.y * orientationGain));
    224140    }
    225141
Note: See TracChangeset for help on using the changeset viewer.