Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2448


Ignore:
Timestamp:
Dec 14, 2008, 8:13:56 PM (15 years ago)
Author:
rgrieder
Message:

Spectator update with new physics stuff.

Location:
code/branches/physics_merge/src/orxonox/objects
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/physics_merge/src/orxonox/objects/Scene.cc

    r2446 r2448  
    8080        // No physics yet, XMLPort will do that.
    8181        const int defaultMaxWorldSize = 100000;
    82         this->negativeWorldRange_ = Vector3(-defaultMaxWorldSize, -defaultMaxWorldSize, -defaultMaxWorldSize);
    83         this->positiveWorldRange_ = Vector3( defaultMaxWorldSize,  defaultMaxWorldSize,  defaultMaxWorldSize);
    84         this->gravity_ = Vector3(0, 0, 0);
     82        this->negativeWorldRange_ = Vector3::UNIT_SCALE * -defaultMaxWorldSize;
     83        this->positiveWorldRange_ = Vector3::UNIT_SCALE *  defaultMaxWorldSize;
     84        this->gravity_ = Vector3::ZERO;
    8585        this->physicalWorld_   = 0;
    8686        this->solver_          = 0;
  • code/branches/physics_merge/src/orxonox/objects/worldentities/pawns/Spectator.cc

    r2442 r2448  
    5252
    5353        this->speed_ = 100;
    54         this->rotationSpeed_ = 3;
     54        this->rotationGain_ = 3;
    5555
    5656        this->yaw_ = 0;
    5757        this->pitch_ = 0;
    5858        this->roll_ = 0;
     59        this->localVelocity_ = Vector3::ZERO;
    5960        this->setHudTemplate("spectatorhud");
    6061        this->hudmode_ = 0;
     
    110111        if (this->isLocallyControlled())
    111112        {
    112             Vector3 velocity = this->getVelocity();
    113             velocity.normalise();
    114             this->setVelocity(this->getOrientation() * velocity * this->speed_);
    115 
    116             this->yaw(Radian(this->yaw_ * this->rotationSpeed_));
    117             this->pitch(Radian(this->pitch_ * this->rotationSpeed_));
    118             this->roll(Radian(this->roll_ * this->rotationSpeed_));
     113            float localSpeedSquared = this->localVelocity_.squaredLength();
     114            float localSpeed;
     115            if (localSpeedSquared > 1.0)
     116                localSpeed = this->speed_ / sqrtf(localSpeedSquared);
     117            else
     118                localSpeed = this->speed_;
     119
     120            this->localVelocity_.x *= localSpeed;
     121            this->localVelocity_.y *= localSpeed;
     122            this->localVelocity_.z *= localSpeed;
     123            this->setVelocity(this->getOrientation() * this->localVelocity_);
     124            this->localVelocity_.x = 0;
     125            this->localVelocity_.y = 0;
     126            this->localVelocity_.z = 0;
     127
     128            this->yaw  (Radian(this->yaw_   * this->rotationGain_));
     129            this->pitch(Radian(this->pitch_ * this->rotationGain_));
     130            this->roll (Radian(this->roll_  * this->rotationGain_));
    119131
    120132            this->yaw_ = this->pitch_ = this->roll_ = 0;
     
    122134
    123135        SUPER(Spectator, tick, dt);
    124 
    125         if (this->isLocallyControlled())
    126         {
    127             this->setVelocity(Vector3::ZERO);
    128         }
    129136    }
    130137
     
    145152    void Spectator::moveFrontBack(const Vector2& value)
    146153    {
    147         this->setVelocity(this->getVelocity() + value.y * this->speed_ * WorldEntity::FRONT);
     154        this->localVelocity_.z -= value.x;
    148155    }
    149156
    150157    void Spectator::moveRightLeft(const Vector2& value)
    151158    {
    152         this->setVelocity(this->getVelocity() + value.y * this->speed_ * WorldEntity::RIGHT);
     159        this->localVelocity_.x += value.x;
    153160    }
    154161
    155162    void Spectator::moveUpDown(const Vector2& value)
    156163    {
    157         this->setVelocity(this->getVelocity() + value.y * this->speed_ * WorldEntity::UP);
     164        this->localVelocity_.y += value.x;
    158165    }
    159166
    160167    void Spectator::rotateYaw(const Vector2& value)
    161168    {
    162         this->yaw_ = value.y;
     169        this->yaw_ += value.y;
    163170    }
    164171
    165172    void Spectator::rotatePitch(const Vector2& value)
    166173    {
    167         this->pitch_ = value.y;
     174        this->pitch_ += value.y;
    168175    }
    169176
    170177    void Spectator::rotateRoll(const Vector2& value)
    171178    {
    172         this->roll_ = value.y;
     179        this->roll_ += value.y;
    173180    }
    174181
  • code/branches/physics_merge/src/orxonox/objects/worldentities/pawns/Spectator.h

    r2087 r2448  
    6969
    7070            float speed_;
    71             float rotationSpeed_;
     71            float rotationGain_;
    7272
    7373            float yaw_;
    7474            float pitch_;
    7575            float roll_;
     76
     77            Vector3 localVelocity_;
    7678
    7779            int hudmode_;
Note: See TracChangeset for help on using the changeset viewer.