Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 20, 2008, 1:38:30 PM (16 years ago)
Author:
FelixSchulthess
Message:

edited radar to support multiple radar objects, wip though

File:
1 edited

Legend:

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

    r1329 r1335  
    5353    }
    5454
    55     void RadarOverlayElement::initialise(){
    56         PanelOverlayElement::initialise();
    57     }
    58 
    5955    void RadarOverlayElement::init(Real leftRel, Real topRel, Real dimRel, Ogre::OverlayContainer* container){
    60         count_ = 0;
     56                om = &Ogre::OverlayManager::getSingleton();       
    6157        dimRel_ = dimRel;
    6258        leftRel_ = leftRel;
     
    6561
    6662        shipPos_ = Vector3(0.0, 0.0, 0.0);
    67         targetPos_ = Vector3(1337.0, 0.0, 0.0);
    6863        initialDir_ = Vector3(1.0, 0.0, 0.0);
    6964        currentDir_ = initialDir_;
     
    7469        setMaterialName("Orxonox/Radar");
    7570        resize();
    76 
    77         om = &Ogre::OverlayManager::getSingleton();
    78         point = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel", "point"));
    79         point->show();
    80         container->addChild(this);
    81         container->addChild(point);
    82         point->setMaterialName("Orxonox/RedDot");
    83         point->setDimensions(5,5);
    84         point->setMetricsMode(Ogre::GMM_PIXELS);
    85 
     71       
     72        container_->addChild(this);
    8673    }
    8774
     
    10289                currentOrth_ = SpaceShip::instance_s->getOrientation()*initialOrth_;
    10390
    104                 radius_ = acos((currentDir_.dotProduct(targetPos_ - shipPos_))/((targetPos_ - shipPos_).length()*currentDir_.length()));
    105         phi_ = acos((currentOrth_.dotProduct(targetPos_ - shipPos_))/((targetPos_ - shipPos_).length()*currentOrth_.length()));
    106         if((currentDir_.crossProduct(currentOrth_)).dotProduct(targetPos_ - shipPos_) > 0) right_ = true;
    107         else right_=false;
     91                if(tomato_ == NULL) return;             
     92               
     93                tomato_->radius_ = acos((currentDir_.dotProduct(tomato_->pos_ - shipPos_))/
     94                        ((tomato_->pos_ - shipPos_).length()*currentDir_.length()));
     95        tomato_->phi_ = acos((currentOrth_.dotProduct(tomato_->pos_ - shipPos_))/
     96                ((tomato_->pos_ - shipPos_).length()*currentOrth_.length()));
     97        if((currentDir_.crossProduct(currentOrth_)).dotProduct(tomato_->pos_ - shipPos_) > 0)
     98                tomato_->right_ = true;
     99        else tomato_->right_=false;
    108100
    109         if (right_){
    110             point->setPosition(sin(phi_)*radius_/3.5*dim_/2+dim_/2+left_-2,-cos(phi_)*radius_/3.5*dim_/2+dim_/2+top_-2);
     101        if (tomato_->right_){
     102            tomato_->panel_->setPosition(sin(tomato_->phi_)*tomato_->radius_/
     103                3.5*dim_/2+dim_/2+left_-2,-cos(tomato_->phi_)*tomato_->radius_/3.5*dim_/2+dim_/2+top_-2);
    111104        }
    112105        else {
    113             point->setPosition(-sin(phi_)*radius_/3.5*dim_/2+dim_/2+left_-2,-cos(phi_)*radius_/3.5*dim_/2+dim_/2+top_-2);
     106            tomato_->panel_->setPosition(-sin(tomato_->phi_)*tomato_->radius_/
     107                3.5*dim_/2+dim_/2+left_-2,-cos(tomato_->phi_)*tomato_->radius_/3.5*dim_/2+dim_/2+top_-2);
    114108        }
    115109    }
    116 
     110   
     111    void RadarOverlayElement::addObject(Vector3 pos){
     112                tomato_ = new RadarObject(container_);
     113                tomato_->pos_ = pos;
     114        }
     115       
     116        //// RadarObject ////
     117       
     118        int RadarObject::count = 0;
     119       
     120        RadarObject::RadarObject(Ogre::OverlayContainer* container){
     121                container_ = container;
     122                pos_ = Vector3(0.0, 0.0, 0.0);
     123                init();
     124        }
     125       
     126        RadarObject::RadarObject(Ogre::OverlayContainer* container, Vector3 pos){
     127                container_ = container;
     128                pos_ = pos;
     129                init();
     130        }
     131       
     132        RadarObject::~RadarObject(){}
     133       
     134        void RadarObject::init(){
     135                om = &Ogre::OverlayManager::getSingleton();
     136                panel_ = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel",
     137                        "Object"+Ogre::StringConverter::toString(count++)));
     138                panel_->setMaterialName("Orxonox/RedDot");
     139                panel_->setDimensions(5,5);
     140        panel_->setMetricsMode(Ogre::GMM_PIXELS);
     141        panel_->show();
     142        container_->addChild(panel_);
     143        }
    117144}
    118145
    119 
    120 
     146/* my local clipboard...
     147COUT(3) << "WWWWWWWWWWWWWWWWWWWWWWWWWWWW\n";
     148COUT(3) << tomato_->radius_ << "  " << tomato_->phi_ << std::endl;
     149COUT(3) << "WWWWWWWWWWWWWWWWWWWWWWWWWWWW\n";
     150*/
Note: See TracChangeset for help on using the changeset viewer.