Changeset 1614 for code/branches/hud
- Timestamp:
- Jun 21, 2008, 2:35:24 PM (16 years ago)
- Location:
- code/branches/hud
- Files:
-
- 2 deleted
- 21 edited
- 2 copied
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
code/branches/hud/src/orxonox/OrxonoxPrereqs.h
r1609 r1614 130 130 } 131 131 132 namespace Ogre 133 { 134 // some got forgotten in OgrePrerequisites 135 class BorderPanelOverlayElement; 136 class PanelOverlayElement; 137 class TextAreaOverlayElement; 138 } 139 132 140 133 141 #endif /* _OrxonoxPrereqs_H__ */ -
code/branches/hud/src/orxonox/Radar.cc
r1613 r1614 23 23 * Reto Grieder 24 24 * Co-authors: 25 * ...25 * Felix Schulthess 26 26 * 27 27 */ … … 38 38 #include "objects/SpaceShip.h" 39 39 #include "core/CoreIncludes.h" 40 #include "RadarListener.h" 40 41 //#include "core/ConfigValueIncludes.h" 41 42 42 43 namespace orxonox 43 44 { 44 RadarListener::RadarListener()45 {46 RegisterRootObject(RadarListener);47 }48 49 45 SetConsoleCommand(Radar, cycleNavigationFocus, true).setAccessLevel(AccessLevel::User); 50 46 SetConsoleCommand(Radar, releaseNavigationFocus, true).setAccessLevel(AccessLevel::User); … … 86 82 } 87 83 88 /*void Radar::unregisterObject(RadarViewable* object)89 {90 if (this->focus_ == object)91 this->focus_ = 0;92 // TODO: check for focus93 }*/94 95 84 const RadarViewable* Radar::getFocus() 96 85 { … … 119 108 for (Iterator<RadarListener> itListener = ObjectList<RadarListener>::begin(); itListener; ++itListener) 120 109 { 110 (*itListener)->radarTick(dt); 111 121 112 for (Iterator<RadarViewable> itElement = ObjectList<RadarViewable>::begin(); itElement; ++itElement) 122 113 { … … 124 115 (*itListener)->displayObject(*itElement, *itElement == this->focus_); 125 116 } 126 127 (*itListener)->radarTick(dt);128 129 if (this->focus_ == 0)130 (*itListener)->hideMarker();131 117 } 132 118 } … … 190 176 } 191 177 178 void Radar::listObjects() const 179 { 180 COUT(3) << "List of RadarObjects:\n"; 181 // iterate through all Radar Objects 182 unsigned int i = 0; 183 for (Iterator<RadarViewable> it = ObjectList<RadarViewable>::start(); it; ++it, ++i) 184 { 185 COUT(3) << i++ << ": " << (*it)->getWorldPosition() << std::endl; 186 } 187 } 188 192 189 193 190 /*static*/ Radar& Radar::getInstance() -
code/branches/hud/src/orxonox/Radar.h
r1613 r1614 23 23 * Reto Grieder 24 24 * Co-authors: 25 * ...25 * Felix Schulthess 26 26 * 27 27 */ … … 37 37 #include "OrxonoxPrereqs.h" 38 38 39 #include <map> 39 40 #include <string> 40 41 #include "core/Iterator.h" … … 45 46 namespace orxonox 46 47 { 47 class _OrxonoxExport RadarListener : virtual public OrxonoxClass48 {49 public:50 RadarListener();51 virtual ~RadarListener() { }52 53 virtual void displayObject(RadarViewable* viewable, bool bIsMarked) = 0;54 virtual void hideMarker() = 0;55 virtual float getRadarSensitivity() = 0;56 virtual void radarTick(float dt) = 0;57 };58 59 48 /** 60 49 @brief This class merely ensures that no one can inherit from Radar. … … 73 62 ~Radar(); 74 63 75 //void unregisterObject(RadarViewable* object);76 64 const RadarViewable* getFocus(); 77 65 RadarViewable::Shape addObjectDescription(const std::string name); 66 67 void listObjects() const; 78 68 79 69 static Radar& getInstance(); -
code/branches/hud/src/orxonox/RadarListener.cc
r1613 r1614 28 28 29 29 #include "OrxonoxStableHeaders.h" 30 #include "RadarViewable.h" 31 #include "core/Debug.h" 32 #include "Radar.h" 30 #include "RadarListener.h" 33 31 34 32 namespace orxonox 35 33 { 36 /** 37 @brief Constructor. 38 */ 39 RadarViewable::RadarViewable() 40 : radarObjectCamouflage_(0.0f) 41 , radarObjectType_(Dot) 42 , radarObject_(0) 43 , radarObjectDescription_("staticObject") 34 RadarListener::RadarListener() 44 35 { 45 RegisterRootObject(Radar Viewable);36 RegisterRootObject(RadarListener); 46 37 } 47 48 void RadarViewable::setRadarObjectDescription(const std::string& str)49 {50 Radar* radar = Radar::getInstancePtr();51 if (radar)52 this->radarObjectType_ = radar->addObjectDescription(str);53 else54 {55 CCOUT(2) << "Attempting to access the radar, but the radar is non existent." << std::endl;56 }57 this->radarObjectDescription_ = str;58 }59 60 /*void RadarViewable::unregisterFromRadar()61 {62 Radar* radar = Radar::getInstancePtr();63 if (radar)64 radar->unregisterObject(this);65 else66 {67 CCOUT(2) << "Attempting to unregister an object to the radar, but the radar is non existent." << std::endl;68 }69 }*/70 38 } -
code/branches/hud/src/orxonox/RadarListener.h
r1613 r1614 27 27 */ 28 28 29 #ifndef _Radar Viewable_H__30 #define _Radar Viewable_H__29 #ifndef _RadarListener_H__ 30 #define _RadarListener_H__ 31 31 32 32 #include "OrxonoxPrereqs.h" 33 #include <string>34 33 #include "core/OrxonoxClass.h" 35 #include "util/Math.h"36 34 37 35 namespace orxonox 38 36 { 39 /** 40 @brief Interface for receiving window events. 41 */ 42 class _OrxonoxExport RadarViewable : virtual public OrxonoxClass 37 class _OrxonoxExport RadarListener : virtual public OrxonoxClass 43 38 { 44 39 public: 45 enum Shape 46 { 47 Square, 48 Dot, 49 Triangle 50 }; 40 RadarListener(); 41 virtual ~RadarListener() { } 51 42 52 public: 53 RadarViewable(); 54 virtual ~RadarViewable() { }//unregisterFromRadar(); } 55 56 float getRadarObjectCamouflage() const { return this->radarObjectCamouflage_; } 57 void setRadarObjectCamouflage(float camouflage) { this->radarObjectCamouflage_ = camouflage; } 58 59 const ColourValue& getRadarObjectColour() const { return this->radarObjectColour_; } 60 void setRadarObjectColour(const ColourValue& colour) { this->radarObjectColour_ = colour; } 61 62 const std::string& getRadarObjectDescription() const { return this->radarObjectDescription_; } 63 void setRadarObjectDescription(const std::string& str); 64 65 const WorldEntity* getWorldEntity() const { return this->radarObject_; } 66 const Vector3& getWorldPosition() const { validate(); return this->radarObject_->getWorldPosition(); } 67 Vector3 getOrientedVelocity() const 68 { validate(); return this->radarObject_->getOrientation() * this->radarObject_->getVelocity(); } 69 70 Shape getRadarObjectType() const { return this->radarObjectType_; } 71 72 protected: 73 WorldEntity* radarObject_; 74 //void unregisterFromRadar(); 75 76 private: 77 void validate() const { if (!this->radarObject_) 78 { COUT(1) << "Assertation: Every RadarViewable has to be assigned a WorldEntity pointer!" << std::endl; assert(0); } } 79 80 float radarObjectCamouflage_; 81 Shape radarObjectType_; 82 std::string radarObjectDescription_; 83 ColourValue radarObjectColour_; 43 virtual void displayObject(RadarViewable* viewable, bool bIsMarked) = 0; 44 virtual float getRadarSensitivity() = 0; 45 virtual void radarTick(float dt) = 0; 84 46 }; 85 47 } 86 48 87 #endif /* _Radar Viewable_H__ */49 #endif /* _RadarListener_H__ */ -
code/branches/hud/src/orxonox/RadarViewable.cc
r1613 r1614 57 57 this->radarObjectDescription_ = str; 58 58 } 59 60 /*void RadarViewable::unregisterFromRadar()61 {62 Radar* radar = Radar::getInstancePtr();63 if (radar)64 radar->unregisterObject(this);65 else66 {67 CCOUT(2) << "Attempting to unregister an object to the radar, but the radar is non existent." << std::endl;68 }69 }*/70 59 } -
code/branches/hud/src/orxonox/RadarViewable.h
r1613 r1614 52 52 public: 53 53 RadarViewable(); 54 virtual ~RadarViewable() { } //unregisterFromRadar(); }54 virtual ~RadarViewable() { } 55 55 56 56 float getRadarObjectCamouflage() const { return this->radarObjectCamouflage_; } … … 72 72 protected: 73 73 WorldEntity* radarObject_; 74 //void unregisterFromRadar();75 74 76 75 private: -
code/branches/hud/src/orxonox/overlays/HUDText.cc
r1604 r1614 31 31 32 32 #include <OgreOverlayManager.h> 33 #include <OgreTextAreaOverlayElement.h> 34 #include <OgrePanelOverlayElement.h> 33 35 34 36 #include "util/Convert.h" … … 41 43 42 44 HUDText::HUDText() 43 : background_(0) 44 , text_(0) 45 : text_(0) 45 46 { 46 47 RegisterObject(HUDText); … … 53 54 if (this->text_) 54 55 OverlayManager::getSingleton().destroyOverlayElement(this->text_); 55 if (this->background_)56 OverlayManager::getSingleton().destroyOverlayElement(this->background_);57 56 } 58 57 } … … 64 63 if (mode == XMLPort::LoadObject) 65 64 { 66 // create background67 this->background_ = static_cast<PanelOverlayElement*>(68 OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "_Background"));69 70 65 this->text_ = static_cast<TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton().createOverlayElement("TextArea", getName() + "_Text")); 71 66 this->text_->setCharHeight(1.0f); 72 67 this->text_->setFontName("Monofur"); 73 68 74 this->overlay_->add2D(this->background_);75 69 this->background_->addChild(this->text_); 76 70 } 77 71 78 XMLPortParam(HUDText, "material", setBackgroundMaterial, getBackgroundMaterial, xmlElement, mode);79 72 XMLPortParam(HUDText, "font", setFont, getFont, xmlElement, mode); 80 73 XMLPortParam(HUDText, "caption", setCaption, getCaption, xmlElement, mode); … … 84 77 this->text_->setCaption(this->caption_); 85 78 } 86 }87 88 void HUDText::setBackgroundMaterial(const std::string& material)89 {90 if (this->background_ && material != "")91 this->background_->setMaterialName(material);92 }93 94 std::string HUDText::getBackgroundMaterial() const95 {96 if (this->background_)97 return this->background_->getMaterialName();98 else99 return "";100 79 } 101 80 -
code/branches/hud/src/orxonox/overlays/HUDText.h
r1601 r1614 32 32 #include "OrxonoxPrereqs.h" 33 33 34 #include <string> 34 35 #include <OgrePrerequisites.h> 35 #include <OgreTextAreaOverlayElement.h>36 #include <OgrePanelOverlayElement.h>37 38 #include "util/Math.h"39 36 #include "overlays/OrxonoxOverlay.h" 40 37 … … 50 47 51 48 protected: 52 void setBackgroundMaterial(const std::string& material);53 std::string getBackgroundMaterial() const;54 49 void setCaption(const std::string& caption); 55 50 const std::string& getCaption() const; … … 58 53 59 54 Ogre::TextAreaOverlayElement* text_; 55 60 56 private: 61 57 std::string caption_; 62 Ogre::PanelOverlayElement* background_;63 58 }; 64 59 } -
code/branches/hud/src/orxonox/overlays/OrxonoxOverlay.cc
r1604 r1614 31 31 32 32 #include <OgreOverlayManager.h> 33 #include <OgrePanelOverlayElement.h> 33 34 #include "util/Convert.h" 34 35 #include "core/CoreIncludes.h" … … 41 42 OrxonoxOverlay::OrxonoxOverlay() 42 43 : overlay_(0) 44 , background_(0) 43 45 , windowAspectRatio_(1.0f) 44 46 , bCorrectAspect_(false) … … 50 52 { 51 53 RegisterObject(OrxonoxOverlay); 54 } 55 56 OrxonoxOverlay::~OrxonoxOverlay() 57 { 58 if (this->background_) 59 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->background_); 52 60 } 53 61 … … 63 71 this->windowResized(GraphicsEngine::getSingleton().getWindowWidth(), 64 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_); 65 78 } 66 79 … … 70 83 XMLPortParam(OrxonoxOverlay, "origin", setOrigin, getOrigin, xmlElement, mode); 71 84 XMLPortParam(OrxonoxOverlay, "position", setPosition, getPosition, xmlElement, mode); 85 XMLPortParam(OrxonoxOverlay, "background", setBackgroundMaterial, getBackgroundMaterial, xmlElement, mode); 72 86 73 87 if (mode == XMLPort::LoadObject) … … 83 97 } 84 98 85 OrxonoxOverlay::~OrxonoxOverlay()99 void OrxonoxOverlay::setBackgroundMaterial(const std::string& material) 86 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 ""; 87 111 } 88 112 -
code/branches/hud/src/orxonox/overlays/OrxonoxOverlay.h
r1604 r1614 39 39 namespace orxonox 40 40 { 41 class _OrxonoxExport OrxonoxOverlay : public BaseObject, public WindowEventListener42 {41 class _OrxonoxExport OrxonoxOverlay : public BaseObject, public WindowEventListener 42 { 43 43 public: 44 Ogre::Overlay* getOverlay() { return this->overlay_; }45 OrxonoxOverlay();46 virtual ~OrxonoxOverlay();44 Ogre::Overlay* getOverlay() { return this->overlay_; } 45 OrxonoxOverlay(); 46 virtual ~OrxonoxOverlay(); 47 47 48 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);48 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); 49 49 50 void setAspectCorrection(bool val);51 bool getAspectCorrection() { return this->bCorrectAspect_; }50 void show() { this->setVisibility(true); } 51 void hide() { this->setVisibility(false); } 52 52 53 /** Sets the position of this overlay. */54 void setPosition(Vector2 pos) { this->position_ = pos; this->positionChanged(); }53 void setAspectCorrection(bool val); 54 bool getAspectCorrection() { return this->bCorrectAspect_; } 55 55 56 /** Gets the current position. */57 Vector2 getPosition() const { return this->position_; }56 /** Sets the position of this overlay. */ 57 void setPosition(Vector2 pos) { this->position_ = pos; this->positionChanged(); } 58 58 59 /** Scrolls the overlay by the offsets provided. */60 void scroll(Vector2 scroll) { this->position_ += scroll; this->positionChanged(); }59 /** Gets the current position. */ 60 Vector2 getPosition() const { return this->position_; } 61 61 62 /** Sets the origin point of this overlay. */63 void setOrigin(Vector2 pos) { this->origin_ = pos; this->positionChanged(); }62 /** Scrolls the overlay by the offsets provided. */ 63 void scroll(Vector2 scroll) { this->position_ += scroll; this->positionChanged(); } 64 64 65 /** Gets the origin point of this overlay*/66 Vector2 getOrigin() const { return this->origin_; }65 /** Sets the origin point of this overlay. */ 66 void setOrigin(Vector2 pos) { this->origin_ = pos; this->positionChanged(); } 67 67 68 /** Sets the rotation applied to this overlay.*/69 void setRotation(const Ogre::Radian& angle) { this->angle_ = angle; this->angleChanged(); }68 /** Gets the origin point of this overlay */ 69 Vector2 getOrigin() const { return this->origin_; } 70 70 71 /** Gets the rotation applied to this overlay, in degrees.*/72 const Radian& getRotation() const { return this->angle_; }71 /** Sets the rotation applied to this overlay.*/ 72 void setRotation(const Ogre::Radian& angle) { this->angle_ = angle; this->angleChanged(); } 73 73 74 /** Adds the passed in angle to the rotation applied to this overlay.*/75 void rotate(const Radian& angle) { this->angle_ += angle; this->angleChanged(); }74 /** Gets the rotation applied to this overlay, in degrees.*/ 75 const Radian& getRotation() const { return this->angle_; } 76 76 77 /** Sets the size ofthis overlay. */78 void setSize(const Vector2& size) { this->size_ = size; this->sizeChanged(); }77 /** Adds the passed in angle to the rotation applied to this overlay. */ 78 void rotate(const Radian& angle) { this->angle_ += angle; this->angleChanged(); } 79 79 80 /** Gets the current size (not corrected)*/81 Vector2 getUncorrectedSize() const { return this->size_; }80 /** Sets the size of this overlay. */ 81 void setSize(const Vector2& size) { this->size_ = size; this->sizeChanged(); } 82 82 83 /** Gets the current size (corrected) */84 Vector2 getSize() const { return this->size_ * this->sizeCorrection_; }83 /** Gets the current size (not corrected) */ 84 Vector2 getUncorrectedSize() const { return this->size_; } 85 85 86 /** Gets the current size correction*/87 Vector2 getSizeCorrection() const { returnthis->sizeCorrection_; }86 /** Gets the current size (corrected) */ 87 Vector2 getSize() const { return this->size_ * this->sizeCorrection_; } 88 88 89 /** Scales the overlay */ 90 void scale(Vector2 scale) { this->size_ *= scale; this->sizeChanged(); } 89 /** Gets the current size correction */ 90 Vector2 getSizeCorrection() const { return this->sizeCorrection_; } 91 92 /** Scales the overlay */ 93 void scale(Vector2 scale) { this->size_ *= scale; this->sizeChanged(); } 91 94 92 95 protected: 93 virtual void changedVisibility();94 virtual void sizeChanged();95 virtual void angleChanged();96 virtual void positionChanged();97 float getWindowAspectRatio() { return windowAspectRatio_; }96 virtual void changedVisibility(); 97 virtual void sizeChanged(); 98 virtual void angleChanged(); 99 virtual void positionChanged(); 100 float getWindowAspectRatio() { return windowAspectRatio_; } 98 101 99 Ogre::Overlay* overlay_; 102 void setBackgroundMaterial(const std::string& material); 103 std::string getBackgroundMaterial() const; 104 105 Ogre::Overlay* overlay_; 106 Ogre::PanelOverlayElement* background_; 100 107 101 108 private: 102 void windowResized(int newWidth, int newHeight);109 void windowResized(int newWidth, int newHeight); 103 110 104 float windowAspectRatio_;105 bool bCorrectAspect_;106 Vector2 size_;107 Vector2 sizeCorrection_;108 Radian angle_;109 Vector2 position_;110 Vector2 origin_;111 float windowAspectRatio_; 112 bool bCorrectAspect_; 113 Vector2 size_; 114 Vector2 sizeCorrection_; 115 Radian angle_; 116 Vector2 position_; 117 Vector2 origin_; 111 118 112 static unsigned int hudOverlayCounter_s;119 static unsigned int hudOverlayCounter_s; 113 120 }; 114 121 } -
code/branches/hud/src/orxonox/overlays/OverlayGroup.cc
r1609 r1614 41 41 42 42 SetConsoleCommand(OverlayGroup, toggleVisibility, false).setAccessLevel(AccessLevel::User); 43 44 OverlayGroup* OverlayGroup::hudInstance_s = 0; 43 SetConsoleCommand(OverlayGroup, scaleGroup, false).setAccessLevel(AccessLevel::User); 45 44 46 45 using namespace Ogre; … … 50 49 { 51 50 RegisterObject(OverlayGroup); 52 53 // Singleton like in Ogre. Constructor and destructor are public,54 // but the assert prevents from having multiple instances.55 assert(hudInstance_s == 0);56 hudInstance_s = this;57 51 } 58 52 59 53 OverlayGroup::~OverlayGroup() 60 54 { 61 if (this->isInitialized())62 {63 }64 65 hudInstance_s = 0;66 55 } 67 56 … … 104 93 } 105 94 106 /*static*/ OverlayGroup& OverlayGroup::getHUD()107 {108 assert(hudInstance_s);109 return *hudInstance_s;110 }111 95 112 96 /*static*/ void OverlayGroup::toggleVisibility(const std::string& name) 113 97 { 114 if (OverlayGroup::getHUD().hudElements_.find(name) != OverlayGroup::getHUD().hudElements_.end())98 for (Iterator<OverlayGroup> it = ObjectList<OverlayGroup>::begin(); it; ++it) 115 99 { 116 OverlayGroup::getHUD().hudElements_[name]->setVisibility(!OverlayGroup::getHUD().hudElements_[name]->isVisible()); 100 if ((*it)->getName() == name) 101 (*it)->setVisibility(!((*it)->isVisible())); 117 102 } 118 103 } 119 104 105 /*static*/ void OverlayGroup::scaleGroup(const std::string& name, float scale) 106 { 107 for (Iterator<OverlayGroup> it = ObjectList<OverlayGroup>::begin(); it; ++it) 108 { 109 if ((*it)->getName() == name) 110 (*it)->scale(Vector2(scale, scale)); 111 } 112 } 120 113 } -
code/branches/hud/src/orxonox/overlays/OverlayGroup.h
r1604 r1614 54 54 55 55 static void toggleVisibility(const std::string& name); 56 static OverlayGroup& getHUD();56 static void scaleGroup(const std::string& name, float scale); 57 57 58 58 private: … … 64 64 std::map<std::string, OrxonoxOverlay*> hudElements_; 65 65 Vector2 scale_; 66 67 static OverlayGroup* hudInstance_s;68 66 }; 69 67 } -
code/branches/hud/src/orxonox/overlays/hud/HUDBar.cc
r1609 r1614 35 35 #include <OgreMaterialManager.h> 36 36 #include <OgreTechnique.h> 37 #include <OgrePanelOverlayElement.h> 37 38 38 39 #include "util/Convert.h" … … 45 46 46 47 HUDBar::HUDBar() 48 : bar_(0) 49 , textureUnitState_(0) 47 50 { 48 51 RegisterObject(HUDBar); 49 50 this->bar_ = 0;51 this->background_ = 0;52 this->textureUnitState_ = 0;53 54 barWidth_s = 0.88f;55 barHeight_s = 1.0f;56 barOffsetLeft_s = 0.06f;57 barOffsetTop_s = 0.0f;58 59 this->value_ = -1;60 this->autoColour_ = true;61 this->right2Left_ = false; // default is left to right progress62 52 } 63 53 … … 68 58 if (this->bar_) 69 59 OverlayManager::getSingleton().destroyOverlayElement(this->bar_); 60 // FIXME: Check whether we have to delete the textureUnitState_; 70 61 } 71 62 } … … 77 68 if (mode == XMLPort::LoadObject) 78 69 { 79 // create background80 this->background_ = static_cast<PanelOverlayElement*>(81 OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "_Background_" + getUniqueNumberStr()));82 this->background_->setMaterialName("Orxonox/BarBackground");83 this->overlay_->add2D(this->background_);84 85 70 // create new material 86 71 std::string materialname = "barmaterial" + getConvertedValue<unsigned int, std::string>(materialcount_s++); … … 93 78 94 79 // create bar 80 barWidth_s = 0.88f; 81 barHeight_s = 1.0f; 82 barOffsetLeft_s = 0.06f; 83 barOffsetTop_s = 0.0f; 95 84 this->bar_ = static_cast<PanelOverlayElement*>(OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "Bar" + getUniqueNumberStr())); 96 85 this->bar_->setMaterialName(materialname); 97 86 this->background_->addChild(bar_); 98 }99 87 100 XMLPortParamLoadOnly(HUDBar, "value", setValue, xmlElement, mode); 88 this->setValue(0); 89 this->autoColour_ = true; 90 this->right2Left_ = false; // default is left to right progress 101 91 102 if (mode == XMLPort::LoadObject)103 {104 92 this->addColour(0.7, ColourValue(0.2, 0.7, 0.2)); 105 93 this->addColour(0.4, ColourValue(0.7, 0.5, 0.2)); 106 94 this->addColour(0.1, ColourValue(0.7, 0.2, 0.2)); 107 95 } 96 97 XMLPortParamLoadOnly(HUDBar, "value", setValue, xmlElement, mode); 108 98 } 109 99 -
code/branches/hud/src/orxonox/overlays/hud/HUDBar.h
r1601 r1614 34 34 #include "OrxonoxPrereqs.h" 35 35 36 #include <map> 36 37 #include <OgrePrerequisites.h> 37 #include <OgrePanelOverlayElement.h>38 39 38 #include "util/Math.h" 40 39 #include "overlays/OrxonoxOverlay.h" … … 67 66 float value_; // progress of bar 68 67 Ogre::PanelOverlayElement* bar_; 69 Ogre::PanelOverlayElement* background_;70 68 Ogre::TextureUnitState* textureUnitState_; 71 69 std::map<float, ColourValue> colours_; -
code/branches/hud/src/orxonox/overlays/hud/HUDFPSText.cc
r1599 r1614 29 29 #include "OrxonoxStableHeaders.h" 30 30 #include "HUDFPSText.h" 31 #include <OgreTextAreaOverlayElement.h> 31 32 #include "GraphicsEngine.h" 32 33 #include "util/Convert.h" -
code/branches/hud/src/orxonox/overlays/hud/HUDNavigation.cc
r1613 r1614 31 31 32 32 #include <OgreOverlayManager.h> 33 #include <OgreStringConverter.h> 34 35 //#include "GraphicsEngine.h" 36 // TODO: remove the SpaceShip and CameraHandler dependencies 37 #include "core/Debug.h" 38 #include "core/CoreIncludes.h" 33 #include <OgreTextAreaOverlayElement.h> 34 #include <OgrePanelOverlayElement.h> 35 36 #include "util/Math.h" 39 37 #include "core/ConsoleCommand.h" 40 38 #include "objects/SpaceShip.h" 41 39 #include "objects/Projectile.h" 42 40 #include "objects/CameraHandler.h" 43 #include "overlays/OverlayGroup.h"44 41 #include "Radar.h" 45 42 … … 68 65 if (this->isInitialized()) 69 66 { 70 if (this->container_)71 OverlayManager::getSingleton().destroyOverlayElement(this->container_);72 67 if (this->navMarker_) 73 68 OverlayManager::getSingleton().destroyOverlayElement(this->navMarker_); … … 76 71 if (this->aimMarker_) 77 72 OverlayManager::getSingleton().destroyOverlayElement(this->aimMarker_); 73 if (this->container_) 74 OverlayManager::getSingleton().destroyOverlayElement(this->container_); 78 75 } 79 76 … … 87 84 if (mode == XMLPort::LoadObject) 88 85 { 89 // create container 86 // create container because we cannot add a Text element to an Overlay 90 87 container_ = static_cast<OverlayContainer*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "_navContainer")); 91 88 -
code/branches/hud/src/orxonox/overlays/hud/HUDNavigation.h
r1613 r1614 33 33 34 34 #include <OgrePrerequisites.h> 35 #include <OgreTextAreaOverlayElement.h>36 #include <OgrePanelOverlayElement.h>37 35 #include "overlays/OrxonoxOverlay.h" 38 #include "util/Math.h"39 36 40 37 namespace orxonox … … 50 47 void tick(float dt); 51 48 52 //void cycleFocus();53 49 float getDist2Focus() const; 54 55 /*inline RadarObject* getFocus() const56 { return this->focus_; }57 void releaseFocus();*/58 59 /*static void cycleNavigationFocus();60 static void releaseNavigationFocus();61 static HUDNavigation& getInstance();*/62 50 63 51 protected: … … 88 76 Ogre::TextAreaOverlayElement* navText_; //!< Text overlay to display the target distance 89 77 bool wasOutOfView_; //!< Performance booster variable: setMaterial is not cheap 90 91 //static HUDNavigation* instance_s;92 78 }; 93 79 } -
code/branches/hud/src/orxonox/overlays/hud/HUDRTRText.cc
r1599 r1614 29 29 #include "OrxonoxStableHeaders.h" 30 30 #include "HUDRTRText.h" 31 #include <OgreTextAreaOverlayElement.h> 31 32 #include "GraphicsEngine.h" 32 33 #include "util/Convert.h" -
code/branches/hud/src/orxonox/overlays/hud/HUDRadar.cc
r1613 r1614 22 22 * Author: 23 23 * Yuning Chai 24 * Felix Schulthess 24 25 * Co-authors: 25 * Felix Schulthess26 * Reto Grieder 26 27 * 27 28 */ … … 30 31 #include "HUDRadar.h" 31 32 32 #include <assert.h>33 33 #include <OgreOverlayManager.h> 34 #include <Ogre MaterialManager.h>34 #include <OgrePanelOverlayElement.h> 35 35 36 #include "util/Math.h" 36 37 #include "core/ConsoleCommand.h" 37 38 #include "objects/SpaceShip.h" 38 39 #include "objects/WorldEntity.h" 39 40 #include "tools/TextureGenerator.h" 40 #include "Radar Viewable.h"41 #include "Radar.h" 41 42 42 43 namespace orxonox 43 44 { 44 45 CreateFactory(HUDRadar); 45 CreateFactory(RadarShape);46 46 47 47 using namespace Ogre; 48 48 49 49 HUDRadar::HUDRadar() 50 : background_(0) 51 , marker_(0) 52 , sensitivity_(1.0f) 50 : marker_(0) 53 51 { 54 52 RegisterObject(HUDRadar); … … 59 57 if (this->isInitialized()) 60 58 { 61 /*if (this->background_) 62 OverlayManager::getSingleton().destroyOverlayElement(this->background_); 63 while (this->radarDots_.size() > 0) 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) 64 63 { 65 OverlayManager::getSingleton().destroyOverlayElement(this->radarDots_[this->radarDots_.size() - 1]); 66 this->radarDots_.pop_back(); 67 }*/ 64 OverlayManager::getSingleton().destroyOverlayElement(*it); 65 } 68 66 } 69 67 } … … 90 88 if (mode == XMLPort::LoadObject) 91 89 { 92 background_ = (Ogre::PanelOverlayElement*)Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "_Background");93 background_->setMaterialName("Orxonox/Radar");94 overlay_->add2D(background_);95 96 90 marker_ = (Ogre::PanelOverlayElement*)Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "_Marker"); 97 91 marker_->setMaterialName("Orxonox/RadarMarker"); … … 100 94 } 101 95 } 102 103 /*void HUDRadar::addShape(RadarShape* shape)104 {105 this->shapes_[shape->getIndex()] = shape;106 }107 108 RadarShape* HUDRadar::getShape(unsigned int index) const109 {110 if (index < this->shapes_.size())111 {112 std::map<unsigned int, RadarShape*>::const_iterator it = shapes_.begin();113 for (unsigned int i = 0; i != index; ++it, ++i)114 ;115 return (*it).second;116 }117 else118 return 0;119 }*/120 96 121 97 void HUDRadar::displayObject(RadarViewable* object, bool bIsMarked) … … 131 107 } 132 108 133 /*static int counter = 0;134 if (++counter < 1120 && counter > 120)135 {136 // we have to create a new entry137 Ogre::PanelOverlayElement* panel = static_cast<Ogre::PanelOverlayElement*>(138 Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "RadarDot" + getUniqueNumberStr()));139 // get right material140 panel->setMaterialName("Orxonox/RadarSquare");141 panel->setDimensions(0.03, 0.03);142 panel->setPosition((1.0 + (rand() & 0xFF) / 256.0 - 0.001) * 0.5, (1.0 - (rand() & 0xFF) / 256.0 - 0.001) * 0.5);143 panel->show();144 this->overlay_->add2D(panel);145 this->overlay_->show();146 }*/147 148 109 // try to find a panel already created 149 110 Ogre::PanelOverlayElement* panel; 150 std::map<RadarViewable*, Ogre::PanelOverlayElement*>::iterator it = this->radarDots_.find(object);151 if (it == this->radarDots_.end())111 //std::map<RadarViewable*, Ogre::PanelOverlayElement*>::iterator it = this->radarDots_.find(object); 112 if (itRadarDots_ == this->radarDots_.end()) 152 113 { 153 114 // we have to create a new entry 154 115 panel = static_cast<Ogre::PanelOverlayElement*>( 155 116 Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "RadarDot" + getUniqueNumberStr())); 156 radarDots_ [object] = panel;117 radarDots_.push_back(panel); 157 118 // get right material 158 119 panel->setMaterialName(TextureGenerator::getMaterialName( 159 120 shapeMaterials_[object->getRadarObjectType()], object->getRadarObjectColour())); 160 121 this->overlay_->add2D(panel); 122 this->itRadarDots_ = this->radarDots_.end(); 161 123 } 162 124 else 163 panel = (*it).second; 125 { 126 panel = *itRadarDots_; 127 ++itRadarDots_; 128 std::string materialName = TextureGenerator::getMaterialName( 129 shapeMaterials_[object->getRadarObjectType()], object->getRadarObjectColour()); 130 if (materialName != panel->getMaterialName()) 131 panel->setMaterialName(materialName); 132 } 164 133 165 134 // set size to fit distance... … … 177 146 { 178 147 this->marker_->show(); 179 this->marker_->setDimensions(size * 1. 2, size * 1.2);180 this->marker_->setPosition((1.0 + coord.x - size * 1. 2) * 0.5, (1.0 - coord.y - size * 1.2) * 0.5);148 this->marker_->setDimensions(size * 1.5, size * 1.5); 149 this->marker_->setPosition((1.0 + coord.x - size * 1.5) * 0.5, (1.0 - coord.y - size * 1.5) * 0.5); 181 150 } 182 151 } … … 184 153 void HUDRadar::radarTick(float dt) 185 154 { 155 this->itRadarDots_ = this->radarDots_.begin(); 156 this->marker_->hide(); 186 157 } 187 188 /*void HUDRadar::tick(float dt)189 {190 // iterate through all RadarObjects191 unsigned int i = 0;192 for (Iterator<RadarViewable> it = ObjectList<RadarViewable>::start(); it; ++it, ++i)193 {194 if ((*it)->isVisibleOnRadar())195 {196 }197 }198 }*/199 200 /*void HUDRadar::listObjects()201 {202 COUT(3) << "List of RadarObjects:\n";203 // iterate through all Radar Objects204 unsigned int i = 0;205 for (Iterator<RadarViewable> it = ObjectList<RadarViewable>::start(); it; ++it, ++i)206 {207 COUT(3) << i++ << ": " << (*it)->getWorldEntity()->getWorldPosition() << std::endl;208 }209 }*/210 158 } -
code/branches/hud/src/orxonox/overlays/hud/HUDRadar.h
r1613 r1614 22 22 * Author: 23 23 * Yuning Chai 24 * Felix Schulthess 24 25 * Co-authors: 25 * Felix Schulthess26 * Reto Grieder 26 27 * 27 28 */ … … 32 33 #include "OrxonoxPrereqs.h" 33 34 35 #include <vector> 36 #include <map> 34 37 #include <OgrePrerequisites.h> 35 #include <OgrePanelOverlayElement.h>36 38 #include "overlays/OrxonoxOverlay.h" 37 #include "objects/Tickable.h" 38 #include "core/BaseObject.h" 39 #include "util/Math.h" 40 #include "core/Debug.h" 41 #include "Radar.h" 39 #include "RadarListener.h" 40 #include "RadarViewable.h" 42 41 43 42 namespace orxonox 44 43 { 45 template <class T, int Dummy> 46 class _OrxonoxExport RadarAttribute : public BaseObject 47 { 48 public: 49 RadarAttribute(); 50 ~RadarAttribute() { } 51 52 void XMLPort(Element& xmlElement, XMLPort::Mode mode); 53 void loadAttribute(Element& xmlElement, XMLPort::Mode mode); 54 55 void setAttribute(const T& attribute) { this->attribute_ = attribute; } 56 const T& getAttribute() const { return this->attribute_; } 57 58 void setIndex(unsigned int index); 59 unsigned int getIndex() { return this->index_; } 60 61 private: 62 unsigned int index_; 63 T attribute_; 64 }; 65 66 template <class T, int Dummy> 67 void RadarAttribute<T, Dummy>::setIndex(unsigned int index) 68 { 69 if (index > 0xFF) 70 { 71 COUT(1) << "Shape index was larger than 255 while parsing a RadarAttribute. " 72 << "Using random number!!!" << std::endl; 73 this->index_ = rand() & 0xFF; 74 } 75 else 76 this->index_ = index; 77 } 78 79 typedef RadarAttribute<std::string, 1> RadarShape; 80 81 template <> 82 RadarShape::RadarAttribute() : index_(0) 83 { RegisterObject(RadarShape); } 84 85 template <> 86 void RadarShape::XMLPort(Element& xmlElement, XMLPort::Mode mode) 87 { 88 BaseObject::XMLPort(xmlElement, mode); 89 XMLPortParam(RadarShape, "shape", setAttribute, getAttribute, xmlElement, mode); 90 XMLPortParam(RadarShape, "index", setIndex, getIndex, xmlElement, mode); 91 } 92 93 94 class _OrxonoxExport HUDRadar : public OrxonoxOverlay, public RadarListener//, public Tickable 44 class _OrxonoxExport HUDRadar : public OrxonoxOverlay, public RadarListener 95 45 { 96 46 public: … … 99 49 100 50 void XMLPort(Element& xmlElement, XMLPort::Mode mode); 101 102 /*void addShape(RadarShape* shape);103 RadarShape* getShape(unsigned int index) const;*/104 51 105 52 float getRadarSensitivity() const { return this->sensitivity_; } … … 112 59 void setMaximumDotSize(float size) { this->maximumDotSize_ = size; } 113 60 114 //void tick(float dt);115 116 //void listObjects();117 118 61 private: 119 62 void displayObject(RadarViewable* viewable, bool bIsMarked); 120 void hideMarker() { this->marker_->hide(); }121 63 float getRadarSensitivity() { return 1.0f; } 122 64 void radarTick(float dt); … … 124 66 std::map<RadarViewable::Shape, std::string> shapeMaterials_; 125 67 126 Ogre::PanelOverlayElement* background_;127 std:: map<RadarViewable*, Ogre::PanelOverlayElement*> radarDots_;68 std::vector<Ogre::PanelOverlayElement*> radarDots_; 69 std::vector<Ogre::PanelOverlayElement*>::iterator itRadarDots_; 128 70 Ogre::PanelOverlayElement* marker_; 129 71 -
code/branches/hud/src/orxonox/overlays/hud/HUDSpeedBar.cc
r1599 r1614 21 21 * 22 22 * Author: 23 * Felix Schulthess 23 24 * Reto Grieder 24 25 * Co-authors: -
code/branches/hud/src/orxonox/overlays/hud/HUDSpeedBar.h
r1599 r1614 21 21 * 22 22 * Author: 23 * Felix Schulthess 23 24 * Reto Grieder 24 25 * Co-authors: -
code/branches/hud/src/orxonox/tools/TextureGenerator.cc
r1613 r1614 23 23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 * Reto Grieder25 * ... 26 26 * 27 27 */ … … 29 29 /** 30 30 @file 31 @brief Implementation of the Settings class.31 @brief Implementation of the TextureGenerator. 32 32 */ 33 33 -
code/branches/hud/visual_studio/vc8/orxonox.vcproj
r1613 r1614 189 189 </File> 190 190 <File 191 RelativePath="..\..\src\orxonox\RadarListener.cc" 192 > 193 </File> 194 <File 191 195 RelativePath="..\..\src\orxonox\RadarViewable.cc" 192 196 > … … 534 538 <File 535 539 RelativePath="..\..\src\orxonox\Radar.h" 540 > 541 </File> 542 <File 543 RelativePath="..\..\src\orxonox\RadarListener.h" 536 544 > 537 545 </File>
Note: See TracChangeset
for help on using the changeset viewer.