Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8191


Ignore:
Timestamp:
Apr 4, 2011, 4:19:57 PM (13 years ago)
Author:
dboehi
Message:

Update version of the boost effect,
the camera is rotating up and down if the
boost is active.

Location:
code/branches/gameimmersion/src/orxonox/worldentities/pawns
Files:
2 edited

Legend:

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

    r8138 r8191  
    8282        this->cameraOriginalPosition = c->getPosition();
    8383        this->cameraOriginalOrientation = c->getOrientation();
     84
     85        this->shakeFrequency_ = 100;
     86        this->shakeAmplitude_ = 40;
     87        this->shakeDeltaTime_ = 0;
    8488    }
    8589
     
    156160                this->boostPower_ += this->boostPowerRate_*dt;
    157161            }
     162
     163        Camera* c = CameraManager::getInstance().getActiveCamera();
    158164            if(this->bBoost_)
    159165            {
    160                 Camera* c = CameraManager::getInstance().getActiveCamera();
    161166                this->boostPower_ -=this->boostRate_*dt;
    162167                if(this->boostPower_ <= 0.0f)
     
    166171                    this->timer_.setTimer(this->boostCooldownDuration_, false, createExecutor(createFunctor(&SpaceShip::boostCooledDown, this)));
    167172                   
    168                     c->setVelocity(0,0,0);
    169                     c->setPosition(this->cameraOriginalPosition);
    170                     c->setOrientation(this->cameraOriginalOrientation);
    171173                }
    172174                else
    173175                {
    174                         //Kamera schuettelt
    175                         COUT(1) << "Afterburner effect\n";
     176                        this->shakeDeltaTime_ += dt;
     177
     178                        //Shaking Camera effect
    176179                        if (c != 0)
    177180                        {
    178                                 c->setVelocity(0.1, 2.0, 0.3);
     181
     182                                if (c->getAngularVelocity() == Vector3(0,0,0))
     183                                {
     184                                        c->setAngularVelocity(Vector3(2,0,0));
     185                                        this->shakeDeltaTime_ = 0;
     186                                }
     187
     188
     189                                //toggle the rotation
     190                                if (1/(this->shakeFrequency_) <= shakeDeltaTime_)
     191                                {
     192                                        c->setAngularVelocity(-c->getAngularVelocity());
     193                                        shakeDeltaTime_ = 0;
     194                                }
     195
     196                               
     197                                /*
     198                                COUT(1) << "Time since change: " << shakeDeltaTime_ << std::endl;
     199                                COUT(1) << "Rotation Rate: " << c->getRotationRate() << std::endl;
     200                                COUT(1) << "Angular Velocity: " << c->getAngularVelocity().length();
     201                                COUT(1) << std::endl;
     202                                */
    179203                        }
    180204                }
    181205            }
     206            else
     207            {
     208                    //reset the camera, if the boost is not active
     209                    //TODO: don't call this every tick
     210                    c->setAngularVelocity(Vector3(0,0,0));
     211                    c->setPosition(this->cameraOriginalPosition);
     212                    c->setOrientation(this->cameraOriginalOrientation);
     213            }
    182214        }
    183215    }
  • code/branches/gameimmersion/src/orxonox/worldentities/pawns/SpaceShip.h

    r8138 r8191  
    103103            btVector3 localAngularAcceleration_;
    104104
     105
     106            float shakeFrequency_;
     107            float shakeAmplitude_;
     108            float shakeDeltaTime_;
     109
    105110        private:
    106111            void registerVariables();
Note: See TracChangeset for help on using the changeset viewer.