Changeset 2087 for code/trunk/src/orxonox/overlays
- Timestamp:
- Nov 1, 2008, 7:04:09 PM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 21 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc
r1755 r2087 44 44 #include "core/XMLPort.h" 45 45 #include "core/ConsoleCommand.h" 46 #include "GraphicsEngine.h"47 46 48 47 namespace orxonox … … 55 54 SetConsoleCommand(OrxonoxOverlay, rotateOverlay, false).accessLevel(AccessLevel::User); 56 55 57 OrxonoxOverlay::OrxonoxOverlay() 58 : overlay_(0) 59 , background_(0) 56 OrxonoxOverlay::OrxonoxOverlay(BaseObject* creator) 57 : BaseObject(creator) 60 58 { 61 59 RegisterObject(OrxonoxOverlay); 60 61 // add this overlay to the static map of OrxonoxOverlays 62 if (overlays_s.find(this->getName()) != overlays_s.end()) 63 { 64 COUT(1) << "Overlay names should be unique or you cannnot access them via console. Name: \"" << this->getName() << "\"" << std::endl; 65 } 66 overlays_s[this->getName()] = this; 67 68 // create the Ogre::Overlay 69 overlay_ = Ogre::OverlayManager::getSingleton().create("OrxonoxOverlay_overlay_" 70 + convertToString(hudOverlayCounter_s++)); 71 72 // create background panel (can be used to show any picture) 73 this->background_ = static_cast<Ogre::PanelOverlayElement*>( 74 Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", 75 "OrxonoxOverlay_background_" + convertToString(hudOverlayCounter_s++))); 76 this->overlay_->add2D(this->background_); 77 78 // We'll have to set the aspect ratio to a default value first. 79 // GSGraphics gets informed about our construction here and can update us in the next tick. 80 this->windowAspectRatio_ = 1.0; 81 this->sizeCorrectionChanged(); 82 83 this->changedVisibility(); 84 85 setSize(Vector2(1.0f, 1.0f)); 86 setPickPoint(Vector2(0.0f, 0.0f)); 87 setPosition(Vector2(0.0f, 0.0f)); 88 setRotation(Degree(0.0)); 89 setAspectCorrection(true); 90 setBackgroundMaterial(""); 62 91 } 63 92 … … 70 99 OrxonoxOverlay::~OrxonoxOverlay() 71 100 { 72 // erase ourself from the map with all overlays 73 std::map<std::string, OrxonoxOverlay*>::iterator it = overlays_s.find(this->getName()); 74 if (it != overlays_s.end()) 75 overlays_s.erase(it); 76 77 if (this->background_) 101 if (this->isInitialized()) 102 { 103 // erase ourself from the map with all overlays 104 std::map<std::string, OrxonoxOverlay*>::iterator it = overlays_s.find(this->getName()); 105 if (it != overlays_s.end()) 106 overlays_s.erase(it); 107 78 108 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->background_); 79 if (this->overlay_)80 109 Ogre::OverlayManager::getSingleton().destroy(this->overlay_); 110 } 81 111 } 82 112 … … 94 124 SUPER(OrxonoxOverlay, XMLPort, xmlElement, mode); 95 125 96 if (mode == XMLPort::LoadObject) 97 { 98 // add this overlay to the static map of OrxonoxOverlays 99 if (overlays_s.find(this->getName()) != overlays_s.end()) 100 { 101 COUT(1) << "Overlay names should be unique or you cannnot access them via console." << std::endl; 102 } 103 overlays_s[this->getName()] = this; 104 105 // create the Ogre::Overlay 106 overlay_ = Ogre::OverlayManager::getSingleton().create("OrxonoxOverlay_overlay_" 107 + convertToString(hudOverlayCounter_s++)); 108 109 // create background panel (can be used to show any picture) 110 this->background_ = static_cast<Ogre::PanelOverlayElement*>( 111 Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", 112 "OrxonoxOverlay_background_" + convertToString(hudOverlayCounter_s++))); 113 this->overlay_->add2D(this->background_); 114 115 // We'll have to get the aspect ratio manually for the first time. Afterwards windowResized() gets 116 // called automatically by the GraphicsEngine. 117 this->windowResized(GraphicsEngine::getInstance().getWindowWidth(), 118 GraphicsEngine::getInstance().getWindowHeight()); 119 120 this->changedVisibility(); 121 } 122 123 XMLPortParam(OrxonoxOverlay, "size", setSize, getSize, xmlElement, mode) 124 .defaultValues(Vector2(1.0f, 1.0f)); 125 XMLPortParam(OrxonoxOverlay, "pickPoint", setPickPoint, getPickPoint, xmlElement, mode) 126 .defaultValues(Vector2(0.0f, 0.0f)); 127 XMLPortParam(OrxonoxOverlay, "position", setPosition, getPosition, xmlElement, mode) 128 .defaultValues(Vector2(0.0f, 0.0f)); 129 XMLPortParam(OrxonoxOverlay, "rotation", setRotation, getRotation, xmlElement, mode) 130 .defaultValues(0.0f); 131 XMLPortParam(OrxonoxOverlay, "correctAspect", setAspectCorrection, getAspectCorrection, xmlElement, mode) 132 .defaultValues(true); 133 XMLPortParam(OrxonoxOverlay, "background", setBackgroundMaterial, getBackgroundMaterial, xmlElement, mode) 134 .defaultValues(""); 126 XMLPortParam(OrxonoxOverlay, "size", setSize, getSize, xmlElement, mode); 127 XMLPortParam(OrxonoxOverlay, "pickPoint", setPickPoint, getPickPoint, xmlElement, mode); 128 XMLPortParam(OrxonoxOverlay, "position", setPosition, getPosition, xmlElement, mode); 129 XMLPortParam(OrxonoxOverlay, "rotation", setRotation, getRotation, xmlElement, mode); 130 XMLPortParam(OrxonoxOverlay, "correctAspect", setAspectCorrection, getAspectCorrection, xmlElement, mode); 131 XMLPortParam(OrxonoxOverlay, "background", setBackgroundMaterial, getBackgroundMaterial, xmlElement, mode); 132 } 133 134 void OrxonoxOverlay::changedName() 135 { 136 OrxonoxOverlay::overlays_s.erase(this->getOldName()); 137 138 if (OrxonoxOverlay::overlays_s.find(this->getName()) != OrxonoxOverlay::overlays_s.end()) 139 COUT(1) << "Overlay names should be unique or you cannnot access them via console. Name: \"" << this->getName() << "\"" << std::endl; 140 141 OrxonoxOverlay::overlays_s[this->getName()] = this; 135 142 } 136 143 … … 148 155 return this->background_->getMaterialName(); 149 156 else 150 return blankString;157 return BLANKSTRING; 151 158 } 152 159 -
code/trunk/src/orxonox/overlays/OrxonoxOverlay.h
r1747 r2087 84 84 85 85 public: 86 OrxonoxOverlay( );86 OrxonoxOverlay(BaseObject* creator); 87 87 virtual ~OrxonoxOverlay(); 88 88 89 89 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); 90 91 virtual void changedName(); 90 92 91 93 //! Shows the overlay with an detour to BaseObject::visibility_ -
code/trunk/src/orxonox/overlays/OverlayGroup.cc
r1854 r2087 50 50 SetConsoleCommand(OverlayGroup, scrollGroup, false).accessLevel(AccessLevel::User); 51 51 52 OverlayGroup::OverlayGroup() 52 OverlayGroup::OverlayGroup(BaseObject* creator) 53 : BaseObject(creator) 53 54 { 54 55 RegisterObject(OverlayGroup); 56 57 setScale(Vector2(1.0, 1.0)); 58 setScroll(Vector2(0.0, 0.0)); 59 } 60 61 OverlayGroup::~OverlayGroup() 62 { 63 for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 64 delete it->second; 55 65 } 56 66 … … 65 75 SUPER(OverlayGroup, XMLPort, xmlElement, mode); 66 76 67 XMLPortParam(OverlayGroup, "scale", setScale, getScale, xmlElement, mode) .defaultValues(Vector2(1.0, 1.0));68 XMLPortParam(OverlayGroup, "scroll", setScroll, getScroll, xmlElement, mode) .defaultValues(Vector2(0.0, 0.0));77 XMLPortParam(OverlayGroup, "scale", setScale, getScale, xmlElement, mode); 78 XMLPortParam(OverlayGroup, "scroll", setScroll, getScroll, xmlElement, mode); 69 79 // loads all the child elements 70 80 XMLPortObject(OverlayGroup, OrxonoxOverlay, "", addElement, getElement, xmlElement, mode); … … 100 110 } 101 111 else 112 { 102 113 hudElements_[element->getName()] = element; 114 element->setVisible(this->isVisible()); 115 } 103 116 } 104 117 -
code/trunk/src/orxonox/overlays/OverlayGroup.h
r1747 r2087 54 54 { 55 55 public: 56 OverlayGroup( );56 OverlayGroup(BaseObject* creator); 57 57 //! Empty destructor. 58 ~OverlayGroup() { }58 ~OverlayGroup(); 59 59 60 60 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); … … 63 63 static void scaleGroup(const std::string& name, float scale); 64 64 static void scrollGroup(const std::string& name, const Vector2& scroll); 65 66 inline const std::map<std::string, OrxonoxOverlay*>& getOverlays() const 67 { return this->hudElements_; } 65 68 66 69 void changedVisibility(); -
code/trunk/src/orxonox/overlays/OverlayText.cc
r1784 r2087 31 31 32 32 #include <OgreOverlayManager.h> 33 #include <OgreTextAreaOverlayElement.h>34 33 #include <OgrePanelOverlayElement.h> 35 34 … … 42 41 CreateFactory(OverlayText); 43 42 44 OverlayText::OverlayText( )45 : text_(0)43 OverlayText::OverlayText(BaseObject* creator) 44 : OrxonoxOverlay(creator) 46 45 { 47 46 RegisterObject(OverlayText); 47 48 this->text_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton() 49 .createOverlayElement("TextArea", "OverlayText_text_" + getUniqueNumberString())); 50 this->text_->setCharHeight(1.0); 51 52 setFont("Monofur"); 53 setColour(ColourValue(1.0, 1.0, 1.0, 1.0)); 54 setCaption(""); 55 setTextSize(1.0f); 56 setAlignmentString("left"); 57 58 this->background_->addChild(this->text_); 48 59 } 49 60 50 61 OverlayText::~OverlayText() 51 62 { 52 if (this-> text_)63 if (this->isInitialized()) 53 64 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->text_); 54 65 } … … 58 69 SUPER(OverlayText, XMLPort, xmlElement, mode); 59 70 60 if (mode == XMLPort::LoadObject) 61 { 62 this->text_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton() 63 .createOverlayElement("TextArea", "OverlayText_text_" + getUniqueNumberStr())); 64 this->text_->setCharHeight(1.0); 65 66 this->background_->addChild(this->text_); 67 } 68 69 XMLPortParam(OverlayText, "font", setFont, getFont, xmlElement, mode).defaultValues("Monofur"); 70 XMLPortParam(OverlayText, "caption", setCaption, getCaption, xmlElement, mode).defaultValues(""); 71 XMLPortParam(OverlayText, "textSize", setTextSize, getTextSize, xmlElement, mode).defaultValues(1.0f); 71 XMLPortParam(OverlayText, "font", setFont, getFont, xmlElement, mode); 72 XMLPortParam(OverlayText, "colour", setColour, getColour, xmlElement, mode); 73 XMLPortParam(OverlayText, "caption", setCaption, getCaption, xmlElement, mode); 74 XMLPortParam(OverlayText, "textSize", setTextSize, getTextSize, xmlElement, mode); 75 XMLPortParam(OverlayText, "align", setAlignmentString, getAlignmentString, xmlElement, mode); 72 76 } 73 77 74 78 void OverlayText::setFont(const std::string& font) 75 79 { 76 if ( this->text_ &&font != "")80 if (font != "") 77 81 this->text_->setFontName(font); 78 82 } 79 83 80 const std::string& OverlayText::getFont() const84 void OverlayText::setAlignmentString(const std::string& alignment) 81 85 { 82 if (this->text_) 83 return this->text_->getFontName(); 84 else 85 return blankString; 86 if (alignment == "right") 87 this->setAlignment(Ogre::TextAreaOverlayElement::Right); 88 else if (alignment == "center") 89 this->setAlignment(Ogre::TextAreaOverlayElement::Center); 90 else // "left" and default 91 this->setAlignment(Ogre::TextAreaOverlayElement::Left); 92 } 93 94 std::string OverlayText::getAlignmentString() const 95 { 96 Ogre::TextAreaOverlayElement::Alignment alignment = this->text_->getAlignment(); 97 98 switch (alignment) 99 { 100 case Ogre::TextAreaOverlayElement::Right: 101 return "right"; 102 case Ogre::TextAreaOverlayElement::Center: 103 return "center"; 104 case Ogre::TextAreaOverlayElement::Left: 105 return "left"; 106 default: 107 assert(false); return ""; 108 } 86 109 } 87 110 88 111 void OverlayText::sizeChanged() 89 112 { 90 if (!this->overlay_)91 return;92 93 113 if (this->rotState_ == Horizontal) 94 114 this->overlay_->setScale(size_.y * sizeCorrection_.y, size_.y * sizeCorrection_.y); -
code/trunk/src/orxonox/overlays/OverlayText.h
r1625 r2087 34 34 #include <string> 35 35 #include <OgrePrerequisites.h> 36 #include <OgreTextAreaOverlayElement.h> 36 37 #include "OrxonoxOverlay.h" 37 38 … … 41 42 { 42 43 public: 43 OverlayText( );44 OverlayText(BaseObject* creator); 44 45 virtual ~OverlayText(); 45 46 46 47 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); 47 48 49 void setCaption(const std::string& caption) { this->text_->setCaption(caption); } 50 std::string getCaption() const { return this->text_->getCaption(); } 51 52 void setFont(const std::string& font); 53 const std::string& getFont() const { return this->text_->getFontName(); } 54 55 void setColour(const ColourValue& colour) { this->text_->setColour(colour); } 56 const ColourValue& getColour() const { return this->text_->getColour(); } 57 58 void setAlignment(Ogre::TextAreaOverlayElement::Alignment alignment) { this->text_->setAlignment(alignment); } 59 Ogre::TextAreaOverlayElement::Alignment getAlignment() const { return this->text_->getAlignment(); } 60 48 61 protected: 49 62 virtual void sizeChanged(); 50 63 51 void setCaption(const std::string& caption) { this->caption_ = caption; } 52 const std::string& getCaption() const { return this->caption_; } 53 54 void setFont(const std::string& font); 55 const std::string& getFont() const; 64 void setAlignmentString(const std::string& alignment); 65 std::string getAlignmentString() const; 56 66 57 67 void setTextSize(float size) { this->setSize(Vector2(size, size)); } … … 59 69 60 70 Ogre::TextAreaOverlayElement* text_; 61 62 private:63 std::string caption_;64 71 }; 65 72 } -
code/trunk/src/orxonox/overlays/console/InGameConsole.cc
r1879 r2087 48 48 #include "core/input/SimpleInputState.h" 49 49 #include "core/input/InputBuffer.h" 50 #include "GraphicsEngine.h"51 50 52 51 namespace orxonox … … 170 169 @brief Initializes the InGameConsole. 171 170 */ 172 void InGameConsole::initialise( )171 void InGameConsole::initialise(int windowWidth, int windowHeight) 173 172 { 174 173 // create the corresponding input state … … 246 245 this->consoleOverlayContainer_->addChild(this->consoleOverlayNoise_); 247 246 248 this->windowResized( GraphicsEngine::getInstance().getWindowWidth(), GraphicsEngine::getInstance().getWindowHeight());247 this->windowResized(windowWidth, windowHeight); 249 248 250 249 // move overlay "above" the top edge of the screen … … 613 612 @return The converted string 614 613 */ 615 /*static*/ Ogre::UTFString InGameConsole::convert2UTF( std::string s)614 /*static*/ Ogre::UTFString InGameConsole::convert2UTF(const std::string& text) 616 615 { 617 616 Ogre::UTFString utf; 618 617 Ogre::UTFString::code_point cp; 619 for (unsigned int i = 0; i < s.size(); ++i)620 { 621 cp = s[i];618 for (unsigned int i = 0; i < text.size(); ++i) 619 { 620 cp = text[i]; 622 621 cp &= 0xFF; 623 622 utf.append(1, cp); -
code/trunk/src/orxonox/overlays/console/InGameConsole.h
r1879 r2087 49 49 ~InGameConsole(); 50 50 51 void initialise( );51 void initialise(int windowWidth, int windowHeight); 52 52 void destroy(); 53 53 void setConfigValues(); … … 60 60 static void openConsole(); 61 61 static void closeConsole(); 62 63 static Ogre::UTFString convert2UTF(const std::string& text); 62 64 63 65 private: // functions … … 83 85 // config value related 84 86 void bHidesAllInputChanged(); 85 86 static Ogre::UTFString convert2UTF(std::string s);87 87 88 88 private: // variables -
code/trunk/src/orxonox/overlays/debug/DebugFPSText.cc
r1755 r2087 38 38 CreateFactory(DebugFPSText); 39 39 40 DebugFPSText::DebugFPSText( )40 DebugFPSText::DebugFPSText(BaseObject* creator) : OverlayText(creator) 41 41 { 42 42 RegisterObject(DebugFPSText); … … 50 50 { 51 51 float fps = GraphicsEngine::getInstance().getAverageFramesPerSecond(); 52 this-> text_->setCaption(this->getCaption() +convertToString(fps));52 this->setCaption(convertToString(fps)); 53 53 } 54 54 } -
code/trunk/src/orxonox/overlays/debug/DebugFPSText.h
r1747 r2087 40 40 { 41 41 public: 42 DebugFPSText( );42 DebugFPSText(BaseObject* creator); 43 43 ~DebugFPSText(); 44 44 -
code/trunk/src/orxonox/overlays/debug/DebugRTRText.cc
r1755 r2087 38 38 CreateFactory(DebugRTRText); 39 39 40 DebugRTRText::DebugRTRText( )40 DebugRTRText::DebugRTRText(BaseObject* creator) : OverlayText(creator) 41 41 { 42 42 RegisterObject(DebugRTRText); … … 50 50 { 51 51 float rtr = GraphicsEngine::getInstance().getAverageTickTime(); 52 this-> text_->setCaption(this->getCaption() +convertToString(rtr));52 this->setCaption(convertToString(rtr)); 53 53 } 54 54 } -
code/trunk/src/orxonox/overlays/debug/DebugRTRText.h
r1747 r2087 40 40 { 41 41 public: 42 DebugRTRText( );42 DebugRTRText(BaseObject* creator); 43 43 ~DebugRTRText(); 44 44 -
code/trunk/src/orxonox/overlays/hud/HUDBar.cc
r1854 r2087 38 38 39 39 #include "util/Convert.h" 40 #include "util/String.h" 40 41 #include "core/CoreIncludes.h" 41 42 #include "core/XMLPort.h" … … 45 46 CreateFactory(BarColour); 46 47 47 BarColour::BarColour( )48 : position_(0.0)48 BarColour::BarColour(BaseObject* creator) 49 : BaseObject(creator) 49 50 { 50 51 RegisterObject(BarColour); 52 53 setColour(ColourValue(1.0, 1.0, 1.0, 1.0)); 54 setPosition(0.0); 51 55 } 52 56 … … 55 59 SUPER(BarColour, XMLPort, xmlElement, mode); 56 60 57 XMLPortParam(BarColour, "colour", setColour, getColour, xmlElement, mode) 58 .defaultValues(ColourValue(1.0, 1.0, 1.0, 1.0)); 59 XMLPortParam(BarColour, "position", setPosition, getPosition, xmlElement, mode).defaultValues(0.0f); 61 XMLPortParam(BarColour, "colour", setColour, getColour, xmlElement, mode); 62 XMLPortParam(BarColour, "position", setPosition, getPosition, xmlElement, mode); 60 63 } 61 64 … … 63 66 unsigned int HUDBar::materialcount_s = 0; 64 67 65 HUDBar::HUDBar() 66 : bar_(0) 67 , textureUnitState_(0) 68 HUDBar::HUDBar(BaseObject* creator) 69 : OrxonoxOverlay(creator) 68 70 { 69 71 RegisterObject(HUDBar); 72 73 // create new material 74 std::string materialname = "barmaterial" + getConvertedValue<unsigned int, std::string>(materialcount_s++); 75 Ogre::MaterialPtr material = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().create(materialname, "General"); 76 material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA); 77 this->textureUnitState_ = material->getTechnique(0)->getPass(0)->createTextureUnitState(); 78 this->textureUnitState_->setTextureName("bar2.tga"); 79 // use the default colour 80 this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, ColourValue(0.2, 0.7, 0.2)); 81 82 this->bar_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 83 .createOverlayElement("Panel", "HUDBar_bar_" + getUniqueNumberString())); 84 this->bar_->setMaterialName(materialname); 85 86 setValue(0.4567654f); 87 setRightToLeft(false); 88 setAutoColour(true); 89 90 this->background_->addChild(bar_); 70 91 } 71 92 72 93 HUDBar::~HUDBar() 73 94 { 74 if (this-> bar_)95 if (this->isInitialized()) 75 96 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->bar_); 76 97 } … … 80 101 SUPER(HUDBar, XMLPort, xmlElement, mode); 81 102 82 if (mode == XMLPort::LoadObject) 83 { 84 // create new material 85 std::string materialname = "barmaterial" + getConvertedValue<unsigned int, std::string>(materialcount_s++); 86 Ogre::MaterialPtr material = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().create(materialname, "General"); 87 material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA); 88 this->textureUnitState_ = material->getTechnique(0)->getPass(0)->createTextureUnitState(); 89 this->textureUnitState_->setTextureName("bar2.tga"); 90 // use the default colour 91 this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, ColourValue(0.2, 0.7, 0.2)); 92 93 this->bar_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 94 .createOverlayElement("Panel", "HUDBar_bar_" + getUniqueNumberStr())); 95 this->bar_->setMaterialName(materialname); 96 this->background_->addChild(bar_); 97 } 98 99 XMLPortParam(HUDBar, "initialValue", setValue, getValue, xmlElement, mode).defaultValues(0.4567654f); 100 XMLPortParam(HUDBar, "rightToLeft", setRightToLeft, getRightToLeft, xmlElement, mode).defaultValues(false); 101 XMLPortParam(HUDBar, "autoColour", setAutoColour, getAutoColour, xmlElement, mode).defaultValues(true); 103 XMLPortParam(HUDBar, "initialValue", setValue, getValue, xmlElement, mode); 104 XMLPortParam(HUDBar, "rightToLeft", setRightToLeft, getRightToLeft, xmlElement, mode); 105 XMLPortParam(HUDBar, "autoColour", setAutoColour, getAutoColour, xmlElement, mode); 102 106 XMLPortObject(HUDBar, BarColour, "", addColour, getColour, xmlElement, mode); 103 107 } -
code/trunk/src/orxonox/overlays/hud/HUDBar.h
r1747 r2087 44 44 { 45 45 public: 46 BarColour( );46 BarColour(BaseObject* creator); 47 47 ~BarColour() { } 48 48 … … 64 64 { 65 65 public: 66 HUDBar( );66 HUDBar(BaseObject* creator); 67 67 virtual ~HUDBar(); 68 68 -
code/trunk/src/orxonox/overlays/hud/HUDNavigation.cc
r1819 r2087 41 41 #include "core/XMLPort.h" 42 42 #include "objects/Radar.h" 43 #include "objects/SpaceShip.h"44 #include "objects/Projectile.h"45 #include "objects/CameraHandler.h"46 43 47 44 namespace orxonox … … 49 46 CreateFactory(HUDNavigation); 50 47 51 HUDNavigation::HUDNavigation() 52 : navMarker_(0) 53 , aimMarker_(0) 54 , navText_(0) 48 HUDNavigation::HUDNavigation(BaseObject* creator) 49 : OrxonoxOverlay(creator) 55 50 { 56 51 RegisterObject(HUDNavigation); 52 53 // create nav text 54 navText_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton() 55 .createOverlayElement("TextArea", "HUDNavigation_navText_" + getUniqueNumberString())); 56 57 // create nav marker 58 navMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 59 .createOverlayElement("Panel", "HUDNavigation_navMarker_" + getUniqueNumberString())); 60 navMarker_->setMaterialName("Orxonox/NavArrows"); 61 62 // create aim marker 63 aimMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 64 .createOverlayElement("Panel", "HUDNavigation_aimMarker_" + getUniqueNumberString())); 65 aimMarker_->setMaterialName("Orxonox/NavCrosshair"); 66 this->wasOutOfView_ = true; // Ensure the material is changed right the first time.. 67 68 setFont("Monofur"); 69 setTextSize(0.05f); 70 setNavMarkerSize(0.05f); 71 setAimMarkerSize(0.04f); 72 73 background_->addChild(navMarker_); 74 background_->addChild(aimMarker_); 75 background_->addChild(navText_); 76 77 // hide at first 78 this->setVisible(false); 57 79 } 58 80 59 81 HUDNavigation::~HUDNavigation() 60 82 { 61 if (this->navMarker_) 83 if (this->isInitialized()) 84 { 62 85 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->navMarker_); 63 if (this->navText_)64 86 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->navText_); 65 if (this->aimMarker_)66 87 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->aimMarker_); 88 } 67 89 } 68 90 … … 71 93 SUPER(HUDNavigation, XMLPort, xmlElement, mode); 72 94 73 if (mode == XMLPort::LoadObject) 74 { 75 // create nav text 76 navText_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton() 77 .createOverlayElement("TextArea", "HUDNavigation_navText_" + getUniqueNumberStr())); 78 79 // create nav marker 80 navMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 81 .createOverlayElement("Panel", "HUDNavigation_navMarker_" + getUniqueNumberStr())); 82 navMarker_->setMaterialName("Orxonox/NavArrows"); 83 wasOutOfView_ = true; // just to ensure the material is changed right the first time.. 84 85 // create aim marker 86 aimMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 87 .createOverlayElement("Panel", "HUDNavigation_aimMarker_" + getUniqueNumberStr())); 88 aimMarker_->setMaterialName("Orxonox/NavCrosshair"); 89 90 background_->addChild(navMarker_); 91 background_->addChild(aimMarker_); 92 background_->addChild(navText_); 93 94 // hide at first 95 this->setVisible(false); 96 } 97 98 XMLPortParam(HUDNavigation, "font", setFont, getFont, xmlElement, mode).defaultValues("Monofur"); 99 XMLPortParam(HUDNavigation, "textSize", setTextSize, getTextSize, xmlElement, mode).defaultValues(0.05f); 100 XMLPortParam(HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlElement, mode) 101 .defaultValues(0.05f); 102 XMLPortParam(HUDNavigation, "aimMarkerSize", setAimMarkerSize, getAimMarkerSize, xmlElement, mode) 103 .defaultValues(0.04f); 95 XMLPortParam(HUDNavigation, "font", setFont, getFont, xmlElement, mode); 96 XMLPortParam(HUDNavigation, "textSize", setTextSize, getTextSize, xmlElement, mode); 97 XMLPortParam(HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlElement, mode); 98 XMLPortParam(HUDNavigation, "aimMarkerSize", setAimMarkerSize, getAimMarkerSize, xmlElement, mode); 104 99 } 105 100 … … 115 110 return this->navText_->getFontName(); 116 111 else 117 return blankString;112 return BLANKSTRING; 118 113 } 119 114 … … 149 144 float textLength = convertToString(dist).size() * navText_->getCharHeight() * 0.3; 150 145 146 /* 151 147 Ogre::Camera* navCam = SpaceShip::getLocalShip()->getCamera()->cam_; 152 148 Matrix4 transformationMatrix = navCam->getProjectionMatrix() * navCam->getViewMatrix(); 149 */ 153 150 // transform to screen coordinates 154 Vector3 pos = transformationMatrix *Radar::getInstance().getFocus()->getWorldPosition();151 Vector3 pos = /*transformationMatrix * */Radar::getInstance().getFocus()->getWorldPosition(); 155 152 156 153 bool outOfView; … … 224 221 { 225 222 // object is in view 226 223 /* 227 224 Vector3 aimpos = transformationMatrix * getPredictedPosition(SpaceShip::getLocalShip()->getPosition(), 228 225 Projectile::getSpeed(), Radar::getInstance().getFocus()->getWorldPosition(), Radar::getInstance().getFocus()->getOrientedVelocity()); 229 226 */ 230 227 if (wasOutOfView_) 231 228 { … … 240 237 241 238 aimMarker_->show(); 239 /* 242 240 aimMarker_->setLeft((aimpos.x + 1.0 - aimMarker_->getWidth()) * 0.5); 243 241 aimMarker_->setTop((-aimpos.y + 1.0 - aimMarker_->getHeight()) * 0.5); 244 242 */ 245 243 navText_->setLeft((pos.x + 1.0 + navMarker_->getWidth()) * 0.5); 246 244 navText_->setTop((-pos.y + 1.0 + navMarker_->getHeight()) * 0.5); … … 250 248 float HUDNavigation::getDist2Focus() const 251 249 { 250 /* 252 251 if (Radar::getInstance().getFocus()) 253 252 return (Radar::getInstance().getFocus()->getWorldPosition() - SpaceShip::getLocalShip()->getPosition()).length(); 254 253 else 254 */ 255 255 return 0; 256 256 } -
code/trunk/src/orxonox/overlays/hud/HUDNavigation.h
r1747 r2087 41 41 { 42 42 public: 43 HUDNavigation( );43 HUDNavigation(BaseObject* creator); 44 44 ~HUDNavigation(); 45 45 -
code/trunk/src/orxonox/overlays/hud/HUDRadar.cc
r1819 r2087 35 35 36 36 #include "util/Math.h" 37 #include "util/String.h" 37 38 #include "core/ConsoleCommand.h" 38 39 #include "core/CoreIncludes.h" 39 40 #include "core/XMLPort.h" 40 #include "objects/SpaceShip.h"41 #include "objects/WorldEntity.h"42 41 #include "objects/Radar.h" 43 42 #include "tools/TextureGenerator.h" … … 47 46 CreateFactory(HUDRadar); 48 47 49 HUDRadar::HUDRadar( )50 : marker_(0)48 HUDRadar::HUDRadar(BaseObject* creator) 49 : OrxonoxOverlay(creator) 51 50 { 52 51 RegisterObject(HUDRadar); 52 53 marker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 54 .createOverlayElement("Panel", "HUDRadar_marker_" + getUniqueNumberString())); 55 marker_->setMaterialName("Orxonox/RadarMarker"); 56 overlay_->add2D(marker_); 57 marker_->hide(); 58 59 setRadarSensitivity(1.0f); 60 setHalfDotSizeDistance(3000.0f); 61 setMaximumDotSize(0.1f); 62 63 shapeMaterials_[RadarViewable::Dot] = "RadarSquare.tga"; 64 shapeMaterials_[RadarViewable::Triangle] = "RadarSquare.tga"; 65 shapeMaterials_[RadarViewable::Square] = "RadarSquare.tga"; 53 66 } 54 67 55 68 HUDRadar::~HUDRadar() 56 69 { 57 if (this->marker_) 70 if (this->isInitialized()) 71 { 58 72 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->marker_); 59 for (std::vector<Ogre::PanelOverlayElement*>::iterator it = this->radarDots_.begin(); 60 it != this->radarDots_.end(); ++it) 61 { 62 Ogre::OverlayManager::getSingleton().destroyOverlayElement(*it); 73 for (std::vector<Ogre::PanelOverlayElement*>::iterator it = this->radarDots_.begin(); 74 it != this->radarDots_.end(); ++it) 75 { 76 Ogre::OverlayManager::getSingleton().destroyOverlayElement(*it); 77 } 63 78 } 64 79 } … … 68 83 SUPER(HUDRadar, XMLPort, xmlElement, mode); 69 84 70 if (mode == XMLPort::LoadObject) 71 { 72 marker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 73 .createOverlayElement("Panel", "HUDRadar_marker_" + getUniqueNumberStr())); 74 marker_->setMaterialName("Orxonox/RadarMarker"); 75 overlay_->add2D(marker_); 76 marker_->hide(); 77 } 78 79 XMLPortParam(HUDRadar, "sensitivity", setRadarSensitivity, getRadarSensitivity, xmlElement, mode) 80 .defaultValues(1.0f); 81 XMLPortParam(HUDRadar, "halfDotSizeDistance", setHalfDotSizeDistance, getHalfDotSizeDistance, 82 xmlElement, mode).defaultValues(3000.0f); 83 XMLPortParam(HUDRadar, "maximumDotSize", setMaximumDotSize, getMaximumDotSize, xmlElement, mode) 84 .defaultValues(0.1f); 85 86 shapeMaterials_[RadarViewable::Dot] = "RadarSquare.tga"; 87 shapeMaterials_[RadarViewable::Triangle] = "RadarSquare.tga"; 88 shapeMaterials_[RadarViewable::Square] = "RadarSquare.tga"; 85 XMLPortParam(HUDRadar, "sensitivity", setRadarSensitivity, getRadarSensitivity, xmlElement, mode); 86 XMLPortParam(HUDRadar, "halfDotSizeDistance", setHalfDotSizeDistance, getHalfDotSizeDistance, xmlElement, mode); 87 XMLPortParam(HUDRadar, "maximumDotSize", setMaximumDotSize, getMaximumDotSize, xmlElement, mode); 89 88 } 90 89 91 90 void HUDRadar::displayObject(RadarViewable* object, bool bIsMarked) 92 91 { 92 /* 93 93 const WorldEntity* wePointer = object->getWorldEntity(); 94 94 … … 100 100 return; 101 101 } 102 102 */ 103 103 // try to find a panel already created 104 104 Ogre::PanelOverlayElement* panel; … … 108 108 // we have to create a new entry 109 109 panel = static_cast<Ogre::PanelOverlayElement*>( 110 Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "RadarDot" + getUniqueNumberStr ()));110 Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "RadarDot" + getUniqueNumberString())); 111 111 radarDots_.push_back(panel); 112 112 // get right material … … 126 126 } 127 127 panel->show(); 128 128 /* 129 129 // set size to fit distance... 130 130 float distance = (wePointer->getWorldPosition() - SpaceShip::getLocalShip()->getPosition()).length(); … … 144 144 this->marker_->setPosition((1.0 + coord.x - size * 1.5) * 0.5, (1.0 - coord.y - size * 1.5) * 0.5); 145 145 } 146 */ 146 147 } 147 148 -
code/trunk/src/orxonox/overlays/hud/HUDRadar.h
r1819 r2087 45 45 { 46 46 public: 47 HUDRadar( );47 HUDRadar(BaseObject* creator); 48 48 ~HUDRadar(); 49 49 -
code/trunk/src/orxonox/overlays/hud/HUDSpeedBar.cc
r1755 r2087 31 31 #include "HUDSpeedBar.h" 32 32 #include "core/CoreIncludes.h" 33 #include "objects/SpaceShip.h"34 33 35 34 namespace orxonox … … 37 36 CreateFactory(HUDSpeedBar); 38 37 39 HUDSpeedBar::HUDSpeedBar() 38 HUDSpeedBar::HUDSpeedBar(BaseObject* creator) 39 : HUDBar(creator) 40 40 { 41 41 RegisterObject(HUDSpeedBar); … … 49 49 void HUDSpeedBar::tick(float dt) 50 50 { 51 /* 51 52 SpaceShip* ship = SpaceShip::getLocalShip(); 52 53 if (ship) … … 57 58 this->setValue(value); 58 59 } 60 */ 59 61 } 60 62 } -
code/trunk/src/orxonox/overlays/hud/HUDSpeedBar.h
r1747 r2087 41 41 { 42 42 public: 43 HUDSpeedBar( );43 HUDSpeedBar(BaseObject* creator); 44 44 ~HUDSpeedBar(); 45 45
Note: See TracChangeset
for help on using the changeset viewer.