Changeset 11584 for code/branches/CampaignMap_HS17/src/modules/overlays/hud
- Timestamp:
- Nov 20, 2017, 5:01:46 PM (7 years ago)
- Location:
- code/branches/CampaignMap_HS17/src/modules/overlays/hud
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/CampaignMap_HS17/src/modules/overlays/hud/StoryModeHUD.cc
r11564 r11584 44 44 #include <typeinfo> 45 45 46 #include "util/Math.h"47 46 #include "util/Convert.h" 48 47 #include "core/command/ConsoleCommandIncludes.h" … … 50 49 #include "core/XMLPort.h" 51 50 #include "CameraManager.h" 52 #include "Scene.h"53 #include "Radar.h"54 51 #include "graphics/Camera.h" 55 #include "controllers/HumanController.h"56 52 #include "worldentities/pawns/Pawn.h" 57 53 #include "worldentities/WorldEntity.h" … … 59 55 #include "tools/TextureGenerator.h" 60 56 57 #include "worldentities/StoryModePlanet.h" 61 58 62 59 namespace orxonox … … 68 65 { 69 66 RegisterObject(StoryModeHUD); 70 71 // Set default values 72 //this->setFont("Monofur"); 73 //this->setTextSize(0.5f); 74 75 // Scales used for dimensions and text size 76 float xScale = this->getActualSize().x; 77 float yScale = this->getActualSize().y; 78 79 // Create text 80 text_ = static_cast<Ogre::TextAreaOverlayElement*>( Ogre::OverlayManager::getSingleton() 81 .createOverlayElement("TextArea", "StoryModeHUD_navText_" + getUniqueNumberString())); 82 //text->setFontName(this->fontName_); 83 //text->setCharHeight(this->textSize_ * yScale); 84 text_->setDimensions(xScale, yScale); 85 86 text_->hide(); 87 88 this->background_->addChild(text_); 67 this->initialize(); 89 68 } 90 69 91 // TODO:92 70 // Destructor of the StoryMode HUD 93 71 StoryModeHUD::~StoryModeHUD() 94 72 { 95 73 for(Ogre::TextAreaOverlayElement* text : texts) 74 delete text; 96 75 } 97 76 … … 107 86 } 108 87 88 void StoryModeHUD::initialize(){ 89 // Scales used for dimensions and text size 90 float xScale = this->getActualSize().x; 91 float yScale = this->getActualSize().y; 92 93 94 for(unsigned int i = 0; i < ObjectList<StoryModePlanet>().size(); i++){ 95 96 Ogre::TextAreaOverlayElement* text = static_cast<Ogre::TextAreaOverlayElement*>( Ogre::OverlayManager::getSingleton() 97 .createOverlayElement("TextArea", "StoryModeHUD_navText_" + getUniqueNumberString())); 98 99 texts.push_back(text); 100 //text->setFontName(this->fontName_); 101 //text->setCharHeight(this->textSize_ * yScale); 102 texts[i]->setDimensions(xScale, yScale); 103 104 texts[i]->hide(); 105 106 this->background_->addChild(texts[i]); 107 } 108 //this->setFont("Monofur"); 109 //this->setTextSize("0.5f"); 110 } 111 109 112 // Set the Font size of the Text. 110 113 void StoryModeHUD::setFont(const std::string& font) … … 117 120 } 118 121 this->fontName_ = font; 119 if(text_ != nullptr) 120 text_->setFontName(this->fontName_); 122 for(Ogre::TextAreaOverlayElement* text : texts) 123 if(text != nullptr) 124 text->setFontName(this->fontName_); 121 125 } 122 126 … … 158 162 const Matrix4& camTransform = cam->getOgreCamera()->getProjectionMatrix() * cam->getOgreCamera()->getViewMatrix(); 159 163 164 int i = 0; 165 for(StoryModePlanet* planet : ObjectList<StoryModePlanet>()){ 160 166 161 //display name next to cursor 162 //TODO: Planet.getName() 163 text_->setCaption("Hello Muthafuckin' World!"); 167 //display name next to cursor 168 texts[i]->setCaption(planet->getLevelName()); 164 169 165 // Transform to screen coordinates166 Vector3 pos = camTransform * Vector3(0,0,0); // planet->getRVWorldPosition();170 // Transform to screen coordinates 171 Vector3 pos = camTransform * planet->getWorldPosition(); 167 172 168 // If you fly passed the description, it gets out of sight 169 if (pos.z > 1.0) 170 return; 171 172 // Position text 173 text_->setLeft((pos.x+1)/2); // The (0,0) Coordinate is in the upper left corner. 174 text_->setTop((-pos.y+1)/2); // With those two calculations we set the desired positions 173 // If you fly passed the description, it gets out of sight 174 if (!(pos.z > 1.0)){ 175 176 // Position text 177 texts[i]->setLeft((pos.x+1)/2); // The (0,0) Coordinate is in the upper left corner. 178 texts[i]->setTop((-pos.y+1)/2); // With those two calculations we set the desired positions 175 179 176 // Make sure the overlays are shown 177 text_->show(); 180 // Make sure the overlays are shown 181 texts[i]->show(); 182 } 183 i++; 178 184 185 } 179 186 } 180 181 //void StoryModeHUD::addObject()182 183 /*void StoryModeHUD::removeObject(RadarViewable* viewable)184 {185 Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second.text_);186 }*/187 187 } -
code/branches/CampaignMap_HS17/src/modules/overlays/hud/StoryModeHUD.h
r11564 r11584 52 52 53 53 private: 54 Ogre::TextAreaOverlayElement* text_;55 54 std::vector<Ogre::TextAreaOverlayElement*> texts; 55 void initialize(); 56 56 void setTextSize(float size); 57 57 float getTextSize() const; … … 60 60 const std::string& getFont() const; 61 61 62 63 62 std::string fontName_; 64 63 float textSize_;
Note: See TracChangeset
for help on using the changeset viewer.