Changeset 2369 for code/branches/objecthierarchy2/src/orxonox/overlays
- Timestamp:
- Dec 10, 2008, 3:37:48 AM (16 years ago)
- Location:
- code/branches/objecthierarchy2/src/orxonox/overlays
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy2/src/orxonox/overlays/OrxonoxOverlay.cc
r2256 r2369 62 62 63 63 this->owner_ = 0; 64 this->group_ = 0; 64 65 65 66 if (!Core::showsGraphics()) 66 67 ThrowException(NoGraphics, "Can't create OrxonoxOverlay, graphics engine not initialized"); 67 68 // add this overlay to the static map of OrxonoxOverlays69 if (overlays_s.find(this->getName()) != overlays_s.end())70 {71 COUT(1) << "Overlay names should be unique or you cannnot access them via console. Name: \"" << this->getName() << "\"" << std::endl;72 }73 overlays_s[this->getName()] = this;74 68 75 69 // create the Ogre::Overlay … … 132 126 133 127 XMLPortParam(OrxonoxOverlay, "size", setSize, getSize, xmlElement, mode); 134 XMLPortParam(OrxonoxOverlay, "pick Point", setPickPoint, getPickPoint, xmlElement, mode);128 XMLPortParam(OrxonoxOverlay, "pickpoint", setPickPoint, getPickPoint, xmlElement, mode); 135 129 XMLPortParam(OrxonoxOverlay, "position", setPosition, getPosition, xmlElement, mode); 136 130 XMLPortParam(OrxonoxOverlay, "rotation", setRotation, getRotation, xmlElement, mode); 137 XMLPortParam(OrxonoxOverlay, "correct Aspect", setAspectCorrection, getAspectCorrection, xmlElement, mode);131 XMLPortParam(OrxonoxOverlay, "correctaspect", setAspectCorrection, getAspectCorrection, xmlElement, mode); 138 132 XMLPortParam(OrxonoxOverlay, "background", setBackgroundMaterial, getBackgroundMaterial, xmlElement, mode); 139 133 } … … 141 135 void OrxonoxOverlay::changedName() 142 136 { 137 SUPER(OrxonoxOverlay, changedName); 138 143 139 OrxonoxOverlay::overlays_s.erase(this->getOldName()); 144 140 -
code/branches/objecthierarchy2/src/orxonox/overlays/OrxonoxOverlay.h
r2256 r2369 125 125 126 126 //! Gets the rotation angle applied to this overlay in degrees. 127 const Radian& getRotation() const { return this->angle_; }127 const Degree& getRotation() const { return this->angle_; } 128 128 129 129 //! Rotates the overlay by angle degrees. … … 166 166 virtual void changedOwner() {} 167 167 168 inline void setOverlayGroup(OverlayGroup* group) 169 { 170 if (group != this->group_) 171 { 172 this->group_ = group; 173 this->changedOverlayGroup(); 174 } 175 } 176 inline OverlayGroup* getOverlayGroup() const 177 { return this->group_; } 178 virtual void changedOverlayGroup() {} 179 168 180 protected: 169 181 virtual void angleChanged(); … … 184 196 Vector2 position_; //!< Position of the pickPoint on the screen. 185 197 Vector2 pickPoint_; //!< Point on the overlay to pick when translating 186 Radianangle_; //!< Rotation angle of the overlay198 Degree angle_; //!< Rotation angle of the overlay 187 199 RotationState rotState_; //!< horizontal, vertical or inbetween 188 200 … … 195 207 static std::map<std::string, OrxonoxOverlay*> overlays_s; 196 208 ControllableEntity* owner_; 209 OverlayGroup* group_; 197 210 }; 198 211 199 212 SUPER_FUNCTION(7, OrxonoxOverlay, changedOwner, false); 213 SUPER_FUNCTION(8, OrxonoxOverlay, changedOverlayGroup, false); 200 214 } 201 215 -
code/branches/objecthierarchy2/src/orxonox/overlays/OverlayGroup.h
r2256 r2369 73 73 { return this->owner_; } 74 74 75 private:76 75 //! Scales each OrxonoxOverlay individually by scale. 77 76 void scale(const Vector2& scale) { this->setScale(scale * this->scale_); } … … 89 88 OrxonoxOverlay* getElement(unsigned int index); 90 89 90 private: 91 91 std::map<std::string, OrxonoxOverlay*> hudElements_; //!< Contains all the OrxonoxOverlays of the this group. 92 92 Vector2 scale_; //!< Current scale (independant of the elements). -
code/branches/objecthierarchy2/src/orxonox/overlays/OverlayText.cc
r2087 r2369 50 50 this->text_->setCharHeight(1.0); 51 51 52 setFont("Monofur");53 setColour(ColourValue(1.0, 1.0, 1.0, 1.0));54 setCaption("");55 setTextSize(1.0f);56 setAlignmentString("left");52 this->setFont("Monofur"); 53 this->setColour(ColourValue(1.0, 1.0, 1.0, 1.0)); 54 this->setCaption(""); 55 this->setTextSize(1.0f); 56 this->setAlignmentString("left"); 57 57 58 58 this->background_->addChild(this->text_); … … 69 69 SUPER(OverlayText, XMLPort, xmlElement, mode); 70 70 71 XMLPortParam(OverlayText, "font", setFont, getFont, xmlElement, mode); 72 XMLPortParam(OverlayText, "colour", setColour, getColour, xmlElement, mode); 73 XMLPortParam(OverlayText, "caption", setCaption, getCaption, xmlElement, mode); 74 XMLPortParam(OverlayText, "textSize", setTextSize, getTextSize, xmlElement, mode); 75 XMLPortParam(OverlayText, "align", setAlignmentString, getAlignmentString, xmlElement, mode); 71 XMLPortParam(OverlayText, "font", setFont, getFont, xmlElement, mode); 72 XMLPortParam(OverlayText, "colour", setColour, getColour, xmlElement, mode); 73 XMLPortParam(OverlayText, "caption", setCaption, getCaption, xmlElement, mode); 74 XMLPortParam(OverlayText, "textsize", setTextSize, getTextSize, xmlElement, mode); 75 XMLPortParam(OverlayText, "align", setAlignmentString, getAlignmentString, xmlElement, mode); 76 XMLPortParam(OverlayText, "spacewidth", setSpaceWidth, getSpaceWidth, xmlElement, mode); 76 77 } 77 78 -
code/branches/objecthierarchy2/src/orxonox/overlays/OverlayText.h
r2087 r2369 47 47 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); 48 48 49 void setCaption(const std::string& caption) { this->text_->setCaption(caption); }50 std::string getCaption() const { return this->text_->getCaption(); }49 inline void setCaption(const std::string& caption) { this->text_->setCaption(caption); } 50 inline std::string getCaption() const { return this->text_->getCaption(); } 51 51 52 52 void setFont(const std::string& font); 53 const std::string& getFont() const { return this->text_->getFontName(); }53 inline const std::string& getFont() const { return this->text_->getFontName(); } 54 54 55 void setColour(const ColourValue& colour) { this->text_->setColour(colour); }56 const ColourValue& getColour() const { return this->text_->getColour(); }55 inline void setSpaceWidth(float width) { this->text_->setSpaceWidth(width); } 56 inline float getSpaceWidth() const { return this->text_->getSpaceWidth(); } 57 57 58 void setAlignment(Ogre::TextAreaOverlayElement::Alignment alignment) { this->text_->setAlignment(alignment); }59 Ogre::TextAreaOverlayElement::Alignment getAlignment() const { return this->text_->getAlignment(); }58 inline void setColour(const ColourValue& colour) { this->text_->setColour(colour); } 59 inline const ColourValue& getColour() const { return this->text_->getColour(); } 60 60 61 protected:62 virtual void sizeChanged();61 inline void setAlignment(Ogre::TextAreaOverlayElement::Alignment alignment) { this->text_->setAlignment(alignment); } 62 inline Ogre::TextAreaOverlayElement::Alignment getAlignment() const { return this->text_->getAlignment(); } 63 63 64 64 void setAlignmentString(const std::string& alignment); 65 65 std::string getAlignmentString() const; 66 66 67 void setTextSize(float size) { this->setSize(Vector2(size, size)); } 68 float getTextSize() const { return this->getSize().y; } 67 inline void setTextSize(float size) { this->setSize(Vector2(size, size)); } 68 inline float getTextSize() const { return this->getSize().y; } 69 70 protected: 71 virtual void sizeChanged(); 69 72 70 73 Ogre::TextAreaOverlayElement* text_; -
code/branches/objecthierarchy2/src/orxonox/overlays/hud/CMakeLists.txt
r2131 r2369 4 4 HUDRadar.cc 5 5 HUDSpeedBar.cc 6 HUDHealthBar.cc 6 7 ChatOverlay.cc 7 8 ) -
code/branches/objecthierarchy2/src/orxonox/overlays/hud/HUDBar.cc
r2087 r2369 51 51 RegisterObject(BarColour); 52 52 53 setColour(ColourValue(1.0, 1.0, 1.0, 1.0));54 setPosition(0.0);53 this->setColour(ColourValue(1.0, 1.0, 1.0, 1.0)); 54 this->setPosition(0.0); 55 55 } 56 56 … … 84 84 this->bar_->setMaterialName(materialname); 85 85 86 setValue(0.4567654f); 87 setRightToLeft(false); 88 setAutoColour(true); 86 this->setValue(0.0f); 87 this->setRightToLeft(false); 88 this->setAutoColour(true); 89 this->currentColour_ = ColourValue::White; 89 90 90 91 this->background_->addChild(bar_); … … 101 102 SUPER(HUDBar, XMLPort, xmlElement, mode); 102 103 103 XMLPortParam(HUDBar, "initialValue", setValue, getValue, xmlElement, mode); 104 XMLPortParam(HUDBar, "rightToLeft", setRightToLeft, getRightToLeft, xmlElement, mode); 105 XMLPortParam(HUDBar, "autoColour", setAutoColour, getAutoColour, xmlElement, mode); 104 XMLPortParam(HUDBar, "initialvalue", setValue, getValue, xmlElement, mode); 105 XMLPortParam(HUDBar, "righttoleft", setRightToLeft, getRightToLeft, xmlElement, mode); 106 XMLPortParam(HUDBar, "autocolour", setAutoColour, getAutoColour, xmlElement, mode); 107 XMLPortParam(HUDBar, "bartexture", setBarTexture, getBarTexture, xmlElement, mode); 106 108 XMLPortObject(HUDBar, BarColour, "", addColour, getColour, xmlElement, mode); 107 109 } … … 130 132 { 131 133 this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour2); 134 this->currentColour_ = colour2; 132 135 } 133 136 else if (value1 < this->value_) 134 137 { 135 138 this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour1); 139 this->currentColour_ = colour1; 136 140 } 137 141 else … … 139 143 //float interpolationfactor = (this->value_ - value2) / (value1 - value2); 140 144 float interpolationfactor = interpolateSmooth((this->value_ - value2) / (value1 - value2), 0.0f, 1.0f); 141 this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour1 * interpolationfactor + colour2 * (1 - interpolationfactor)); 145 this->currentColour_ = colour1 * interpolationfactor + colour2 * (1 - interpolationfactor); 146 this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, this->currentColour_); 147 142 148 } 143 149 } … … 181 187 this->colours_.clear(); 182 188 } 189 190 void HUDBar::setBarTexture(const std::string& texture) 191 { 192 this->textureUnitState_->setTextureName(texture); 193 } 194 195 const std::string& HUDBar::getBarTexture() const 196 { 197 return this->textureUnitState_->getTextureName(); 198 } 183 199 } -
code/branches/objecthierarchy2/src/orxonox/overlays/hud/HUDBar.h
r2087 r2369 71 71 void clearColours(); 72 72 73 void setRightToLeft(bool r2l) { this->right2Left_ = r2l; this->valueChanged(); } 74 bool getRightToLeft() const { return this->right2Left_; } 73 inline void setRightToLeft(bool r2l) 74 { 75 if (r2l != this->right2Left_) 76 { 77 this->right2Left_ = r2l; 78 this->valueChanged(); 79 } 80 } 81 inline bool getRightToLeft() const 82 { return this->right2Left_; } 75 83 76 void setValue(float value) { this->value_ = clamp(value, 0.0f, 1.0f); this->valueChanged(); } 77 float getValue() const { return this->value_; } 84 inline void setValue(float value) 85 { 86 float temp = clamp(value, 0.0f, 1.0f); 87 if (temp != this->value_) 88 { 89 this->value_ = temp; 90 this->valueChanged(); 91 } 92 } 93 inline float getValue() const 94 { return this->value_; } 78 95 79 void setAutoColour(bool val) { this->autoColour_ = val; this->valueChanged(); } 80 bool getAutoColour() const { return this->autoColour_; } 96 inline void setAutoColour(bool val) 97 { 98 if (val != this->autoColour_) 99 { 100 this->autoColour_ = val; 101 this->valueChanged(); 102 103 if (!val) 104 this->currentColour_ = ColourValue::White; 105 } 106 } 107 inline bool getAutoColour() const 108 { return this->autoColour_; } 109 110 void setBarTexture(const std::string& texture); 111 const std::string& getBarTexture() const; 112 113 inline const ColourValue& getCurrentBarColour() const 114 { return this->currentColour_; } 81 115 82 116 protected: … … 90 124 bool autoColour_; //!< whether bar changes colour automatically 91 125 float value_; //!< progress of bar 126 ColourValue currentColour_; 92 127 93 128 Ogre::PanelOverlayElement* bar_; -
code/branches/objecthierarchy2/src/orxonox/overlays/hud/HUDSpeedBar.cc
r2361 r2369 56 56 if (this->owner_ && this->owner_->getEngine()) 57 57 { 58 float v = this->owner_->getVelocity().length(); 59 float value = v / (this->owner_->getEngine()->getMaxSpeedFront() * this->owner_->getEngine()->getSpeedFactor() * this->owner_->getEngine()->getBoostFactor()); 60 if (value != this->getValue()) 61 this->setValue(value); 58 float value = this->owner_->getVelocity().length() / (this->owner_->getEngine()->getMaxSpeedFront() * this->owner_->getEngine()->getSpeedFactor() * this->owner_->getEngine()->getBoostFactor()); 59 this->setValue(value); 62 60 } 63 61 }
Note: See TracChangeset
for help on using the changeset viewer.