Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1286


Ignore:
Timestamp:
May 15, 2008, 3:49:49 PM (16 years ago)
Author:
chaiy
Message:

radar works well

Location:
code/branches/hud3/src/orxonox/hud
Files:
4 edited

Legend:

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

    r1283 r1286  
    5050 
    5151  void RadarOverlayElement::initRadarOverlayElement(Real left, Real top, int dim, Ogre::OverlayContainer* container){
     52
     53
    5254   
    53     int dirX, dirY, dirZ;      //flying direction
    54     int ortX, ortY, ortZ;      //orthogonal direction
    55     int dX, dY, dZ;            //distance between main ship and the object
    56     int vecX, vecY, vecZ;      //vector product dir X ort
    57     double alpha;              //defines the radius in the radar
    58     double beta;               //defines the angle in the radar
    59     bool right;                //checks whether the object is on the right side (since cos is not bijective)
     55    dirX_ = 1;
     56    dirY_ = 0;
     57    dirZ_ = 0;
    6058   
    61     dirX = 1;
    62     dirY = 0;
    63     dirZ = 0;
     59    ortX_ = 0;
     60    ortY_ = 0;
     61    ortZ_ = 1;
    6462   
    65     ortX = 0;
    66     ortY = 0;
    67     ortZ = 1;
     63    dX_ = 0;
     64    dY_ = 0;
     65    dZ_ = -1;
    6866   
    69     dX = 0;
    70     dY = 2;
    71     dZ = 0;
     67    alpha_ = acos((dirX_*dX_+dirY_*dY_+dirZ_*dZ_)/(sqrt(pow(dX_,2)+pow(dY_,2)+pow(dZ_,2))*sqrt(pow(dirX_,2)+pow(dirY_,2)+pow(dirZ_,2))));
     68    beta_ = acos((ortX_*dX_+ortY_*dY_+ortZ_*dZ_)/(sqrt(pow(dX_,2)+pow(dY_,2)+pow(dZ_,2))*sqrt(pow(ortX_,2)+pow(ortY_,2)+pow(ortZ_,2))));
     69    vecX_ = dirY_*ortZ_ - dirZ_*ortY_;
     70    vecY_ = dirZ_*ortX_ - dirX_*ortZ_;
     71    vecZ_ = dirX_*ortY_ - dirY_*ortX_;
    7272   
    73     alpha = acos((dirX*dX+dirY*dY+dirZ*dZ)/(sqrt(pow(dX,2)+pow(dY,2)+pow(dZ,2))*sqrt(pow(dirX,2)+pow(dirY,2)+pow(dirZ,2))));
    74     beta = acos((ortX*dX+ortY*dY+ortZ*dZ)/(sqrt(pow(dX,2)+pow(dY,2)+pow(dZ,2))*sqrt(pow(ortX,2)+pow(ortY,2)+pow(ortZ,2))));
    75     vecX = dirY*ortZ - dirZ*ortY;
    76     vecY = dirZ*ortX - dirX*ortZ;
    77     vecZ = dirX*ortY - dirY*ortX;
    78    
    79     if((vecX*dX+vecY*dY+vecZ*dZ)>0){right=true;}
    80     else right=false;
     73    if((vecX_*dX_+vecY_*dY_+vecZ_*dZ_)>0){right_=true;}
     74    else right_=false;
    8175   
    8276    setMetricsMode(Ogre::GMM_PIXELS);
    8377    setPosition(left,top);
    84     setDimensions(dim-15,dim-20);
     78    setDimensions(dim,dim);
    8579    setMaterialName("Orxonox/Radar");
    8680   
     
    9286    container->addChild(point);
    9387   
    94     if (right){
    95       point->setPosition(sin(beta)*alpha/3.14*dim/2+dim/2,-cos(beta)*alpha/3.14*dim/2+dim/2);
     88    if (right_){
     89      point->setPosition(sin(beta_)*alpha_/3.5*dim/2+dim/2+left-2,-cos(beta_)*alpha_/3.5*dim/2+dim/2+top-2);
    9690      point->setMaterialName("Orxonox/RedPoint");
    9791      point->setDimensions(5,5);
     
    10094 
    10195    else {
    102       point->setPosition(-sin(beta)*alpha/3.14*dim/2+dim/2,-cos(beta)*alpha/3.14*dim/2+dim/2);
     96      point->setPosition(-sin(beta_)*alpha_/3.5*dim/2+dim/2+left-2,-cos(beta_)*alpha_/3.5*dim/2+dim/2+top-2);
    10397      point->setMaterialName("Orxonox/RedPoint");
    10498      point->setDimensions(5,5);
    10599      point->setMetricsMode(Ogre::GMM_PIXELS);
    106100    }
    107 
    108    
    109 
    110    
    111   } 
     101  }
     102   
     103  void RadarOverlayElement::setMainShipPosition(int dirX, dirY, dirZ, ortX, ortY, ortZ){
     104    dirX_=dirX;
     105    dirY_=dirY;
     106    dirZ_=dirZ;
     107    ortX_=ortX;
     108    ortY_=ortY;
     109    ortZ_=ortZ;
     110  }
     111 
     112 
     113 
    112114}
    113115
  • code/branches/hud3/src/orxonox/hud/RadarOverlayElement.cc~

    r1283 r1286  
    5050 
    5151  void RadarOverlayElement::initRadarOverlayElement(Real left, Real top, int dim, Ogre::OverlayContainer* container){
     52
     53
    5254   
    53     int dirX, dirY, dirZ;      //flying direction
    54     int ortX, ortY, ortZ;      //orthogonal direction
    55     int dX, dY, dZ;            //distance between main ship and the object
    56     int vecX, vecY, vecZ;      //vector product dir X ort
    57     double alpha;              //defines the radius in the radar
    58     double beta;               //defines the angle in the radar
    59     bool right;                //checks whether the object is on the right side (since cos is not bijective)
     55    dirX_ = 1;
     56    dirY_ = 0;
     57    dirZ_ = 0;
    6058   
    61     dirX = 1;
    62     dirY = 0;
    63     dirZ = 0;
     59    ortX_ = 0;
     60    ortY_ = 0;
     61    ortZ_ = 1;
    6462   
    65     ortX = 0;
    66     ortY = 0;
    67     ortZ = 1;
     63    dX_ = 0;
     64    dY_ = 0;
     65    dZ_ = -1;
    6866   
    69     dX = 2;
    70     dY = 0;
    71     dZ = 0;
     67    alpha_ = acos((dirX_*dX_+dirY_*dY_+dirZ_*dZ_)/(sqrt(pow(dX_,2)+pow(dY_,2)+pow(dZ_,2))*sqrt(pow(dirX_,2)+pow(dirY_,2)+pow(dirZ_,2))));
     68    beta_ = acos((ortX_*dX_+ortY_*dY_+ortZ_*dZ_)/(sqrt(pow(dX_,2)+pow(dY_,2)+pow(dZ_,2))*sqrt(pow(ortX_,2)+pow(ortY_,2)+pow(ortZ_,2))));
     69    vecX_ = dirY_*ortZ_ - dirZ_*ortY_;
     70    vecY_ = dirZ_*ortX_ - dirX_*ortZ_;
     71    vecZ_ = dirX_*ortY_ - dirY_*ortX_;
    7272   
    73     alpha = acos((dirX*dX+dirY*dY+dirZ*dZ)/(sqrt(pow(dX,2)+pow(dY,2)+pow(dZ,2))*sqrt(pow(dirX,2)+pow(dirY,2)+pow(dirZ,2))));
    74     beta = acos((ortX*dX+ortY*dY+ortZ*dZ)/(sqrt(pow(dX,2)+pow(dY,2)+pow(dZ,2))*sqrt(pow(ortX,2)+pow(ortY,2)+pow(ortZ,2))));
    75     vecX = dirY*ortZ - dirZ*ortY;
    76     vecY = dirZ*ortX - dirX*ortZ;
    77     vecZ = dirX*ortY - dirY*ortX;
    78    
    79     if((vecX*dX+vecY*dY+vecZ*dZ)>0){right=true;}
    80     else right=false;
     73    if((vecX_*dX_+vecY_*dY_+vecZ_*dZ_)>0){right_=true;}
     74    else right_=false;
    8175   
    8276    setMetricsMode(Ogre::GMM_PIXELS);
    8377    setPosition(left,top);
    84     setDimensions(dim-15,dim-20);
     78    setDimensions(dim,dim);
    8579    setMaterialName("Orxonox/Radar");
    8680   
     
    9286    container->addChild(point);
    9387   
    94     if (right){
    95       point->setPosition(sin(beta)*alpha/3.14*dim/2+dim/2,-cos(beta)*alpha/3.14*dim/2+dim/2);
     88    if (right_){
     89      point->setPosition(sin(beta_)*alpha_/3.5*dim/2+dim/2+left-2,-cos(beta_)*alpha_/3.5*dim/2+dim/2+top-2);
    9690      point->setMaterialName("Orxonox/RedPoint");
    9791      point->setDimensions(5,5);
     
    10094 
    10195    else {
    102       point->setPosition(-sin(beta)*alpha/3.14*dim/2+dim/2,-cos(beta)*alpha/3.14*dim/2+dim/2);
     96      point->setPosition(-sin(beta_)*alpha_/3.5*dim/2+dim/2+left-2,-cos(beta_)*alpha_/3.5*dim/2+dim/2+top-2);
    10397      point->setMaterialName("Orxonox/RedPoint");
    10498      point->setDimensions(5,5);
    10599      point->setMetricsMode(Ogre::GMM_PIXELS);
    106100    }
    107 
    108    
    109 
    110    
    111   } 
     101  }
     102   
     103  void setMainShipPosition(int dirX, dirY, dirZ, ortX, ortY, ortZ){
     104    dirX_=dirX;
     105    dirY_=dirY;
     106    dirZ_=dirZ;
     107    ortX_=ortX;
     108    ortY_=ortY;
     109    ortZ_=ortZ;
     110  }
     111 
     112 
     113 
    112114}
    113115
  • code/branches/hud3/src/orxonox/hud/RadarOverlayElement.h

    r1283 r1286  
    4343  {
    4444  private:
    45     int number_;
    46 
     45   
     46    PanelOverlayElement* point[100];
     47   
     48    int dirX_, dirY_, dirZ_;      //flying direction
     49    int ortX_, ortY_, ortZ_;      //orthogonal direction
     50    int dX_, dY_, dZ_;            //distance between main ship and the object
     51    int vecX_, vecY_, vecZ_;      //vector product dir X ort
     52    double alpha_;              //defines the radius in the radar
     53    double beta_;               //defines the angle in the radar
     54    bool right_;                //checks whether the object is on the right side (since cos is not bijective)
     55   
     56    static int ID = 0;
    4757
    4858  public:
     
    5363
    5464    void initRadarOverlayElement(Real left, Real top, int dim, Ogre::OverlayContainer* container);
     65    void setMainShipPosition(int dirX, dirY, dirZ, ortX, ortY, ortZ);
     66   
     67    int newShip(int X, int Y, int Z);
     68   
     69    void resetShip(int shipID, int Y, int Z);
    5570  };
    5671}       
  • code/branches/hud3/src/orxonox/hud/RadarOverlayElement.h~

    r1283 r1286  
    3232#include <string.h>
    3333#include <OgreOverlayElement.h>
     34#include <OgrePanelOverlayElement.h>
     35
    3436#include <OgrePrerequisites.h>
    3537#include "../OrxonoxPrereqs.h"
     
    4143  {
    4244  private:
    43     int number_;
    44 
     45   
     46    PanelOverlayElement* point[100];
     47   
     48    int dirX_, dirY_, dirZ_;      //flying direction
     49    int ortX_, ortY_, ortZ_;      //orthogonal direction
     50    int dX_, dY_, dZ_;            //distance between main ship and the object
     51    int vecX_, vecY_, vecZ_;      //vector product dir X ort
     52    double alpha_;              //defines the radius in the radar
     53    double beta_;               //defines the angle in the radar
     54    bool right_;                //checks whether the object is on the right side (since cos is not bijective)
     55   
     56    static int ID;
    4557
    4658  public:
     
    5163
    5264    void initRadarOverlayElement(Real left, Real top, int dim, Ogre::OverlayContainer* container);
     65    void setMainShipPosition(int dirX, dirY, dirZ, ortX, ortY, ortZ);
     66   
     67    int newShip(int X, int Y, int Z);
     68   
     69    void resetShip(int shipID, int Y, int Z);
    5370  };
    5471}       
Note: See TracChangeset for help on using the changeset viewer.