Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

today I got pawn'ed

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