Changeset 1615 for code/branches/hud/src
- Timestamp:
- Jun 22, 2008, 12:06:55 AM (16 years ago)
- Location:
- code/branches/hud/src
- Files:
-
- 21 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
code/branches/hud/src/orxonox/CMakeLists.txt
r1613 r1615 4 4 Orxonox.cc 5 5 Radar.cc 6 RadarListener.cc 6 7 RadarViewable.cc 7 8 Settings.cc … … 9 10 overlays/OrxonoxOverlay.cc 10 11 overlays/OverlayGroup.cc 12 overlays/OverlayText.cc 11 13 12 14 overlays/console/InGameConsole.cc … … 18 20 overlays/hud/HUDRTRText.cc 19 21 overlays/hud/HUDSpeedBar.cc 20 overlays/hud/HUDText.cc21 overlays/hud/HUDRadar.cc22 22 23 23 tolua/tolua_bind.cc -
code/branches/hud/src/orxonox/RadarListener.h
r1614 r1615 42 42 43 43 virtual void displayObject(RadarViewable* viewable, bool bIsMarked) = 0; 44 virtual float getRadarSensitivity() = 0;44 virtual float getRadarSensitivity() const = 0; 45 45 virtual void radarTick(float dt) = 0; 46 46 }; -
code/branches/hud/src/orxonox/overlays/OrxonoxOverlay.cc
r1614 r1615 30 30 #include "OrxonoxOverlay.h" 31 31 32 #include <cmath> 32 33 #include <OgreOverlayManager.h> 33 34 #include <OgrePanelOverlayElement.h> 34 35 #include "util/Convert.h" 36 #include "util/String.h" 35 37 #include "core/CoreIncludes.h" 36 38 #include "GraphicsEngine.h" … … 38 40 namespace orxonox 39 41 { 40 unsigned int OrxonoxOverlay::hudOverlayCounter_s = 0; 41 42 OrxonoxOverlay::OrxonoxOverlay() 43 : overlay_(0) 44 , background_(0) 45 , windowAspectRatio_(1.0f) 46 , bCorrectAspect_(false) 47 , size_(1.0f, 1.0f) 48 , sizeCorrection_(1.0f, 1.0f) 49 , angle_(0.0f) 50 , position_(0.0f, 0.0f) 51 , origin_(0.0f, 0.0f) 52 { 53 RegisterObject(OrxonoxOverlay); 54 } 55 56 OrxonoxOverlay::~OrxonoxOverlay() 57 { 58 if (this->background_) 59 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->background_); 60 } 61 62 void OrxonoxOverlay::XMLPort(Element& xmlElement, XMLPort::Mode mode) 63 { 64 BaseObject::XMLPort(xmlElement, mode); 65 66 if (mode == XMLPort::LoadObject) 67 { 68 overlay_ = Ogre::OverlayManager::getSingleton().create("OrxonoxOverlay" 69 + convertToString(hudOverlayCounter_s++) + "_" + this->getName()); 70 71 this->windowResized(GraphicsEngine::getSingleton().getWindowWidth(), 72 GraphicsEngine::getSingleton().getWindowHeight()); 73 74 // create background 75 this->background_ = static_cast<Ogre::PanelOverlayElement*>( 76 Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", getUniqueNumberStr() + "_Background")); 77 this->overlay_->add2D(this->background_); 78 } 79 80 XMLPortParam(OrxonoxOverlay, "correctAspect", setAspectCorrection, getAspectCorrection, xmlElement, mode); 81 XMLPortParam(OrxonoxOverlay, "size", setSize, getUncorrectedSize, xmlElement, mode); 82 XMLPortParam(OrxonoxOverlay, "rotation", setRotation, getRotation, xmlElement, mode); 83 XMLPortParam(OrxonoxOverlay, "origin", setOrigin, getOrigin, xmlElement, mode); 84 XMLPortParam(OrxonoxOverlay, "position", setPosition, getPosition, xmlElement, mode); 85 XMLPortParam(OrxonoxOverlay, "background", setBackgroundMaterial, getBackgroundMaterial, xmlElement, mode); 86 87 if (mode == XMLPort::LoadObject) 88 { 89 this->overlay_->show(); 90 if (!this->isVisible()) 91 this->overlay_->hide(); 92 93 this->sizeChanged(); 94 this->positionChanged(); 95 this->angleChanged(); 96 } 97 } 98 99 void OrxonoxOverlay::setBackgroundMaterial(const std::string& material) 100 { 101 if (this->background_ && material != "") 102 this->background_->setMaterialName(material); 103 } 104 105 std::string OrxonoxOverlay::getBackgroundMaterial() const 106 { 107 if (this->background_) 108 return this->background_->getMaterialName(); 109 else 110 return ""; 111 } 112 113 void OrxonoxOverlay::changedVisibility() 114 { 115 if (this->overlay_) 116 { 117 if (this->isVisible()) 118 this->overlay_->show(); 119 else 120 this->overlay_->hide(); 121 } 122 } 123 124 void OrxonoxOverlay::windowResized(int newWidth, int newHeight) 125 { 126 this->windowAspectRatio_ = newWidth/(float)newHeight; 127 128 this->setAspectCorrection(this->bCorrectAspect_); 129 } 130 131 void OrxonoxOverlay::setAspectCorrection(bool val) 132 { 133 if (val) 134 { 135 // note: this is only an approximation that is mostly valid when the 136 // magnitude of the width is about the magnitude of the height. 137 // Correctly we would have to take the square root of width*height 138 this->sizeCorrection_.x = 2.0 / (this->windowAspectRatio_ + 1.0); 139 this->sizeCorrection_.y = this->windowAspectRatio_ * this->sizeCorrection_.x; 140 } 141 else 142 { 143 this->sizeCorrection_ = Vector2::UNIT_SCALE; 144 } 145 146 this->bCorrectAspect_ = val; 147 this->sizeChanged(); 148 } 149 150 /** 42 unsigned int OrxonoxOverlay::hudOverlayCounter_s = 0; 43 std::map<std::string, OrxonoxOverlay*> OrxonoxOverlay::overlays_s; 44 45 SetConsoleCommand(OrxonoxOverlay, scaleOverlay, false).setAccessLevel(AccessLevel::User); 46 SetConsoleCommand(OrxonoxOverlay, scrollOverlay, false).setAccessLevel(AccessLevel::User); 47 SetConsoleCommand(OrxonoxOverlay, rotateOverlay, false).setAccessLevel(AccessLevel::User); 48 49 OrxonoxOverlay::OrxonoxOverlay() 50 : overlay_(0) 51 , background_(0) 52 , windowAspectRatio_(1.0f) 53 , bCorrectAspect_(false) 54 , size_(1.0f, 1.0f) 55 , sizeCorrection_(1.0f, 1.0f) 56 , angle_(0.0f) 57 , position_(0.0f, 0.0f) 58 , origin_(0.0f, 0.0f) 59 { 60 RegisterObject(OrxonoxOverlay); 61 } 62 63 OrxonoxOverlay::~OrxonoxOverlay() 64 { 65 if (this->background_) 66 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->background_); 67 68 std::map<std::string, OrxonoxOverlay*>::iterator it = overlays_s.find(this->getName()); 69 if (it != overlays_s.end()) 70 overlays_s.erase(it); 71 } 72 73 void OrxonoxOverlay::XMLPort(Element& xmlElement, XMLPort::Mode mode) 74 { 75 BaseObject::XMLPort(xmlElement, mode); 76 77 if (mode == XMLPort::LoadObject) 78 { 79 if (overlays_s.find(this->getName()) != overlays_s.end()) 80 { 81 COUT(1) << "Overlay names should be unique or you cannnot access them via console." << std::endl; 82 } 83 overlays_s[this->getName()] = this; 84 85 overlay_ = Ogre::OverlayManager::getSingleton().create("OrxonoxOverlay_overlay_" 86 + convertToString(hudOverlayCounter_s++)); 87 88 // create background 89 this->background_ = static_cast<Ogre::PanelOverlayElement*>( 90 Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", 91 "OrxonoxOverlay_background_" + convertToString(hudOverlayCounter_s++))); 92 this->overlay_->add2D(this->background_); 93 94 this->windowResized(GraphicsEngine::getSingleton().getWindowWidth(), 95 GraphicsEngine::getSingleton().getWindowHeight()); 96 } 97 98 XMLPortParam(OrxonoxOverlay, "correctAspect", setAspectCorrection, getAspectCorrection, xmlElement, mode); 99 XMLPortParam(OrxonoxOverlay, "size", setSize, getUncorrectedSize, xmlElement, mode); 100 XMLPortParam(OrxonoxOverlay, "rotation", setRotation, getRotation, xmlElement, mode); 101 XMLPortParam(OrxonoxOverlay, "origin", setOrigin, getOrigin, xmlElement, mode); 102 XMLPortParam(OrxonoxOverlay, "position", setPosition, getPosition, xmlElement, mode); 103 XMLPortParam(OrxonoxOverlay, "background", setBackgroundMaterial, getBackgroundMaterial, xmlElement, mode); 104 105 if (mode == XMLPort::LoadObject) 106 { 107 this->overlay_->show(); 108 if (!this->isVisible()) 109 this->overlay_->hide(); 110 111 this->sizeChanged(); 112 this->positionChanged(); 113 this->angleChanged(); 114 } 115 } 116 117 void OrxonoxOverlay::setBackgroundMaterial(const std::string& material) 118 { 119 if (this->background_ && material != "") 120 this->background_->setMaterialName(material); 121 } 122 123 const std::string& OrxonoxOverlay::getBackgroundMaterial() const 124 { 125 if (this->background_) 126 return this->background_->getMaterialName(); 127 else 128 return blankString; 129 } 130 131 void OrxonoxOverlay::changedVisibility() 132 { 133 if (this->overlay_) 134 { 135 if (this->isVisible()) 136 this->overlay_->show(); 137 else 138 this->overlay_->hide(); 139 } 140 } 141 142 void OrxonoxOverlay::windowResized(int newWidth, int newHeight) 143 { 144 this->windowAspectRatio_ = newWidth/(float)newHeight; 145 146 this->setAspectCorrection(this->bCorrectAspect_); 147 } 148 149 void OrxonoxOverlay::setAspectCorrection(bool val) 150 { 151 this->bCorrectAspect_ = val; 152 this->sizeCorrectionChanged(); 153 } 154 155 void OrxonoxOverlay::sizeCorrectionChanged() 156 { 157 if (this->bCorrectAspect_) 158 { 159 float angle = this->angle_.valueDegrees(); 160 float tempAspect; 161 if (angle > 89.0 && angle < 91.0 || angle > 269 && angle < 271) 162 tempAspect = 1.0 / this->windowAspectRatio_; 163 else if (angle > 359 && angle < 1 || angle > 179 && angle < 181) 164 tempAspect = this->windowAspectRatio_; 165 else 166 tempAspect = 1.0; 167 168 // note: this is only an approximation that is mostly valid when the 169 // magnitude of the width is about the magnitude of the height. 170 // Correctly we would have to take the square root of width*height 171 this->sizeCorrection_.x = 2.0 / (tempAspect + 1.0); 172 this->sizeCorrection_.y = tempAspect * this->sizeCorrection_.x; 173 } 174 else 175 { 176 this->sizeCorrection_ = Vector2::UNIT_SCALE; 177 } 178 this->sizeChanged(); 179 } 180 181 /** 151 182 @remarks 152 This function can be overriden by any derivative.153 */154 void OrxonoxOverlay::sizeChanged()155 {156 this->overlay_->setScale(size_.x * sizeCorrection_.x, size_.y * sizeCorrection_.y);157 positionChanged();158 }159 160 /**183 This function can be overriden by any derivative. 184 */ 185 void OrxonoxOverlay::sizeChanged() 186 { 187 this->overlay_->setScale(size_.x * sizeCorrection_.x, size_.y * sizeCorrection_.y); 188 positionChanged(); 189 } 190 191 /** 161 192 @remarks 162 This function can be overriden by any derivative. 163 */ 164 void OrxonoxOverlay::angleChanged() 165 { 166 this->overlay_->setRotate(this->angle_); 167 } 168 169 /** 193 This function can be overriden by any derivative. 194 */ 195 void OrxonoxOverlay::angleChanged() 196 { 197 this->overlay_->setRotate(this->angle_); 198 this->sizeCorrectionChanged(); 199 } 200 201 /** 170 202 @remarks 171 This function can be overriden by any derivative. 172 */ 173 void OrxonoxOverlay::positionChanged() 174 { 175 Vector2 scroll = (position_ - 0.5 - size_ * sizeCorrection_ * (origin_ - 0.5)) * 2.0; 176 this->overlay_->setScroll(scroll.x, -scroll.y); 177 } 203 This function can be overriden by any derivative. 204 */ 205 void OrxonoxOverlay::positionChanged() 206 { 207 float angle = abs(this->angle_.valueRadians()); 208 angle -= Ogre::Math::PI * (int)(angle / (Ogre::Math::PI)); 209 if (angle > Ogre::Math::PI * 0.5) 210 angle = Ogre::Math::PI - angle; 211 Vector2 actualSize = size_ * sizeCorrection_; 212 float radius = actualSize.length(); 213 float phi = atan(actualSize.y / actualSize.x); 214 Vector2 boundingBox(radius * cos(angle - phi), radius * sin(angle + phi)); 215 Vector2 scroll = (position_ - 0.5 - boundingBox * (origin_ - 0.5)) * 2.0; 216 this->overlay_->setScroll(scroll.x, -scroll.y); 217 } 218 219 220 /*static*/ void OrxonoxOverlay::scaleOverlay(const std::string& name, float scale) 221 { 222 std::map<std::string, OrxonoxOverlay*>::const_iterator it = overlays_s.find(name); 223 if (it != overlays_s.end()) 224 (*it).second->scale(Vector2(scale, scale)); 225 } 226 227 /*static*/ void OrxonoxOverlay::scrollOverlay(const std::string& name, const Vector2& scroll) 228 { 229 std::map<std::string, OrxonoxOverlay*>::const_iterator it = overlays_s.find(name); 230 if (it != overlays_s.end()) 231 (*it).second->scroll(scroll); 232 } 233 234 /*static*/ void OrxonoxOverlay::rotateOverlay(const std::string& name, const Degree& angle) 235 { 236 std::map<std::string, OrxonoxOverlay*>::const_iterator it = overlays_s.find(name); 237 if (it != overlays_s.end()) 238 (*it).second->rotate(angle); 239 } 178 240 } -
code/branches/hud/src/orxonox/overlays/OrxonoxOverlay.h
r1614 r1615 42 42 { 43 43 public: 44 Ogre::Overlay* getOverlay() { return this->overlay_; }45 44 OrxonoxOverlay(); 46 45 virtual ~OrxonoxOverlay(); … … 70 69 71 70 /** Sets the rotation applied to this overlay.*/ 72 void setRotation(const Ogre::Radian& angle) { this->angle_ = angle; this->angleChanged(); }71 void setRotation(const Degree& angle) { this->angle_ = angle; this->angleChanged(); } 73 72 74 73 /** Gets the rotation applied to this overlay, in degrees.*/ … … 76 75 77 76 /** Adds the passed in angle to the rotation applied to this overlay. */ 78 void rotate(const Radian& angle) { this->angle_ += angle; this->angleChanged(); }77 void rotate(const Degree& angle) { this->angle_ += angle; this->angleChanged(); } 79 78 80 79 /** Sets the size of this overlay. */ … … 93 92 void scale(Vector2 scale) { this->size_ *= scale; this->sizeChanged(); } 94 93 94 static void scaleOverlay(const std::string& name, float scale); 95 static void scrollOverlay(const std::string& name, const Vector2& scroll); 96 static void rotateOverlay(const std::string& name, const Degree& angle); 97 95 98 protected: 96 99 virtual void changedVisibility(); … … 98 101 virtual void angleChanged(); 99 102 virtual void positionChanged(); 100 float getWindowAspectRatio() { return windowAspectRatio_; }103 virtual void sizeCorrectionChanged(); 101 104 102 105 void setBackgroundMaterial(const std::string& material); 103 std::stringgetBackgroundMaterial() const;106 const std::string& getBackgroundMaterial() const; 104 107 105 108 Ogre::Overlay* overlay_; 106 109 Ogre::PanelOverlayElement* background_; 107 108 private:109 void windowResized(int newWidth, int newHeight);110 111 110 float windowAspectRatio_; 112 111 bool bCorrectAspect_; … … 117 116 Vector2 origin_; 118 117 118 private: 119 void windowResized(int newWidth, int newHeight); 120 119 121 static unsigned int hudOverlayCounter_s; 122 static std::map<std::string, OrxonoxOverlay*> overlays_s; 120 123 }; 121 124 } -
code/branches/hud/src/orxonox/overlays/OverlayGroup.cc
r1614 r1615 30 30 #include "OverlayGroup.h" 31 31 32 #include <assert.h>33 32 #include "core/Debug.h" 34 33 #include "core/ConsoleCommand.h" … … 38 37 namespace orxonox 39 38 { 40 CreateFactory(OverlayGroup);39 CreateFactory(OverlayGroup); 41 40 42 SetConsoleCommand(OverlayGroup, toggleVisibility, false).setAccessLevel(AccessLevel::User); 43 SetConsoleCommand(OverlayGroup, scaleGroup, false).setAccessLevel(AccessLevel::User); 41 SetConsoleCommand(OverlayGroup, toggleVisibility, false).setAccessLevel(AccessLevel::User); 42 SetConsoleCommand(OverlayGroup, scaleGroup, false).setAccessLevel(AccessLevel::User); 43 SetConsoleCommand(OverlayGroup, scrollGroup, false).setAccessLevel(AccessLevel::User); 44 44 45 using namespace Ogre; 45 OverlayGroup::OverlayGroup() 46 : scale_(1.0, 1.0) 47 { 48 RegisterObject(OverlayGroup); 49 } 46 50 47 OverlayGroup::OverlayGroup() 48 : scale_(1.0, 1.0) 49 { 50 RegisterObject(OverlayGroup); 51 } 51 OverlayGroup::~OverlayGroup() 52 { 53 } 52 54 53 OverlayGroup::~OverlayGroup()54 {55 }55 void OverlayGroup::XMLPort(Element& xmlElement, XMLPort::Mode mode) 56 { 57 BaseObject::XMLPort(xmlElement, mode); 56 58 57 void OverlayGroup::XMLPort(Element& xmlElement, XMLPort::Mode mode) 58 { 59 BaseObject::XMLPort(xmlElement, mode); 59 XMLPortParam(OverlayGroup, "scale", setScale, getScale, xmlElement, mode); 60 XMLPortParam(OverlayGroup, "scroll", setScroll, getScroll, xmlElement, mode); 61 XMLPortObject(OverlayGroup, OrxonoxOverlay, "", addElement, getElement, xmlElement, mode, false, true); 62 } 60 63 61 XMLPortParam(OverlayGroup, "scale", scale, getScale, xmlElement, mode); 62 XMLPortObject(OverlayGroup, OrxonoxOverlay, "", addElement, getElement, xmlElement, mode, false, true); 63 } 64 void OverlayGroup::setScale(const Vector2& scale) 65 { 66 for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 67 (*it).second->scale(scale / this->scale_); 68 this->scale_ = scale; 69 } 64 70 65 void OverlayGroup::scale(const Vector2& scale)66 {67 for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)68 (*it).second->scale(scale);69 this->scale_ = scale;70 }71 void OverlayGroup::setScroll(const Vector2& scroll) 72 { 73 for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 74 (*it).second->scroll(scroll - this->scroll_); 75 this->scroll_ = scroll; 76 } 71 77 72 void OverlayGroup::addElement(OrxonoxOverlay* element) 73 { 74 if (hudElements_.find(element->getName()) != hudElements_.end()) 78 void OverlayGroup::addElement(OrxonoxOverlay* element) 75 79 { 76 COUT(1) << "Ambiguous names encountered while load the HUD overlays" << std::endl; 80 if (hudElements_.find(element->getName()) != hudElements_.end()) 81 { 82 COUT(1) << "Ambiguous names encountered while load the HUD overlays" << std::endl; 83 } 84 else 85 hudElements_[element->getName()] = element; 77 86 } 78 else79 hudElements_[element->getName()] = element;80 }81 87 82 OrxonoxOverlay* OverlayGroup::getElement(unsigned int index) 83 { 84 if (index < this->hudElements_.size()) 88 OrxonoxOverlay* OverlayGroup::getElement(unsigned int index) 85 89 { 86 std::map<std::string, OrxonoxOverlay*>::const_iterator it = hudElements_.begin(); 87 for (unsigned int i = 0; i != index; ++it, ++i) 88 ; 89 return (*it).second; 90 if (index < this->hudElements_.size()) 91 { 92 std::map<std::string, OrxonoxOverlay*>::const_iterator it = hudElements_.begin(); 93 for (unsigned int i = 0; i != index; ++it, ++i) 94 ; 95 return (*it).second; 96 } 97 else 98 return 0; 90 99 } 91 else92 return 0;93 }94 100 95 101 96 /*static*/ void OverlayGroup::toggleVisibility(const std::string& name) 97 { 98 for (Iterator<OverlayGroup> it = ObjectList<OverlayGroup>::begin(); it; ++it) 102 /*static*/ void OverlayGroup::toggleVisibility(const std::string& name) 99 103 { 100 if ((*it)->getName() == name) 101 (*it)->setVisibility(!((*it)->isVisible())); 104 for (Iterator<OverlayGroup> it = ObjectList<OverlayGroup>::begin(); it; ++it) 105 { 106 if ((*it)->getName() == name) 107 (*it)->setVisibility(!((*it)->isVisible())); 108 } 102 109 } 103 }104 110 105 /*static*/ void OverlayGroup::scaleGroup(const std::string& name, float scale) 106 { 107 for (Iterator<OverlayGroup> it = ObjectList<OverlayGroup>::begin(); it; ++it) 111 /*static*/ void OverlayGroup::scaleGroup(const std::string& name, float scale) 108 112 { 109 if ((*it)->getName() == name) 110 (*it)->scale(Vector2(scale, scale)); 113 for (Iterator<OverlayGroup> it = ObjectList<OverlayGroup>::begin(); it; ++it) 114 { 115 if ((*it)->getName() == name) 116 (*it)->scale(Vector2(scale, scale)); 117 } 111 118 } 112 } 119 120 /*static*/ void OverlayGroup::scrollGroup(const std::string& name, const Vector2& scroll) 121 { 122 for (Iterator<OverlayGroup> it = ObjectList<OverlayGroup>::begin(); it; ++it) 123 { 124 if ((*it)->getName() == name) 125 (*it)->scroll(scroll); 126 } 127 } 113 128 } -
code/branches/hud/src/orxonox/overlays/OverlayGroup.h
r1614 r1615 39 39 namespace orxonox 40 40 { 41 class HUDBar;42 class OrxonoxOverlay;43 44 41 class _OrxonoxExport OverlayGroup : public BaseObject 45 42 { 46 43 public: 47 44 OverlayGroup(); 48 45 ~OverlayGroup(); 49 46 50 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); 51 52 void scale(const Vector2& scale); 53 Vector2 getScale() const { return this->scale_; } 47 void XMLPort(Element& xmlElement, XMLPort::Mode mode); 54 48 55 49 static void toggleVisibility(const std::string& name); 56 50 static void scaleGroup(const std::string& name, float scale); 51 static void scrollGroup(const std::string& name, const Vector2& scroll); 52 static void rotateGroup(const std::string& name, Radian angle); 57 53 58 private: 59 OverlayGroup(const OverlayGroup& instance); 54 private: 55 void scale(const Vector2& scale) { this->setScale(scale * this->scale_); } 56 void setScale(const Vector2& scale); 57 Vector2 getScale() const { return this->scale_; } 58 59 void scroll(const Vector2& scroll) { this->setScroll(scroll + this->scroll_); } 60 void setScroll(const Vector2& scroll); 61 Vector2 getScroll() const { return this->scale_; } 60 62 61 63 void addElement(OrxonoxOverlay* element); … … 64 66 std::map<std::string, OrxonoxOverlay*> hudElements_; 65 67 Vector2 scale_; 68 Vector2 scroll_; 66 69 }; 67 70 } -
code/branches/hud/src/orxonox/overlays/OverlayText.cc
r1614 r1615 28 28 29 29 #include "OrxonoxStableHeaders.h" 30 #include " HUDText.h"30 #include "OverlayText.h" 31 31 32 32 #include <OgreOverlayManager.h> … … 35 35 36 36 #include "util/Convert.h" 37 #include "util/String.h" 37 38 38 39 namespace orxonox 39 40 { 40 CreateFactory(HUDText);41 CreateFactory(OverlayText); 41 42 42 using namespace Ogre; 43 44 HUDText::HUDText() 45 : text_(0) 46 { 47 RegisterObject(HUDText); 48 } 49 50 HUDText::~HUDText() 51 { 52 if (this->isInitialized()) 43 OverlayText::OverlayText() 44 : text_(0) 53 45 { 54 if (this->text_) 55 OverlayManager::getSingleton().destroyOverlayElement(this->text_); 56 } 57 } 58 59 void HUDText::XMLPort(Element& xmlElement, XMLPort::Mode mode) 60 { 61 OrxonoxOverlay::XMLPort(xmlElement, mode); 62 63 if (mode == XMLPort::LoadObject) 64 { 65 this->text_ = static_cast<TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton().createOverlayElement("TextArea", getName() + "_Text")); 66 this->text_->setCharHeight(1.0f); 67 this->text_->setFontName("Monofur"); 68 69 this->background_->addChild(this->text_); 46 RegisterObject(OverlayText); 70 47 } 71 48 72 XMLPortParam(HUDText, "font", setFont, getFont, xmlElement, mode); 73 XMLPortParam(HUDText, "caption", setCaption, getCaption, xmlElement, mode); 49 OverlayText::~OverlayText() 50 { 51 if (this->text_) 52 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->text_); 53 } 74 54 75 if (mode == XMLPort::LoadObject)55 void OverlayText::XMLPort(Element& xmlElement, XMLPort::Mode mode) 76 56 { 77 this->text_->setCaption(this->caption_); 57 if (mode == XMLPort::LoadObject) 58 { 59 // setting this to true makes the text more readable when the 60 // resolution aspect is far from 1.0 61 this->bCorrectAspect_ = true; // can be overridden by xml 62 } 63 64 OrxonoxOverlay::XMLPort(xmlElement, mode); 65 66 if (mode == XMLPort::LoadObject) 67 { 68 this->text_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton() 69 .createOverlayElement("TextArea", "OverlayText_text_" + getUniqueNumberStr())); 70 this->text_->setCharHeight(1.0f); 71 this->text_->setFontName("Monofur"); 72 73 this->background_->addChild(this->text_); 74 } 75 76 XMLPortParam(OverlayText, "font", setFont, getFont, xmlElement, mode); 77 XMLPortParam(OverlayText, "caption", setCaption, getCaption, xmlElement, mode); 78 XMLPortParam(OverlayText, "textSize", setTextSize, getTextSize, xmlElement, mode); 79 80 if (mode == XMLPort::LoadObject) 81 { 82 this->text_->setCaption(this->caption_); 83 } 78 84 } 79 }80 85 81 void HUDText::setCaption(const std::string& caption) 82 { 83 this->caption_ = caption; 84 } 86 void OverlayText::setFont(const std::string& font) 87 { 88 if (this->text_ && font != "") 89 this->text_->setFontName(font); 90 } 85 91 86 const std::string& HUDText::getCaption() const 87 { 88 return this->caption_; 89 } 92 const std::string& OverlayText::getFont() const 93 { 94 if (this->text_) 95 return this->text_->getFontName(); 96 else 97 return blankString; 98 } 90 99 91 void HUDText::setFont(const std::string& font) 92 { 93 if (this->text_ && font != "") 94 this->text_->setFontName(font); 95 } 96 97 std::string HUDText::getFont() const 98 { 99 if (this->text_) 100 return this->text_->getFontName(); 101 else 102 return ""; 103 } 100 void OverlayText::sizeChanged() 101 { 102 this->overlay_->setScale(getSize().y, getSize().y); 103 positionChanged(); 104 } 104 105 } -
code/branches/hud/src/orxonox/overlays/OverlayText.h
r1614 r1615 27 27 */ 28 28 29 #ifndef _ HUDText_H__30 #define _ HUDText_H__29 #ifndef _OverlayText_H__ 30 #define _OverlayText_H__ 31 31 32 32 #include "OrxonoxPrereqs.h" … … 34 34 #include <string> 35 35 #include <OgrePrerequisites.h> 36 #include " overlays/OrxonoxOverlay.h"36 #include "OrxonoxOverlay.h" 37 37 38 38 namespace orxonox 39 39 { 40 class _OrxonoxExport HUDText : public OrxonoxOverlay41 {42 public:43 HUDText();44 virtual ~HUDText();40 class _OrxonoxExport OverlayText : public OrxonoxOverlay 41 { 42 public: 43 OverlayText(); 44 virtual ~OverlayText(); 45 45 46 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);46 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); 47 47 48 protected: 49 void setCaption(const std::string& caption); 50 const std::string& getCaption() const; 51 void setFont(const std::string& font); 52 std::string getFont() const; 48 protected: 49 virtual void sizeChanged(); 53 50 54 Ogre::TextAreaOverlayElement* text_; 51 void setCaption(const std::string& caption) { this->caption_ = caption; } 52 const std::string& getCaption() const { return this->caption_; } 55 53 56 private: 57 std::string caption_; 58 }; 54 void setFont(const std::string& font); 55 const std::string& getFont() const; 56 57 void setTextSize(float size) { this->setSize(Vector2(size, size)); } 58 float getTextSize() const { return this->getUncorrectedSize().y; } 59 60 Ogre::TextAreaOverlayElement* text_; 61 62 private: 63 std::string caption_; 64 }; 59 65 } 60 #endif /* _ HUDText_H__ */66 #endif /* _OverlayText_H__ */ -
code/branches/hud/src/orxonox/overlays/console/InGameConsole.cc
r1601 r1615 54 54 SetConsoleCommand(InGameConsole, closeConsole, true); 55 55 56 using namespace Ogre;57 58 56 /** 59 57 @brief Constructor: Creates and initializes the InGameConsole. … … 119 117 120 118 // create a container 121 this->consoleOverlayContainer_ = static_cast<O verlayContainer*>(ovMan->createOverlayElement("Panel", "InGameConsoleContainer"));119 this->consoleOverlayContainer_ = static_cast<Ogre::OverlayContainer*>(ovMan->createOverlayElement("Panel", "InGameConsoleContainer")); 122 120 this->consoleOverlayContainer_->setMetricsMode(Ogre::GMM_RELATIVE); 123 121 this->consoleOverlayContainer_->setPosition((1 - this->relativeWidth) / 2, 0); … … 126 124 127 125 // create BorderPanel 128 this->consoleOverlayBorder_ = static_cast< BorderPanelOverlayElement*>(ovMan->createOverlayElement("BorderPanel", "InGameConsoleBorderPanel"));126 this->consoleOverlayBorder_ = static_cast<Ogre::BorderPanelOverlayElement*>(ovMan->createOverlayElement("BorderPanel", "InGameConsoleBorderPanel")); 129 127 this->consoleOverlayBorder_->setMetricsMode(Ogre::GMM_PIXELS); 130 128 this->consoleOverlayBorder_->setMaterialName("ConsoleCenter"); … … 139 137 140 138 // create the text lines 141 this->consoleOverlayTextAreas_ = new TextAreaOverlayElement*[LINES];139 this->consoleOverlayTextAreas_ = new Ogre::TextAreaOverlayElement*[LINES]; 142 140 for (int i = 0; i < LINES; i++) 143 141 { 144 this->consoleOverlayTextAreas_[i] = static_cast< TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleTextArea" + Ogre::StringConverter::toString(i)));142 this->consoleOverlayTextAreas_[i] = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleTextArea" + Ogre::StringConverter::toString(i))); 145 143 this->consoleOverlayTextAreas_[i]->setMetricsMode(Ogre::GMM_PIXELS); 146 144 this->consoleOverlayTextAreas_[i]->setFontName("Monofur"); … … 153 151 154 152 // create cursor (also a text area overlay element) 155 this->consoleOverlayCursor_ = static_cast< TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleCursor"));153 this->consoleOverlayCursor_ = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleCursor")); 156 154 this->consoleOverlayCursor_->setMetricsMode(Ogre::GMM_PIXELS); 157 155 this->consoleOverlayCursor_->setFontName("Monofur"); … … 163 161 164 162 // create noise 165 this->consoleOverlayNoise_ = static_cast< PanelOverlayElement*>(ovMan->createOverlayElement("Panel", "InGameConsoleNoise"));163 this->consoleOverlayNoise_ = static_cast<Ogre::PanelOverlayElement*>(ovMan->createOverlayElement("Panel", "InGameConsoleNoise")); 166 164 this->consoleOverlayNoise_->setMetricsMode(Ogre::GMM_PIXELS); 167 165 this->consoleOverlayNoise_->setPosition(5,0); -
code/branches/hud/src/orxonox/overlays/hud/HUDBar.cc
r1614 r1615 43 43 unsigned int HUDBar::materialcount_s = 0; 44 44 45 using namespace Ogre;46 47 45 HUDBar::HUDBar() 48 46 : bar_(0) … … 54 52 HUDBar::~HUDBar() 55 53 { 56 if (this->isInitialized()) 57 { 58 if (this->bar_) 59 OverlayManager::getSingleton().destroyOverlayElement(this->bar_); 60 // FIXME: Check whether we have to delete the textureUnitState_; 61 } 54 if (this->bar_) 55 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->bar_); 62 56 } 63 57 … … 82 76 barOffsetLeft_s = 0.06f; 83 77 barOffsetTop_s = 0.0f; 84 this->bar_ = static_cast<PanelOverlayElement*>(OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "Bar" + getUniqueNumberStr())); 78 79 this->bar_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 80 .createOverlayElement("Panel", "HUDBar_bar_" + getUniqueNumberStr())); 85 81 this->bar_->setMaterialName(materialname); 86 82 this->background_->addChild(bar_); -
code/branches/hud/src/orxonox/overlays/hud/HUDBar.h
r1614 r1615 41 41 namespace orxonox 42 42 { 43 class _OrxonoxExport HUDBar : public OrxonoxOverlay44 {43 class _OrxonoxExport HUDBar : public OrxonoxOverlay 44 { 45 45 public: 46 HUDBar();47 virtual ~HUDBar();46 HUDBar(); 47 virtual ~HUDBar(); 48 48 49 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);49 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); 50 50 51 void setValue(float value);52 void addColour(float value, const ColourValue& colour);53 void clearColours();51 virtual void setValue(float value); 52 void addColour(float value, const ColourValue& colour); 53 void clearColours(); 54 54 55 inline void setRightToLeft(bool r2l)55 inline void setRightToLeft(bool r2l) 56 56 { this->right2Left_ = r2l; } 57 inline bool getRightToLeft() const57 inline bool getRightToLeft() const 58 58 { return this->right2Left_; } 59 inline float getValue() const59 inline float getValue() const 60 60 { return this->value_; } 61 61 62 62 private: 63 static unsigned int materialcount_s; 64 bool right2Left_; 65 bool autoColour_; // whether bar changes colour automatically 66 float value_; // progress of bar 67 Ogre::PanelOverlayElement* bar_; 68 Ogre::TextureUnitState* textureUnitState_; 69 std::map<float, ColourValue> colours_; 63 bool right2Left_; 64 bool autoColour_; //!< whether bar changes colour automatically 65 float value_; //!< progress of bar 70 66 71 float barWidth_s; 72 float barHeight_s; 73 float barOffsetLeft_s; 74 float barOffsetTop_s; 67 Ogre::PanelOverlayElement* bar_; 68 Ogre::TextureUnitState* textureUnitState_; 69 std::map<float, ColourValue> colours_; 70 71 float barWidth_s; 72 float barHeight_s; 73 float barOffsetLeft_s; 74 float barOffsetTop_s; 75 76 static unsigned int materialcount_s; 75 77 }; 76 78 } -
code/branches/hud/src/orxonox/overlays/hud/HUDFPSText.cc
r1614 r1615 35 35 namespace orxonox 36 36 { 37 CreateFactory(HUDFPSText);37 CreateFactory(HUDFPSText); 38 38 39 HUDFPSText::HUDFPSText()40 {41 RegisterObject(HUDFPSText);42 }39 HUDFPSText::HUDFPSText() 40 { 41 RegisterObject(HUDFPSText); 42 } 43 43 44 HUDFPSText::~HUDFPSText() 45 { 46 if (this->isInitialized()) 44 HUDFPSText::~HUDFPSText() 47 45 { 48 46 } 49 }50 47 51 void HUDFPSText::tick(float dt)52 {53 float fps = GraphicsEngine::getSingleton().getAverageFPS();54 this->text_->setCaption(this->getCaption() + convertToString(fps));55 }48 void HUDFPSText::tick(float dt) 49 { 50 float fps = GraphicsEngine::getSingleton().getAverageFPS(); 51 this->text_->setCaption(this->getCaption() + convertToString(fps)); 52 } 56 53 } -
code/branches/hud/src/orxonox/overlays/hud/HUDFPSText.h
r1599 r1615 32 32 #include "OrxonoxPrereqs.h" 33 33 34 #include " HUDText.h"34 #include "overlays/OverlayText.h" 35 35 36 36 namespace orxonox 37 37 { 38 class _OrxonoxExport HUDFPSText : public HUDText, public Tickable39 {40 public:41 HUDFPSText();42 virtual~HUDFPSText();38 class _OrxonoxExport HUDFPSText : public OverlayText, public Tickable 39 { 40 public: 41 HUDFPSText(); 42 ~HUDFPSText(); 43 43 44 //virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); 44 private: 45 void tick(float dt); 45 46 46 virtual void tick(float dt); 47 48 private: 49 }; 47 private: 48 }; 50 49 } 51 50 #endif /* _HUDFPSText_H__ */ -
code/branches/hud/src/orxonox/overlays/hud/HUDNavigation.cc
r1614 r1615 35 35 36 36 #include "util/Math.h" 37 #include "util/String.h" 37 38 #include "core/ConsoleCommand.h" 38 39 #include "objects/SpaceShip.h" … … 45 46 CreateFactory(HUDNavigation); 46 47 47 //HUDNavigation* HUDNavigation::instance_s = 0;48 49 using namespace Ogre;50 51 48 HUDNavigation::HUDNavigation() 52 : container_(0) 53 , navMarker_(0) 54 , aimMarker_(0) 55 , navText_(0) 49 : navMarker_(0) 50 , aimMarker_(0) 51 , navText_(0) 56 52 { 57 53 RegisterObject(HUDNavigation); 58 59 /*assert(instance_s == 0); // singleton class60 HUDNavigation::instance_s = this;*/61 54 } 62 55 63 56 HUDNavigation::~HUDNavigation() 64 57 { 65 if (this->isInitialized()) 66 { 67 if (this->navMarker_) 68 OverlayManager::getSingleton().destroyOverlayElement(this->navMarker_); 69 if (this->navText_) 70 OverlayManager::getSingleton().destroyOverlayElement(this->navText_); 71 if (this->aimMarker_) 72 OverlayManager::getSingleton().destroyOverlayElement(this->aimMarker_); 73 if (this->container_) 74 OverlayManager::getSingleton().destroyOverlayElement(this->container_); 75 } 76 77 //HUDNavigation::instance_s = 0; 58 if (this->navMarker_) 59 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->navMarker_); 60 if (this->navText_) 61 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->navText_); 62 if (this->aimMarker_) 63 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->aimMarker_); 78 64 } 79 65 … … 84 70 if (mode == XMLPort::LoadObject) 85 71 { 86 // create container because we cannot add a Text element to an Overlay87 container_ = static_cast<OverlayContainer*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "_navContainer"));88 89 72 // create nav text 90 navText_ = static_cast<TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton().createOverlayElement("TextArea", getName() + "_navText")); 73 navText_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton() 74 .createOverlayElement("TextArea", "HUDNavigation_navText_" + getUniqueNumberStr())); 91 75 navText_->setCharHeight(0.05f); 92 76 navText_->setFontName("Monofur"); 93 77 94 78 // create nav marker 95 navMarker_ = static_cast<PanelOverlayElement*>(OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "_navMarker")); 79 navMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 80 .createOverlayElement("Panel", "HUDNavigation_navMarker_" + getUniqueNumberStr())); 96 81 navMarker_->setMaterialName("Orxonox/NavArrows"); 97 82 navMarkerSize_ = 0.05; //default … … 99 84 100 85 // create aim marker 101 aimMarker_ = static_cast<PanelOverlayElement*>(OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "_aimMarker")); 86 aimMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 87 .createOverlayElement("Panel", "HUDNavigation_aimMarker_" + getUniqueNumberStr())); 102 88 aimMarker_->setMaterialName("Orxonox/NavCrosshair"); 103 89 aimMarkerSize_ = 0.04; // default 104 90 105 container_->addChild(navMarker_);106 container_->addChild(aimMarker_);107 container_->addChild(navText_);108 container_->show(); 109 110 overlay_->add2D(container_);91 background_->addChild(navMarker_); 92 background_->addChild(aimMarker_); 93 background_->addChild(navText_); 94 95 // hide at first 96 this->setVisibility(false); 111 97 } 112 98 … … 122 108 } 123 109 124 void HUDNavigation::setNavMarkerSize(float size)125 {126 this->navMarkerSize_ = size;127 }128 129 float HUDNavigation::getNavMarkerSize() const130 {131 return this->navMarkerSize_;132 }133 134 void HUDNavigation::setAimMarkerSize(float size)135 {136 this->aimMarkerSize_ = size;137 }138 139 float HUDNavigation::getAimMarkerSize() const140 {141 return this->aimMarkerSize_;142 }143 144 110 void HUDNavigation::setFont(const std::string& font) 145 111 { … … 148 114 } 149 115 150 std::stringHUDNavigation::getFont() const116 const std::string& HUDNavigation::getFont() const 151 117 { 152 118 if (this->navText_) 153 119 return this->navText_->getFontName(); 154 120 else 155 return "";121 return blankString; 156 122 } 157 123 … … 310 276 navText_->setCharHeight(navText_->getCharHeight() * yScale); 311 277 } 312 313 /*static*/ /*HUDNavigation& HUDNavigation::getInstance()314 {315 assert(instance_s);316 return *instance_s;317 }*/318 278 } -
code/branches/hud/src/orxonox/overlays/hud/HUDNavigation.h
r1614 r1615 39 39 class _OrxonoxExport HUDNavigation : public OrxonoxOverlay, public Tickable 40 40 { 41 41 public: 42 42 HUDNavigation(); 43 43 ~HUDNavigation(); … … 45 45 void XMLPort(Element& xmlElement, XMLPort::Mode mode); 46 46 47 void tick(float dt); 48 49 float getDist2Focus() const; 50 51 protected: 47 private: 52 48 void sizeChanged(); 53 49 void angleChanged() { } 54 50 void positionChanged() { } 55 51 56 private: 57 HUDNavigation(HUDNavigation& instance); 52 void tick(float dt); 53 54 // XMLPort accessors 55 void setNavMarkerSize(float size) { this->navMarkerSize_ = size; } 56 float getNavMarkerSize() const { return this->navMarkerSize_; } 57 58 void setAimMarkerSize(float size) { this->aimMarkerSize_ = size; } 59 float getAimMarkerSize() const { return this->aimMarkerSize_; } 60 61 void setTextSize(float size); 62 float getTextSize() const; 63 64 void setFont(const std::string& font); 65 const std::string& getFont() const; 66 58 67 void updateMarker(); 59 68 void updateFocus(); 69 float getDist2Focus() const; 60 70 61 // XMLPort accessors62 void setNavMarkerSize(float size);63 float getNavMarkerSize() const;64 void setAimMarkerSize(float size);65 float getAimMarkerSize() const;66 void setTextSize(float size);67 float getTextSize() const;68 void setFont(const std::string& font);69 std::string getFont() const;70 71 Ogre::OverlayContainer* container_; //!< Container that holds the navigation elements72 71 Ogre::PanelOverlayElement* navMarker_; //!< the panel used to show the arrow and the target marker 73 72 float navMarkerSize_; //!< One paramter size of the navigation marker … … 76 75 Ogre::TextAreaOverlayElement* navText_; //!< Text overlay to display the target distance 77 76 bool wasOutOfView_; //!< Performance booster variable: setMaterial is not cheap 78 };77 }; 79 78 } 80 79 -
code/branches/hud/src/orxonox/overlays/hud/HUDRTRText.cc
r1614 r1615 35 35 namespace orxonox 36 36 { 37 CreateFactory(HUDRTRText);37 CreateFactory(HUDRTRText); 38 38 39 HUDRTRText::HUDRTRText()40 {41 RegisterObject(HUDRTRText);42 }39 HUDRTRText::HUDRTRText() 40 { 41 RegisterObject(HUDRTRText); 42 } 43 43 44 HUDRTRText::~HUDRTRText() 45 { 46 if (this->isInitialized()) 44 HUDRTRText::~HUDRTRText() 47 45 { 48 46 } 49 }50 47 51 void HUDRTRText::tick(float dt)52 {53 float rtr = GraphicsEngine::getSingleton().getAverageRTR();54 this->text_->setCaption(this->getCaption() + convertToString(rtr));55 }48 void HUDRTRText::tick(float dt) 49 { 50 float rtr = GraphicsEngine::getSingleton().getAverageRTR(); 51 this->text_->setCaption(this->getCaption() + convertToString(rtr)); 52 } 56 53 } -
code/branches/hud/src/orxonox/overlays/hud/HUDRTRText.h
r1599 r1615 32 32 #include "OrxonoxPrereqs.h" 33 33 34 #include " HUDText.h"34 #include "overlays/OverlayText.h" 35 35 36 36 namespace orxonox 37 37 { 38 class _OrxonoxExport HUDRTRText : public HUDText, public Tickable39 {40 public:41 HUDRTRText();42 virtual~HUDRTRText();38 class _OrxonoxExport HUDRTRText : public OverlayText, public Tickable 39 { 40 public: 41 HUDRTRText(); 42 ~HUDRTRText(); 43 43 44 //virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); 45 46 virtual void tick(float dt); 47 48 private: 49 }; 44 private: 45 void tick(float dt); 46 }; 50 47 } 51 48 #endif /* _HUDRTRText_H__ */ -
code/branches/hud/src/orxonox/overlays/hud/HUDRadar.cc
r1614 r1615 45 45 CreateFactory(HUDRadar); 46 46 47 using namespace Ogre;48 49 47 HUDRadar::HUDRadar() 50 48 : marker_(0) … … 55 53 HUDRadar::~HUDRadar() 56 54 { 57 if (this->isInitialized()) 55 if (this->marker_) 56 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->marker_); 57 for (std::vector<Ogre::PanelOverlayElement*>::iterator it = this->radarDots_.begin(); 58 it != this->radarDots_.end(); ++it) 58 59 { 59 if (this->marker_) 60 OverlayManager::getSingleton().destroyOverlayElement(this->marker_); 61 for (std::vector<Ogre::PanelOverlayElement*>::iterator it = this->radarDots_.begin(); 62 it != this->radarDots_.end(); ++it) 63 { 64 OverlayManager::getSingleton().destroyOverlayElement(*it); 65 } 60 Ogre::OverlayManager::getSingleton().destroyOverlayElement(*it); 66 61 } 67 62 } … … 69 64 void HUDRadar::XMLPort(Element& xmlElement, XMLPort::Mode mode) 70 65 { 66 if (mode == XMLPort::LoadObject) 67 this->bCorrectAspect_ = true; 68 71 69 OrxonoxOverlay::XMLPort(xmlElement, mode); 72 70 73 71 if (mode == XMLPort::LoadObject) 74 72 { 73 marker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 74 .createOverlayElement("Panel", "HUDRadar_marker_" + getUniqueNumberStr())); 75 marker_->setMaterialName("Orxonox/RadarMarker"); 76 overlay_->add2D(marker_); 77 marker_->hide(); 78 75 79 this->sensitivity_ = 1.0f; 76 80 this->halfDotSizeDistance_ = 3000.0f; … … 85 89 shapeMaterials_[RadarViewable::Triangle] = "RadarSquare.tga"; 86 90 shapeMaterials_[RadarViewable::Square] = "RadarSquare.tga"; 87 88 if (mode == XMLPort::LoadObject)89 {90 marker_ = (Ogre::PanelOverlayElement*)Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "_Marker");91 marker_->setMaterialName("Orxonox/RadarMarker");92 overlay_->add2D(marker_);93 marker_->hide();94 }95 91 } 96 92 -
code/branches/hud/src/orxonox/overlays/hud/HUDRadar.h
r1614 r1615 44 44 class _OrxonoxExport HUDRadar : public OrxonoxOverlay, public RadarListener 45 45 { 46 46 public: 47 47 HUDRadar(); 48 48 ~HUDRadar(); … … 50 50 void XMLPort(Element& xmlElement, XMLPort::Mode mode); 51 51 52 float getRadarSensitivity() const { return this->sensitivity_; } 53 void setRadarSensitivity(float sensitivity) { this->sensitivity_ = sensitivity; } 54 52 private: 53 // XML accessors 55 54 float getHalfDotSizeDistance() const { return this->halfDotSizeDistance_; } 56 55 void setHalfDotSizeDistance(float distance) { this->halfDotSizeDistance_ = distance; } … … 59 58 void setMaximumDotSize(float size) { this->maximumDotSize_ = size; } 60 59 61 private: 60 float getRadarSensitivity() const { return this->sensitivity_; } 61 // used also by RadarListener interface! 62 void setRadarSensitivity(float sensitivity) { this->sensitivity_ = sensitivity; } 63 64 // RadarListener interface 62 65 void displayObject(RadarViewable* viewable, bool bIsMarked); 63 float getRadarSensitivity() { return 1.0f; }64 66 void radarTick(float dt); 65 67 -
code/branches/hud/src/orxonox/overlays/hud/HUDSpeedBar.cc
r1614 r1615 34 34 namespace orxonox 35 35 { 36 CreateFactory(HUDSpeedBar);36 CreateFactory(HUDSpeedBar); 37 37 38 using namespace Ogre; 38 HUDSpeedBar::HUDSpeedBar() 39 { 40 RegisterObject(HUDSpeedBar); 39 41 40 HUDSpeedBar::HUDSpeedBar() 41 { 42 RegisterObject(HUDSpeedBar); 42 } 43 43 44 } 45 46 HUDSpeedBar::~HUDSpeedBar() 47 { 48 if (this->isInitialized()) 44 HUDSpeedBar::~HUDSpeedBar() 49 45 { 50 46 } 51 }52 47 53 void HUDSpeedBar::tick(float dt) 54 { 55 SpaceShip* ship = SpaceShip::getLocalShip(); 56 if (ship) 48 void HUDSpeedBar::tick(float dt) 57 49 { 58 float v = ship->getVelocity().length(); 59 float vmax = ship->getMaxSpeed(); 60 this->setValue(v/vmax); 50 SpaceShip* ship = SpaceShip::getLocalShip(); 51 if (ship) 52 { 53 float v = ship->getVelocity().length(); 54 float vmax = ship->getMaxSpeed(); 55 this->setValue(v/vmax); 56 } 61 57 } 62 }63 58 } -
code/branches/hud/src/orxonox/overlays/hud/HUDSpeedBar.h
r1614 r1615 37 37 namespace orxonox 38 38 { 39 class _OrxonoxExport HUDSpeedBar : public HUDBar, public Tickable40 {39 class _OrxonoxExport HUDSpeedBar : public HUDBar, public Tickable 40 { 41 41 public: 42 HUDSpeedBar(); 43 virtual ~HUDSpeedBar(); 44 45 //virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); 46 47 virtual void tick(float dt); 42 HUDSpeedBar(); 43 ~HUDSpeedBar(); 48 44 49 45 private: 50 46 void tick(float dt); 51 47 }; 52 48 } -
code/branches/hud/src/util/String.cc
r1505 r1615 31 31 #include <cctype> 32 32 #include <iostream> 33 34 /** 35 @brief Blank string as variable so you can use const std::string& even 36 if you have to return "". 37 */ 38 std::string blankString = ""; 33 39 34 40 /** -
code/branches/hud/src/util/String.h
r1595 r1615 34 34 #include <string> 35 35 #include <sstream> 36 37 extern _UtilExport std::string blankString; 36 38 37 39 _UtilExport void strip(std::string* str);
Note: See TracChangeset
for help on using the changeset viewer.