- Timestamp:
- May 17, 2008, 3:05:27 PM (17 years ago)
- Location:
- code/branches/hud3/src/orxonox
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/hud3/src/orxonox/hud/BarOverlayElement.cc
r1283 r1314 29 29 #include <OgreOverlayElement.h> 30 30 #include <OgrePanelOverlayElement.h> 31 32 31 #include "GraphicsEngine.h" 33 32 #include "BarOverlayElement.h" 34 33 … … 51 50 52 51 53 void BarOverlayElement::initBarOverlayElement(Real left, Real top, Real width, Real height, 54 int dir, int colour){ 55 setMetricsMode(Ogre::GMM_PIXELS); 56 dir_ = dir; 57 left_ = left; 58 top_ = top; 59 width_ = width; 60 height_ = height; 61 setPosition(left_,top_); 62 setDimensions(width_,height_); 63 setColour(colour); 52 void BarOverlayElement::initBarOverlayElement(Real leftRel, Real topRel, Real widthRel, Real heightRel, int dir, int colour){ 53 windowW_ = GraphicsEngine::getSingleton().getWindowWidth(); 54 windowH_ = GraphicsEngine::getSingleton().getWindowHeight(); 55 56 dir_ = dir; 57 leftRel_ = leftRel; 58 topRel_ = topRel; 59 widthRel_ = widthRel; 60 heightRel_ = heightRel; 61 62 left_ = leftRel_ * windowW_; 63 top_ = topRel_ * windowH_; 64 width_ = widthRel_ * windowW_; 65 height_ = heightRel_ * windowH_; 66 67 setMetricsMode(Ogre::GMM_PIXELS); 68 setPosition(left_,top_); 69 setDimensions(width_,height_); 70 setColour(colour); 64 71 } 65 72 66 73 67 74 void BarOverlayElement::reset(int percentage){ 68 switch(dir_){75 switch(dir_){ 69 76 case 1: 70 71 72 73 74 75 76 77 78 79 80 81 82 83 setDimensions(width_*percentage/100,height_); 84 }77 setPosition(left_,top_); 78 setDimensions(width_,height_*percentage/100); 79 break; 80 case 2: 81 setPosition(left_+width_-width_*percentage/100,top_); 82 setDimensions(width_*percentage/100,height_); 83 break; 84 case 3: 85 setPosition(left_,top_+height_-height_*percentage/100); 86 setDimensions(width_,height_*percentage/100); 87 break; 88 default: 89 setPosition(left_,top_); 90 setDimensions(width_*percentage/100,height_); 91 } 85 92 } 86 87 93 94 88 95 void BarOverlayElement::setColour(int colour){ 89 switch(colour){90 91 92 93 94 95 96 97 98 }96 switch(colour){ 97 case 0: 98 setMaterialName("Orxonox/Red"); 99 break; 100 case 1: 101 setMaterialName("Orxonox/Yellow"); 102 break; 103 case 2: 104 setMaterialName("Orxonox/Green"); 105 } 99 106 } 100 107 … … 103 110 104 111 SmartBarOverlayElement::~SmartBarOverlayElement(void){} 105 106 112 113 107 114 void SmartBarOverlayElement::initialise(){ 108 115 PanelOverlayElement::initialise(); … … 112 119 setMetricsMode(Ogre::GMM_PIXELS); 113 120 */ } 114 121 115 122 void SmartBarOverlayElement::initSmartBarOverlayElement(Real left, Real top, Real width, Real height, int dir) 116 123 { -
code/branches/hud3/src/orxonox/hud/BarOverlayElement.h
r1283 r1314 44 44 { 45 45 private: 46 46 47 47 int percentage_; 48 int dir_; 48 int dir_; 49 49 int left_; 50 50 int top_; 51 51 int width_; 52 52 int height_; 53 Ogre::Real leftRel_; 54 Ogre::Real topRel_; 55 Ogre::Real widthRel_; 56 Ogre::Real heightRel_; 57 int windowW_, windowH_; 53 58 54 59 static Ogre::String& typeName_s; … … 69 74 virtual void initialise(); 70 75 71 void initBarOverlayElement(Real left , Real top, Real width, Real height,76 void initBarOverlayElement(Real leftRel, Real topRel, Real widthRel, Real heightRel, 72 77 int dir, int colour); 73 78 … … 77 82 }; 78 83 79 84 80 85 class _OrxonoxExport SmartBarOverlayElement : public BarOverlayElement 81 86 { … … 83 88 84 89 public: 85 90 86 91 SmartBarOverlayElement(const Ogre::String& name); 87 92 virtual ~SmartBarOverlayElement(void); 88 93 virtual void initialise(); 89 94 90 95 void initSmartBarOverlayElement(Ogre::Real left, Ogre::Real top, Ogre::Real width, Ogre::Real height, int dir); 91 96 void reset(int percentage); 92 97 93 98 }; 94 99 } -
code/branches/hud3/src/orxonox/hud/HUD.cc
r1310 r1314 48 48 49 49 HUD::HUD(int zoom){ 50 51 Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton(); 50 om = &Ogre::OverlayManager::getSingleton(); 52 51 53 52 BarOverlayElementFactory *barOverlayElementFactory = new BarOverlayElementFactory(); 54 o verlayManager.addOverlayElementFactory(barOverlayElementFactory);53 om->addOverlayElementFactory(barOverlayElementFactory); 55 54 56 55 SmartBarOverlayElementFactory *smartBarOverlayElementFactory = new SmartBarOverlayElementFactory(); 57 o verlayManager.addOverlayElementFactory(smartBarOverlayElementFactory);56 om->addOverlayElementFactory(smartBarOverlayElementFactory); 58 57 59 58 RadarOverlayElementFactory *radarOverlayElementFactory = new RadarOverlayElementFactory(); 60 o verlayManager.addOverlayElementFactory(radarOverlayElementFactory);59 om->addOverlayElementFactory(radarOverlayElementFactory); 61 60 62 Ogre::Overlay* orxonoxOverlay = overlayManager.create("Orxonox/HUD");61 orxonoxHUD = om->create("Orxonox/HUD"); 63 62 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")); 65 64 66 energyCounter = static_cast<SmartBarOverlayElement*>(o verlayManager.createOverlayElement("SmartBar", "energyCounter"));67 //energyCounter->show();65 energyCounter = static_cast<SmartBarOverlayElement*>(om->createOverlayElement("SmartBar", "energyCounter")); 66 energyCounter->show(); 68 67 68 speedo = static_cast<SmartBarOverlayElement*>(om->createOverlayElement("SmartBar", "speedo")); 69 speedo->show(); 69 70 70 radar = static_cast<RadarOverlayElement*>(o verlayManager.createOverlayElement("Radar", "radar"));71 radar = static_cast<RadarOverlayElement*>(om->createOverlayElement("Radar", "radar")); 71 72 radar->show(); 72 73 … … 108 109 test->show(); 109 110 test->setMetricsMode(Ogre::GMM_PIXELS); 110 energyCounterPanel->addChild(test);111 container->addChild(test); 111 112 112 113 COUT(0)<<alpha<<" "<<beta<<" "<<right<<std::endl; 113 114 */ 114 115 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(); 118 120 119 orxonox Overlay->add2D(energyCounterPanel);120 orxonox Overlay->show();121 orxonoxHUD->add2D(container); 122 orxonoxHUD->show(); 121 123 122 124 … … 133 135 */ 134 136 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); 140 142 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); 143 145 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); 145 150 146 151 … … 149 154 void HUD::tick(float dt) 150 155 { 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; 151 160 radar->update(); 152 161 /*if (this->ogreNode_) -
code/branches/hud3/src/orxonox/hud/HUD.h
r1308 r1314 36 36 37 37 #include "OrxonoxPrereqs.h" 38 38 #include "objects/SpaceShip.h" 39 39 #include "core/Tickable.h" 40 40 #include "BarOverlayElement.h" … … 44 44 namespace orxonox 45 45 { 46 class _OrxonoxExport HUD : public Tickable 47 { 48 private: 46 class _OrxonoxExport HUD : public Tickable 47 { 48 private: 49 Ogre::OverlayManager* om; 50 Ogre::Overlay* orxonoxHUD; 51 Ogre::OverlayContainer* container; 52 SmartBarOverlayElement* energyCounter; 53 SmartBarOverlayElement* speedo; 54 RadarOverlayElement* radar; 49 55 50 public: 51 HUD(int zoom); 52 ~HUD(); 56 public: 57 HUD(int zoom); 58 ~HUD(); 59 virtual void tick(float); 53 60 54 virtual void tick(float); 55 56 SmartBarOverlayElement* energyCounter; 57 58 RadarOverlayElement* radar; 59 }; 61 }; 60 62 } 61 63 -
code/branches/hud3/src/orxonox/hud/RadarOverlayElement.cc
r1311 r1314 57 57 } 58 58 59 void RadarOverlayElement::initRadarOverlayElement(Real left, Real top, Real dim, Ogre::OverlayContainer* container){ 60 61 windowW = GraphicsEngine::getSingleton().getWindowWidth(); 62 windowH = GraphicsEngine::getSingleton().getWindowHeight(); 63 dim_ = dim*windowH; //convert relative data to absolute 64 left_ = left*windowW-dim_/2; // ... 65 top_ = top*windowH-dim_/2; // ... 59 void RadarOverlayElement::initRadarOverlayElement(Real leftRel, Real topRel, Real dimRel, Ogre::OverlayContainer* container){ 66 60 count_ = 0; 61 dimRel_ = dimRel; 62 leftRel_ = leftRel; 63 topRel_ = topRel; 67 64 container_ = container; 68 65 … … 76 73 setMetricsMode(Ogre::GMM_PIXELS); 77 74 setMaterialName("Orxonox/Radar"); 78 setPosition(left_, top_); 79 setDimensions(dim_,dim_); 75 resize(); 80 76 81 77 om = &Ogre::OverlayManager::getSingleton(); … … 87 83 point->setMetricsMode(Ogre::GMM_PIXELS); 88 84 85 } 86 87 void RadarOverlayElement::resize() { 88 // if window is resized, we must adapt these... 89 windowW_ = GraphicsEngine::getSingleton().getWindowWidth(); 90 windowH_ = GraphicsEngine::getSingleton().getWindowHeight(); 91 dim_ = dimRel_*windowH_; 92 left_ = leftRel_*windowW_-dim_/2; 93 top_ = topRel_*windowH_-dim_/2; 94 setPosition(left_, top_); 95 setDimensions(dim_,dim_); 89 96 } 90 97 … … 99 106 100 107 void RadarOverlayElement::update() { 108 resize(); 101 109 shipPos_ = SpaceShip::instance_s->getPosition(); 102 110 currentDir_ = SpaceShip::instance_s->getOrientation()*initialDir_; // according to beni.... -
code/branches/hud3/src/orxonox/hud/RadarOverlayElement.h
r1310 r1314 48 48 Ogre::PanelOverlayElement* point; 49 49 Ogre::OverlayContainer* container_; 50 Ogre::OverlayManager* om; //pointer to the one and only overlay manager51 Vector3 initialDir_; // direction of nose50 Ogre::OverlayManager* om; // pointer to the one and only overlay manager 51 Vector3 initialDir_; // direction of nose 52 52 Vector3 currentDir_; 53 Vector3 initialOrth_; // direction of normal53 Vector3 initialOrth_; // direction of normal 54 54 Vector3 currentOrth_; 55 Vector3 targetPos_; //position of target56 Vector3 shipPos_; //position of ship55 Vector3 targetPos_; // position of target 56 Vector3 shipPos_; // position of ship 57 57 58 double radius_; //defines the radius on the radar 59 double phi_; //defines the angle on the radar 60 float left_, top_, dim_; 61 bool right_; //checks whether the object is on the right side (since cos is not bijective) 58 Ogre::Real radius_; // radius on the radar 59 Ogre::Real phi_; // angle on the radar 60 bool right_; // checks whether the object is on the right side (since cos is not bijective) 61 Ogre::Real leftRel_, topRel_, dimRel_; // relative position/dimension 62 int left_, top_, dim_; // absolute position/dimension 63 int windowW_, windowH_; // absolute window dimensions 62 64 int count_; 63 int windowW, windowH; 65 66 void resize(); 64 67 65 68 public: … … 69 72 virtual void initialise(); 70 73 void update(); 71 void initRadarOverlayElement(Real left , Real top, Real dim, Ogre::OverlayContainer* container);74 void initRadarOverlayElement(Real leftRel, Real topRel, Real dimRel, Ogre::OverlayContainer* container); 72 75 void setMainShipPosition(int dirX, int dirY, int dirZ, int ortX, int ortY, int ortZ); 73 76 int newShip(int X, int Y, int Z); -
code/branches/hud3/src/orxonox/objects/SpaceShip.cc
r1310 r1314 270 270 camName_=camera; 271 271 // change camera attributes here, if you want to ;) 272 Quaternion q1 = Quaternion(Radian(Degree(90)),Vector3(0,-1,0));273 Quaternion q2 = Quaternion(Radian(Degree(90)),Vector3(0,0,-1));274 //camNode_->setOrientation(q1*q2);275 272 } 276 273 … … 298 295 cam_->setTargetNode(this->getNode()); 299 296 // cam->setPosition(Vector3(0,-350,0)); 297 Quaternion q1 = Quaternion(Radian(Degree(90)),Vector3(0,-1,0)); 298 Quaternion q2 = Quaternion(Radian(Degree(90)),Vector3(0,0,-1)); 299 //camNode_->setOrientation(q1*q2); 300 300 if(network::Client::getSingleton()!=0 && network::Client::getSingleton()->getShipID()==objectID){ 301 301 this->setBacksync(true); … … 448 448 } 449 449 450 float SpaceShip::getMaxSpeed() { return maxSpeed_; } 451 450 452 void SpaceShip::tick(float dt) 451 453 { -
code/branches/hud3/src/orxonox/objects/SpaceShip.h
r1310 r1314 64 64 65 65 void getFocus(); 66 67 68 69 66 static SpaceShip* instance_s; 67 static Vector3 getSPosition(); 68 static Quaternion getSOrientation(); 69 static std::string whereAmI(); 70 70 static void setMaxSpeedTest(float value) 71 71 { SpaceShip::instance_s->setMaxSpeed(value); } … … 77 77 bool mouseScrolled (const MouseState& state) { return true; } 78 78 79 float getMaxSpeed(); 79 80 80 81 private:
Note: See TracChangeset
for help on using the changeset viewer.