Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 17, 2008, 3:05:27 PM (17 years ago)
Author:
FelixSchulthess
Message:

added speedometer.

File:
1 edited

Legend:

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

    r1310 r1314  
    4848
    4949  HUD::HUD(int zoom){
    50 
    51     Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();
     50    om = &Ogre::OverlayManager::getSingleton();
    5251
    5352    BarOverlayElementFactory *barOverlayElementFactory = new BarOverlayElementFactory();
    54     overlayManager.addOverlayElementFactory(barOverlayElementFactory);
     53    om->addOverlayElementFactory(barOverlayElementFactory);
    5554
    5655    SmartBarOverlayElementFactory *smartBarOverlayElementFactory = new SmartBarOverlayElementFactory();
    57     overlayManager.addOverlayElementFactory(smartBarOverlayElementFactory);
     56    om->addOverlayElementFactory(smartBarOverlayElementFactory);
    5857
    5958    RadarOverlayElementFactory *radarOverlayElementFactory = new RadarOverlayElementFactory();
    60     overlayManager.addOverlayElementFactory(radarOverlayElementFactory);
     59    om->addOverlayElementFactory(radarOverlayElementFactory);
    6160
    62     Ogre::Overlay* orxonoxOverlay = overlayManager.create("Orxonox/HUD");
     61    orxonoxHUD = om->create("Orxonox/HUD");
    6362
    64     Ogre::OverlayContainer* energyCounterPanel = static_cast<Ogre::OverlayContainer*>(overlayManager.createOverlayElement("Panel", "Orxonox/HUD/energyCounterPanel"));
     63    container = static_cast<Ogre::OverlayContainer*>(om->createOverlayElement("Panel", "Orxonox/HUD/container"));
    6564
    66     energyCounter = static_cast<SmartBarOverlayElement*>(overlayManager.createOverlayElement("SmartBar", "energyCounter"));
    67     //energyCounter->show();
     65    energyCounter = static_cast<SmartBarOverlayElement*>(om->createOverlayElement("SmartBar", "energyCounter"));
     66    energyCounter->show();
    6867
     68    speedo = static_cast<SmartBarOverlayElement*>(om->createOverlayElement("SmartBar", "speedo"));
     69    speedo->show();
    6970
    70     radar = static_cast<RadarOverlayElement*>(overlayManager.createOverlayElement("Radar", "radar"));
     71    radar = static_cast<RadarOverlayElement*>(om->createOverlayElement("Radar", "radar"));
    7172    radar->show();
    7273
     
    108109    test->show();
    109110    test->setMetricsMode(Ogre::GMM_PIXELS);
    110     energyCounterPanel->addChild(test);
     111    container->addChild(test);
    111112
    112113    COUT(0)<<alpha<<" "<<beta<<" "<<right<<std::endl;
    113114*/
    114115
    115     energyCounterPanel->addChild(energyCounter);
    116     energyCounterPanel->addChild(radar);
    117     energyCounterPanel->show();
     116    container->addChild(energyCounter);
     117    container->addChild(speedo);
     118    container->addChild(radar);
     119    container->show();
    118120
    119     orxonoxOverlay->add2D(energyCounterPanel);
    120     orxonoxOverlay->show();
     121    orxonoxHUD->add2D(container);
     122    orxonoxHUD->show();
    121123
    122124
     
    133135*/
    134136
    135     energyCounterPanel->setLeft(0.0);
    136     energyCounterPanel->setTop(0.0);
    137     energyCounterPanel->setWidth(1.0);
    138     energyCounterPanel->setHeight(1.0);
    139     energyCounterPanel->setMetricsMode(Ogre::GMM_RELATIVE);
     137    container->setLeft(0.0);
     138    container->setTop(0.0);
     139    container->setWidth(1.0);
     140    container->setHeight(1.0);
     141    container->setMetricsMode(Ogre::GMM_RELATIVE);
    140142
    141     energyCounter->initSmartBarOverlayElement(10,10,200,20,BarOverlayElement::LEFT);
    142     energyCounter->reset(80);
     143    energyCounter->initSmartBarOverlayElement(0.01, 0.01, 0.2, 0.02, BarOverlayElement::LEFT);
     144    energyCounter->reset(100);
    143145
    144     radar->initRadarOverlayElement(0.5, 0.8, 0.2, energyCounterPanel);
     146    speedo->initSmartBarOverlayElement(0.01, 0.04, 0.2, 0.02, BarOverlayElement::LEFT);
     147    speedo->reset(80);
     148
     149    radar->initRadarOverlayElement(0.5, 0.9, 0.2, container);
    145150
    146151
     
    149154  void HUD::tick(float dt)
    150155  {
     156      float v = SpaceShip::instance_s->getVelocity().length();
     157      float vmax = SpaceShip::instance_s->getMaxSpeed();
     158      speedo->reset(100*v/vmax);
     159      COUT(3) << 100*v/vmax << std::endl;
    151160      radar->update();
    152161    /*if (this->ogreNode_)
Note: See TracChangeset for help on using the changeset viewer.