Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6210


Ignore:
Timestamp:
Dec 2, 2009, 6:46:20 PM (14 years ago)
Author:
wirthmi
Message:

Buggy version!

Location:
code/branches/presentation2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/data/defaultConfig/keybindings.ini

    r6201 r6210  
    154154Left="fire 0"
    155155Middle=
    156 Right="fire 1"
     156Right= fire 1 | unfire
    157157Wheel1Down="NewHumanController decelerate"
    158158Wheel1Up="NewHumanController accelerate"
  • code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc

    r6195 r6210  
    4444#include "Scene.h"
    4545
     46#include <cmath>
     47
     48
    4649namespace orxonox
    4750{
     
    4952    SetConsoleCommand(NewHumanController, accelerate,          false).keybindMode(KeybindMode::OnPress);
    5053    SetConsoleCommand(NewHumanController, decelerate,          false).keybindMode(KeybindMode::OnPress);
     54    SetConsoleCommand(NewHumanController, unfire,              true).keybindMode(KeybindMode::OnRelease);
    5155
    5256    CreateUnloadableFactory(NewHumanController);
     
    6266
    6367        overlaySize_ = 0.08;
     68        arrowsSize_ = 0.4;
    6469        controlMode_ = 0;
    6570        acceleration_ = 0;
     71        firemode_ = -1;
     72        showArrows_ = true;
    6673
    6774        //currentPitch_ = 1;
     
    7481            crossHairOverlay_->setSize(Vector2(overlaySize_, overlaySize_));
    7582            crossHairOverlay_->hide();
     83            //crossHairOverlay_->setAspectCorrection(true); not working
    7684
    7785            centerOverlay_ = new OrxonoxOverlay(this);
     
    8088            centerOverlay_->setPosition(Vector2(0.5 - overlaySize_*2.5/2.0, 0.5 - overlaySize_*2.5/2.0));\
    8189            centerOverlay_->hide();
     90
     91            if (showArrows_)
     92            {
     93                arrowsOverlay1_ = new OrxonoxOverlay(this);
     94                arrowsOverlay1_->setBackgroundMaterial("Orxonox/DirectionArrows1");
     95                arrowsOverlay1_->setSize(Vector2(0.02727, 0.36 * arrowsSize_));
     96                arrowsOverlay1_->setPickPoint(Vector2(0.5, 0.5));
     97                arrowsOverlay1_->setPosition(Vector2(0.5, 0.5));
     98                arrowsOverlay1_->hide();
     99   
     100                arrowsOverlay2_ = new OrxonoxOverlay(this);
     101                arrowsOverlay2_->setBackgroundMaterial("Orxonox/DirectionArrows2");
     102                arrowsOverlay2_->setSize(Vector2(0.02727, 0.59 * arrowsSize_));
     103                arrowsOverlay2_->setPickPoint(Vector2(0.5, 0.5));
     104                arrowsOverlay2_->setPosition(Vector2(0.5, 0.5));
     105                arrowsOverlay2_->hide();
     106   
     107                arrowsOverlay3_ = new OrxonoxOverlay(this);
     108                arrowsOverlay3_->setBackgroundMaterial("Orxonox/DirectionArrows3");
     109                arrowsOverlay3_->setSize(Vector2(0.02727, 0.77 * arrowsSize_));
     110                arrowsOverlay3_->setPickPoint(Vector2(0.5, 0.5));
     111                arrowsOverlay3_->setPosition(Vector2(0.5, 0.5));
     112                arrowsOverlay3_->hide();
     113   
     114                arrowsOverlay4_ = new OrxonoxOverlay(this);
     115                arrowsOverlay4_->setBackgroundMaterial("Orxonox/DirectionArrows4");
     116                arrowsOverlay4_->setSize(Vector2(0.02727, arrowsSize_));
     117                arrowsOverlay4_->setPickPoint(Vector2(0.5, 0.5));
     118                arrowsOverlay4_->setPosition(Vector2(0.5, 0.5));
     119                arrowsOverlay4_->hide();
     120            }
    82121        }
    83122
     
    89128        NewHumanController::localController_s = this;
    90129
     130        controlPaused_ = true;
     131
    91132//HumanController::localController_s->getControllableEntity()->getCamera()->setDrag(true);
    92133    }
     
    98139            if (this->crossHairOverlay_)
    99140                this->crossHairOverlay_->destroy();
     141            if (this->centerOverlay_)
     142                this->centerOverlay_->destroy();
     143
     144            if (showArrows_)
     145            {
     146                if (this->arrowsOverlay1_)
     147                    this->arrowsOverlay1_->destroy();
     148                if (this->arrowsOverlay2_)
     149                    this->arrowsOverlay2_->destroy();
     150                if (this->arrowsOverlay3_)
     151                    this->arrowsOverlay3_->destroy();
     152                if (this->arrowsOverlay4_)
     153                    this->arrowsOverlay4_->destroy();
     154            }
    100155        }
    101156    }
     
    105160        if (GameMode::showsGraphics())
    106161        {
     162
    107163            if( this->controllableEntity_ && !this->controllableEntity_->isInMouseLook() )
    108164            {
     
    110166                if ( !controlPaused_ ) {
    111167                    this->crossHairOverlay_->setPosition(Vector2(static_cast<float>(this->currentYaw_)/2*-1+.5-overlaySize_/2, static_cast<float>(this->currentPitch_)/2*-1+.5-overlaySize_/2));
     168
     169                    if ( this->controlMode_ == 0 || ( this->controlMode_ == 1 && this->firemode_ == 1 ) )
     170                        alignArrows();
     171                    else
     172                        hideArrows();
     173
    112174                    this->crossHairOverlay_->show();
    113175                    this->centerOverlay_->show();
     
    117179                this->crossHairOverlay_->hide();
    118180                this->centerOverlay_->hide();
     181
     182                hideArrows();
    119183            }
    120184
     
    171235*/
    172236
     237        this->firemode_ = firemode;
     238
    173239        if (firemode == 1 && this->controlMode_ == 1)
    174240        {
     
    180246            HumanController::localController_s->getControllableEntity()->fire(firemode);
    181247
     248    }
     249
     250    void NewHumanController::unfire()
     251    {
     252        if (NewHumanController::localController_s)
     253            NewHumanController::localController_s->doUnfire();
     254    }
     255
     256    void NewHumanController::doUnfire()
     257    {
     258        COUT(0) << "dounfire" << endl;
     259        this->firemode_ = -1;
     260        hideArrows();
    182261    }
    183262
     
    273352    {
    274353//         SUPER(NewHumanController, yaw, value);
    275         if (this->controlMode_ == 0)
     354        if (this->controlMode_ == 0 || ( this->controllableEntity_ && this->controllableEntity_->isInMouseLook() ) )
    276355            HumanController::yaw(value);
    277356
     
    282361    {
    283362//         SUPER(NewHumanController, pitch, value);
    284         if (this->controlMode_ == 0)
     363        if (this->controlMode_ == 0 || ( this->controllableEntity_ && this->controllableEntity_->isInMouseLook() ) )
    285364            HumanController::pitch(value);
    286365
     
    292371        if (NewHumanController::localController_s && NewHumanController::localController_s->controlMode_ == 0)
    293372        {
    294             if (NewHumanController::localController_s->controllableEntity_ && !NewHumanController::localController_s->controllableEntity_->isInMouseLook() )
    295373                NewHumanController::localController_s->controlMode_ = 1;
     374                NewHumanController::localController_s->hideArrows();
    296375        }
    297376        else
     
    304383        this->currentYaw_ = 0;
    305384        this->currentPitch_ = 0;
     385        if (this->getControllableEntity() && this->getControllableEntity()->getIdentifier()->getName() == "SpaceShip") {
     386            this->doResumeControl();
     387        }
    306388    }
    307389
     
    330412    void NewHumanController::doPauseControl() {
    331413        this->controlPaused_ = true;
     414
    332415        this->crossHairOverlay_->hide();
    333416        this->centerOverlay_->hide();
     417
     418        hideArrows();
     419    }
     420
     421    void NewHumanController::alignArrows() {
     422        if (showArrows_) {
     423            hideArrows();
     424   
     425            float distance = sqrt(pow(static_cast<float>(this->currentYaw_)/2*-1,2) + pow(static_cast<float>(this->currentPitch_)/2*-1,2));
     426   
     427            if ( distance > 0.04 && distance <= 0.59 * arrowsSize_ / 2.0 ) {
     428                this->arrowsOverlay1_->setRotation(Degree(-90 + -1.0 * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / (2.0f * Ogre::Math::PI) * 360.0f));
     429   
     430                this->arrowsOverlay1_->show();
     431            }
     432            else if ( distance > 0.59 * arrowsSize_ / 2.0 && distance <= 0.77 * arrowsSize_ / 2.0 ) {
     433                this->arrowsOverlay2_->setRotation(Degree(-90 + -1.0 * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / (2.0f * Ogre::Math::PI) * 360.0f));
     434   
     435                this->arrowsOverlay2_->show();
     436            }
     437            else if ( distance > 0.77 * arrowsSize_ / 2.0 && distance <= arrowsSize_ / 2.0 ) {
     438                this->arrowsOverlay3_->setRotation(Degree(-90 + -1.0 * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / (2.0f * Ogre::Math::PI) * 360.0f));
     439   
     440                this->arrowsOverlay3_->show();
     441            }
     442            else if ( distance > arrowsSize_ / 2.0 ) {
     443                this->arrowsOverlay4_->setRotation(Degree(-90 + -1.0 * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / (2.0f * Ogre::Math::PI) * 360.0f));
     444   
     445                this->arrowsOverlay4_->show();
     446            }
     447        }
     448    }
     449
     450    void NewHumanController::hideArrows() {
     451        if (showArrows_) {
     452            this->arrowsOverlay1_->hide();
     453            this->arrowsOverlay2_->hide();
     454            this->arrowsOverlay3_->hide();
     455            this->arrowsOverlay4_->hide();
     456        }
    334457    }
    335458}
  • code/branches/presentation2/src/orxonox/controllers/NewHumanController.h

    r6195 r6210  
    5656            virtual void doFire(unsigned int firemode);
    5757
     58            static void unfire();
     59            virtual void doUnfire();
     60
    5861            static void changeMode();
    5962
     
    6467        protected:
    6568            void updateTarget();
     69            void alignArrows();
     70            void hideArrows();
    6671
    6772            unsigned int                controlMode_;
     
    7277            OrxonoxOverlay*             crossHairOverlay_;
    7378            OrxonoxOverlay*             centerOverlay_;
     79            OrxonoxOverlay*             arrowsOverlay1_;
     80            OrxonoxOverlay*             arrowsOverlay2_;
     81            OrxonoxOverlay*             arrowsOverlay3_;
     82            OrxonoxOverlay*             arrowsOverlay4_;
    7483            float                       overlaySize_;
     84            float                       arrowsSize_;
    7585            bool                        accelerating_;
    7686            float                       acceleration_;
     87            int                         firemode_;
     88            bool                        showArrows_;
    7789            ClassTreeMask               targetMask_;
    7890    };
Note: See TracChangeset for help on using the changeset viewer.