Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/sagerjFS16/src/orxonox/controllers/NewHumanController.cc @ 11164

Last change on this file since 11164 was 11164, checked in by sagerj, 8 years ago

added orxout() for every release lvl for debug purpose

  • Property svn:eol-style set to native
File size: 24.9 KB
Line 
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:
23 *      Michael Wirth
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "NewHumanController.h"
30
31#include <cmath>
32#include <OgreRay.h>
33#include <OgreSceneQuery.h>
34#include <OgreCamera.h>
35#include <OgreSceneManager.h>
36#include <bullet/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h>
37
38#include "core/CoreIncludes.h"
39#include "core/command/ConsoleCommandIncludes.h"
40#include "core/input/KeyBinder.h"
41#include "core/input/KeyBinderManager.h"
42#include "worldentities/ControllableEntity.h"
43#include "worldentities/pawns/Pawn.h"
44#include "infos/PlayerInfo.h"
45#include "overlays/OrxonoxOverlay.h"
46#include "graphics/Camera.h"
47#include "sound/SoundManager.h"
48#include "tools/BulletConversions.h"
49#include "Scene.h"
50
51namespace orxonox
52{
53    SetConsoleCommand("NewHumanController", "changeMode", &NewHumanController::changeMode).keybindMode(KeybindMode::OnPress);
54    SetConsoleCommand("NewHumanController", "accelerate", &NewHumanController::accelerate).keybindMode(KeybindMode::OnPress);
55    SetConsoleCommand("NewHumanController", "decelerate", &NewHumanController::decelerate).keybindMode(KeybindMode::OnPress);
56    //SetConsoleCommand("NewHumanController", "release",    &NewHumanController::release   ).keybindMode(KeybindMode::OnRelease).addShortcut();
57
58    RegisterUnloadableClass(NewHumanController);
59
60    NewHumanController* NewHumanController::localController_s = nullptr;
61
62    NewHumanController::NewHumanController(Context* context)
63        : HumanController(context)
64        , crossHairOverlay_(nullptr)
65        , centerOverlay_(nullptr)
66        , damageOverlayTop_(nullptr)
67        , damageOverlayRight_(nullptr)
68        , damageOverlayBottom_(nullptr)
69        , damageOverlayLeft_(nullptr)
70        , damageOverlayTT_(0)
71        , damageOverlayTR_(0)
72        , damageOverlayTB_(0)
73        , damageOverlayTL_(0)
74        , arrowsOverlay1_(nullptr)
75        , arrowsOverlay2_(nullptr)
76        , arrowsOverlay3_(nullptr)
77        , arrowsOverlay4_(nullptr)
78    {
79        RegisterObject(NewHumanController);
80
81        overlaySize_ = 0.08f;
82        arrowsSize_ = 0.4f;
83
84        damageOverlayTime_ = 0.6f;
85
86        controlMode_ = 0;
87        acceleration_ = 0;
88        accelerating_ = false;
89        firemode_ = -1;
90
91        showArrows_ = true;
92        showOverlays_ = false;
93        showDamageOverlay_ = true;
94
95        //currentPitch_ = 1;
96        //currentYaw_ = 1;
97
98        if (GameMode::showsGraphics())
99        {
100            crossHairOverlay_ = new OrxonoxOverlay(this->getContext());
101            crossHairOverlay_->setBackgroundMaterial("Orxonox/Crosshair3");
102            crossHairOverlay_->setSize(Vector2(overlaySize_, overlaySize_));
103            crossHairOverlay_->hide();
104            //crossHairOverlay_->setAspectCorrection(true); not working
105
106            centerOverlay_ = new OrxonoxOverlay(this->getContext());
107            centerOverlay_->setBackgroundMaterial("Orxonox/CenterOverlay");
108            centerOverlay_->setSize(Vector2(overlaySize_ * 2.5f, overlaySize_ * 2.5f));
109            centerOverlay_->setPosition(Vector2(0.5f - overlaySize_*2.5f/2.0f, 0.5f - overlaySize_*2.5f/2.0f));
110            centerOverlay_->hide();
111
112            if (showDamageOverlay_)
113            {
114                damageOverlayTop_ = new OrxonoxOverlay(this->getContext());
115                damageOverlayTop_->setBackgroundMaterial("Orxonox/DamageOverlayTop");
116                damageOverlayTop_->setSize(Vector2(overlaySize_ * 2.5f, overlaySize_ * 2.5f));
117                damageOverlayTop_->setPosition(Vector2(0.5f - overlaySize_*2.5f/2.0f, 0.5f - overlaySize_*2.5f/2.0f));
118                damageOverlayTop_->hide();
119
120                damageOverlayRight_ = new OrxonoxOverlay(this->getContext());
121                damageOverlayRight_->setBackgroundMaterial("Orxonox/DamageOverlayRight");
122                damageOverlayRight_->setSize(Vector2(overlaySize_ * 2.5f, overlaySize_ * 2.5f));
123                damageOverlayRight_->setPosition(Vector2(0.5f - overlaySize_*2.5f/2.0f, 0.5f - overlaySize_*2.5f/2.0f));
124                damageOverlayRight_->hide();
125
126                damageOverlayBottom_ = new OrxonoxOverlay(this->getContext());
127                damageOverlayBottom_->setBackgroundMaterial("Orxonox/DamageOverlayBottom");
128                damageOverlayBottom_->setSize(Vector2(overlaySize_ * 2.5f, overlaySize_ * 2.5f));
129                damageOverlayBottom_->setPosition(Vector2(0.5f - overlaySize_*2.5f/2.0f, 0.5f - overlaySize_*2.5f/2.0f));
130                damageOverlayBottom_->hide();
131
132                damageOverlayLeft_ = new OrxonoxOverlay(this->getContext());
133                damageOverlayLeft_->setBackgroundMaterial("Orxonox/DamageOverlayLeft");
134                damageOverlayLeft_->setSize(Vector2(overlaySize_ * 2.5f, overlaySize_ * 2.5f));
135                damageOverlayLeft_->setPosition(Vector2(0.5f - overlaySize_*2.5f/2.0f, 0.5f - overlaySize_*2.5f/2.0f));
136                damageOverlayLeft_->hide();
137            }
138
139            if (showArrows_)
140            {
141                arrowsOverlay1_ = new OrxonoxOverlay(this->getContext());
142                arrowsOverlay1_->setBackgroundMaterial("Orxonox/DirectionArrows1");
143                arrowsOverlay1_->setSize(Vector2(0.02727f, 0.36f * arrowsSize_));
144                arrowsOverlay1_->setPickPoint(Vector2(0.5f, 0.5f));
145                arrowsOverlay1_->setPosition(Vector2(0.5f, 0.5f));
146                arrowsOverlay1_->hide();
147
148                arrowsOverlay2_ = new OrxonoxOverlay(this->getContext());
149                arrowsOverlay2_->setBackgroundMaterial("Orxonox/DirectionArrows2");
150                arrowsOverlay2_->setSize(Vector2(0.02727f, 0.59f * arrowsSize_));
151                arrowsOverlay2_->setPickPoint(Vector2(0.5f, 0.5f));
152                arrowsOverlay2_->setPosition(Vector2(0.5f, 0.5f));
153                arrowsOverlay2_->hide();
154
155                arrowsOverlay3_ = new OrxonoxOverlay(this->getContext());
156                arrowsOverlay3_->setBackgroundMaterial("Orxonox/DirectionArrows3");
157                arrowsOverlay3_->setSize(Vector2(0.02727f, 0.77f * arrowsSize_));
158                arrowsOverlay3_->setPickPoint(Vector2(0.5f, 0.5f));
159                arrowsOverlay3_->setPosition(Vector2(0.5f, 0.5f));
160                arrowsOverlay3_->hide();
161
162                arrowsOverlay4_ = new OrxonoxOverlay(this->getContext());
163                arrowsOverlay4_->setBackgroundMaterial("Orxonox/DirectionArrows4");
164                arrowsOverlay4_->setSize(Vector2(0.02727f, arrowsSize_));
165                arrowsOverlay4_->setPickPoint(Vector2(0.5f, 0.5f));
166                arrowsOverlay4_->setPosition(Vector2(0.5f, 0.5f));
167                arrowsOverlay4_->hide();
168            }
169        }
170
171        // HACK: Define which objects are targetable when considering the creator of an orxonox::Model
172        this->targetMask_.exclude(ClassByString("BaseObject"));
173        this->targetMask_.include(ClassByString("WorldEntity"));
174        this->targetMask_.exclude(ClassByString("Projectile"));
175
176        NewHumanController::localController_s = this;
177
178        controlPaused_ = false;
179
180        //HumanController::localController_s->getControllableEntity()->getCamera()->setDrag(true);
181    }
182
183    NewHumanController::~NewHumanController()
184    {
185        if (this->isInitialized())
186        {
187            if (this->crossHairOverlay_)
188                this->crossHairOverlay_->destroy();
189            if (this->centerOverlay_)
190                this->centerOverlay_->destroy();
191
192            if (this->arrowsOverlay1_)
193                this->arrowsOverlay1_->destroy();
194            if (this->arrowsOverlay2_)
195                this->arrowsOverlay2_->destroy();
196            if (this->arrowsOverlay3_)
197                this->arrowsOverlay3_->destroy();
198            if (this->arrowsOverlay4_)
199                this->arrowsOverlay4_->destroy();
200            if (this->damageOverlayTop_)
201                this->damageOverlayTop_->destroy();
202            if (this->damageOverlayLeft_)
203                this->damageOverlayLeft_->destroy();
204            if (this->damageOverlayRight_)
205                this->damageOverlayRight_->destroy();
206            if (this->damageOverlayBottom_)
207                this->damageOverlayBottom_->destroy();
208        }
209    }
210
211    void NewHumanController::tick(float dt)
212    {
213        if (GameMode::showsGraphics())
214        {
215
216            if (this->controllableEntity_ && !this->controllableEntity_->isInMouseLook())
217            {
218                this->updateTarget();
219
220                if (!controlPaused_ )
221                {
222                    if (this->getControllableEntity() && ((this->getControllableEntity()->isExactlyA(ClassByString("SpaceShip")) || (this->getControllableEntity()->isExactlyA(ClassByString("ModularSpaceShip")))) || this->getControllableEntity()->isExactlyA(ClassByString("Rocket"))))
223                        this->showOverlays();
224                    else if (this->getControllableEntity() &&  this->getControllableEntity()->isExactlyA(ClassByString("FpsPlayer")))
225                    {
226                        this->showOverlays();
227                        this->hideArrows();
228                    }
229
230                    this->crossHairOverlay_->setPosition(Vector2(static_cast<float>(this->currentYaw_)/2*-1+.5f-overlaySize_/2, static_cast<float>(this->currentPitch_)/2*-1+.5f-overlaySize_/2));
231
232                    if (this->controlMode_ == 0 || (this->controlMode_ == 1 && this->firemode_ == 1))
233                    {
234                        if (this->showOverlays_ && this->showArrows_)
235                            alignArrows();
236                    }
237                    else
238                        hideArrows();
239
240                    if (this->showDamageOverlay_ && (this->damageOverlayTT_ > 0 || this->damageOverlayTR_ > 0 || this->damageOverlayTB_ > 0 || this->damageOverlayTL_ > 0))
241                    {
242                        this->damageOverlayTT_ -= dt;
243                        this->damageOverlayTR_ -= dt;
244                        this->damageOverlayTB_ -= dt;
245                        this->damageOverlayTL_ -= dt;
246                        if (this->damageOverlayTT_ <= 0)
247                            this->damageOverlayTop_->hide();
248                        if (this->damageOverlayTR_ <= 0)
249                            this->damageOverlayRight_->hide();
250                        if (this->damageOverlayTB_ <= 0)
251                            this->damageOverlayBottom_->hide();
252                        if (this->damageOverlayTL_ <= 0)
253                            this->damageOverlayLeft_->hide();
254                    }
255                }
256            }
257            else
258                this->hideOverlays();
259
260            if (this->acceleration_ > 0)
261            {
262                if (this->accelerating_)
263                    HumanController::moveFrontBack(Vector2(1, 0));
264                else
265                    HumanController::moveFrontBack(Vector2(this->acceleration_, 0));
266                this->accelerating_ = false;
267                //HumanController::moveFrontBack(Vector2(clamp(this->acceleration_ + this->currentAcceleration_, 0.0f, 1.0f), 0));
268            }
269        }
270
271        // Reset pitch and yaw rates
272        // TODO: Reactivate this to fix the game pad problem with 0 input
273        //this->currentPitch_ = 0;
274        //this->currentYaw_ = 0;
275
276        HumanController::tick(dt);
277    }
278
279    void NewHumanController::doFire(unsigned int firemode)
280    {
281        if (!this->controllableEntity_)
282            return;
283
284        this->firemode_ = firemode;
285
286        if (firemode == 1 && this->controlMode_ == 1)
287        {
288            //unlocked steering, steer on right mouse click
289            HumanController::yaw(Vector2(this->currentYaw_, 0));
290            HumanController::pitch(Vector2(this->currentPitch_, 0));
291        }
292        else
293            HumanController::doFire(firemode); //call for formationflight
294    }
295
296    /*void NewHumanController::release(unsigned int firemode)
297    {
298        if (NewHumanController::localController_s)
299            NewHumanController::localController_s->doRelease(firemode);
300        orxout() << "Trigger " << firemode << endl;
301    }
302
303    /void NewHumanController::doRelease(unsigned int firemode)
304    {
305        // this->firemode_ = -1; (outdated code from unfire)
306        // hideArrows();
307        if (!this->controllableEntity_)
308            return;
309
310        this->firemode_ = firemode;
311
312        HumanController::doRelease(firemode); //call for formationflight
313    }*/
314
315    void NewHumanController::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage)
316    {
317        //Used in HumanController for formationFlight
318        HumanController::hit(originator,contactpoint,damage);
319
320        if (this->showDamageOverlay_ && !this->controlPaused_ && this->controllableEntity_ && !this->controllableEntity_->isInMouseLook())
321        {
322            Vector3 posA;
323            if (originator)
324                posA = originator->getWorldPosition();
325            else
326                posA = multi_cast<Vector3>(contactpoint.getPositionWorldOnA());
327            //Vector3 posB = multi_cast<Vector3>(contactpoint.getPositionWorldOnB());
328            //posA and posB are almost identical
329
330            Vector3 relativeHit = this->getControllableEntity()->getWorldOrientation().UnitInverse() * (this->getControllableEntity()->getWorldPosition() - posA);
331
332            //back is z positive
333            //x is left positive
334            //y is down positive
335            relativeHit.normalise();
336
337            float threshold = 0.3f;
338            if (relativeHit.x > threshold) // Left
339            {
340                this->damageOverlayLeft_->show();
341                this->damageOverlayTL_ = this->damageOverlayTime_;
342                //this->damageOverlayLeft_->setBackgroundAlpha(0.3);
343            }
344            if (relativeHit.x < -threshold) //Right
345            {
346                this->damageOverlayRight_->show();
347                this->damageOverlayTR_ = this->damageOverlayTime_;
348                //this->damageOverlayRight_->setBackgroundAlpha(0.3);
349            }
350            if (relativeHit.y > threshold) //Top
351            {
352                this->damageOverlayBottom_->show();
353                this->damageOverlayTB_ = this->damageOverlayTime_;
354                //this->damageOverlayTop_->setBackgroundAlpha(0.3);
355            }
356            if (relativeHit.y < -threshold) //Bottom
357            {
358                this->damageOverlayTop_->show();
359                this->damageOverlayTT_ = this->damageOverlayTime_;
360                //this->damageOverlayBottom_->setBackgroundAlpha(0.3);
361            }
362        }
363    }
364
365    void NewHumanController::centerCursor()
366    {
367        this->currentYaw_ = 0;
368        this->currentPitch_ = 0;
369
370        if( KeyBinderManager::exists() )
371            KeyBinderManager::getInstance().getCurrent()->resetMouseAxes();
372    }
373
374    void NewHumanController::updateTarget()
375    {
376        Ogre::RaySceneQuery * rsq = HumanController::localController_s->getControllableEntity()->getScene()->getSceneManager()->createRayQuery(Ogre::Ray());
377
378        Ogre::Ray mouseRay = HumanController::localController_s->getControllableEntity()->getCamera()->getOgreCamera()->getCameraToViewportRay(static_cast<float>(this->currentYaw_)/2*-1+.5f, static_cast<float>(this->currentPitch_)/2*-1+.5f);
379
380        rsq->setRay(mouseRay);
381        rsq->setSortByDistance(true);
382
383        /*
384        Distance of objects:
385        ignore everything under 200 maybe even take 1000 as min distance to shoot at
386
387        shots are regularly traced and are entities!!!!!!!!! this is the biggest problem
388        they vanish only after a distance of 10'000
389        */
390
391
392        Ogre::RaySceneQueryResult& result = rsq->execute();
393        Pawn* pawn = orxonox_cast<Pawn*>(this->getControllableEntity());
394        WorldEntity* myWe = static_cast<WorldEntity*>(this->getControllableEntity());
395
396        Ogre::RaySceneQueryResult::iterator itr;
397        for (itr = result.begin(); itr != result.end(); ++itr)
398        {
399//             orxout() << "testing object as target" << endl;
400            if (itr->movable->isInScene() && itr->movable->getMovableType() == "Entity" && itr->distance > 200)
401            {
402                // Try to cast the user pointer
403                WorldEntity* wePtr;
404                try
405                {
406                    wePtr = orxonox_cast<WorldEntity*>(Ogre::any_cast<OrxonoxClass*>(itr->movable->getUserAny()));
407                }
408                catch (...)
409                {
410                    continue;
411                }
412
413                // make sure we don't shoot ourselves
414                if( wePtr==myWe )
415                    continue;
416
417                if (wePtr)
418                {
419                    // go through all parents of object and look whether they are sightable or not
420                    bool isSightable = false;
421                    WorldEntity* parent = wePtr->getParent();
422                    while (parent)
423                    {
424                        if (this->targetMask_.isExcluded(parent->getIdentifier()) || parent==myWe)
425                        {
426                            parent = parent->getParent();
427                            continue;
428                        }
429                        else
430                        {
431                            isSightable = true;
432                            break;
433                        }
434                    }
435                    if (!isSightable)
436                        continue;
437                }
438
439                if (this->getControllableEntity() && this->getControllableEntity()->getTarget() != wePtr)
440                    this->getControllableEntity()->setTarget(wePtr);
441
442                if (pawn)
443                    pawn->setAimPosition( mouseRay.getOrigin() + mouseRay.getDirection() * itr->distance );
444
445                //itr->movable->getParentSceneNode()->showBoundingBox(true);
446                //return mouseRay.getOrigin() + mouseRay.getDirection() * itr->distance; //or itr->movable->getParentSceneNode()->_getDerivedPosition()
447                return;
448            }
449        }
450
451        if (pawn)
452            pawn->setAimPosition( mouseRay.getOrigin() + mouseRay.getDirection() * 3000 );
453
454        if( this->getControllableEntity() && this->getControllableEntity()->getTarget() != nullptr )
455            this->getControllableEntity()->setTarget( nullptr );
456
457        //return this->controllableEntity_->getWorldPosition() + (this->controllableEntity_->getWorldOrientation() * Vector3::NEGATIVE_UNIT_Z * 2000);
458        //return this->controllableEntity_->getWorldPosition() + (this->controllableEntity_->getCamera()->getOgreCamera()->getOrientation() * Vector3::NEGATIVE_UNIT_Z);
459    }
460
461    void NewHumanController::frontback(const Vector2& value)
462    {
463        this->accelerating_ = true;
464
465        //if (this->acceleration_ == 0)
466        HumanController::frontback(value);
467    }
468
469    void NewHumanController::yaw(const Vector2& value)
470    {
471        //SUPER(NewHumanController, yaw, value);
472        if (this->controlMode_ == 0 || (this->controllableEntity_ && this->controllableEntity_->isInMouseLook()))
473            HumanController::yaw(value);
474
475        if (this->getControllableEntity() && !this->getControllableEntity()->isExactlyA(ClassByString("FpsPlayer")))
476            this->currentYaw_ = value.x;
477    }
478
479    void NewHumanController::pitch(const Vector2& value)
480    {
481        //SUPER(NewHumanController, pitch, value);
482        if (this->controlMode_ == 0 || (this->controllableEntity_ && this->controllableEntity_->isInMouseLook()))
483            HumanController::pitch(value);
484
485        if (this->getControllableEntity() && !this->getControllableEntity()->isExactlyA(ClassByString("FpsPlayer")))
486            this->currentPitch_ = value.x;
487    }
488
489    void NewHumanController::changeMode()
490    {
491        if (NewHumanController::localController_s)
492        {
493            if (NewHumanController::localController_s->controlMode_ == 0)
494            {
495                NewHumanController::localController_s->controlMode_ = 1;
496                NewHumanController::localController_s->hideArrows();
497            }
498            else
499                NewHumanController::localController_s->controlMode_ = 0;
500        }
501    }
502
503    void NewHumanController::changedControllableEntity()
504    {
505        HumanController::changedControllableEntity(); // super
506
507        this->controlMode_ = 0;
508        this->centerCursor();
509        if (this->getControllableEntity() && ((this->getControllableEntity()->isExactlyA(ClassByString("SpaceShip")) || (this->getControllableEntity()->isExactlyA(ClassByString("ModularSpaceShip")))) || this->getControllableEntity()->isExactlyA(ClassByString("Rocket"))))
510        {
511            this->showOverlays_ = true;
512            if (!this->controlPaused_)
513            {
514                this->showOverlays();
515                this->alignArrows();
516            }
517        }
518        else
519        {
520            this->showOverlays_ = false;
521            this->hideOverlays();
522        }
523    }
524
525    void NewHumanController::accelerate()
526    {
527        if (NewHumanController::localController_s)
528            NewHumanController::localController_s->acceleration_ = clamp(NewHumanController::localController_s->acceleration_ + 0.2f, 0.00f, 1.0f);
529    }
530
531    void NewHumanController::decelerate()
532    {
533        if (NewHumanController::localController_s)
534            NewHumanController::localController_s->acceleration_ = clamp(NewHumanController::localController_s->acceleration_ - 0.1f, 0.0f, 1.0f);
535    }
536
537    void NewHumanController::doResumeControl()
538    {
539        this->controlPaused_ = false;
540        if (this->showOverlays_)
541            this->showOverlays();
542    }
543
544    void NewHumanController::doPauseControl()
545    {
546        this->controlPaused_ = true;
547        this->hideOverlays();
548    }
549
550    void NewHumanController::alignArrows()
551    {
552        if (showArrows_)
553        {
554            hideArrows();
555
556            float distance = sqrt(pow(static_cast<float>(this->currentYaw_)/2*-1,2) + pow(static_cast<float>(this->currentPitch_)/2*-1,2));
557
558            if (distance > 0.04f && distance <= 0.59f * arrowsSize_ / 2.0f )
559            {
560                this->arrowsOverlay1_->setRotation(Degree(-90 + -1.0f * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / math::twoPi * 360.0f));
561                this->arrowsOverlay1_->show();
562            }
563            else if (distance > 0.59f * arrowsSize_ / 2.0f && distance <= 0.77f * arrowsSize_ / 2.0f )
564            {
565                this->arrowsOverlay2_->setRotation(Degree(-90 + -1.0f * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / math::twoPi * 360.0f));
566                this->arrowsOverlay2_->show();
567            }
568            else if (distance > 0.77f * arrowsSize_ / 2.0f && distance <= arrowsSize_ / 2.0f)
569            {
570                this->arrowsOverlay3_->setRotation(Degree(-90 + -1.0f * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / math::twoPi * 360.0f));
571                this->arrowsOverlay3_->show();
572            }
573            else if (distance > arrowsSize_ / 2.0f)
574            {
575                this->arrowsOverlay4_->setRotation(Degree(-90 + -1.0f * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / math::twoPi * 360.0f));
576                this->arrowsOverlay4_->show();
577            }
578        }
579    }
580
581    void NewHumanController::showOverlays()
582    {
583        if (!GameMode::showsGraphics())
584            return;
585        this->crossHairOverlay_->show();
586        this->centerOverlay_->show();
587
588        if (showArrows_)
589        {
590            this->arrowsOverlay1_->show();
591            this->arrowsOverlay2_->show();
592            this->arrowsOverlay3_->show();
593            this->arrowsOverlay4_->show();
594        }
595    }
596
597    void NewHumanController::hideOverlays()
598    {
599        if (!GameMode::showsGraphics())
600            return;
601        this->crossHairOverlay_->hide();
602        this->centerOverlay_->hide();
603
604        if (showDamageOverlay_)
605        {
606            this->damageOverlayTop_->hide();
607            this->damageOverlayRight_->hide();
608            this->damageOverlayBottom_->hide();
609            this->damageOverlayLeft_->hide();
610        }
611
612        this->hideArrows();
613    }
614
615    void NewHumanController::hideArrows()
616    {
617        if(!GameMode::showsGraphics())
618            return;
619        if (showArrows_)
620        {
621            this->arrowsOverlay1_->hide();
622            this->arrowsOverlay2_->hide();
623            this->arrowsOverlay3_->hide();
624            this->arrowsOverlay4_->hide();
625        }
626    }
627
628
629
630
631
632}
Note: See TracBrowser for help on using the repository browser.