Changeset 1627 for code/trunk/src
- Timestamp:
- Jun 26, 2008, 7:00:59 PM (16 years ago)
- Location:
- code/trunk/src/orxonox
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/objects/Model.cc
r1559 r1627 59 59 /** 60 60 @brief XML loading and saving. 61 @p 62 aram xmlelement The XML-element 61 @param xmlelement The XML-element 63 62 @param loading Loading (true) or saving (false) 64 63 @return The XML-element … … 100 99 { 101 100 WorldEntity::changedVisibility(); 102 this->mesh_.setVisible(this->isVisible()); 101 if (this->isInitialized()) 102 this->mesh_.setVisible(this->isVisible()); 103 103 } 104 104 } -
code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc
r1625 r1627 96 96 if (mode == XMLPort::LoadObject) 97 97 { 98 // set some default values99 this->windowAspectRatio_ = 1.0f;100 this->bCorrectAspect_ = false;101 this->size_ = Vector2(1.0f, 1.0f);102 this->sizeCorrection_ = Vector2(1.0f, 1.0f);103 this->position_ = Vector2(0.0f, 0.0f);104 this->pickPoint_ = Vector2(0.0f, 0.0f);105 this->angle_ = Radian(0.0f);106 107 98 // add this overlay to the static map of OrxonoxOverlays 108 99 if (overlays_s.find(this->getName()) != overlays_s.end()) … … 122 113 this->overlay_->add2D(this->background_); 123 114 124 // We'll have to get the aspect ratio for the first. Afterwards windowResized() gets115 // We'll have to get the aspect ratio manually for the first time. Afterwards windowResized() gets 125 116 // called automatically by the GraphicsEngine. 126 117 this->windowResized(GraphicsEngine::getSingleton().getWindowWidth(), 127 118 GraphicsEngine::getSingleton().getWindowHeight()); 119 120 this->changedVisibility(); 121 122 this->setSize(Vector2(0.5f, 0.5f)); 123 this->setPickPoint(Vector2(0.5f, 0.5f)); 124 this->setPosition(Vector2(0.5f, 0.5f)); 125 this->setRotation(Degree(0.0f)); 126 this->setAspectCorrection(true); 127 this->setBackgroundMaterial(""); 128 128 } 129 129 130 XMLPortParam(OrxonoxOverlay, "correctAspect", setAspectCorrection, getAspectCorrection, xmlElement, mode); 131 XMLPortParam(OrxonoxOverlay, "size", setSize, getSize, xmlElement, mode); 132 XMLPortParam(OrxonoxOverlay, "rotation", setRotation, getRotation, xmlElement, mode); 133 // see setPickPoint() 134 XMLPortParam(OrxonoxOverlay, "pickPoint", setPickPoint, getPickPoint, xmlElement, mode); 135 XMLPortParam(OrxonoxOverlay, "position", setPosition, getPosition, xmlElement, mode); 136 XMLPortParam(OrxonoxOverlay, "background", setBackgroundMaterial, getBackgroundMaterial, xmlElement, mode); 137 138 if (mode == XMLPort::LoadObject) 139 { 140 // call all the virtual 'setters' 141 this->changedVisibility(); 142 this->angleChanged(); 143 this->sizeCorrectionChanged(); 144 this->sizeChanged(); 145 // probably gets called 4 times (by all the methods), but sizeChanged() could be overwritten. 146 this->positionChanged(); 147 } 130 XMLPortParam(OrxonoxOverlay, "size", setSize, getSize, xmlElement, mode) 131 .defaultValues(Vector2(0.5f, 0.5f)); 132 XMLPortParam(OrxonoxOverlay, "pickPoint", setPickPoint, getPickPoint, xmlElement, mode) 133 .defaultValues(Vector2(0.0f, 0.0f)); 134 XMLPortParam(OrxonoxOverlay, "position", setPosition, getPosition, xmlElement, mode) 135 .defaultValues(Vector2(0.0f, 0.0f)); 136 XMLPortParam(OrxonoxOverlay, "rotation", setRotation, getRotation, xmlElement, mode) 137 .defaultValues(0.0f); 138 XMLPortParam(OrxonoxOverlay, "correctAspect", setAspectCorrection, getAspectCorrection, xmlElement, mode) 139 .defaultValues(true); 140 XMLPortParam(OrxonoxOverlay, "background", setBackgroundMaterial, getBackgroundMaterial, xmlElement, mode) 141 .defaultValues(""); 148 142 } 149 143 -
code/trunk/src/orxonox/overlays/OverlayGroup.cc
r1625 r1627 66 66 if (mode == XMLPort::LoadObject) 67 67 { 68 // set default values 69 this->scale_ = Vector2(1.0, 1.0); 70 this->scroll_ = Vector2(0.0, 0.0); 68 this->setScale(Vector2(1.0f, 1.0f)); 69 this->setScroll(Vector2(0.0f, 0.0f)); 71 70 } 72 71 73 XMLPortParam(OverlayGroup, "scale", setScale, getScale, xmlElement, mode);74 XMLPortParam(OverlayGroup, "scroll", setScroll, getScroll, xmlElement, mode) ;72 XMLPortParam(OverlayGroup, "scale", setScale, getScale, xmlElement, mode).defaultValues(Vector2(1.0, 1.0)); 73 XMLPortParam(OverlayGroup, "scroll", setScroll, getScroll, xmlElement, mode).defaultValues(Vector2(0.0, 0.0)); 75 74 // loads all the child elements 76 75 XMLPortObject(OverlayGroup, OrxonoxOverlay, "", addElement, getElement, xmlElement, mode, false, true); -
code/trunk/src/orxonox/overlays/OverlayText.cc
r1625 r1627 57 57 void OverlayText::XMLPort(Element& xmlElement, XMLPort::Mode mode) 58 58 { 59 if (mode == XMLPort::LoadObject)60 {61 // setting this to true makes the text more readable when the62 // resolution aspect is far from 1.063 this->bCorrectAspect_ = true; // can be overridden by xml64 }65 66 59 OrxonoxOverlay::XMLPort(xmlElement, mode); 67 60 … … 70 63 this->text_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton() 71 64 .createOverlayElement("TextArea", "OverlayText_text_" + getUniqueNumberStr())); 72 this->text_->setCharHeight(1.0f);73 this->text_->setFontName("Monofur");74 65 75 66 this->background_->addChild(this->text_); 67 68 this->setFont("Monofur"); 69 this->caption_ = ""; 70 this->setTextSize(1.0f); 76 71 } 77 72 78 XMLPortParam(OverlayText, "font", setFont, getFont, xmlElement, mode); 79 XMLPortParam(OverlayText, "caption", setCaption, getCaption, xmlElement, mode); 80 XMLPortParam(OverlayText, "textSize", setTextSize, getTextSize, xmlElement, mode); 81 82 if (mode == XMLPort::LoadObject) 83 { 84 this->text_->setCaption(this->caption_); 85 } 73 XMLPortParam(OverlayText, "font", setFont, getFont, xmlElement, mode).defaultValues("Monofur"); 74 XMLPortParam(OverlayText, "caption", setCaption, getCaption, xmlElement, mode).defaultValues(""); 75 XMLPortParam(OverlayText, "textSize", setTextSize, getTextSize, xmlElement, mode).defaultValues(1.0f); 86 76 } 87 77 … … 102 92 void OverlayText::sizeChanged() 103 93 { 94 if (!this->overlay_) 95 return; 96 104 97 this->overlay_->setScale(size_.y * sizeCorrection_.y, size_.y * sizeCorrection_.y); 105 98 positionChanged(); -
code/trunk/src/orxonox/overlays/hud/HUDBar.cc
r1626 r1627 55 55 BaseObject::XMLPort(xmlElement, mode); 56 56 57 XMLPortParam(BarColour, "colour", setColour, getColour, xmlElement, mode); 58 XMLPortParam(BarColour, "position", setPosition, getPosition, xmlElement, mode); 57 if (mode == XMLPort::LoadObject) 58 { 59 this->setColour(ColourValue(1.0, 1.0, 1.0, 1.0)); 60 this->setPosition(0.0f); 61 } 62 63 XMLPortParam(BarColour, "colour", setColour, getColour, xmlElement, mode) 64 .defaultValues(ColourValue(1.0, 1.0, 1.0, 1.0)); 65 XMLPortParam(BarColour, "position", setPosition, getPosition, xmlElement, mode).defaultValues(0.0f); 59 66 } 60 67 … … 90 97 this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, ColourValue(0.2, 0.7, 0.2)); 91 98 92 // create bar93 barWidth_s = 0.88f;94 barHeight_s = 1.0f;95 barOffsetLeft_s = 0.06f;96 barOffsetTop_s = 0.0f;97 98 99 this->bar_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 99 100 .createOverlayElement("Panel", "HUDBar_bar_" + getUniqueNumberStr())); … … 101 102 this->background_->addChild(bar_); 102 103 103 this->setValue(0 );104 this-> autoColour_ = true;105 this-> right2Left_ = false; // default is left to right progress104 this->setValue(0.0f); 105 this->setRightToLeft(false); 106 this->setAutoColour(true); 106 107 } 107 108 108 XMLPortParamLoadOnly(HUDBar, "value", setValue, xmlElement, mode); 109 XMLPortParam(HUDBar, "right2left", setRightToLeft, getRightToLeft, xmlElement, mode); 109 XMLPortParam(HUDBar, "initialValue", setValue, getValue, xmlElement, mode).defaultValues(0.0f); 110 XMLPortParam(HUDBar, "rightToLeft", setRightToLeft, getRightToLeft, xmlElement, mode).defaultValues(false); 111 XMLPortParam(HUDBar, "autoColour", setAutoColour, getAutoColour, xmlElement, mode).defaultValues(true); 110 112 XMLPortObject(HUDBar, BarColour, "", addColour, getColour, xmlElement, mode, false, true); 111 113 } 112 114 113 void HUDBar:: setValue(float value)115 void HUDBar::valueChanged() 114 116 { 115 this->value_ = clamp<float>(value, 0, 1);116 117 if (this->autoColour_ && this->textureUnitState_) 117 118 { … … 153 154 { 154 155 // backward casew 155 this->bar_->setPosition( barOffsetLeft_s + barWidth_s * (1 - this->value_), barOffsetTop_s);156 this->bar_->setDimensions( barWidth_s * this->value_, barHeight_s);156 this->bar_->setPosition(0.06f + 0.88f * (1 - this->value_), 0.0f); 157 this->bar_->setDimensions(0.88f * this->value_, 1.0f); 157 158 } 158 159 else 159 160 { 160 161 // default case 161 this->bar_->setPosition( barOffsetLeft_s, barOffsetTop_s);162 this->bar_->setDimensions( barWidth_s * this->value_, barHeight_s);162 this->bar_->setPosition(0.06f, 0.0f); 163 this->bar_->setDimensions(0.88f * this->value_, 1.0f); 163 164 } 164 165 if (this->value_ != 0) -
code/trunk/src/orxonox/overlays/hud/HUDBar.h
r1626 r1627 60 60 }; 61 61 62 62 63 class _OrxonoxExport HUDBar : public OrxonoxOverlay 63 64 { … … 68 69 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); 69 70 70 virtual void setValue(float value);71 71 void clearColours(); 72 72 73 inline void setRightToLeft(bool r2l) 74 { this->right2Left_ = r2l; this->setValue(this->value_); } 75 inline bool getRightToLeft() const 76 { return this->right2Left_; } 77 inline float getValue() const 78 { return this->value_; } 73 void setRightToLeft(bool r2l) { this->right2Left_ = r2l; this->valueChanged(); } 74 bool getRightToLeft() const { return this->right2Left_; } 75 76 void setValue(float value) { this->value_ = clamp(value, 0.0f, 1.0f); this->valueChanged(); } 77 float getValue() const { return this->value_; } 78 79 void setAutoColour(bool val) { this->autoColour_ = val; this->valueChanged(); } 80 bool getAutoColour() const { return this->autoColour_; } 81 82 protected: 83 virtual void valueChanged(); 79 84 80 85 private: … … 91 96 std::vector<BarColour*> barColours_; 92 97 93 float barWidth_s;94 float barHeight_s;95 float barOffsetLeft_s;96 float barOffsetTop_s;97 98 98 static unsigned int materialcount_s; 99 99 }; -
code/trunk/src/orxonox/overlays/hud/HUDNavigation.cc
r1625 r1627 76 76 navText_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton() 77 77 .createOverlayElement("TextArea", "HUDNavigation_navText_" + getUniqueNumberStr())); 78 navText_->setCharHeight(0.05f);79 navText_->setFontName("Monofur");80 78 81 79 // create nav marker … … 83 81 .createOverlayElement("Panel", "HUDNavigation_navMarker_" + getUniqueNumberStr())); 84 82 navMarker_->setMaterialName("Orxonox/NavArrows"); 85 navMarkerSize_ = 0.05; //default86 83 wasOutOfView_ = true; // just to ensure the material is changed right the first time.. 87 84 … … 90 87 .createOverlayElement("Panel", "HUDNavigation_aimMarker_" + getUniqueNumberStr())); 91 88 aimMarker_->setMaterialName("Orxonox/NavCrosshair"); 92 aimMarkerSize_ = 0.04; // default93 89 94 90 background_->addChild(navMarker_); … … 98 94 // hide at first 99 95 this->setVisible(false); 100 } 101 102 XMLPortParam(HUDNavigation, "font", setFont, getFont, xmlElement, mode); 103 XMLPortParam(HUDNavigation, "textSize", setTextSize, getTextSize, xmlElement, mode); 104 XMLPortParam(HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlElement, mode); 105 XMLPortParam(HUDNavigation, "aimMarkerSize", setAimMarkerSize, getAimMarkerSize, xmlElement, mode); 106 107 if (mode == XMLPort::LoadObject) 108 { 109 this->sizeChanged(); 110 } 96 97 this->setFont("Monofur"); 98 this->setTextSize(0.05f); 99 this->setNavMarkerSize(0.05f); 100 this->setAimMarkerSize(0.04f); 101 } 102 103 XMLPortParam(HUDNavigation, "font", setFont, getFont, xmlElement, mode).defaultValues("Monofur"); 104 XMLPortParam(HUDNavigation, "textSize", setTextSize, getTextSize, xmlElement, mode).defaultValues(0.05f); 105 XMLPortParam(HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlElement, mode) 106 .defaultValues(0.05f); 107 XMLPortParam(HUDNavigation, "aimMarkerSize", setAimMarkerSize, getAimMarkerSize, xmlElement, mode) 108 .defaultValues(0.04f); 111 109 } 112 110 -
code/trunk/src/orxonox/overlays/hud/HUDNavigation.h
r1625 r1627 54 54 55 55 // XMLPort accessors 56 void setNavMarkerSize(float size) { this->navMarkerSize_ = size; }56 void setNavMarkerSize(float size) { this->navMarkerSize_ = size; this->sizeChanged(); } 57 57 float getNavMarkerSize() const { return this->navMarkerSize_; } 58 58 59 void setAimMarkerSize(float size) { this->aimMarkerSize_ = size; }59 void setAimMarkerSize(float size) { this->aimMarkerSize_ = size; this->sizeChanged(); } 60 60 float getAimMarkerSize() const { return this->aimMarkerSize_; } 61 61 -
code/trunk/src/orxonox/overlays/hud/HUDRadar.cc
r1625 r1627 66 66 void HUDRadar::XMLPort(Element& xmlElement, XMLPort::Mode mode) 67 67 { 68 if (mode == XMLPort::LoadObject)69 this->bCorrectAspect_ = true;70 71 68 OrxonoxOverlay::XMLPort(xmlElement, mode); 72 69 … … 79 76 marker_->hide(); 80 77 81 this->se nsitivity_ = 1.0f;82 this-> halfDotSizeDistance_ = 3000.0f;83 this-> maximumDotSize_ = 0.1;78 this->setRadarSensitivity(1.0f); 79 this->setHalfDotSizeDistance(3000.0f); 80 this->setMaximumDotSize(0.1f); 84 81 } 85 82 86 XMLPortParam(HUDRadar, "sensitivity", setRadarSensitivity, getRadarSensitivity, xmlElement, mode); 87 XMLPortParam(HUDRadar, "halfDotSizeDistance", setHalfDotSizeDistance, getHalfDotSizeDistance, xmlElement, mode); 88 XMLPortParam(HUDRadar, "maximumDotSize", setMaximumDotSize, getMaximumDotSize, xmlElement, mode); 83 XMLPortParam(HUDRadar, "sensitivity", setRadarSensitivity, getRadarSensitivity, xmlElement, mode) 84 .defaultValues(1.0f); 85 XMLPortParam(HUDRadar, "halfDotSizeDistance", setHalfDotSizeDistance, getHalfDotSizeDistance, 86 xmlElement, mode).defaultValues(3000.0f); 87 XMLPortParam(HUDRadar, "maximumDotSize", setMaximumDotSize, getMaximumDotSize, xmlElement, mode) 88 .defaultValues(0.1f); 89 89 90 90 shapeMaterials_[RadarViewable::Dot] = "RadarSquare.tga"; -
code/trunk/src/orxonox/tools/Mesh.h
r1558 r1627 52 52 53 53 inline void setVisible(bool visible) 54 { this->entity_->setVisible(visible); }54 { if (this->entity_) this->entity_->setVisible(visible); } 55 55 inline bool getVisible() const 56 { return this->entity_->getVisible(); }56 { if (this->entity_) return this->entity_->getVisible(); else return false; } 57 57 58 58 private:
Note: See TracChangeset
for help on using the changeset viewer.