Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8427


Ignore:
Timestamp:
May 9, 2011, 3:19:22 PM (13 years ago)
Author:
dboehi
Message:

Shake effect now depends on the velocity of the space ship

File:
1 edited

Legend:

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

    r8379 r8427  
    142142        if (this->hasLocalController())
    143143        {
     144               
    144145/*
    145146            this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_);
     
    165166            }
    166167
     168           // COUT(0) << "Velocity: " << this->getVelocity().length() << " - " << this->getVelocity().squaredLength() << std::endl;
    167169
    168170
     
    172174                if(this->boostPower_ <= 0.0f)
    173175                {
    174                     this->bBoost_ = false;
     176                    this->boost(false);
    175177                    this->bBoostCooldown_ = true;
    176178                    this->timer_.setTimer(this->boostCooldownDuration_, false, createExecutor(createFunctor(&SpaceShip::boostCooledDown, this)));
    177179                   
    178180                }
    179                 else
     181                if (this->getVelocity().squaredLength() > 20)
    180182                {
    181183                        this->shakeDt_ += dt;
    182184                       
    183185                        Camera* c = this->getCamera();
     186                       
     187                        this->shakeFrequency_ = this->getVelocity().squaredLength() / 10000;
     188                       
     189                        COUT(0) << "ShakeFrequency: " << this->shakeFrequency_ << std::endl;
    184190
    185191                        //Shaking Camera effect
    186192                        if (c != 0)
    187193                        {
    188 
    189                                 if (c->getAngularVelocity() == Vector3(0,0,0))
    190                                 {
    191                                         c->setAngularVelocity(Vector3(2,0,0));
     194                                c->setAngularVelocity(Vector3(shakeFrequency_,0 , 0));
     195
     196                                //if (c->getAngularVelocity() == Vector3(0,0,0))
     197                                //{
     198                                //      c->setAngularVelocity(Vector3(2,0,0));
    192199
    193200                                        //set the delta to half the period time,
    194201                                        //so the camera shakes up and down.
    195                                         this->shakeDt_ = 1/(2 * this->shakeFrequency_);
    196                                 }
     202                                //      this->shakeDt_ = 1/(2 * this->shakeFrequency_);
     203                                //}
    197204
    198205
     
    209216    }
    210217
     218
    211219    void SpaceShip::boostCooledDown(void)
    212220    {
     
    264272    */
    265273    void SpaceShip::boost(bool bBoost)
    266     {
    267         Camera* c = this->getCamera();
    268        
     274    {   
    269275        if(bBoost && !this->bBoostCooldown_)
    270276            this->bBoost_ = true;
    271277        if(!bBoost)
    272278        {
     279            this->resetCamera();
    273280            this->bBoost_ = false;
    274             this->resetCamera();
    275281        }
    276282    }
     
    321327    void SpaceShip::resetCamera()
    322328    {
     329            //COUT(0) << "Resetting camera\n";
    323330            Camera *c = this->getCamera();
    324            
    325             assert(c != 0);
    326331         
    327332            if (c == 0)
Note: See TracChangeset for help on using the changeset viewer.