Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1614 for code/branches/hud


Ignore:
Timestamp:
Jun 21, 2008, 2:35:24 PM (16 years ago)
Author:
rgrieder
Message:
  • Dots on the Radar actually disappear now when a Ship gets destroyed…
  • svn save to keep History of HUDText when renaming AND moving
Location:
code/branches/hud
Files:
2 deleted
21 edited
2 copied
2 moved

Legend:

Unmodified
Added
Removed
  • code/branches/hud/src/orxonox/OrxonoxPrereqs.h

    r1609 r1614  
    130130}
    131131
     132namespace Ogre
     133{
     134    // some got forgotten in OgrePrerequisites
     135    class BorderPanelOverlayElement;
     136    class PanelOverlayElement;
     137    class TextAreaOverlayElement;
     138}
     139
    132140
    133141#endif /* _OrxonoxPrereqs_H__ */
  • code/branches/hud/src/orxonox/Radar.cc

    r1613 r1614  
    2323 *      Reto Grieder
    2424 *   Co-authors:
    25  *      ...
     25 *      Felix Schulthess
    2626 *
    2727 */
     
    3838#include "objects/SpaceShip.h"
    3939#include "core/CoreIncludes.h"
     40#include "RadarListener.h"
    4041//#include "core/ConfigValueIncludes.h"
    4142
    4243namespace orxonox
    4344{
    44     RadarListener::RadarListener()
    45     {
    46         RegisterRootObject(RadarListener);
    47     }
    48 
    4945    SetConsoleCommand(Radar, cycleNavigationFocus, true).setAccessLevel(AccessLevel::User);
    5046    SetConsoleCommand(Radar, releaseNavigationFocus, true).setAccessLevel(AccessLevel::User);
     
    8682    }
    8783
    88     /*void Radar::unregisterObject(RadarViewable* object)
    89     {
    90         if (this->focus_ == object)
    91             this->focus_ = 0;
    92         // TODO: check for focus
    93     }*/
    94 
    9584    const RadarViewable* Radar::getFocus()
    9685    {
     
    119108        for (Iterator<RadarListener> itListener = ObjectList<RadarListener>::begin(); itListener; ++itListener)
    120109        {
     110            (*itListener)->radarTick(dt);
     111
    121112            for (Iterator<RadarViewable> itElement = ObjectList<RadarViewable>::begin(); itElement; ++itElement)
    122113            {
     
    124115                    (*itListener)->displayObject(*itElement, *itElement == this->focus_);
    125116            }
    126 
    127             (*itListener)->radarTick(dt);
    128 
    129             if (this->focus_ == 0)
    130                 (*itListener)->hideMarker();
    131117        }
    132118    }
     
    190176    }
    191177
     178    void Radar::listObjects() const
     179    {
     180        COUT(3) << "List of RadarObjects:\n";
     181        // iterate through all Radar Objects
     182        unsigned int i = 0;
     183        for (Iterator<RadarViewable> it = ObjectList<RadarViewable>::start(); it; ++it, ++i)
     184        {
     185            COUT(3) << i++ << ": " << (*it)->getWorldPosition() << std::endl;
     186        }
     187    }
     188
    192189
    193190    /*static*/ Radar& Radar::getInstance()
  • code/branches/hud/src/orxonox/Radar.h

    r1613 r1614  
    2323 *      Reto Grieder
    2424 *   Co-authors:
    25  *      ...
     25 *      Felix Schulthess
    2626 *
    2727 */
     
    3737#include "OrxonoxPrereqs.h"
    3838
     39#include <map>
    3940#include <string>
    4041#include "core/Iterator.h"
     
    4546namespace orxonox
    4647{
    47     class _OrxonoxExport RadarListener : virtual public OrxonoxClass
    48     {
    49     public:
    50         RadarListener();
    51         virtual ~RadarListener() { }
    52 
    53         virtual void displayObject(RadarViewable* viewable, bool bIsMarked) = 0;
    54         virtual void hideMarker() = 0;
    55         virtual float getRadarSensitivity() = 0;
    56         virtual void radarTick(float dt) = 0;
    57     };
    58 
    5948    /**
    6049    @brief This class merely ensures that no one can inherit from Radar.
     
    7362        ~Radar();
    7463
    75         //void unregisterObject(RadarViewable* object);
    7664        const RadarViewable* getFocus();
    7765        RadarViewable::Shape addObjectDescription(const std::string name);
     66
     67        void listObjects() const;
    7868
    7969        static Radar& getInstance();
  • code/branches/hud/src/orxonox/RadarListener.cc

    r1613 r1614  
    2828
    2929#include "OrxonoxStableHeaders.h"
    30 #include "RadarViewable.h"
    31 #include "core/Debug.h"
    32 #include "Radar.h"
     30#include "RadarListener.h"
    3331
    3432namespace orxonox
    3533{
    36     /**
    37         @brief Constructor.
    38     */
    39     RadarViewable::RadarViewable()
    40         : radarObjectCamouflage_(0.0f)
    41         , radarObjectType_(Dot)
    42         , radarObject_(0)
    43         , radarObjectDescription_("staticObject")
     34    RadarListener::RadarListener()
    4435    {
    45         RegisterRootObject(RadarViewable);
     36        RegisterRootObject(RadarListener);
    4637    }
    47 
    48     void RadarViewable::setRadarObjectDescription(const std::string& str)
    49     {
    50         Radar* radar = Radar::getInstancePtr();
    51         if (radar)
    52             this->radarObjectType_ = radar->addObjectDescription(str);
    53         else
    54         {
    55             CCOUT(2) << "Attempting to access the radar, but the radar is non existent." << std::endl;
    56         }
    57         this->radarObjectDescription_ = str;
    58     }
    59 
    60     /*void RadarViewable::unregisterFromRadar()
    61     {
    62         Radar* radar = Radar::getInstancePtr();
    63         if (radar)
    64             radar->unregisterObject(this);
    65         else
    66         {
    67             CCOUT(2) << "Attempting to unregister an object to the radar, but the radar is non existent." << std::endl;
    68         }
    69     }*/
    7038}
  • code/branches/hud/src/orxonox/RadarListener.h

    r1613 r1614  
    2727 */
    2828
    29 #ifndef _RadarViewable_H__
    30 #define _RadarViewable_H__
     29#ifndef _RadarListener_H__
     30#define _RadarListener_H__
    3131
    3232#include "OrxonoxPrereqs.h"
    33 #include <string>
    3433#include "core/OrxonoxClass.h"
    35 #include "util/Math.h"
    3634
    3735namespace orxonox
    3836{
    39     /**
    40     @brief Interface for receiving window events.
    41     */
    42     class _OrxonoxExport RadarViewable : virtual public OrxonoxClass
     37    class _OrxonoxExport RadarListener : virtual public OrxonoxClass
    4338    {
    4439    public:
    45         enum Shape
    46         {
    47             Square,
    48             Dot,
    49             Triangle
    50         };
     40        RadarListener();
     41        virtual ~RadarListener() { }
    5142
    52     public:
    53         RadarViewable();
    54         virtual ~RadarViewable() { }//unregisterFromRadar(); }
    55 
    56         float getRadarObjectCamouflage() const { return this->radarObjectCamouflage_; }
    57         void setRadarObjectCamouflage(float camouflage) { this->radarObjectCamouflage_ = camouflage; }
    58 
    59         const ColourValue& getRadarObjectColour() const { return this->radarObjectColour_; }
    60         void setRadarObjectColour(const ColourValue& colour) { this->radarObjectColour_ = colour; }
    61 
    62         const std::string& getRadarObjectDescription() const { return this->radarObjectDescription_; }
    63         void setRadarObjectDescription(const std::string& str);
    64 
    65         const WorldEntity* getWorldEntity() const { return this->radarObject_; }
    66         const Vector3& getWorldPosition() const { validate(); return this->radarObject_->getWorldPosition(); }
    67         Vector3 getOrientedVelocity() const
    68             { validate(); return this->radarObject_->getOrientation() * this->radarObject_->getVelocity(); }
    69 
    70         Shape getRadarObjectType() const { return this->radarObjectType_; }
    71 
    72     protected:
    73         WorldEntity* radarObject_;
    74         //void unregisterFromRadar();
    75 
    76     private:
    77         void validate() const { if (!this->radarObject_)
    78         { COUT(1) << "Assertation: Every RadarViewable has to be assigned a WorldEntity pointer!" << std::endl; assert(0); } }
    79 
    80         float radarObjectCamouflage_;
    81         Shape radarObjectType_;
    82         std::string radarObjectDescription_;
    83         ColourValue radarObjectColour_;
     43        virtual void displayObject(RadarViewable* viewable, bool bIsMarked) = 0;
     44        virtual float getRadarSensitivity() = 0;
     45        virtual void radarTick(float dt) = 0;
    8446    };
    8547}
    8648
    87 #endif /* _RadarViewable_H__ */
     49#endif /* _RadarListener_H__ */
  • code/branches/hud/src/orxonox/RadarViewable.cc

    r1613 r1614  
    5757        this->radarObjectDescription_ = str;
    5858    }
    59 
    60     /*void RadarViewable::unregisterFromRadar()
    61     {
    62         Radar* radar = Radar::getInstancePtr();
    63         if (radar)
    64             radar->unregisterObject(this);
    65         else
    66         {
    67             CCOUT(2) << "Attempting to unregister an object to the radar, but the radar is non existent." << std::endl;
    68         }
    69     }*/
    7059}
  • code/branches/hud/src/orxonox/RadarViewable.h

    r1613 r1614  
    5252    public:
    5353        RadarViewable();
    54         virtual ~RadarViewable() { }//unregisterFromRadar(); }
     54        virtual ~RadarViewable() { }
    5555
    5656        float getRadarObjectCamouflage() const { return this->radarObjectCamouflage_; }
     
    7272    protected:
    7373        WorldEntity* radarObject_;
    74         //void unregisterFromRadar();
    7574
    7675    private:
  • code/branches/hud/src/orxonox/overlays/HUDText.cc

    r1604 r1614  
    3131
    3232#include <OgreOverlayManager.h>
     33#include <OgreTextAreaOverlayElement.h>
     34#include <OgrePanelOverlayElement.h>
    3335
    3436#include "util/Convert.h"
     
    4143
    4244  HUDText::HUDText()
    43     : background_(0)
    44     , text_(0)
     45    : text_(0)
    4546  {
    4647    RegisterObject(HUDText);
     
    5354      if (this->text_)
    5455          OverlayManager::getSingleton().destroyOverlayElement(this->text_);
    55       if (this->background_)
    56           OverlayManager::getSingleton().destroyOverlayElement(this->background_);
    5756    }
    5857  }
     
    6463    if (mode == XMLPort::LoadObject)
    6564    {
    66       // create background
    67       this->background_ = static_cast<PanelOverlayElement*>(
    68               OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "_Background"));
    69 
    7065      this->text_ = static_cast<TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton().createOverlayElement("TextArea", getName() + "_Text"));
    7166      this->text_->setCharHeight(1.0f);
    7267      this->text_->setFontName("Monofur");
    7368
    74       this->overlay_->add2D(this->background_);
    7569      this->background_->addChild(this->text_);
    7670    }
    7771
    78     XMLPortParam(HUDText, "material", setBackgroundMaterial, getBackgroundMaterial, xmlElement, mode);
    7972    XMLPortParam(HUDText, "font", setFont, getFont, xmlElement, mode);
    8073    XMLPortParam(HUDText, "caption", setCaption, getCaption, xmlElement, mode);
     
    8477      this->text_->setCaption(this->caption_);
    8578    }
    86   }
    87 
    88   void HUDText::setBackgroundMaterial(const std::string& material)
    89   {
    90     if (this->background_ && material != "")
    91       this->background_->setMaterialName(material);
    92   }
    93 
    94   std::string HUDText::getBackgroundMaterial() const
    95   {
    96     if (this->background_)
    97       return this->background_->getMaterialName();
    98     else
    99       return "";
    10079  }
    10180
  • code/branches/hud/src/orxonox/overlays/HUDText.h

    r1601 r1614  
    3232#include "OrxonoxPrereqs.h"
    3333
     34#include <string>
    3435#include <OgrePrerequisites.h>
    35 #include <OgreTextAreaOverlayElement.h>
    36 #include <OgrePanelOverlayElement.h>
    37 
    38 #include "util/Math.h"
    3936#include "overlays/OrxonoxOverlay.h"
    4037
     
    5047
    5148  protected:
    52     void setBackgroundMaterial(const std::string& material);
    53     std::string getBackgroundMaterial() const;
    5449    void setCaption(const std::string& caption);
    5550    const std::string& getCaption() const;
     
    5853
    5954    Ogre::TextAreaOverlayElement* text_;
     55
    6056  private:
    6157    std::string caption_;
    62     Ogre::PanelOverlayElement* background_;
    6358  };
    6459}
  • code/branches/hud/src/orxonox/overlays/OrxonoxOverlay.cc

    r1604 r1614  
    3131
    3232#include <OgreOverlayManager.h>
     33#include <OgrePanelOverlayElement.h>
    3334#include "util/Convert.h"
    3435#include "core/CoreIncludes.h"
     
    4142  OrxonoxOverlay::OrxonoxOverlay()
    4243    : overlay_(0)
     44    , background_(0)
    4345    , windowAspectRatio_(1.0f)
    4446    , bCorrectAspect_(false)
     
    5052  {
    5153    RegisterObject(OrxonoxOverlay);
     54  }
     55
     56  OrxonoxOverlay::~OrxonoxOverlay()
     57  {
     58    if (this->background_)
     59      Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->background_);
    5260  }
    5361
     
    6371      this->windowResized(GraphicsEngine::getSingleton().getWindowWidth(),
    6472            GraphicsEngine::getSingleton().getWindowHeight());
     73
     74      // create background
     75      this->background_ = static_cast<Ogre::PanelOverlayElement*>(
     76          Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", getUniqueNumberStr() + "_Background"));
     77      this->overlay_->add2D(this->background_);
    6578    }
    6679
     
    7083    XMLPortParam(OrxonoxOverlay, "origin", setOrigin, getOrigin, xmlElement, mode);
    7184    XMLPortParam(OrxonoxOverlay, "position", setPosition, getPosition, xmlElement, mode);
     85    XMLPortParam(OrxonoxOverlay, "background", setBackgroundMaterial, getBackgroundMaterial, xmlElement, mode);
    7286
    7387    if (mode == XMLPort::LoadObject)
     
    8397  }
    8498
    85   OrxonoxOverlay::~OrxonoxOverlay()
     99  void OrxonoxOverlay::setBackgroundMaterial(const std::string& material)
    86100  {
     101    if (this->background_ && material != "")
     102      this->background_->setMaterialName(material);
     103  }
     104
     105  std::string OrxonoxOverlay::getBackgroundMaterial() const
     106  {
     107    if (this->background_)
     108      return this->background_->getMaterialName();
     109    else
     110      return "";
    87111  }
    88112
  • code/branches/hud/src/orxonox/overlays/OrxonoxOverlay.h

    r1604 r1614  
    3939namespace orxonox
    4040{
    41   class _OrxonoxExport OrxonoxOverlay : public BaseObject, public WindowEventListener
    42   {
     41    class _OrxonoxExport OrxonoxOverlay : public BaseObject, public WindowEventListener
     42    {
    4343    public:
    44       Ogre::Overlay* getOverlay() { return this->overlay_; }
    45       OrxonoxOverlay();
    46       virtual ~OrxonoxOverlay();
     44        Ogre::Overlay* getOverlay() { return this->overlay_; }
     45        OrxonoxOverlay();
     46        virtual ~OrxonoxOverlay();
    4747
    48       virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
     48        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
    4949
    50       void setAspectCorrection(bool val);
    51       bool getAspectCorrection() { return this->bCorrectAspect_; }
     50        void show() { this->setVisibility(true); }
     51        void hide() { this->setVisibility(false); }
    5252
    53       /** Sets the position of this overlay. */
    54       void setPosition(Vector2 pos) { this->position_ = pos; this->positionChanged(); }
     53        void setAspectCorrection(bool val);
     54        bool getAspectCorrection() { return this->bCorrectAspect_; }
    5555
    56       /** Gets the current position. */
    57       Vector2 getPosition() const { return this->position_; }
     56        /** Sets the position of this overlay. */
     57        void setPosition(Vector2 pos) { this->position_ = pos; this->positionChanged(); }
    5858
    59       /** Scrolls the overlay by the offsets provided. */
    60       void scroll(Vector2 scroll) { this->position_ += scroll; this->positionChanged(); }
     59        /** Gets the current position. */
     60        Vector2 getPosition() const { return this->position_; }
    6161
    62       /** Sets the origin point of this overlay. */
    63       void setOrigin(Vector2 pos) { this->origin_ = pos; this->positionChanged(); }
     62        /** Scrolls the overlay by the offsets provided. */
     63        void scroll(Vector2 scroll) { this->position_ += scroll; this->positionChanged(); }
    6464
    65       /** Gets the origin point of this overlay */
    66       Vector2 getOrigin() const { return this->origin_; }
     65        /** Sets the origin point of this overlay. */
     66        void setOrigin(Vector2 pos) { this->origin_ = pos; this->positionChanged(); }
    6767
    68       /** Sets the rotation applied to this overlay.*/
    69       void setRotation(const Ogre::Radian& angle) { this->angle_ = angle; this->angleChanged(); }
     68        /** Gets the origin point of this overlay */
     69        Vector2 getOrigin() const { return this->origin_; }
    7070
    71       /** Gets the rotation applied to this overlay, in degrees.*/
    72       const Radian& getRotation() const { return this->angle_; }
     71        /** Sets the rotation applied to this overlay.*/
     72        void setRotation(const Ogre::Radian& angle) { this->angle_ = angle; this->angleChanged(); }
    7373
    74       /** Adds the passed in angle to the rotation applied to this overlay. */
    75       void rotate(const Radian& angle) { this->angle_ += angle; this->angleChanged(); }
     74        /** Gets the rotation applied to this overlay, in degrees.*/
     75        const Radian& getRotation() const { return this->angle_; }
    7676
    77       /** Sets the size of this overlay. */
    78       void setSize(const Vector2& size) { this->size_ = size; this->sizeChanged(); }
     77        /** Adds the passed in angle to the rotation applied to this overlay. */
     78        void rotate(const Radian& angle) { this->angle_ += angle; this->angleChanged(); }
    7979
    80       /** Gets the current size (not corrected) */
    81       Vector2 getUncorrectedSize() const { return this->size_; }
     80        /** Sets the size of this overlay. */
     81        void setSize(const Vector2& size) { this->size_ = size; this->sizeChanged(); }
    8282
    83       /** Gets the current size (corrected) */
    84       Vector2 getSize() const { return this->size_ * this->sizeCorrection_; }
     83        /** Gets the current size (not corrected) */
     84        Vector2 getUncorrectedSize() const { return this->size_; }
    8585
    86       /** Gets the current size correction */
    87       Vector2 getSizeCorrection() const { return this->sizeCorrection_; }
     86        /** Gets the current size (corrected) */
     87        Vector2 getSize() const { return this->size_ * this->sizeCorrection_; }
    8888
    89       /** Scales the overlay */
    90       void scale(Vector2 scale) { this->size_ *= scale; this->sizeChanged(); }
     89        /** Gets the current size correction */
     90        Vector2 getSizeCorrection() const { return this->sizeCorrection_; }
     91
     92        /** Scales the overlay */
     93        void scale(Vector2 scale) { this->size_ *= scale; this->sizeChanged(); }
    9194
    9295    protected:
    93       virtual void changedVisibility();
    94       virtual void sizeChanged();
    95       virtual void angleChanged();
    96       virtual void positionChanged();
    97       float getWindowAspectRatio() { return windowAspectRatio_; }
     96        virtual void changedVisibility();
     97        virtual void sizeChanged();
     98        virtual void angleChanged();
     99        virtual void positionChanged();
     100        float getWindowAspectRatio() { return windowAspectRatio_; }
    98101
    99       Ogre::Overlay* overlay_;
     102        void setBackgroundMaterial(const std::string& material);
     103        std::string getBackgroundMaterial() const;
     104
     105        Ogre::Overlay* overlay_;
     106        Ogre::PanelOverlayElement* background_;
    100107
    101108    private:
    102       void windowResized(int newWidth, int newHeight);
     109        void windowResized(int newWidth, int newHeight);
    103110
    104       float windowAspectRatio_;
    105       bool bCorrectAspect_;
    106       Vector2 size_;
    107       Vector2 sizeCorrection_;
    108       Radian angle_;
    109       Vector2 position_;
    110       Vector2 origin_;
     111        float windowAspectRatio_;
     112        bool bCorrectAspect_;
     113        Vector2 size_;
     114        Vector2 sizeCorrection_;
     115        Radian angle_;
     116        Vector2 position_;
     117        Vector2 origin_;
    111118
    112       static unsigned int hudOverlayCounter_s;
     119        static unsigned int hudOverlayCounter_s;
    113120  };
    114121}
  • code/branches/hud/src/orxonox/overlays/OverlayGroup.cc

    r1609 r1614  
    4141
    4242  SetConsoleCommand(OverlayGroup, toggleVisibility, false).setAccessLevel(AccessLevel::User);
    43 
    44   OverlayGroup* OverlayGroup::hudInstance_s = 0;
     43  SetConsoleCommand(OverlayGroup, scaleGroup, false).setAccessLevel(AccessLevel::User);
    4544
    4645  using namespace Ogre;
     
    5049  {
    5150    RegisterObject(OverlayGroup);
    52 
    53     // Singleton like in Ogre. Constructor and destructor are public,
    54     // but the assert prevents from having multiple instances.
    55     assert(hudInstance_s == 0);
    56     hudInstance_s = this;
    5751  }
    5852
    5953  OverlayGroup::~OverlayGroup()
    6054  {
    61     if (this->isInitialized())
    62     {
    63     }
    64 
    65     hudInstance_s = 0;
    6655  }
    6756
     
    10493  }
    10594
    106   /*static*/ OverlayGroup& OverlayGroup::getHUD()
    107   {
    108     assert(hudInstance_s);
    109     return *hudInstance_s;
    110   }
    11195
    11296  /*static*/ void OverlayGroup::toggleVisibility(const std::string& name)
    11397  {
    114     if (OverlayGroup::getHUD().hudElements_.find(name) != OverlayGroup::getHUD().hudElements_.end())
     98    for (Iterator<OverlayGroup> it = ObjectList<OverlayGroup>::begin(); it; ++it)
    11599    {
    116       OverlayGroup::getHUD().hudElements_[name]->setVisibility(!OverlayGroup::getHUD().hudElements_[name]->isVisible());
     100        if ((*it)->getName() == name)
     101            (*it)->setVisibility(!((*it)->isVisible()));
    117102    }
    118103  }
    119104
     105  /*static*/ void OverlayGroup::scaleGroup(const std::string& name, float scale)
     106  {
     107    for (Iterator<OverlayGroup> it = ObjectList<OverlayGroup>::begin(); it; ++it)
     108    {
     109        if ((*it)->getName() == name)
     110            (*it)->scale(Vector2(scale, scale));
     111    }
     112  }
    120113}
  • code/branches/hud/src/orxonox/overlays/OverlayGroup.h

    r1604 r1614  
    5454
    5555        static void toggleVisibility(const std::string& name);
    56         static OverlayGroup& getHUD();
     56        static void scaleGroup(const std::string& name, float scale);
    5757
    5858      private:
     
    6464        std::map<std::string, OrxonoxOverlay*> hudElements_;
    6565        Vector2 scale_;
    66 
    67         static OverlayGroup* hudInstance_s;
    6866    };
    6967}
  • code/branches/hud/src/orxonox/overlays/hud/HUDBar.cc

    r1609 r1614  
    3535#include <OgreMaterialManager.h>
    3636#include <OgreTechnique.h>
     37#include <OgrePanelOverlayElement.h>
    3738
    3839#include "util/Convert.h"
     
    4546
    4647    HUDBar::HUDBar()
     48        : bar_(0)
     49        , textureUnitState_(0)
    4750    {
    4851        RegisterObject(HUDBar);
    49 
    50         this->bar_ = 0;
    51         this->background_ = 0;
    52         this->textureUnitState_ = 0;
    53 
    54         barWidth_s = 0.88f;
    55         barHeight_s = 1.0f;
    56         barOffsetLeft_s = 0.06f;
    57         barOffsetTop_s = 0.0f;
    58 
    59         this->value_ = -1;
    60         this->autoColour_ = true;
    61         this->right2Left_ = false; // default is left to right progress
    6252    }
    6353
     
    6858            if (this->bar_)
    6959                OverlayManager::getSingleton().destroyOverlayElement(this->bar_);
     60            // FIXME: Check whether we have to delete the textureUnitState_;
    7061        }
    7162    }
     
    7768        if (mode == XMLPort::LoadObject)
    7869        {
    79             // create background
    80             this->background_ = static_cast<PanelOverlayElement*>(
    81                     OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "_Background_" + getUniqueNumberStr()));
    82             this->background_->setMaterialName("Orxonox/BarBackground");
    83             this->overlay_->add2D(this->background_);
    84 
    8570            // create new material
    8671            std::string materialname = "barmaterial" + getConvertedValue<unsigned int, std::string>(materialcount_s++);
     
    9378
    9479            // create bar
     80            barWidth_s = 0.88f;
     81            barHeight_s = 1.0f;
     82            barOffsetLeft_s = 0.06f;
     83            barOffsetTop_s = 0.0f;
    9584            this->bar_ = static_cast<PanelOverlayElement*>(OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "Bar" + getUniqueNumberStr()));
    9685            this->bar_->setMaterialName(materialname);
    9786            this->background_->addChild(bar_);
    98         }
    9987
    100         XMLPortParamLoadOnly(HUDBar, "value", setValue, xmlElement, mode);
     88            this->setValue(0);
     89            this->autoColour_ = true;
     90            this->right2Left_ = false; // default is left to right progress
    10191
    102         if (mode == XMLPort::LoadObject)
    103         {
    10492            this->addColour(0.7, ColourValue(0.2, 0.7, 0.2));
    10593            this->addColour(0.4, ColourValue(0.7, 0.5, 0.2));
    10694            this->addColour(0.1, ColourValue(0.7, 0.2, 0.2));
    10795        }
     96
     97        XMLPortParamLoadOnly(HUDBar, "value", setValue, xmlElement, mode);
    10898    }
    10999
  • code/branches/hud/src/orxonox/overlays/hud/HUDBar.h

    r1601 r1614  
    3434#include "OrxonoxPrereqs.h"
    3535
     36#include <map>
    3637#include <OgrePrerequisites.h>
    37 #include <OgrePanelOverlayElement.h>
    38 
    3938#include "util/Math.h"
    4039#include "overlays/OrxonoxOverlay.h"
     
    6766      float value_;                       // progress of bar
    6867      Ogre::PanelOverlayElement* bar_;
    69       Ogre::PanelOverlayElement* background_;
    7068      Ogre::TextureUnitState* textureUnitState_;
    7169      std::map<float, ColourValue> colours_;
  • code/branches/hud/src/orxonox/overlays/hud/HUDFPSText.cc

    r1599 r1614  
    2929#include "OrxonoxStableHeaders.h"
    3030#include "HUDFPSText.h"
     31#include <OgreTextAreaOverlayElement.h>
    3132#include "GraphicsEngine.h"
    3233#include "util/Convert.h"
  • code/branches/hud/src/orxonox/overlays/hud/HUDNavigation.cc

    r1613 r1614  
    3131
    3232#include <OgreOverlayManager.h>
    33 #include <OgreStringConverter.h>
    34 
    35 //#include "GraphicsEngine.h"
    36 // TODO: remove the SpaceShip and CameraHandler dependencies
    37 #include "core/Debug.h"
    38 #include "core/CoreIncludes.h"
     33#include <OgreTextAreaOverlayElement.h>
     34#include <OgrePanelOverlayElement.h>
     35
     36#include "util/Math.h"
    3937#include "core/ConsoleCommand.h"
    4038#include "objects/SpaceShip.h"
    4139#include "objects/Projectile.h"
    4240#include "objects/CameraHandler.h"
    43 #include "overlays/OverlayGroup.h"
    4441#include "Radar.h"
    4542
     
    6865        if (this->isInitialized())
    6966        {
    70             if (this->container_)
    71                 OverlayManager::getSingleton().destroyOverlayElement(this->container_);
    7267            if (this->navMarker_)
    7368                OverlayManager::getSingleton().destroyOverlayElement(this->navMarker_);
     
    7671            if (this->aimMarker_)
    7772                OverlayManager::getSingleton().destroyOverlayElement(this->aimMarker_);
     73            if (this->container_)
     74                OverlayManager::getSingleton().destroyOverlayElement(this->container_);
    7875        }
    7976
     
    8784        if (mode == XMLPort::LoadObject)
    8885        {
    89             // create container
     86            // create container because we cannot add a Text element to an Overlay
    9087            container_ = static_cast<OverlayContainer*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "_navContainer"));
    9188
  • code/branches/hud/src/orxonox/overlays/hud/HUDNavigation.h

    r1613 r1614  
    3333
    3434#include <OgrePrerequisites.h>
    35 #include <OgreTextAreaOverlayElement.h>
    36 #include <OgrePanelOverlayElement.h>
    3735#include "overlays/OrxonoxOverlay.h"
    38 #include "util/Math.h"
    3936
    4037namespace orxonox
     
    5047        void tick(float dt);
    5148
    52         //void cycleFocus();
    5349        float getDist2Focus() const;
    54 
    55         /*inline RadarObject* getFocus() const
    56             { return this->focus_; }
    57         void releaseFocus();*/
    58 
    59         /*static void cycleNavigationFocus();
    60         static void releaseNavigationFocus();
    61         static HUDNavigation& getInstance();*/
    6250
    6351      protected:
     
    8876        Ogre::TextAreaOverlayElement* navText_;     //!< Text overlay to display the target distance
    8977        bool wasOutOfView_;                         //!< Performance booster variable: setMaterial is not cheap
    90 
    91         //static HUDNavigation* instance_s;
    9278  };
    9379}
  • code/branches/hud/src/orxonox/overlays/hud/HUDRTRText.cc

    r1599 r1614  
    2929#include "OrxonoxStableHeaders.h"
    3030#include "HUDRTRText.h"
     31#include <OgreTextAreaOverlayElement.h>
    3132#include "GraphicsEngine.h"
    3233#include "util/Convert.h"
  • code/branches/hud/src/orxonox/overlays/hud/HUDRadar.cc

    r1613 r1614  
    2222 *   Author:
    2323 *      Yuning Chai
     24 *      Felix Schulthess
    2425 *   Co-authors:
    25  *      Felix Schulthess
     26 *      Reto Grieder
    2627 *
    2728 */
     
    3031#include "HUDRadar.h"
    3132
    32 #include <assert.h>
    3333#include <OgreOverlayManager.h>
    34 #include <OgreMaterialManager.h>
     34#include <OgrePanelOverlayElement.h>
    3535
     36#include "util/Math.h"
    3637#include "core/ConsoleCommand.h"
    3738#include "objects/SpaceShip.h"
    3839#include "objects/WorldEntity.h"
    3940#include "tools/TextureGenerator.h"
    40 #include "RadarViewable.h"
     41#include "Radar.h"
    4142
    4243namespace orxonox
    4344{
    4445    CreateFactory(HUDRadar);
    45     CreateFactory(RadarShape);
    4646
    4747    using namespace Ogre;
    4848
    4949    HUDRadar::HUDRadar()
    50       : background_(0)
    51       , marker_(0)
    52       , sensitivity_(1.0f)
     50        : marker_(0)
    5351    {
    5452        RegisterObject(HUDRadar);
     
    5957        if (this->isInitialized())
    6058        {
    61             /*if (this->background_)
    62                 OverlayManager::getSingleton().destroyOverlayElement(this->background_);
    63             while (this->radarDots_.size() > 0)
     59            if (this->marker_)
     60                OverlayManager::getSingleton().destroyOverlayElement(this->marker_);
     61            for (std::vector<Ogre::PanelOverlayElement*>::iterator it = this->radarDots_.begin();
     62                it != this->radarDots_.end(); ++it)
    6463            {
    65                 OverlayManager::getSingleton().destroyOverlayElement(this->radarDots_[this->radarDots_.size() - 1]);
    66                 this->radarDots_.pop_back();
    67             }*/
     64                OverlayManager::getSingleton().destroyOverlayElement(*it);
     65            }
    6866        }
    6967    }
     
    9088        if (mode == XMLPort::LoadObject)
    9189        {
    92             background_ = (Ogre::PanelOverlayElement*)Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "_Background");
    93             background_->setMaterialName("Orxonox/Radar");
    94             overlay_->add2D(background_);
    95 
    9690            marker_ = (Ogre::PanelOverlayElement*)Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "_Marker");
    9791            marker_->setMaterialName("Orxonox/RadarMarker");
     
    10094        }
    10195    }
    102 
    103     /*void HUDRadar::addShape(RadarShape* shape)
    104     {
    105         this->shapes_[shape->getIndex()] = shape;
    106     }
    107 
    108     RadarShape* HUDRadar::getShape(unsigned int index) const
    109     {
    110         if (index < this->shapes_.size())
    111         {
    112             std::map<unsigned int, RadarShape*>::const_iterator it = shapes_.begin();
    113             for (unsigned int i = 0; i != index; ++it, ++i)
    114                 ;
    115             return (*it).second;
    116         }
    117         else
    118             return 0;
    119     }*/
    12096
    12197    void HUDRadar::displayObject(RadarViewable* object, bool bIsMarked)
     
    131107        }
    132108
    133         /*static int counter = 0;
    134         if (++counter < 1120 && counter > 120)
    135         {
    136             // we have to create a new entry
    137             Ogre::PanelOverlayElement* panel = static_cast<Ogre::PanelOverlayElement*>(
    138                 Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "RadarDot" + getUniqueNumberStr()));
    139             // get right material
    140             panel->setMaterialName("Orxonox/RadarSquare");
    141             panel->setDimensions(0.03, 0.03);
    142             panel->setPosition((1.0 + (rand() & 0xFF) / 256.0 - 0.001) * 0.5, (1.0 - (rand() & 0xFF) / 256.0 - 0.001) * 0.5);
    143             panel->show();
    144             this->overlay_->add2D(panel);
    145             this->overlay_->show();
    146         }*/
    147 
    148109        // try to find a panel already created
    149110        Ogre::PanelOverlayElement* panel;
    150         std::map<RadarViewable*, Ogre::PanelOverlayElement*>::iterator it = this->radarDots_.find(object);
    151         if (it == this->radarDots_.end())
     111        //std::map<RadarViewable*, Ogre::PanelOverlayElement*>::iterator it = this->radarDots_.find(object);
     112        if (itRadarDots_ == this->radarDots_.end())
    152113        {
    153114            // we have to create a new entry
    154115            panel = static_cast<Ogre::PanelOverlayElement*>(
    155116                Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "RadarDot" + getUniqueNumberStr()));
    156             radarDots_[object] = panel;
     117            radarDots_.push_back(panel);
    157118            // get right material
    158119            panel->setMaterialName(TextureGenerator::getMaterialName(
    159120                shapeMaterials_[object->getRadarObjectType()], object->getRadarObjectColour()));
    160121            this->overlay_->add2D(panel);
     122            this->itRadarDots_ = this->radarDots_.end();
    161123        }
    162124        else
    163             panel = (*it).second;
     125        {
     126            panel = *itRadarDots_;
     127            ++itRadarDots_;
     128            std::string materialName = TextureGenerator::getMaterialName(
     129                shapeMaterials_[object->getRadarObjectType()], object->getRadarObjectColour());
     130            if (materialName != panel->getMaterialName())
     131                panel->setMaterialName(materialName);
     132        }
    164133
    165134        // set size to fit distance...
     
    177146        {
    178147            this->marker_->show();
    179             this->marker_->setDimensions(size * 1.2, size * 1.2);
    180             this->marker_->setPosition((1.0 + coord.x - size * 1.2) * 0.5, (1.0 - coord.y - size * 1.2) * 0.5);
     148            this->marker_->setDimensions(size * 1.5, size * 1.5);
     149            this->marker_->setPosition((1.0 + coord.x - size * 1.5) * 0.5, (1.0 - coord.y - size * 1.5) * 0.5);
    181150        }
    182151    }
     
    184153    void HUDRadar::radarTick(float dt)
    185154    {
     155        this->itRadarDots_ = this->radarDots_.begin();
     156        this->marker_->hide();
    186157    }
    187 
    188     /*void HUDRadar::tick(float dt)
    189     {
    190         // iterate through all RadarObjects
    191         unsigned int i = 0;
    192         for (Iterator<RadarViewable> it = ObjectList<RadarViewable>::start(); it; ++it, ++i)
    193         {
    194             if ((*it)->isVisibleOnRadar())
    195             {
    196             }
    197         }
    198     }*/
    199 
    200     /*void HUDRadar::listObjects()
    201     {
    202         COUT(3) << "List of RadarObjects:\n";
    203         // iterate through all Radar Objects
    204         unsigned int i = 0;
    205         for (Iterator<RadarViewable> it = ObjectList<RadarViewable>::start(); it; ++it, ++i)
    206         {
    207             COUT(3) << i++ << ": " << (*it)->getWorldEntity()->getWorldPosition() << std::endl;
    208         }
    209     }*/
    210158}
  • code/branches/hud/src/orxonox/overlays/hud/HUDRadar.h

    r1613 r1614  
    2222 *   Author:
    2323 *      Yuning Chai
     24 *      Felix Schulthess
    2425 *   Co-authors:
    25  *      Felix Schulthess
     26 *      Reto Grieder
    2627 *
    2728 */
     
    3233#include "OrxonoxPrereqs.h"
    3334
     35#include <vector>
     36#include <map>
    3437#include <OgrePrerequisites.h>
    35 #include <OgrePanelOverlayElement.h>
    3638#include "overlays/OrxonoxOverlay.h"
    37 #include "objects/Tickable.h"
    38 #include "core/BaseObject.h"
    39 #include "util/Math.h"
    40 #include "core/Debug.h"
    41 #include "Radar.h"
     39#include "RadarListener.h"
     40#include "RadarViewable.h"
    4241
    4342namespace orxonox
    4443{
    45     template <class T, int Dummy>
    46     class _OrxonoxExport RadarAttribute : public BaseObject
    47     {
    48       public:
    49         RadarAttribute();
    50         ~RadarAttribute() { }
    51 
    52         void XMLPort(Element& xmlElement, XMLPort::Mode mode);
    53         void loadAttribute(Element& xmlElement, XMLPort::Mode mode);
    54 
    55         void setAttribute(const T& attribute) { this->attribute_ = attribute; }
    56         const T& getAttribute() const { return this->attribute_; }
    57 
    58         void setIndex(unsigned int index);
    59         unsigned int getIndex() { return this->index_; }
    60 
    61       private:
    62         unsigned int index_;
    63         T attribute_;
    64     };
    65 
    66     template <class T, int Dummy>
    67     void RadarAttribute<T, Dummy>::setIndex(unsigned int index)
    68     {
    69         if (index > 0xFF)
    70         {
    71             COUT(1) << "Shape index was larger than 255 while parsing a RadarAttribute. "
    72               << "Using random number!!!" << std::endl;
    73             this->index_ = rand() & 0xFF;
    74         }
    75         else
    76             this->index_ = index;
    77     }
    78 
    79     typedef RadarAttribute<std::string, 1> RadarShape;
    80 
    81     template <>
    82     RadarShape::RadarAttribute() : index_(0)
    83         { RegisterObject(RadarShape); }
    84 
    85     template <>
    86     void RadarShape::XMLPort(Element& xmlElement, XMLPort::Mode mode)
    87     {
    88         BaseObject::XMLPort(xmlElement, mode);
    89         XMLPortParam(RadarShape, "shape", setAttribute, getAttribute, xmlElement, mode);
    90         XMLPortParam(RadarShape, "index", setIndex, getIndex, xmlElement, mode);
    91     }
    92 
    93 
    94     class _OrxonoxExport HUDRadar : public OrxonoxOverlay, public RadarListener//, public Tickable
     44    class _OrxonoxExport HUDRadar : public OrxonoxOverlay, public RadarListener
    9545    {
    9646      public:
     
    9949
    10050        void XMLPort(Element& xmlElement, XMLPort::Mode mode);
    101 
    102         /*void addShape(RadarShape* shape);
    103         RadarShape* getShape(unsigned int index) const;*/
    10451
    10552        float getRadarSensitivity() const { return this->sensitivity_; }
     
    11259        void setMaximumDotSize(float size) { this->maximumDotSize_ = size; }
    11360
    114         //void tick(float dt);
    115 
    116         //void listObjects();
    117 
    11861      private:
    11962        void displayObject(RadarViewable* viewable, bool bIsMarked);
    120         void hideMarker() { this->marker_->hide(); }
    12163        float getRadarSensitivity() { return 1.0f; }
    12264        void radarTick(float dt);
     
    12466        std::map<RadarViewable::Shape, std::string> shapeMaterials_;
    12567
    126         Ogre::PanelOverlayElement* background_;
    127         std::map<RadarViewable*, Ogre::PanelOverlayElement*> radarDots_;
     68        std::vector<Ogre::PanelOverlayElement*> radarDots_;
     69        std::vector<Ogre::PanelOverlayElement*>::iterator itRadarDots_;
    12870        Ogre::PanelOverlayElement* marker_;
    12971
  • code/branches/hud/src/orxonox/overlays/hud/HUDSpeedBar.cc

    r1599 r1614  
    2121 *
    2222 *   Author:
     23 *      Felix Schulthess
    2324 *      Reto Grieder
    2425 *   Co-authors:
  • code/branches/hud/src/orxonox/overlays/hud/HUDSpeedBar.h

    r1599 r1614  
    2121 *
    2222 *   Author:
     23 *      Felix Schulthess
    2324 *      Reto Grieder
    2425 *   Co-authors:
  • code/branches/hud/src/orxonox/tools/TextureGenerator.cc

    r1613 r1614  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      Reto Grieder
     25 *      ...
    2626 *
    2727 */
     
    2929/**
    3030    @file
    31     @brief Implementation of the Settings class.
     31    @brief Implementation of the TextureGenerator.
    3232*/
    3333
  • code/branches/hud/visual_studio/vc8/orxonox.vcproj

    r1613 r1614  
    189189                        </File>
    190190                        <File
     191                                RelativePath="..\..\src\orxonox\RadarListener.cc"
     192                                >
     193                        </File>
     194                        <File
    191195                                RelativePath="..\..\src\orxonox\RadarViewable.cc"
    192196                                >
     
    534538                        <File
    535539                                RelativePath="..\..\src\orxonox\Radar.h"
     540                                >
     541                        </File>
     542                        <File
     543                                RelativePath="..\..\src\orxonox\RadarListener.h"
    536544                                >
    537545                        </File>
Note: See TracChangeset for help on using the changeset viewer.