Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 16, 2008, 5:57:05 PM (17 years ago)
Author:
FelixSchulthess
Message:

repositioned hud layout

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/hud3/src/orxonox/hud/RadarOverlayElement.cc

    r1308 r1310  
    4141#include <OgreStringConverter.h>
    4242#include "RadarOverlayElement.h"
     43#include "GraphicsEngine.h"
    4344
    4445namespace orxonox
     
    5657    }
    5758
    58     void RadarOverlayElement::initRadarOverlayElement(Real left, Real top, int dim, Ogre::OverlayContainer* container){
    59         dim_ = dim;
    60         left_ = left;
    61         top_ = top;
    62         count_ = 100;
     59    void RadarOverlayElement::initRadarOverlayElement(Real left, Real top, Real dim, Ogre::OverlayContainer* container){
     60
     61        windowW = GraphicsEngine::getSingleton().getWindowWidth();
     62        windowH = GraphicsEngine::getSingleton().getWindowHeight();
     63        dim_ = dim*windowH;                         //conver relative data to absolute
     64        left_ = left*windowW-dim_/2;                // ...
     65        top_ = top*windowH-dim_/2;                  // ...
     66        count_ = 0;
    6367        container_ = container;
    6468
     
    6973        initialOrth_ = Vector3(0.0, 0.0, 1.0);
    7074        currentOrth_ = initialOrth_;
    71      
     75
    7276        setMetricsMode(Ogre::GMM_PIXELS);
    73         setPosition(left,top);
     77        setMaterialName("Orxonox/Radar");
     78        setPosition(left_, top_);
    7479        setDimensions(dim_,dim_);
    75         setMaterialName("Orxonox/Radar");
    7680
    7781        om = &Ogre::OverlayManager::getSingleton();
     
    9599
    96100    void RadarOverlayElement::update() {
    97         if(count_++ >= 100) {           // for testing purposes
    98                         count_ = 0;
    99                         COUT(3) << "pos:  " << shipPos_ << std::endl;
    100                         COUT(3) << "dir:  " << currentDir_ << std::endl;
    101                         COUT(3) << "orth: " << currentOrth_ << std::endl << std::endl;         
    102         }
    103101        shipPos_ = SpaceShip::instance_s->getPosition();
    104102        currentDir_ = SpaceShip::instance_s->getOrientation()*initialDir_;              // according to beni....
    105103                currentOrth_ = SpaceShip::instance_s->getOrientation()*initialOrth_;
    106                
     104
    107105                radius_ = acos((currentDir_.dotProduct(targetPos_ - shipPos_))/((targetPos_ - shipPos_).length()*currentDir_.length()));
    108106        phi_ = acos((currentOrth_.dotProduct(targetPos_ - shipPos_))/((targetPos_ - shipPos_).length()*currentOrth_.length()));
    109         vec_ = currentDir_.crossProduct(currentOrth_);
    110         if(vec_.dotProduct(targetPos_ - shipPos_) > 0) right_ = true;
     107        if((currentDir_.crossProduct(currentOrth_)).dotProduct(targetPos_ - shipPos_) > 0) right_ = true;
    111108        else right_=false;
    112        
     109
    113110        if (right_){
    114             point->setPosition(sin(phi_)*radius_/3.5*dim_/2+dim_/2+left_-2,-cos(phi_)*radius_/3.5*dim_/2+dim_/2+top_-2);         
     111            point->setPosition(sin(phi_)*radius_/3.5*dim_/2+dim_/2+left_-2,-cos(phi_)*radius_/3.5*dim_/2+dim_/2+top_-2);
    115112        }
    116113        else {
Note: See TracChangeset for help on using the changeset viewer.