Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc @ 6312

Last change on this file since 6312 was 6312, checked in by wirthmi, 16 years ago

Fixes for damage overlay

  • Property svn:eol-style set to native
File size: 23.1 KB
RevLine 
[5979]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
[5981]23 *      Michael Wirth
[5979]24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "NewHumanController.h"
30
[6256]31#include <cmath>
[6033]32#include <OgreRay.h>
33#include <OgreSceneQuery.h>
34#include <OgreCamera.h>
35#include <OgreSceneManager.h>
[5981]36
[5979]37#include "core/CoreIncludes.h"
38#include "core/ConsoleCommand.h"
39#include "worldentities/ControllableEntity.h"
[6111]40#include "worldentities/pawns/Pawn.h"
[5979]41#include "infos/PlayerInfo.h"
[6055]42#include "overlays/OrxonoxOverlay.h"
[5979]43#include "graphics/Camera.h"
44#include "sound/SoundManager.h"
45#include "Scene.h"
[6295]46#include "tools/BulletConversions.h"
47#include "bullet/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h"
[5979]48
49namespace orxonox
50{
[6091]51    SetConsoleCommand(NewHumanController, changeMode,          false).keybindMode(KeybindMode::OnPress);
[6149]52    SetConsoleCommand(NewHumanController, accelerate,          false).keybindMode(KeybindMode::OnPress);
53    SetConsoleCommand(NewHumanController, decelerate,          false).keybindMode(KeybindMode::OnPress);
[6210]54    SetConsoleCommand(NewHumanController, unfire,              true).keybindMode(KeybindMode::OnRelease);
[6091]55
[5979]56    CreateUnloadableFactory(NewHumanController);
57
[6091]58    NewHumanController* NewHumanController::localController_s = 0;
59
[6122]60    NewHumanController::NewHumanController(BaseObject* creator)
61        : HumanController(creator)
62        , crossHairOverlay_(NULL)
[6195]63        , centerOverlay_(NULL)
[5979]64    {
65        RegisterObject(NewHumanController);
[6001]66
[6055]67        overlaySize_ = 0.08;
[6210]68        arrowsSize_ = 0.4;
[6310]69
70        damageOverlayTime_ = 0.6;
71
[6055]72        controlMode_ = 0;
[6149]73        acceleration_ = 0;
[6236]74        accelerating_ = false;
[6210]75        firemode_ = -1;
[6310]76
[6210]77        showArrows_ = true;
[6236]78        showOverlays_ = false;
[6310]79        showDamageOverlay_ = true;
[6033]80
[6149]81        //currentPitch_ = 1;
82        //currentYaw_ = 1;
83
[6122]84        if (GameMode::showsGraphics())
85        {
86            crossHairOverlay_ = new OrxonoxOverlay(this);
87            crossHairOverlay_->setBackgroundMaterial("Orxonox/Crosshair3");
88            crossHairOverlay_->setSize(Vector2(overlaySize_, overlaySize_));
[6195]89            crossHairOverlay_->hide();
[6210]90            //crossHairOverlay_->setAspectCorrection(true); not working
[6195]91
92            centerOverlay_ = new OrxonoxOverlay(this);
93            centerOverlay_->setBackgroundMaterial("Orxonox/CenterOverlay");
94            centerOverlay_->setSize(Vector2(overlaySize_ * 2.5, overlaySize_ * 2.5));
95            centerOverlay_->setPosition(Vector2(0.5 - overlaySize_*2.5/2.0, 0.5 - overlaySize_*2.5/2.0));\
96            centerOverlay_->hide();
[6210]97
[6310]98            if ( showDamageOverlay_ )
[6210]99            {
[6310]100                damageOverlayTop_ = new OrxonoxOverlay(this);
101                damageOverlayTop_->setBackgroundMaterial("Orxonox/DamageOverlayTop");
102                damageOverlayTop_->setSize(Vector2(overlaySize_ * 2.5, overlaySize_ * 2.5));
103                damageOverlayTop_->setPosition(Vector2(0.5 - overlaySize_*2.5/2.0, 0.5 - overlaySize_*2.5/2.0));\
104                damageOverlayTop_->hide();
105
106                damageOverlayRight_ = new OrxonoxOverlay(this);
107                damageOverlayRight_->setBackgroundMaterial("Orxonox/DamageOverlayRight");
108                damageOverlayRight_->setSize(Vector2(overlaySize_ * 2.5, overlaySize_ * 2.5));
109                damageOverlayRight_->setPosition(Vector2(0.5 - overlaySize_*2.5/2.0, 0.5 - overlaySize_*2.5/2.0));\
110                damageOverlayRight_->hide();
111
112                damageOverlayBottom_ = new OrxonoxOverlay(this);
113                damageOverlayBottom_->setBackgroundMaterial("Orxonox/DamageOverlayBottom");
114                damageOverlayBottom_->setSize(Vector2(overlaySize_ * 2.5, overlaySize_ * 2.5));
115                damageOverlayBottom_->setPosition(Vector2(0.5 - overlaySize_*2.5/2.0, 0.5 - overlaySize_*2.5/2.0));\
116                damageOverlayBottom_->hide();
117
118                damageOverlayLeft_ = new OrxonoxOverlay(this);
119                damageOverlayLeft_->setBackgroundMaterial("Orxonox/DamageOverlayLeft");
120                damageOverlayLeft_->setSize(Vector2(overlaySize_ * 2.5, overlaySize_ * 2.5));
121                damageOverlayLeft_->setPosition(Vector2(0.5 - overlaySize_*2.5/2.0, 0.5 - overlaySize_*2.5/2.0));\
122                damageOverlayLeft_->hide();
123            }
124
125            if ( showArrows_ )
126            {
[6210]127                arrowsOverlay1_ = new OrxonoxOverlay(this);
[6289]128                arrowsOverlay1_->setBackgroundMaterial("Orxonox/DirectionArrows1");
[6210]129                arrowsOverlay1_->setSize(Vector2(0.02727, 0.36 * arrowsSize_));
130                arrowsOverlay1_->setPickPoint(Vector2(0.5, 0.5));
131                arrowsOverlay1_->setPosition(Vector2(0.5, 0.5));
132                arrowsOverlay1_->hide();
133   
134                arrowsOverlay2_ = new OrxonoxOverlay(this);
[6289]135                arrowsOverlay2_->setBackgroundMaterial("Orxonox/DirectionArrows2");
[6210]136                arrowsOverlay2_->setSize(Vector2(0.02727, 0.59 * arrowsSize_));
137                arrowsOverlay2_->setPickPoint(Vector2(0.5, 0.5));
138                arrowsOverlay2_->setPosition(Vector2(0.5, 0.5));
139                arrowsOverlay2_->hide();
140   
141                arrowsOverlay3_ = new OrxonoxOverlay(this);
[6289]142                arrowsOverlay3_->setBackgroundMaterial("Orxonox/DirectionArrows3");
[6210]143                arrowsOverlay3_->setSize(Vector2(0.02727, 0.77 * arrowsSize_));
144                arrowsOverlay3_->setPickPoint(Vector2(0.5, 0.5));
145                arrowsOverlay3_->setPosition(Vector2(0.5, 0.5));
146                arrowsOverlay3_->hide();
147   
148                arrowsOverlay4_ = new OrxonoxOverlay(this);
[6289]149                arrowsOverlay4_->setBackgroundMaterial("Orxonox/DirectionArrows4");
[6210]150                arrowsOverlay4_->setSize(Vector2(0.02727, arrowsSize_));
151                arrowsOverlay4_->setPickPoint(Vector2(0.5, 0.5));
152                arrowsOverlay4_->setPosition(Vector2(0.5, 0.5));
153                arrowsOverlay4_->hide();
154            }
[6122]155        }
[6045]156
[6058]157        // HACK: Define which objects are targetable when considering the creator of an orxonox::Model
[6055]158        this->targetMask_.exclude(ClassByString("BaseObject"));
159        this->targetMask_.include(ClassByString("WorldEntity"));
160        this->targetMask_.exclude(ClassByString("Projectile"));
[6091]161
162        NewHumanController::localController_s = this;
[6195]163
[6236]164        controlPaused_ = false;
[6210]165
[6195]166//HumanController::localController_s->getControllableEntity()->getCamera()->setDrag(true);
[5979]167    }
168
169    NewHumanController::~NewHumanController()
170    {
[6055]171        if (this->isInitialized())
[5981]172        {
[6122]173            if (this->crossHairOverlay_)
174                this->crossHairOverlay_->destroy();
[6210]175            if (this->centerOverlay_)
176                this->centerOverlay_->destroy();
177
178            if (showArrows_)
179            {
180                if (this->arrowsOverlay1_)
181                    this->arrowsOverlay1_->destroy();
182                if (this->arrowsOverlay2_)
183                    this->arrowsOverlay2_->destroy();
184                if (this->arrowsOverlay3_)
185                    this->arrowsOverlay3_->destroy();
186                if (this->arrowsOverlay4_)
187                    this->arrowsOverlay4_->destroy();
188            }
[5981]189        }
[5979]190    }
191
[6055]192    void NewHumanController::tick(float dt)
193    {
[6122]194        if (GameMode::showsGraphics())
[6111]195        {
[6210]196
[6122]197            if( this->controllableEntity_ && !this->controllableEntity_->isInMouseLook() )
198            {
[6157]199                this->updateTarget();
[6289]200
[6195]201                if ( !controlPaused_ ) {
[6310]202                    if (this->getControllableEntity() && (this->getControllableEntity()->getIdentifier()->getName() == "SpaceShip" || this->getControllableEntity()->getIdentifier()->getName() == "Rocket"))
[6289]203                        this->showOverlays();
204
[6195]205                    this->crossHairOverlay_->setPosition(Vector2(static_cast<float>(this->currentYaw_)/2*-1+.5-overlaySize_/2, static_cast<float>(this->currentPitch_)/2*-1+.5-overlaySize_/2));
[6210]206
207                    if ( this->controlMode_ == 0 || ( this->controlMode_ == 1 && this->firemode_ == 1 ) )
[6236]208                    {
[6289]209                        if ( this->showOverlays_ && this->showArrows_)
[6236]210                            alignArrows();
211                    }
[6210]212                    else
213                        hideArrows();
[6310]214
215                    if ( this->showDamageOverlay_ && ( this->damageOverlayTT_ > 0 || this->damageOverlayTR_ > 0 || this->damageOverlayTB_ > 0 || this->damageOverlayTL_ > 0 ) ) {
216                        this->damageOverlayTT_ -= dt;
217                        this->damageOverlayTR_ -= dt;
218                        this->damageOverlayTB_ -= dt;
219                        this->damageOverlayTL_ -= dt;
220                        if ( this->damageOverlayTT_ <= 0 )
221                            this->damageOverlayTop_->hide();
222                        if ( this->damageOverlayTR_ <= 0 )
223                            this->damageOverlayRight_->hide();
224                        if ( this->damageOverlayTB_ <= 0 )
225                            this->damageOverlayBottom_->hide();
226                        if ( this->damageOverlayTL_ <= 0 )
227                            this->damageOverlayLeft_->hide();
228                    }
[6195]229                }
[6122]230            }
[6279]231            else
232                this->hideOverlays();
[6210]233
[6149]234            if ( this->acceleration_ > 0 )
[6173]235            {
236/*
237if (this->controllableEntity_ && this->controllableEntity_->getEngine()) {
238    std::cout << this->controllableEntity_->getEngine()->getAccelerationFront() << endl;
239}
240*/
241                if ( this->accelerating_ )
242                    HumanController::moveFrontBack(Vector2(1, 0));
243                else
244                    HumanController::moveFrontBack(Vector2(this->acceleration_, 0)); 
245                this->accelerating_ = false;
246                //HumanController::moveFrontBack(Vector2(clamp(this->acceleration_ + this->currentAcceleration_, 0.0f, 1.0f), 0));
247            }
[6111]248        }
[6001]249
250        HumanController::tick(dt);
251    }
252
[5993]253    /*void NewHumanController::tick(float dt)
[5979]254    {
255        if (GameMode::playsSound() && NewHumanController::localController_s && NewHumanController::localController_s->controllableEntity_)
256        {
257            // Update sound listener
258            Camera* camera = NewHumanController::localController_s->controllableEntity_->getCamera();
259            if (camera)
260            {
261                SoundManager::getInstance().setListenerPosition(camera->getWorldPosition());
262                SoundManager::getInstance().setListenerOrientation(camera->getWorldOrientation());
263            }
264            else
265                COUT(3) << "NewHumanController, Warning: Using a ControllableEntity without Camera" << std::endl;
266        }
[5993]267    }*/
268   
[6033]269    void NewHumanController::doFire(unsigned int firemode)
270    {
271        //if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) {
272
273/*
[6055]274        // Get results, create a node/entity on the position
275        for ( itr = result.begin(); itr != result.end(); itr++ )
276        {
277            if (itr->movable && itr->movable->getName() == "Head")
278            {
279                soundMgr->StopSound( &jaguarSoundChannel );
280                soundMgr->PlaySound( jaguarSound, headNode, &jaguarSoundChannel );
281                break;
282            } // if
283        }
[6033]284*/
285
[6210]286        this->firemode_ = firemode;
287
[6157]288        if (firemode == 1 && this->controlMode_ == 1)
289        {
[6143]290            //unlocked steering, steer on right mouse click
[6144]291            HumanController::yaw(Vector2(this->currentYaw_, 0));
292            HumanController::pitch(Vector2(this->currentPitch_, 0));
[6143]293        }
[6157]294        else
[6143]295            HumanController::localController_s->getControllableEntity()->fire(firemode);
296
[6045]297    }
298
[6295]299    void NewHumanController::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage) {
[6312]300        if ( this->showDamageOverlay_ && !this->controlPaused_ && this->controllableEntity_ && !this->controllableEntity_->isInMouseLook() ) {
[6310]301            Vector3 posA;
302            if ( originator )
303                posA = originator->getWorldPosition();
304            else
305                posA = multi_cast<Vector3>(contactpoint.getPositionWorldOnA());
306            //Vector3 posB = multi_cast<Vector3>(contactpoint.getPositionWorldOnB());
307            //posA and posB are almost identical
[6295]308
[6310]309            Vector3 relativeHit = this->getControllableEntity()->getWorldOrientation().UnitInverse() * (this->getControllableEntity()->getWorldPosition() - posA);
[6295]310
[6310]311            //back is z positive
312            //x is left positive
313            //y is down positive
314            relativeHit.normalise();
315            COUT(0) << relativeHit << endl;
316
317            float threshold = 0.3;
318            // && abs(relativeHit.y) < 0.5
319            if ( relativeHit.x > threshold) // Left
320            {
321                this->damageOverlayLeft_->show();
322                this->damageOverlayTL_ = this->damageOverlayTime_;
323                //this->damageOverlayLeft_->setBackgroundAlpha(0.3);
324            }
325            if ( relativeHit.x < -threshold) //Right
326            {
327                this->damageOverlayRight_->show();
328                this->damageOverlayTR_ = this->damageOverlayTime_;
329                //this->damageOverlayRight_->setBackgroundAlpha(0.3);
330            }
331            if ( relativeHit.y > threshold) //Top
332            {
[6312]333                this->damageOverlayBottom_->show();
334                this->damageOverlayTB_ = this->damageOverlayTime_;
[6310]335                //this->damageOverlayTop_->setBackgroundAlpha(0.3);
336            }
337            if ( relativeHit.y < -threshold) //Bottom
338            {
[6312]339                this->damageOverlayTop_->show();
340                this->damageOverlayTT_ = this->damageOverlayTime_;
[6310]341                //this->damageOverlayBottom_->setBackgroundAlpha(0.3);
342            }
343
344        }
[6295]345    }
346
[6210]347    void NewHumanController::unfire()
348    {
349        if (NewHumanController::localController_s)
350            NewHumanController::localController_s->doUnfire();
351    }
352
353    void NewHumanController::doUnfire()
354    {
355        this->firemode_ = -1;
356        hideArrows();
357    }
358
[6111]359    void NewHumanController::updateTarget()
[6055]360    {
361        Ogre::RaySceneQuery * rsq = HumanController::localController_s->getControllableEntity()->getScene()->getSceneManager()->createRayQuery(Ogre::Ray());
[6033]362
[6058]363        Ogre::Ray mouseRay = HumanController::localController_s->getControllableEntity()->getCamera()->getOgreCamera()->getCameraToViewportRay(static_cast<float>(this->currentYaw_)/2*-1+.5, static_cast<float>(this->currentPitch_)/2*-1+.5);
[6033]364
[6055]365        rsq->setRay(mouseRay);
366        rsq->setSortByDistance(true);
[6033]367
[6055]368        /*
369        Distance of objects:
370        ignore everything under 200 maybe even take 1000 as min distance to shoot at
[6033]371
[6055]372        shots are regularly traced and are entities!!!!!!!!! this is the biggest problem
373        they vanish only after a distance of 10'000
374        */
[6045]375
376
[6055]377        Ogre::RaySceneQueryResult& result = rsq->execute();
[6111]378        Pawn* pawn = orxonox_cast<Pawn*>(this->getControllableEntity());
[6033]379
[6055]380        Ogre::RaySceneQueryResult::iterator itr;
381        for (itr = result.begin(); itr != result.end(); ++itr)
382        {
383            if (itr->movable->isInScene() && itr->movable->getMovableType() == "Entity" && itr->distance > 500)
[6045]384            {
[6055]385                // Try to cast the user pointer
386                WorldEntity* wePtr = dynamic_cast<WorldEntity*>(itr->movable->getUserObject());
387                if (wePtr)
388                {
[6114]389                    // go through all parents of object and look wheter they are Sightable or not
390                    bool isSightable = false;
391                    WorldEntity* parent = wePtr->getParent();
392                    while( parent )
393                    {
394                        if (this->targetMask_.isExcluded(parent->getIdentifier()))
395                        {
396                            parent = parent->getParent();
397                            continue;
398                        }
399                        else
400                        {
401                            isSightable = true;
402                            break;
403                        }
404                    }
405                    if ( !isSightable )
[6055]406                        continue;
[6045]407                }
[6143]408
409                if ( this->getControllableEntity() && this->getControllableEntity()->getTarget() != wePtr )
410                {
[6116]411                    this->getControllableEntity()->setTarget(wePtr);
[6143]412                }
[6091]413
[6143]414                if( pawn )
415                {
416                    pawn->setAimPosition( mouseRay.getOrigin() + mouseRay.getDirection() * itr->distance );
417                }
418
[6195]419                //itr->movable->getParentSceneNode()->showBoundingBox(true);
[6091]420                //std::cout << itr->movable->getParentSceneNode()->_getDerivedPosition() << endl;
[6111]421                //return mouseRay.getOrigin() + mouseRay.getDirection() * itr->distance; //or itr->movable->getParentSceneNode()->_getDerivedPosition()
422                return;
[6045]423            }
[6091]424
[6055]425        }
[6111]426        if ( pawn )
427        {
428            pawn->setAimPosition( mouseRay.getOrigin() + mouseRay.getDirection() * 1200 );
429        }
[6143]430
431        if( this->getControllableEntity() && this->getControllableEntity()->getTarget() != 0 )
432            this->getControllableEntity()->setTarget( 0 );
[6111]433   
[6033]434
[6091]435        //return this->controllableEntity_->getWorldPosition() + (this->controllableEntity_->getWorldOrientation() * Vector3::NEGATIVE_UNIT_Z * 2000);
[6058]436        //return this->controllableEntity_->getWorldPosition() + (this->controllableEntity_->getCamera()->getOgreCamera()->getOrientation() * Vector3::NEGATIVE_UNIT_Z);
[6033]437    }
438
[6149]439    void NewHumanController::frontback(const Vector2& value)
440    {
[6173]441        this->accelerating_ = true;
[6149]442
[6173]443        //if (this->acceleration_ == 0)
[6149]444            HumanController::frontback(value);
445    }
446
[5993]447    void NewHumanController::yaw(const Vector2& value)
448    {
449//         SUPER(NewHumanController, yaw, value);
[6210]450        if (this->controlMode_ == 0 || ( this->controllableEntity_ && this->controllableEntity_->isInMouseLook() ) )
[6091]451            HumanController::yaw(value);
[6143]452
[5993]453        this->currentYaw_ = value.x;
[5979]454    }
[6055]455
[5993]456    void NewHumanController::pitch(const Vector2& value)
[5981]457    {
[5993]458//         SUPER(NewHumanController, pitch, value);
[6210]459        if (this->controlMode_ == 0 || ( this->controllableEntity_ && this->controllableEntity_->isInMouseLook() ) )
[6091]460            HumanController::pitch(value);
461
[5993]462        this->currentPitch_ = value.x;
[5981]463    }
[6091]464
[6149]465    void NewHumanController::changeMode()
466    {
[6111]467        if (NewHumanController::localController_s && NewHumanController::localController_s->controlMode_ == 0)
468        {
469                NewHumanController::localController_s->controlMode_ = 1;
[6210]470                NewHumanController::localController_s->hideArrows();
[6111]471        }
[6091]472        else
473            NewHumanController::localController_s->controlMode_ = 0;
474    }
[6143]475
[6115]476    void NewHumanController::changedControllableEntity()
477    {
478        this->controlMode_ = 0;
479        this->currentYaw_ = 0;
480        this->currentPitch_ = 0;
[6236]481        if (this->getControllableEntity() && this->getControllableEntity()->getIdentifier()->getName() == "SpaceShip")
482        {
483            this->showOverlays_ = true;
484            if( !this->controlPaused_ )
485            {
486                this->showOverlays();
487                this->alignArrows();
488            }
489        }
490        else
491        {
492            this->showOverlays_ = false;
493            this->hideOverlays();
494        }
[6115]495    }
[6149]496
497    void NewHumanController::accelerate()
498    {
[6157]499        if ( NewHumanController::localController_s )
500        {
[6173]501            NewHumanController::localController_s->acceleration_ = clamp(NewHumanController::localController_s->acceleration_ + 0.2f, 0.00f, 1.0f);
[6149]502        }
503    }
504
505    void NewHumanController::decelerate()
506    {
[6157]507        if ( NewHumanController::localController_s )
508        {
[6173]509            NewHumanController::localController_s->acceleration_ = clamp(NewHumanController::localController_s->acceleration_ - 0.1f, 0.0f, 1.0f);
[6149]510        }
511    }
[6195]512
513    void NewHumanController::doResumeControl() {
514        this->controlPaused_ = false;
[6236]515        if( this->showOverlays_ ) {
516            this->showOverlays();
517        }
[6195]518    }
519
520    void NewHumanController::doPauseControl() {
521        this->controlPaused_ = true;
[6289]522
[6236]523        this->hideOverlays();
[6195]524    }
[6210]525
526    void NewHumanController::alignArrows() {
527        if (showArrows_) {
528            hideArrows();
529   
530            float distance = sqrt(pow(static_cast<float>(this->currentYaw_)/2*-1,2) + pow(static_cast<float>(this->currentPitch_)/2*-1,2));
531   
532            if ( distance > 0.04 && distance <= 0.59 * arrowsSize_ / 2.0 ) {
533                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));
534   
535                this->arrowsOverlay1_->show();
536            }
537            else if ( distance > 0.59 * arrowsSize_ / 2.0 && distance <= 0.77 * arrowsSize_ / 2.0 ) {
538                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));
539   
540                this->arrowsOverlay2_->show();
541            }
542            else if ( distance > 0.77 * arrowsSize_ / 2.0 && distance <= arrowsSize_ / 2.0 ) {
543                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));
544   
545                this->arrowsOverlay3_->show();
546            }
547            else if ( distance > arrowsSize_ / 2.0 ) {
548                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));
549   
550                this->arrowsOverlay4_->show();
551            }
552        }
553    }
554
[6236]555    void NewHumanController::showOverlays() {
556        this->crossHairOverlay_->show();
557        this->centerOverlay_->show();
[6289]558
[6236]559        if (showArrows_) {
560            this->arrowsOverlay1_->show();
561            this->arrowsOverlay2_->show();
562            this->arrowsOverlay3_->show();
563            this->arrowsOverlay4_->show();
564        }
565    }
566
567    void NewHumanController::hideOverlays() {
568        this->crossHairOverlay_->hide();
569        this->centerOverlay_->hide();
[6289]570
[6310]571        if ( showDamageOverlay_ ) {
572            this->damageOverlayTop_->hide();
573            this->damageOverlayRight_->hide();
574            this->damageOverlayBottom_->hide();
575            this->damageOverlayLeft_->hide();
576        }
577
[6236]578        this->hideArrows();
579    }
580
[6210]581    void NewHumanController::hideArrows() {
582        if (showArrows_) {
583            this->arrowsOverlay1_->hide();
584            this->arrowsOverlay2_->hide();
585            this->arrowsOverlay3_->hide();
586            this->arrowsOverlay4_->hide();
587        }
588    }
[5979]589}
Note: See TracBrowser for help on using the repository browser.