Changeset 2046 for code/branches/objecthierarchy/src/orxonox/overlays/hud
- Timestamp:
- Oct 29, 2008, 11:55:37 AM (16 years ago)
- Location:
- code/branches/objecthierarchy/src/orxonox/overlays/hud
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/orxonox/overlays/hud/ChatOverlay.cc
r2042 r2046 49 49 CreateFactory(ChatOverlay); 50 50 51 ChatOverlay::ChatOverlay(BaseObject* creator) : OverlayText(creator) 51 ChatOverlay::ChatOverlay(BaseObject* creator) 52 : OverlayText(creator) 52 53 { 53 54 RegisterObject(ChatOverlay); 54 55 55 this->displayTime_ = 0 ;56 this->displayTime_ = 0.0; 56 57 57 58 this->setConfigValues(); -
code/branches/objecthierarchy/src/orxonox/overlays/hud/HUDBar.cc
r2019 r2046 46 46 CreateFactory(BarColour); 47 47 48 BarColour::BarColour(BaseObject* creator) : BaseObject(creator), 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(BaseObject* creator) : OrxonoxOverlay(creator), bar_(0), textureUnitState_(0) 68 HUDBar::HUDBar(BaseObject* creator) 69 : OrxonoxOverlay(creator) 66 70 { 67 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_); 68 91 } 69 92 70 93 HUDBar::~HUDBar() 71 94 { 72 if (this-> bar_)95 if (this->isInitialized()) 73 96 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->bar_); 74 97 } … … 78 101 SUPER(HUDBar, XMLPort, xmlElement, mode); 79 102 80 if (mode == XMLPort::LoadObject) 81 { 82 // create new material 83 std::string materialname = "barmaterial" + getConvertedValue<unsigned int, std::string>(materialcount_s++); 84 Ogre::MaterialPtr material = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().create(materialname, "General"); 85 material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA); 86 this->textureUnitState_ = material->getTechnique(0)->getPass(0)->createTextureUnitState(); 87 this->textureUnitState_->setTextureName("bar2.tga"); 88 // use the default colour 89 this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, ColourValue(0.2, 0.7, 0.2)); 90 91 this->bar_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 92 .createOverlayElement("Panel", "HUDBar_bar_" + getUniqueNumberString())); 93 this->bar_->setMaterialName(materialname); 94 this->background_->addChild(bar_); 95 } 96 97 XMLPortParam(HUDBar, "initialValue", setValue, getValue, xmlElement, mode).defaultValues(0.4567654f); 98 XMLPortParam(HUDBar, "rightToLeft", setRightToLeft, getRightToLeft, xmlElement, mode).defaultValues(false); 99 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); 100 106 XMLPortObject(HUDBar, BarColour, "", addColour, getColour, xmlElement, mode); 101 107 } -
code/branches/objecthierarchy/src/orxonox/overlays/hud/HUDNavigation.cc
r2019 r2046 48 48 HUDNavigation::HUDNavigation(BaseObject* creator) 49 49 : OrxonoxOverlay(creator) 50 , navMarker_(0)51 , aimMarker_(0)52 , navText_(0)53 50 { 54 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); 55 79 } 56 80 57 81 HUDNavigation::~HUDNavigation() 58 82 { 59 if (this->navMarker_) 83 if (this->isInitialized()) 84 { 60 85 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->navMarker_); 61 if (this->navText_)62 86 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->navText_); 63 if (this->aimMarker_)64 87 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->aimMarker_); 88 } 65 89 } 66 90 … … 69 93 SUPER(HUDNavigation, XMLPort, xmlElement, mode); 70 94 71 if (mode == XMLPort::LoadObject) 72 { 73 // create nav text 74 navText_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton() 75 .createOverlayElement("TextArea", "HUDNavigation_navText_" + getUniqueNumberString())); 76 77 // create nav marker 78 navMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 79 .createOverlayElement("Panel", "HUDNavigation_navMarker_" + getUniqueNumberString())); 80 navMarker_->setMaterialName("Orxonox/NavArrows"); 81 wasOutOfView_ = true; // just to ensure the material is changed right the first time.. 82 83 // create aim marker 84 aimMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 85 .createOverlayElement("Panel", "HUDNavigation_aimMarker_" + getUniqueNumberString())); 86 aimMarker_->setMaterialName("Orxonox/NavCrosshair"); 87 88 background_->addChild(navMarker_); 89 background_->addChild(aimMarker_); 90 background_->addChild(navText_); 91 92 // hide at first 93 this->setVisible(false); 94 } 95 96 XMLPortParam(HUDNavigation, "font", setFont, getFont, xmlElement, mode).defaultValues("Monofur"); 97 XMLPortParam(HUDNavigation, "textSize", setTextSize, getTextSize, xmlElement, mode).defaultValues(0.05f); 98 XMLPortParam(HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlElement, mode) 99 .defaultValues(0.05f); 100 XMLPortParam(HUDNavigation, "aimMarkerSize", setAimMarkerSize, getAimMarkerSize, xmlElement, mode) 101 .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); 102 99 } 103 100 -
code/branches/objecthierarchy/src/orxonox/overlays/hud/HUDRadar.cc
r2019 r2046 46 46 CreateFactory(HUDRadar); 47 47 48 HUDRadar::HUDRadar(BaseObject* creator) : OrxonoxOverlay(creator), marker_(0) 48 HUDRadar::HUDRadar(BaseObject* creator) 49 : OrxonoxOverlay(creator) 49 50 { 50 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"; 51 66 } 52 67 53 68 HUDRadar::~HUDRadar() 54 69 { 55 if (this->marker_) 70 if (this->isInitialized()) 71 { 56 72 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->marker_); 57 for (std::vector<Ogre::PanelOverlayElement*>::iterator it = this->radarDots_.begin(); 58 it != this->radarDots_.end(); ++it) 59 { 60 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 } 61 78 } 62 79 } … … 66 83 SUPER(HUDRadar, XMLPort, xmlElement, mode); 67 84 68 if (mode == XMLPort::LoadObject) 69 { 70 marker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 71 .createOverlayElement("Panel", "HUDRadar_marker_" + getUniqueNumberString())); 72 marker_->setMaterialName("Orxonox/RadarMarker"); 73 overlay_->add2D(marker_); 74 marker_->hide(); 75 } 76 77 XMLPortParam(HUDRadar, "sensitivity", setRadarSensitivity, getRadarSensitivity, xmlElement, mode) 78 .defaultValues(1.0f); 79 XMLPortParam(HUDRadar, "halfDotSizeDistance", setHalfDotSizeDistance, getHalfDotSizeDistance, 80 xmlElement, mode).defaultValues(3000.0f); 81 XMLPortParam(HUDRadar, "maximumDotSize", setMaximumDotSize, getMaximumDotSize, xmlElement, mode) 82 .defaultValues(0.1f); 83 84 shapeMaterials_[RadarViewable::Dot] = "RadarSquare.tga"; 85 shapeMaterials_[RadarViewable::Triangle] = "RadarSquare.tga"; 86 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); 87 88 } 88 89 -
code/branches/objecthierarchy/src/orxonox/overlays/hud/HUDSpeedBar.cc
r2019 r2046 36 36 CreateFactory(HUDSpeedBar); 37 37 38 HUDSpeedBar::HUDSpeedBar(BaseObject* creator) : HUDBar(creator) 38 HUDSpeedBar::HUDSpeedBar(BaseObject* creator) 39 : HUDBar(creator) 39 40 { 40 41 RegisterObject(HUDSpeedBar);
Note: See TracChangeset
for help on using the changeset viewer.