Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 16, 2008, 11:27:09 AM (16 years ago)
Author:
FelixSchulthess
Message:

dot on radar moves now, but not continious (nonsatisfying)

File:
1 edited

Legend:

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

    r1302 r1308  
    6060        left_ = left;
    6161        top_ = top;
    62         count_ = 0;
     62        count_ = 100;
    6363        container_ = container;
    6464
    6565        shipPos_ = Vector3(0.0, 0.0, 0.0);
    66         targetPos_ = Vector3(42.0, 42.0, 0.0);
    67         initialDir_ = Vector3(0.0, 0.0, 1.0);
     66        targetPos_ = Vector3(42.0, 0.0, 0.0);
     67        initialDir_ = Vector3(1.0, 0.0, 0.0);
    6868        currentDir_ = initialDir_;
    69         initialOrth_ = Vector3(0.0, 1.0, 0.0);
     69        initialOrth_ = Vector3(0.0, 0.0, 1.0);
    7070        currentOrth_ = initialOrth_;
    71 
    72         alpha_ = acos((currentDir_.dotProduct(targetPos_ - shipPos_))/((targetPos_ - shipPos_).length()*currentDir_.length()));
    73         beta_ = acos((currentOrth_.dotProduct(targetPos_ - shipPos_))/((targetPos_ - shipPos_).length()*currentOrth_.length()));
    74         vec_ = currentDir_.crossProduct(currentOrth_);
    75 
    76         if(vec_.dotProduct(targetPos_ - shipPos_) > 0)
    77             right_ = true;
    78         else
    79             right_=false;
    80 
     71     
    8172        setMetricsMode(Ogre::GMM_PIXELS);
    8273        setPosition(left,top);
     
    8879        point->show();
    8980        container->addChild(point);
     81        point->setMaterialName("Orxonox/RedPoint");
     82        point->setDimensions(5,5);
     83        point->setMetricsMode(Ogre::GMM_PIXELS);
    9084
    91         if (right_){
    92             point->setPosition(sin(beta_)*alpha_/3.5*dim_/2+dim_/2+left-2,-cos(beta_)*alpha_/3.5*dim_/2+dim_/2+top-2);
    93             point->setMaterialName("Orxonox/RedPoint");
    94             point->setDimensions(5,5);
    95             point->setMetricsMode(Ogre::GMM_PIXELS);
    96         }
    97 
    98         else {
    99             point->setPosition(-sin(beta_)*alpha_/3.5*dim_/2+dim_/2+left-2,-cos(beta_)*alpha_/3.5*dim_/2+dim_/2+top-2);
    100             point->setMaterialName("Orxonox/RedPoint");
    101             point->setDimensions(5,5);
    102             point->setMetricsMode(Ogre::GMM_PIXELS);
    103         }
    10485    }
    10586
     
    11495
    11596    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        }
    116103        shipPos_ = SpaceShip::instance_s->getPosition();
    117         currentDir_ = SpaceShip::instance_s->getOrientation()*initialDir_; // according to beni....
     104        currentDir_ = SpaceShip::instance_s->getOrientation()*initialDir_;              // according to beni....
     105                currentOrth_ = SpaceShip::instance_s->getOrientation()*initialOrth_;
     106               
     107                radius_ = acos((currentDir_.dotProduct(targetPos_ - shipPos_))/((targetPos_ - shipPos_).length()*currentDir_.length()));
     108        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;
     111        else right_=false;
     112       
     113        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);         
     115        }
     116        else {
     117            point->setPosition(-sin(phi_)*radius_/3.5*dim_/2+dim_/2+left_-2,-cos(phi_)*radius_/3.5*dim_/2+dim_/2+top_-2);
     118        }
    118119    }
    119120
Note: See TracChangeset for help on using the changeset viewer.