Changeset 2369 for code/branches
- Timestamp:
- Dec 10, 2008, 3:37:48 AM (16 years ago)
- Location:
- code/branches/objecthierarchy2/src
- Files:
-
- 4 added
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy2/src/core/BaseObject.h
r2254 r2369 196 196 SUPER_FUNCTION(4, BaseObject, processEvent, false); 197 197 SUPER_FUNCTION(6, BaseObject, changedMainState, false); 198 SUPER_FUNCTION(9, BaseObject, changedName, false); 198 199 } 199 200 -
code/branches/objecthierarchy2/src/core/Super.h
r2361 r2369 259 259 #define SUPER_changedOwner(classname, functionname, ...) \ 260 260 SUPER_NOARGS(classname, functionname) 261 262 #define SUPER_changedOverlayGroup(classname, functionname, ...) \ 263 SUPER_NOARGS(classname, functionname) 264 265 #define SUPER_changedName(classname, functionname, ...) \ 266 SUPER_NOARGS(classname, functionname) 261 267 // (1/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- 262 268 … … 501 507 () 502 508 SUPER_FUNCTION_GLOBAL_DECLARATION_PART2; 509 510 SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(8, changedOverlayGroup, false) 511 () 512 SUPER_FUNCTION_GLOBAL_DECLARATION_PART2; 513 514 SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(9, changedName, false) 515 () 516 SUPER_FUNCTION_GLOBAL_DECLARATION_PART2; 503 517 // (2/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- 504 518 … … 552 566 SUPER_INTRUSIVE_DECLARATION(changedMainState); 553 567 SUPER_INTRUSIVE_DECLARATION(changedOwner); 568 SUPER_INTRUSIVE_DECLARATION(changedOverlayGroup); 569 SUPER_INTRUSIVE_DECLARATION(changedName); 554 570 // (3/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- 555 571 -
code/branches/objecthierarchy2/src/core/Template.cc
r2173 r2369 72 72 void Template::changedName() 73 73 { 74 SUPER(Template, changedName); 75 74 76 if (this->getName() != "") 75 77 { -
code/branches/objecthierarchy2/src/orxonox/CMakeLists.txt
r2171 r2369 4 4 LevelManager.cc 5 5 Main.cc 6 PawnManager.cc 6 7 PlayerManager.cc 7 8 Settings.cc -
code/branches/objecthierarchy2/src/orxonox/CameraManager.cc
r2171 r2369 30 30 31 31 #include <OgreViewport.h> 32 #include <OgreSceneManager.h> 33 #include <OgreCamera.h> 32 34 33 35 #include "core/Core.h" 34 36 #include "objects/worldentities/Camera.h" 35 37 #include "objects/Scene.h" 38 #include "util/String.h" 36 39 37 40 namespace orxonox … … 44 47 assert(singletonRef_s == 0); 45 48 singletonRef_s = this; 49 50 this->fallbackCamera_ = 0; 46 51 } 47 52 … … 50 55 assert(singletonRef_s != 0); 51 56 singletonRef_s = 0; 57 58 if (this->fallbackCamera_) 59 { 60 this->fallbackCamera_->getSceneManager()->destroyCamera(this->fallbackCamera_); 61 COUT(0) << "remove camera-manager" << std::endl; 62 } 52 63 } 53 64 … … 68 79 if (this->cameraList_.size() > 0) 69 80 this->cameraList_.front()->removeFocus(); 81 else if (this->fallbackCamera_) 82 { 83 this->fallbackCamera_->getSceneManager()->destroyCamera(this->fallbackCamera_); 84 this->fallbackCamera_ = 0; 85 COUT(0) << "remove fallback camera" << std::endl; 86 } 70 87 71 88 camera->setFocus(this->viewport_); 72 89 90 // make sure we don't add it twice 91 for (std::list<Camera*>::iterator it = this->cameraList_.begin(); it != this->cameraList_.end(); ++it) 92 if ((*it) == camera) 93 return; 94 73 95 // add to list 74 std::list<Camera*>::iterator it;75 for (it = this->cameraList_.begin(); it != this->cameraList_.end(); ++it)76 {77 if ((*it) == camera)78 return; // make sure we don't add it twice79 }80 96 this->cameraList_.push_front(camera); 81 97 } … … 92 108 this->cameraList_.pop_front(); 93 109 94 // set new focus if necessary 95 if (cameraList_.size() > 0) 96 cameraList_.front()->setFocus(this->viewport_); 110 // set new focus if possible 111 if (this->cameraList_.size() > 0) 112 this->cameraList_.front()->setFocus(this->viewport_); 113 else 114 { 115 // there are no more cameras, create a fallback 116 if (!this->fallbackCamera_) 117 { 118 COUT(0) << "create fallback camera" << std::endl; 119 this->fallbackCamera_ = camera->getScene()->getSceneManager()->createCamera(getUniqueNumberString()); 120 } 121 this->viewport_->setCamera(this->fallbackCamera_); 122 COUT(0) << "use fallback camera" << std::endl; 123 } 97 124 } 98 125 else -
code/branches/objecthierarchy2/src/orxonox/CameraManager.h
r2171 r2369 62 62 std::list<Camera*> cameraList_; 63 63 Ogre::Viewport* viewport_; 64 Ogre::Camera* fallbackCamera_; 64 65 65 66 static CameraManager* singletonRef_s; -
code/branches/objecthierarchy2/src/orxonox/OrxonoxPrereqs.h
r2362 r2369 82 82 class CameraManager; 83 83 class LevelManager; 84 class PawnManager; 84 85 class PlayerManager; 85 86 … … 179 180 class HUDRadar; 180 181 class HUDSpeedBar; 182 class HUDHealthBar; 181 183 class InGameConsole; 182 184 class OrxonoxOverlay; -
code/branches/objecthierarchy2/src/orxonox/objects/EventTarget.cc
r2087 r2369 48 48 void EventTarget::changedName() 49 49 { 50 SUPER(EventTarget, changedName); 51 50 52 for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it) 51 53 if (it->getName() == this->getName()) -
code/branches/objecthierarchy2/src/orxonox/objects/gametypes/Gametype.cc
r2361 r2369 169 169 for (std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 170 170 { 171 if (!it->first->getControllableEntity() && (!it->first->isReadyToSpawn() || !this->bStarted_)) 172 { 173 SpawnPoint* spawn = this->getBestSpawnPoint(it->first); 174 if (spawn) 175 { 176 // force spawn at spawnpoint with default pawn 177 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(spawn); 178 spawn->spawn(entity); 179 it->first->startControl(entity); 180 it->second = PlayerState::Dead; 181 } 182 else 183 { 184 COUT(1) << "Error: No SpawnPoints in current Gametype" << std::endl; 185 abort(); 171 if (!it->first->getControllableEntity()) 172 { 173 it->second = PlayerState::Dead; 174 175 if (!it->first->isReadyToSpawn() || !this->bStarted_) 176 { 177 SpawnPoint* spawn = this->getBestSpawnPoint(it->first); 178 if (spawn) 179 { 180 // force spawn at spawnpoint with default pawn 181 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(spawn); 182 spawn->spawn(entity); 183 it->first->startControl(entity); 184 it->second = PlayerState::Dead; 185 } 186 else 187 { 188 COUT(1) << "Error: No SpawnPoints in current Gametype" << std::endl; 189 abort(); 190 } 186 191 } 187 192 } … … 211 216 { 212 217 bool allplayersready = true; 218 bool hashumanplayers = false; 213 219 for (std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 214 220 { 215 221 if (!it->first->isReadyToSpawn()) 216 222 allplayersready = false; 217 } 218 if (allplayersready) 223 if (it->first->isHumanPlayer()) 224 hashumanplayers = true; 225 } 226 if (allplayersready && hashumanplayers) 219 227 { 220 228 this->startCountdown_ = this->initialStartCountdown_; -
code/branches/objecthierarchy2/src/orxonox/objects/infos/PlayerInfo.cc
r2362 r2369 77 77 void PlayerInfo::changedName() 78 78 { 79 SUPER(PlayerInfo, changedName); 80 79 81 if (this->isInitialized() && this->getGametype()) 80 82 this->getGametype()->playerChangedName(this); -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Camera.cc
r2361 r2369 54 54 { 55 55 RegisterObject(Camera); 56 56 COUT(0) << this << ": created camera" << std::endl; 57 57 if (!this->getScene() || !this->getScene()->getSceneManager()) 58 58 ThrowException(AbortLoading, "Can't create Camera, no scene or no scene manager given."); … … 70 70 this->configvaluecallback_changedNearClipDistance(); 71 71 72 this->requestFocus(); // ! HACK ! REMOVE THIS !72 // this->requestFocus(); // ! HACK ! REMOVE THIS ! 73 73 } 74 74 … … 80 80 this->getScene()->getSceneManager()->destroyCamera(this->camera_); 81 81 } 82 COUT(0) << this << ": destroyed camera" << std::endl; 82 83 } 83 84 … … 122 123 void Camera::removeFocus() 123 124 { 125 COUT(0) << this << ": remove focus" << std::endl; 124 126 this->bHasFocus_ = false; 125 127 } … … 142 144 this->bHasFocus_ = true; 143 145 viewport->setCamera(this->camera_); 146 COUT(0) << this << ": set focus" << std::endl; 144 147 145 148 // reactivate all visible compositors -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/pawns/Pawn.cc
r2256 r2369 33 33 #include "core/XMLPort.h" 34 34 #include "util/Math.h" 35 #include "PawnManager.h" 35 36 #include "objects/infos/PlayerInfo.h" 36 37 #include "objects/gametypes/Gametype.h" … … 45 46 RegisterObject(Pawn); 46 47 47 this->bAlive_ = false; 48 PawnManager::touch(); 49 50 this->bAlive_ = true; 48 51 49 52 this->health_ = 0; … … 70 73 Pawn::~Pawn() 71 74 { 75 if (this->isInitialized()) 76 { 77 for (ObjectList<PawnListener>::iterator it = ObjectList<PawnListener>::begin(); it != ObjectList<PawnListener>::end(); ++it) 78 it->destroyedPawn(this); 79 } 72 80 } 73 81 … … 76 84 SUPER(Pawn, XMLPort, xmlelement, mode); 77 85 78 XMLPortParam(Pawn, "health", setHealth, getHeal ht, xmlelement, mode).defaultValues(100);86 XMLPortParam(Pawn, "health", setHealth, getHealth, xmlelement, mode).defaultValues(100); 79 87 XMLPortParam(Pawn, "maxhealth", setMaxHealth, getMaxHealth, xmlelement, mode).defaultValues(200); 80 88 XMLPortParam(Pawn, "initialhealth", setInitialHealth, getInitialHealth, xmlelement, mode).defaultValues(100); … … 85 93 REGISTERDATA(this->bAlive_, direction::toclient); 86 94 REGISTERDATA(this->health_, direction::toclient); 95 REGISTERDATA(this->initialHealth_, direction::toclient); 87 96 } 88 97 … … 90 99 { 91 100 SUPER(Pawn, tick, dt); 101 102 this->health_ -= 15 * dt * rnd(); 92 103 93 104 if (this->health_ <= 0) … … 129 140 void Pawn::death() 130 141 { 142 // Set bAlive_ to false and wait for PawnManager to do the destruction 131 143 this->bAlive_ = false; 144 132 145 if (this->getGametype()) 133 146 this->getGametype()->pawnKilled(this, this->lastHitOriginator_); 147 148 this->setDestroyWhenPlayerLeft(false); 149 134 150 if (this->getPlayer()) 135 151 this->getPlayer()->stopControl(this); 136 137 delete this;138 152 139 153 // play death effect … … 151 165 this->spawn(); 152 166 } 167 168 /////////////////// 169 // Pawn Listener // 170 /////////////////// 171 PawnListener::PawnListener() 172 { 173 RegisterRootObject(PawnListener); 174 } 153 175 } -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/pawns/Pawn.h
r2256 r2369 55 55 inline void removeHealth(float health) 56 56 { this->setHealth(this->health_ - health); } 57 inline float getHeal ht() const57 inline float getHealth() const 58 58 { return this->health_; } 59 59 … … 96 96 WeaponSystem* weaponSystem_; 97 97 }; 98 99 class _OrxonoxExport PawnListener : public OrxonoxClass 100 { 101 friend class Pawn; 102 103 public: 104 PawnListener(); 105 virtual ~PawnListener() {} 106 107 protected: 108 virtual void destroyedPawn(Pawn* pawn) = 0; 109 }; 98 110 } 99 111 -
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.