Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 16, 2008, 6:01:13 PM (16 years ago)
Author:
landauf
Message:

Merged objecthierarchy2 into presentation branch

Couln't merge 2 lines in Gamestate.cc and a whole block of code in GSDedicated.cc (it seems like oli implemented in both branches something like a network-tick-limiter but with different approaches)

Not yet tested in network mode and with bots
The SpaceShips movement is also not yet fully adopted to the new physics (see Engine class)

Location:
code/branches/presentation
Files:
17 edited
4 copied

Legend:

Unmodified
Added
Removed
  • code/branches/presentation

  • code/branches/presentation/src/orxonox/overlays/OrxonoxOverlay.cc

    r2171 r2485  
    6161        RegisterObject(OrxonoxOverlay);
    6262
     63        this->owner_ = 0;
     64        this->group_ = 0;
     65
    6366        if (!Core::showsGraphics())
    6467            ThrowException(NoGraphics, "Can't create OrxonoxOverlay, graphics engine not initialized");
    65 
    66         // add this overlay to the static map of OrxonoxOverlays
    67         if (overlays_s.find(this->getName()) != overlays_s.end())
    68         {
    69             COUT(1) << "Overlay names should be unique or you cannnot access them via console. Name: \"" << this->getName() << "\"" << std::endl;
    70         }
    71         overlays_s[this->getName()] = this;
    7268
    7369        // create the Ogre::Overlay
     
    130126
    131127        XMLPortParam(OrxonoxOverlay, "size",      setSize,      getSize,      xmlElement, mode);
    132         XMLPortParam(OrxonoxOverlay, "pickPoint", setPickPoint, getPickPoint, xmlElement, mode);
     128        XMLPortParam(OrxonoxOverlay, "pickpoint", setPickPoint, getPickPoint, xmlElement, mode);
    133129        XMLPortParam(OrxonoxOverlay, "position",  setPosition,  getPosition,  xmlElement, mode);
    134130        XMLPortParam(OrxonoxOverlay, "rotation",  setRotation,  getRotation,  xmlElement, mode);
    135         XMLPortParam(OrxonoxOverlay, "correctAspect", setAspectCorrection,   getAspectCorrection,   xmlElement, mode);
     131        XMLPortParam(OrxonoxOverlay, "correctaspect", setAspectCorrection,   getAspectCorrection,   xmlElement, mode);
    136132        XMLPortParam(OrxonoxOverlay, "background",    setBackgroundMaterial, getBackgroundMaterial, xmlElement, mode);
    137133    }
     
    139135    void OrxonoxOverlay::changedName()
    140136    {
     137        SUPER(OrxonoxOverlay, changedName);
     138
    141139        OrxonoxOverlay::overlays_s.erase(this->getOldName());
    142140
  • code/branches/presentation/src/orxonox/overlays/OrxonoxOverlay.h

    r2087 r2485  
    125125
    126126        //! 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_; }
    128128
    129129        //! Rotates the overlay by angle degrees.
     
    154154        virtual void changedVisibility();
    155155
     156        inline void setOwner(ControllableEntity* owner)
     157        {
     158            if (this->owner_ != owner)
     159            {
     160                this->owner_ = owner;
     161                this->changedOwner();
     162            }
     163        }
     164        inline ControllableEntity* getOwner() const
     165            { return this->owner_; }
     166        virtual void changedOwner() {}
     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
    156180    protected:
    157181        virtual void angleChanged();
     
    172196        Vector2 position_;                         //!< Position of the pickPoint on the screen.
    173197        Vector2 pickPoint_;                        //!< Point on the overlay to pick when translating
    174         Radian angle_;                             //!< Rotation angle of the overlay
     198        Degree angle_;                             //!< Rotation angle of the overlay
    175199        RotationState rotState_;             //!< horizontal, vertical or inbetween
    176200
     
    182206            We could also use the ObjectList, but that doesn't guarantee XMLPort(.) was called and is slower. */
    183207        static std::map<std::string, OrxonoxOverlay*> overlays_s;
     208        ControllableEntity* owner_;
     209        OverlayGroup* group_;
    184210  };
     211
     212  SUPER_FUNCTION(7, OrxonoxOverlay, changedOwner, false);
     213  SUPER_FUNCTION(8, OrxonoxOverlay, changedOverlayGroup, false);
    185214}
    186215
  • code/branches/presentation/src/orxonox/overlays/OverlayGroup.cc

    r2087 r2485  
    5555        RegisterObject(OverlayGroup);
    5656
     57        this->owner_ = 0;
     58
    5759        setScale(Vector2(1.0, 1.0));
    5860        setScroll(Vector2(0.0, 0.0));
     
    113115            hudElements_[element->getName()] = element;
    114116            element->setVisible(this->isVisible());
     117            if (this->owner_)
     118                element->setOwner(this->owner_);
    115119        }
    116120    }
     
    137141    }
    138142
     143    void OverlayGroup::setOwner(ControllableEntity* owner)
     144    {
     145        this->owner_ = owner;
     146
     147        for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
     148            (*it).second->setOwner(owner);
     149    }
    139150
    140151    //########### Console commands ############
  • code/branches/presentation/src/orxonox/overlays/OverlayGroup.h

    r2087 r2485  
    6969        void changedVisibility();
    7070
    71     private:
     71        void setOwner(ControllableEntity* owner);
     72        inline ControllableEntity* getOwner() const
     73            { return this->owner_; }
     74
    7275        //! Scales each OrxonoxOverlay individually by scale.
    7376        void scale(const Vector2& scale) { this->setScale(scale * this->scale_); }
     
    8588        OrxonoxOverlay* getElement(unsigned int index);
    8689
     90    private:
    8791        std::map<std::string, OrxonoxOverlay*> hudElements_;    //!< Contains all the OrxonoxOverlays of the this group.
    8892        Vector2 scale_;                                         //!< Current scale (independant of the elements).
    8993        Vector2 scroll_;                                        //!< Current scrolling offset.
     94        ControllableEntity* owner_;                             //!< The owner of this OverlayGroup
    9095    };
    9196}
  • code/branches/presentation/src/orxonox/overlays/OverlayText.cc

    r2087 r2485  
    5050        this->text_->setCharHeight(1.0);
    5151
    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");
    5757
    5858        this->background_->addChild(this->text_);
     
    6969        SUPER(OverlayText, XMLPort, xmlElement, mode);
    7070
    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);
    7677    }
    7778
  • code/branches/presentation/src/orxonox/overlays/OverlayText.h

    r2087 r2485  
    4747        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
    4848
    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(); }
    5151
    5252        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(); }
    5454
    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(); }
    5757
    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(); }
    6060
    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(); }
    6363
    6464        void setAlignmentString(const std::string& alignment);
    6565        std::string getAlignmentString() const;
    6666
    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();
    6972
    7073        Ogre::TextAreaOverlayElement* text_;
  • code/branches/presentation/src/orxonox/overlays/debug/DebugFPSText.cc

    r2087 r2485  
    4949    void DebugFPSText::tick(float dt)
    5050    {
     51        SUPER(DebugFPSText, tick, dt);
     52
    5153        float fps = GraphicsEngine::getInstance().getAverageFramesPerSecond();
    5254        this->setCaption(convertToString(fps));
  • code/branches/presentation/src/orxonox/overlays/debug/DebugRTRText.cc

    r2087 r2485  
    4949    void DebugRTRText::tick(float dt)
    5050    {
     51        SUPER(DebugRTRText, tick, dt);
     52
    5153        float rtr = GraphicsEngine::getInstance().getAverageTickTime();
    5254        this->setCaption(convertToString(rtr));
  • code/branches/presentation/src/orxonox/overlays/hud/CMakeLists.txt

    r2131 r2485  
    44  HUDRadar.cc
    55  HUDSpeedBar.cc
     6  HUDHealthBar.cc
    67  ChatOverlay.cc
     8  GametypeStatus.cc
    79)
    810
  • code/branches/presentation/src/orxonox/overlays/hud/HUDBar.cc

    r2087 r2485  
    5151        RegisterObject(BarColour);
    5252
    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);
    5555    }
    5656
     
    8484        this->bar_->setMaterialName(materialname);
    8585
    86         setValue(0.4567654f);
    87         setRightToLeft(false);
    88         setAutoColour(true);
     86        this->value_ = 1.0f;  // initielize with 1.0f to trigger a change when calling setValue(0.0f) on the line below
     87        this->setValue(0.0f); // <--
     88        this->setRightToLeft(false);
     89        this->setAutoColour(true);
     90        this->currentColour_ = ColourValue::White;
    8991
    9092        this->background_->addChild(bar_);
     
    101103        SUPER(HUDBar, XMLPort, xmlElement, mode);
    102104
    103         XMLPortParam(HUDBar, "initialValue", setValue,       getValue,       xmlElement, mode);
    104         XMLPortParam(HUDBar, "rightToLeft",  setRightToLeft, getRightToLeft, xmlElement, mode);
    105         XMLPortParam(HUDBar, "autoColour",   setAutoColour,  getAutoColour,  xmlElement, mode);
     105        XMLPortParam(HUDBar, "initialvalue", setValue,       getValue,       xmlElement, mode);
     106        XMLPortParam(HUDBar, "righttoleft",  setRightToLeft, getRightToLeft, xmlElement, mode);
     107        XMLPortParam(HUDBar, "autocolour",   setAutoColour,  getAutoColour,  xmlElement, mode);
     108        XMLPortParam(HUDBar, "bartexture",   setBarTexture,  getBarTexture, xmlElement, mode);
    106109        XMLPortObject(HUDBar, BarColour, "", addColour, getColour, xmlElement, mode);
    107110    }
     
    130133                {
    131134                    this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour2);
     135                    this->currentColour_ = colour2;
    132136                }
    133137                else if (value1 < this->value_)
    134138                {
    135139                    this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour1);
     140                    this->currentColour_ = colour1;
    136141                }
    137142                else
     
    139144                    //float interpolationfactor = (this->value_ - value2) / (value1 - value2);
    140145                    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));
     146                    this->currentColour_ = colour1 * interpolationfactor + colour2 * (1 - interpolationfactor);
     147                    this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, this->currentColour_);
     148
    142149                }
    143150            }
     
    181188        this->colours_.clear();
    182189    }
     190
     191    void HUDBar::setBarTexture(const std::string& texture)
     192    {
     193        this->textureUnitState_->setTextureName(texture);
     194    }
     195
     196    const std::string& HUDBar::getBarTexture() const
     197    {
     198        return this->textureUnitState_->getTextureName();
     199    }
    183200}
  • code/branches/presentation/src/orxonox/overlays/hud/HUDBar.h

    r2087 r2485  
    7171        void clearColours();
    7272
    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_; }
    7583
    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_; }
    7895
    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_; }
    81115
    82116    protected:
     
    90124        bool autoColour_;                   //!< whether bar changes colour automatically
    91125        float value_;                       //!< progress of bar
     126        ColourValue currentColour_;
    92127
    93128        Ogre::PanelOverlayElement* bar_;
  • code/branches/presentation/src/orxonox/overlays/hud/HUDNavigation.cc

    r2087 r2485  
    129129    void HUDNavigation::tick(float dt)
    130130    {
     131        SUPER(HUDNavigation, tick, dt);
     132
    131133        if (!Radar::getInstance().getFocus())
    132134        {
     
    149151*/
    150152        // transform to screen coordinates
    151         Vector3 pos = /*transformationMatrix * */Radar::getInstance().getFocus()->getWorldPosition();
     153        Vector3 pos = /*transformationMatrix * */Radar::getInstance().getFocus()->getRVWorldPosition();
    152154
    153155        bool outOfView;
     
    223225/*
    224226            Vector3 aimpos = transformationMatrix * getPredictedPosition(SpaceShip::getLocalShip()->getPosition(),
    225                     Projectile::getSpeed(), Radar::getInstance().getFocus()->getWorldPosition(), Radar::getInstance().getFocus()->getOrientedVelocity());
     227                    Projectile::getSpeed(), Radar::getInstance().getFocus()->getRVWorldPosition(), Radar::getInstance().getFocus()->getRVOrientedVelocity());
    226228*/
    227229            if (wasOutOfView_)
     
    250252/*
    251253        if (Radar::getInstance().getFocus())
    252             return (Radar::getInstance().getFocus()->getWorldPosition() - SpaceShip::getLocalShip()->getPosition()).length();
     254            return (Radar::getInstance().getFocus()->getRVWorldPosition() - SpaceShip::getLocalShip()->getPosition()).length();
    253255        else
    254256*/
  • code/branches/presentation/src/orxonox/overlays/hud/HUDRadar.cc

    r2087 r2485  
    4040#include "core/XMLPort.h"
    4141#include "objects/Radar.h"
     42#include "objects/worldentities/WorldEntity.h"
     43#include "objects/worldentities/pawns/Pawn.h"
    4244#include "tools/TextureGenerator.h"
    4345
     
    5153        RegisterObject(HUDRadar);
    5254
    53         marker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
     55        this->marker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
    5456            .createOverlayElement("Panel", "HUDRadar_marker_" + getUniqueNumberString()));
    55         marker_->setMaterialName("Orxonox/RadarMarker");
    56         overlay_->add2D(marker_);
    57         marker_->hide();
     57        this->marker_->setMaterialName("Orxonox/RadarMarker");
     58        this->overlay_->add2D(this->marker_);
     59        this->marker_->hide();
    5860
    59         setRadarSensitivity(1.0f);
    60         setHalfDotSizeDistance(3000.0f);
    61         setMaximumDotSize(0.1f);
     61        this->setRadarSensitivity(1.0f);
     62        this->setHalfDotSizeDistance(3000.0f);
     63        this->setMaximumDotSize(0.1f);
    6264
    63         shapeMaterials_[RadarViewable::Dot]      = "RadarSquare.tga";
    64         shapeMaterials_[RadarViewable::Triangle] = "RadarSquare.tga";
    65         shapeMaterials_[RadarViewable::Square]   = "RadarSquare.tga";
     65        this->shapeMaterials_[RadarViewable::Dot]      = "RadarDot.tga";
     66        this->shapeMaterials_[RadarViewable::Triangle] = "RadarSquare.tga";
     67        this->shapeMaterials_[RadarViewable::Square]   = "RadarSquare.tga";
     68
     69        this->owner_ = 0;
    6670    }
    6771
     
    9094    void HUDRadar::displayObject(RadarViewable* object, bool bIsMarked)
    9195    {
    92 /*
     96        if (object == (RadarViewable*)this->owner_)
     97            return;
     98
    9399        const WorldEntity* wePointer = object->getWorldEntity();
    94100
    95101        // Just to be sure that we actually have a WorldEntity.
    96102        // We could do a dynamic_cast, but that would be a lot slower.
    97         if (!wePointer)
     103        if (!wePointer || !this->owner_)
    98104        {
    99             CCOUT(4) << "Cannot display a non-WorldEntitiy on the radar" << std::endl;
     105            if (!wePointer)
     106                CCOUT(2) << "Cannot display a non-WorldEntitiy on the radar" << std::endl;
     107            if (!this->owner_)
     108                CCOUT(2) << "No owner defined" << std::endl;
    100109            return;
    101110        }
    102 */
     111
    103112        // try to find a panel already created
    104113        Ogre::PanelOverlayElement* panel;
     
    112121            // get right material
    113122            panel->setMaterialName(TextureGenerator::getMaterialName(
    114                 shapeMaterials_[object->getRadarObjectType()], object->getRadarObjectColour()));
     123                shapeMaterials_[object->getRadarObjectShape()], object->getRadarObjectColour()));
    115124            this->overlay_->add2D(panel);
    116125            this->itRadarDots_ = this->radarDots_.end();
     
    121130            ++itRadarDots_;
    122131            std::string materialName = TextureGenerator::getMaterialName(
    123                 shapeMaterials_[object->getRadarObjectType()], object->getRadarObjectColour());
     132                shapeMaterials_[object->getRadarObjectShape()], object->getRadarObjectColour());
    124133            if (materialName != panel->getMaterialName())
    125134                panel->setMaterialName(materialName);
    126135        }
    127136        panel->show();
    128 /*
     137
    129138        // set size to fit distance...
    130         float distance = (wePointer->getWorldPosition() - SpaceShip::getLocalShip()->getPosition()).length();
     139        float distance = (wePointer->getWorldPosition() - this->owner_->getPosition()).length();
    131140        // calculate the size with 1/distance dependency for simplicity (instead of exp(-distance * lambda)
    132141        float size = maximumDotSize_ * halfDotSizeDistance_ / (halfDotSizeDistance_ + distance);
     
    134143
    135144        // calc position on radar...
    136         Vector2 coord = get2DViewcoordinates(SpaceShip::getLocalShip()->getPosition(), SpaceShip::getLocalShip()->getDir(), SpaceShip::getLocalShip()->getOrth(), wePointer->getWorldPosition());
     145        Vector2 coord = get2DViewcoordinates(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition());
    137146        coord *= Ogre::Math::PI / 3.5; // small adjustment to make it fit the texture
    138147        panel->setPosition((1.0 + coord.x - size) * 0.5, (1.0 - coord.y - size) * 0.5);
     
    144153            this->marker_->setPosition((1.0 + coord.x - size * 1.5) * 0.5, (1.0 - coord.y - size * 1.5) * 0.5);
    145154        }
    146 */
    147155    }
    148156
     
    154162        this->marker_->hide();
    155163    }
     164
     165    void HUDRadar::changedOwner()
     166    {
     167        SUPER(HUDRadar, changedOwner);
     168
     169        this->owner_ = dynamic_cast<Pawn*>(this->getOwner());
     170    }
    156171}
  • code/branches/presentation/src/orxonox/overlays/hud/HUDRadar.h

    r2087 r2485  
    4949
    5050        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
     51        virtual void changedOwner();
    5152
    5253    private:
     
    7677
    7778        float sensitivity_;
     79
     80        Pawn* owner_;
    7881    };
    7982}
  • code/branches/presentation/src/orxonox/overlays/hud/HUDSpeedBar.cc

    r2087 r2485  
    3131#include "HUDSpeedBar.h"
    3232#include "core/CoreIncludes.h"
     33#include "objects/worldentities/pawns/SpaceShip.h"
     34#include "objects/items/Engine.h"
    3335
    3436namespace orxonox
     
    4143        RegisterObject(HUDSpeedBar);
    4244
     45        this->owner_ = 0;
    4346    }
    4447
     
    4952    void HUDSpeedBar::tick(float dt)
    5053    {
    51 /*
    52         SpaceShip* ship = SpaceShip::getLocalShip();
    53         if (ship)
     54        SUPER(HUDSpeedBar, tick, dt);
     55
     56        if (this->owner_ && this->owner_->getEngine())
    5457        {
    55             float v = ship->getVelocity().length();
    56             float value = v / ship->getMaxSpeed();
    57             if (value != this->getValue())
    58                 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);
    5960        }
    60 */
     61    }
     62
     63    void HUDSpeedBar::changedOwner()
     64    {
     65        SUPER(HUDSpeedBar, changedOwner);
     66
     67        this->owner_ = dynamic_cast<SpaceShip*>(this->getOwner());
    6168    }
    6269}
  • code/branches/presentation/src/orxonox/overlays/hud/HUDSpeedBar.h

    r2087 r2485  
    4545
    4646        virtual void tick(float dt);
     47        virtual void changedOwner();
     48
     49    private:
     50        SpaceShip* owner_;
    4751    };
    4852}
Note: See TracChangeset for help on using the changeset viewer.