Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 6, 2008, 6:06:32 PM (17 years ago)
Author:
rgrieder
Message:
  • added a Factory to create OverlayElements by the ourselves
  • added a 3D ogre head to demonstrate the ability to use 3D content in an Overlay (could be used in a radar or whatever needs 3D)
File:
1 edited

Legend:

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

    r991 r1000  
    3131#include <OgreOverlayContainer.h>
    3232#include <OgreOverlayManager.h>
     33#include <OgreSceneNode.h>
    3334
    3435#include "HUD.h"
    3536#include "Bar.h"
     37#include "TestElement.h"
     38// ugly hack
     39#include "Orxonox.h"
    3640
    3741
     
    6064    energyCounterPanel->addChild(energyCounter->element);
    6165
     66    TestOverlayElementFactory *factory = new TestOverlayElementFactory();
     67    overlayManager.addOverlayElementFactory(factory);
     68    Ogre::OverlayElement* testElement = overlayManager.createOverlayElementFromFactory("Test", "testElement");
     69
    6270    Ogre::Overlay* orxonoxOverlay = overlayManager.create("Orxonox/HUD");
    6371    orxonoxOverlay->add2D(energyCounterPanel);
     72
     73    // important: don't use SceneManager to create the node! but register the creator scene manager.
     74    ogreNode_ = new Ogre::SceneNode(Orxonox::getSingleton()->getSceneManager(), "hudNoedely");
     75   
     76    ogreNode_->setPosition(80,-60,-200);
     77    ogreNode_->setScale(0.4,0.4,0.4);
     78    // ugly hack, but I haven't figured out yet how we could change this, since we really need the
     79    // scene manager..
     80    ogreNode_->attachObject(Orxonox::getSingleton()->getSceneManager()->createEntity("head", "ogrehead.mesh"));
     81    orxonoxOverlay->add3D(ogreNode_);
     82
    6483    orxonoxOverlay->show();
     84  }
     85
     86  void HUD::tick(float dt)
     87  {
     88    if (this->ogreNode_)
     89    {
     90      this->ogreNode_->roll(Ogre::Degree(dt*200),Ogre::Node::TS_LOCAL);
     91      this->ogreNode_->yaw(Ogre::Degree(dt*200),Ogre::Node::TS_LOCAL);     
     92      this->ogreNode_->pitch(Ogre::Degree(dt*200),Ogre::Node::TS_LOCAL);     
     93    }
    6594  }
    6695
Note: See TracChangeset for help on using the changeset viewer.