Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/archive/environment2/src/orxonox/controllers/NewHumanController.cc @ 12106

Last change on this file since 12106 was 8351, checked in by rgrieder, 14 years ago

Merged kicklib2 branch back to trunk (includes former branches ois_update, mac_osx and kicklib).

Notes for updating

Linux:
You don't need an extra package for CEGUILua and Tolua, it's already shipped with CEGUI.
However you do need to make sure that the OgreRenderer is installed too with CEGUI 0.7 (may be a separate package).
Also, Orxonox now recognises if you install the CgProgramManager (a separate package available on newer Ubuntu on Debian systems).

Windows:
Download the new dependency packages versioned 6.0 and use these. If you have problems with that or if you don't like the in game console problem mentioned below, you can download the new 4.3 version of the packages (only available for Visual Studio 2005/2008).

Key new features:

  • *Support for Mac OS X*
  • Visual Studio 2010 support
  • Bullet library update to 2.77
  • OIS library update to 1.3
  • Support for CEGUI 0.7 —> Support for Arch Linux and even SuSE
  • Improved install target
  • Compiles now with GCC 4.6
  • Ogre Cg Shader plugin activated for Linux if available
  • And of course lots of bug fixes

There are also some regressions:

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