Changeset 2087 for code/trunk/src/orxonox/overlays/hud
- Timestamp:
- Nov 1, 2008, 7:04:09 PM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 9 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
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.