Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 18, 2011, 4:04:40 PM (13 years ago)
Author:
dboehi
Message:

Added possibibility to change the frequency of the shaking camera in the
space ship configuration file.

File:
1 edited

Legend:

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

    r8191 r8254  
    8383        this->cameraOriginalOrientation = c->getOrientation();
    8484
    85         this->shakeFrequency_ = 100;
     85        this->shakeFrequency_ = 20;
    8686        this->shakeAmplitude_ = 40;
    87         this->shakeDeltaTime_ = 0;
     87        this->shakeDt_ = 0;
    8888    }
    8989
     
    106106        XMLPortParamVariable(SpaceShip, "boostRate", boostRate_, xmlelement, mode);
    107107        XMLPortParamVariable(SpaceShip, "boostCooldownDuration", boostCooldownDuration_, xmlelement, mode);
     108        XMLPortParamVariable(SpaceShip, "shakeFrequency", shakeFrequency_, xmlelement, mode);
    108109    }
    109110
     
    161162            }
    162163
    163         Camera* c = CameraManager::getInstance().getActiveCamera();
     164
     165        Camera* c = this->getCamera();
    164166            if(this->bBoost_)
    165167            {
     
    174176                else
    175177                {
    176                         this->shakeDeltaTime_ += dt;
     178                        this->shakeDt_ += dt;
    177179
    178180                        //Shaking Camera effect
     
    183185                                {
    184186                                        c->setAngularVelocity(Vector3(2,0,0));
    185                                         this->shakeDeltaTime_ = 0;
     187
     188                                        //set the delta to half the period time,
     189                                        //so the camera shakes up and down.
     190                                        this->shakeDt_ = 1/(2 * this->shakeFrequency_);
    186191                                }
    187192
    188193
    189194                                //toggle the rotation
    190                                 if (1/(this->shakeFrequency_) <= shakeDeltaTime_)
     195                                if (1/(this->shakeFrequency_) <= shakeDt_)
    191196                                {
    192197                                        c->setAngularVelocity(-c->getAngularVelocity());
    193                                         shakeDeltaTime_ = 0;
     198                                        shakeDt_ = 0;
    194199                                }
    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                                 */
    203200                        }
    204201                }
     
    208205                    //reset the camera, if the boost is not active
    209206                    //TODO: don't call this every tick
    210                     c->setAngularVelocity(Vector3(0,0,0));
    211                     c->setPosition(this->cameraOriginalPosition);
    212                     c->setOrientation(this->cameraOriginalOrientation);
     207                    this->resetCamera();
    213208            }
    214209        }
     
    325320        return list;
    326321    }
     322   
     323    void SpaceShip::resetCamera()
     324    {
     325            Camera *c = this->getCamera();
     326           
     327            assert(c != 0);
     328           
     329            c->setAngularVelocity(Vector3(0,0,0));
     330            c->setPosition(this->cameraOriginalPosition);
     331            c->setOrientation(this->cameraOriginalOrientation);
     332    }
    327333}
Note: See TracChangeset for help on using the changeset viewer.