Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1411


Ignore:
Timestamp:
May 24, 2008, 5:35:34 PM (16 years ago)
Author:
FelixSchulthess
Message:

rewritten navigation algebra… very ugly, and not optimized

Location:
code/branches/network/src/orxonox
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network/src/orxonox/Orxonox.cc

    r1406 r1411  
    401401      client_g = network::Client::createSingleton();
    402402    else
    403      
     403
    404404      client_g = network::Client::createSingleton(serverIp_, serverPort_);
    405405
     
    490490//      orxonoxHUD_->setRocket2(ogreRoot.getCurrentFrameNumber());
    491491      if (eventTimes[3].back() - eventTimes[3].front() != 0)
    492         HUD::setFPS(50000.0f/(eventTimes[3].back() - eventTimes[3].front()));
     492        HUD::getSingleton().setFPS(50000.0f/(eventTimes[3].back() - eventTimes[3].front()));
    493493
    494494      // Iterate through all Tickables and call their tick(dt) function
  • code/branches/network/src/orxonox/hud/BarOverlayElement.cc

    r1410 r1411  
    2828#include "OrxonoxStableHeaders.h"
    2929#include "BarOverlayElement.h"
    30 
    3130#include <OgreOverlayManager.h>
    3231#include "GraphicsEngine.h"
  • code/branches/network/src/orxonox/hud/BarOverlayElement.h

    r1410 r1411  
    2626*/
    2727
     28#ifndef _BAR_H__
     29#define _BAR_H__
    2830
    29 #ifndef _BarOverlayElement_H__
    30 #define _BarOverlayElement_H__
    31 
    32 #include "OrxonoxPrereqs.h"
    33 
     31#include <OgrePanelOverlayElement.h>
    3432#include <OgrePrerequisites.h>
    35 #include <OgrePanelOverlayElement.h>
     33#include "../OrxonoxPrereqs.h"
    3634
    3735namespace orxonox
     
    4038  {
    4139    private:
    42       bool autoColor_;                    // whether bar changes color automatically
    43       float value_;                       // progress of bar
    44       int color_;
    45       int left_;
    46       int top_;
    47       int width_;
    48       int height_;
    49       int windowW_, windowH_;
    50       Ogre::Real leftRel_;
    51       Ogre::Real topRel_;
    52       Ogre::Real dimRel_;
    53       Ogre::OverlayManager* om;           // our overlay manager
    54       Ogre::OverlayContainer* container_; // our parent container to attach to
    55       Ogre::OverlayContainer* background_;
    56       Ogre::String name_;
     40        bool autoColor_;                    // whether bar changes color automatically
     41        float value_;                       // progress of bar
     42        int color_;
     43        int left_;
     44        int top_;
     45        int width_;
     46        int height_;
     47        int windowW_, windowH_;
     48        Ogre::Real leftRel_;
     49        Ogre::Real topRel_;
     50        Ogre::Real dimRel_;
     51        Ogre::OverlayManager* om;           // our overlay manager
     52        Ogre::OverlayContainer* container_; // our parent container to attach to
     53        Ogre::OverlayContainer* background_;
     54        Ogre::String name_;
    5755
    5856    public:
    59       bool left2Right;
    60       static const int RED = 0;           // predefined colors
    61       static const int YELLOW = 1;
    62       static const int GREEN = 2;
     57        bool left2Right;
     58        static const int RED = 0;           // predefined colors
     59        static const int YELLOW = 1;
     60        static const int GREEN = 2;
    6361
    64       BarOverlayElement(const Ogre::String& name);
    65       virtual ~BarOverlayElement();
    66       void init(Real leftRel, Real topRel, Real dimRel, Ogre::OverlayContainer* container);
    67       void resize();
    68       void setValue(float value);
    69       void setColor(int color);
    70       float getValue();
    71       int getBarColor();
     62        BarOverlayElement(const Ogre::String& name);
     63        virtual ~BarOverlayElement();
     64        void init(Real leftRel, Real topRel, Real dimRel, Ogre::OverlayContainer* container);
     65        void resize();
     66        void setValue(float value);
     67        void setColor(int color);
     68        float getValue();
     69        int getBarColor();
    7270    };
    7371}
     72#endif
    7473
    75 #endif /* _BarOverlayElement_H__ */
     74
  • code/branches/network/src/orxonox/hud/HUD.cc

    r1410 r1411  
    131131    }
    132132
     133    void HUD::setFPS(float fps){
     134        fpsText->setCaption("FPS: " + Ogre::StringConverter::toString(fps));
     135    }
     136
    133137    void HUD::addRadarObject(Vector3 pos){
    134138        // check if this is the first RadarObject to create
     
    152156    }
    153157
    154     /*static*/ void HUD::setFPS(float fps){
    155         HUD::getSingleton().fpsText->setCaption("FPS: " + Ogre::StringConverter::toString(fps));
    156     }
    157 
    158158    /*static*/ void HUD::setEnergy(float value){
    159159        HUD::getSingleton().energyBar->setValue(value);
  • code/branches/network/src/orxonox/hud/HUD.h

    r1410 r1411  
    5858      public:
    5959        virtual void tick(float);
     60        void setFPS(float fps);
    6061        void addRadarObject(Vector3 pos);
    6162        RadarObject* getFirstRadarObject();
     
    6364        static HUD* instance_s;
    6465        static HUD& getSingleton();
    65         static void setFPS(float fps);
    6666        static void setEnergy(float value);
    6767        static void cycleNavigationFocus();
  • code/branches/network/src/orxonox/hud/Navigation.cc

    r1410 r1411  
    103103        int xPos = xPosRel*windowW_;
    104104        int yPos = yPosRel*windowH_;
     105        int xFromCenter = xPos-windowW_/2;
     106        int yFromCenter = yPos-windowH_/2;
    105107        // is object in view?
     108        float radius = RadarOverlayElement::calcRadius(navCamPos_, currentDir_, currentOrth_, focus_);
     109        bool isRight = (currentDir_.crossProduct(currentOrth_)).dotProduct(focus_->pos_ - navCamPos_)>0;
     110        bool isAbove = currentOrth_.dotProduct(focus_->pos_ - navCamPos_)>0;
    106111        bool outOfView = (xPosRel<0 || xPosRel>1 || yPosRel<0 || yPosRel>1);
    107112        // if object is behind us, it is out of view anyway:
    108         if(!outOfView && RadarOverlayElement::calcRadius(navCamPos_, currentDir_, currentOrth_, focus_)>3.14/2) outOfView = true;
     113        if(!outOfView && radius>3.14/2) outOfView = true;
    109114
    110115        if(outOfView){
    111             // NO!
     116            // object is not in view
    112117            navMarker_->setMaterialName("Orxonox/NavArrows");
    113118            navMarker_->setDimensions(16,16);
    114             float phiUpRight = atan((float)(windowW_)/(float)(windowH_));
    115             // from the angle we find out where to draw the marker
     119            float phiUpperCorner = atan((float)(windowW_)/(float)(windowH_));
     120            // from the angle we find out on which edge to draw the marker
    116121            // and which of the four arrows to take
    117             float phiNav = RadarOverlayElement::calcPhi(navCamPos_, currentDir_, currentOrth_, focus_);
    118             bool right = RadarOverlayElement::calcRight(navCamPos_, currentDir_, currentOrth_, focus_);
    119             if(right){
    120                 if(phiNav<phiUpRight){
    121                     // arrow up
    122                     navMarker_->setPosition(tan(phiNav)*windowH_/2+windowW_/2, 0);
     122            float phiNav = atan((float) xFromCenter / (float) yFromCenter);
     123
     124            if(isAbove && isRight){
     125                // top right quadrant
     126                if(-phiNav<phiUpperCorner){
     127                    COUT(3) << "arrow up\n";
     128                    navMarker_->setPosition(-tan(phiNav)*windowH_/2+windowW_/2, 0);
    123129                    navMarker_->setUV(0.5, 0.0, 1.0, 0.5);
    124130                    navText_->setLeft(navMarker_->getLeft()+navMarker_->getWidth());
    125131                    navText_->setTop(navMarker_->getHeight());
    126132                }
    127                 else if(phiNav>3.14-phiUpRight){
    128                     // arrow down
    129                     navMarker_->setPosition(-tan(phiNav)*windowH_/2+windowW_/2, windowH_-16);
    130                     navMarker_->setUV(0.0, 0.5, 0.5, 1.0);
    131                     navText_->setLeft(navMarker_->getLeft()+navMarker_->getWidth());
    132                     navText_->setTop(navMarker_->getTop()-navMarker_->getHeight());
    133                 }
    134                 else {
    135                     // arrow right
    136                     navMarker_->setPosition(windowW_-16, -tan((3.14-2*phiNav)/2)*windowW_/2+windowH_/2);
     133                else {
     134                    COUT(3) << "arrow right\n";
     135                    navMarker_->setPosition(windowW_-16, tan((3.14-2*phiNav)/2)*windowW_/2+windowH_/2);
    137136                    navMarker_->setUV(0.5, 0.5, 1.0, 1.0);
    138137                    navText_->setLeft(navMarker_->getLeft()-navMarker_->getWidth());
     
    140139                }
    141140            }
    142             else{
    143                 if(phiNav<phiUpRight) {
    144                     // arrow up
     141            if(!isAbove && isRight){
     142                // bottom right quadrant
     143                if(phiNav<phiUpperCorner) {
     144                    COUT(3) << "arrow down\n";
     145                    navMarker_->setPosition(tan(phiNav)*windowH_/2+windowW_/2, windowH_-16);
     146                    navMarker_->setUV(0.0, 0.5, 0.5, 1.0);
     147                    navText_->setLeft(navMarker_->getLeft()+navMarker_->getWidth());
     148                    navText_->setTop(navMarker_->getTop()-navMarker_->getHeight());
     149                }
     150                else {
     151                    COUT(3) << "arrow right\n";
     152                    navMarker_->setPosition(windowW_-16, tan((3.14-2*phiNav)/2)*windowW_/2+windowH_/2);
     153                    navMarker_->setUV(0.5, 0.5, 1.0, 1.0);
     154                    navText_->setLeft(navMarker_->getLeft()-navMarker_->getWidth());
     155                    navText_->setTop(navMarker_->getTop()+navMarker_->getHeight());
     156                }
     157            }
     158            if(isAbove && !isRight){
     159                // top left quadrant
     160                if(phiNav<phiUpperCorner){
     161                    COUT(3) << "arrow up\n";
    145162                    navMarker_->setPosition(-tan(phiNav)*windowH_/2+windowW_/2, 0);
    146163                    navMarker_->setUV(0.5, 0.0, 1.0, 0.5);
     
    148165                    navText_->setTop(navMarker_->getHeight());
    149166                }
    150                 else if(phiNav>3.14-phiUpRight) {
    151                     // arrow down
    152                     navMarker_->setPosition(tan(phiNav)*windowH_/2+windowW_/2, windowH_-16);
    153                     navMarker_->setUV(0.0, 0.5, 0.5, 1.0);
    154                     navText_->setLeft(navMarker_->getLeft()+navMarker_->getWidth());
    155                     navText_->setTop(navMarker_->getTop()-navMarker_->getHeight());
    156                 }
    157                 else {
    158                     // arrow left
     167                else {
     168                    COUT(3) << "arrow left\n";
    159169                    navMarker_->setPosition(0, -tan((3.14-2*phiNav)/2)*windowW_/2+windowH_/2);
    160170                    navMarker_->setUV(0.0, 0.0, 0.5, 0.5);
     
    163173                }
    164174            }
     175            if(!isAbove && !isRight){
     176                // bottom left quadrant
     177                if(phiNav>-phiUpperCorner) {
     178                    COUT(3) << "arrow down\n";
     179                    navMarker_->setPosition(tan(phiNav)*windowH_/2+windowW_/2, windowH_-16);
     180                    navMarker_->setUV(0.0, 0.5, 0.5, 1.0);
     181                    navText_->setLeft(navMarker_->getLeft()+navMarker_->getWidth());
     182                    navText_->setTop(navMarker_->getTop()-navMarker_->getHeight());
     183                }
     184                else {
     185                    COUT(3) << "arrow left\n";
     186                    navMarker_->setPosition(0, -tan((3.14-2*phiNav)/2)*windowW_/2+windowH_/2);
     187                    navMarker_->setUV(0.0, 0.0, 0.5, 0.5);
     188                    navText_->setLeft(navMarker_->getWidth());
     189                    navText_->setTop(navMarker_->getTop()+navMarker_->getHeight());
     190                }
     191            }
    165192        }
    166193        else{
    167             // YES!
     194            // object is in view
    168195            navMarker_->setMaterialName("Orxonox/NavTDC");
    169196            navMarker_->setDimensions(24,24);
  • code/branches/network/src/orxonox/hud/RadarObject.h

    r1410 r1411  
    2020*
    2121*   Author:
    22 *      Yuning Chai
     22*      Felix Schulthess
    2323*   Co-authors:
    2424*      ...
  • code/branches/network/src/orxonox/hud/RadarOverlayElement.h

    r1410 r1411  
    2222*      Yuning Chai
    2323*   Co-authors:
    24 *      ...
     24*      Felix Schulthess
    2525*
    2626*/
Note: See TracChangeset for help on using the changeset viewer.