Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1598


Ignore:
Timestamp:
Jun 14, 2008, 4:19:42 PM (16 years ago)
Author:
rgrieder
Message:

scale, position, alignment and rotation work with overlays
Simply override virtual void size|position|angleChanged() method to have custom behavior

Location:
code/branches/hud
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/hud/bin/hud/hud.oxh

    r1595 r1598  
    11<HUD name="OrxonoxHUD">
    2   <HUDSpeedBar name ="SpeedBar1" size=0.35,0.2 scroll=-0.6,-1.0 value=0 />
    3   <HUDFPSText name="FPSText" size = 0.043,0.043 scroll=-0.93,0.9 font="Monofur" caption="Frames per second: " />
    4   <HUDRTRText name="RTRText" size = 0.043,0.043 scroll=-0.93,0.8 font="Monofur" caption="Render time ratio: " />
     2  <HUDSpeedBar name ="SpeedBar1" size=0.35,0.05 position=0.02,0.98 origin=0,1 value=0 />
     3  <HUDFPSText name="FPSText" size = 0.043,0.043 position=-0.05,0.05 font="Monofur" caption="Frames per second: " />
     4  <HUDRTRText name="RTRText" size = 0.043,0.043 position=-0.05,0.2 font="Monofur" caption="Render time ratio: " />
    55  <Navigation name="Navigation" correctAspect=true font="Monofur" navmarkersize=0.03,0.03 />
    66</HUD>
  • code/branches/hud/src/orxonox/hud/HUDBar.cc

    r1590 r1598  
    5353
    5454        barWidth_s = 0.88f;
    55         barHeight_s = 0.3f;
     55        barHeight_s = 1.0f;
    5656        barOffsetLeft_s = 0.06f;
    5757        barOffsetTop_s = 0.0f;
     
    8282            this->background_->setMaterialName("Orxonox/BarBackground");
    8383            this->background_->setMetricsMode(GMM_RELATIVE);
    84             this->background_->setDimensions(1.0f, 0.3f);
     84            this->background_->setDimensions(1.0f, 1.0f);
    8585            this->background_->setPosition(0.0f, 0.0f);
    8686            this->overlay_->add2D(this->background_);
  • code/branches/hud/src/orxonox/hud/HUDOverlay.cc

    r1595 r1598  
    4343    , windowAspectRatio_(1.0f)
    4444    , bCorrectAspect_(false)
    45     , size_(1.0f)
    46     , sizeCorrection_(1.0f)
     45    , size_(1.0f, 1.0f)
     46    , sizeCorrection_(1.0f, 1.0f)
     47    , angle_(0.0f)
     48    , position_(0.0f, 0.0f)
     49    , origin_(0.5f, 0.5f)
    4750  {
    4851    RegisterObject(HUDOverlay);
     
    6265    }
    6366
     67    XMLPortParam(HUDOverlay, "correctAspect", setAspectCorrection, getAspectCorrection, xmlElement, mode);
    6468    XMLPortParam(HUDOverlay, "size", setSize, getSize, xmlElement, mode);
    65     XMLPortParam(HUDOverlay, "correctAspect", setAspectCorrection, getAspectCorrection, xmlElement, mode);
    66     XMLPortParam(HUDOverlay, "scroll", setScroll, getScroll, xmlElement, mode);
    6769    XMLPortParam(HUDOverlay, "rotation", setRotation, getRotation, xmlElement, mode);
     70    XMLPortParam(HUDOverlay, "origin", setOrigin, getOrigin, xmlElement, mode);
     71    XMLPortParam(HUDOverlay, "position", setPosition, getPosition, xmlElement, mode);
    6872
    6973    if (mode == XMLPort::LoadObject)
     
    124128  void HUDOverlay::sizeChanged()
    125129  {
    126     this->overlay_->setScale(size_.x * sizeCorrection_.x, size_.x * sizeCorrection_.y);
     130    this->overlay_->setScale(size_.x * sizeCorrection_.x, size_.y * sizeCorrection_.y);
    127131  }
    128132
     133  /**
     134    @remarks
     135      This function can be overriden by any derivative.
     136  */
     137  void HUDOverlay::angleChanged()
     138  {
     139    this->overlay_->setRotate(this->angle_);
     140  }
     141
     142  /**
     143    @remarks
     144      This function can be overriden by any derivative.
     145  */
     146  void HUDOverlay::positionChanged()
     147  {
     148    Vector2 scroll = (position_ - 0.5 - size_ * (origin_ - 0.5)) * 2.0;
     149    this->overlay_->setScroll(scroll.x, -scroll.y);
     150  }
    129151}
  • code/branches/hud/src/orxonox/hud/HUDOverlay.h

    r1595 r1598  
    5050      bool getAspectCorrection() { return this->bCorrectAspect_; }
    5151
    52       /** Sets the scrolling factor of this overlay. */
    53       void setScroll(Vector2 scroll) { overlay_->setScroll(scroll.x, scroll.y); }
     52      /** Sets the position of this overlay. */
     53      void setPosition(Vector2 pos) { this->position_ = pos; this->positionChanged(); }
    5454
    55       /** Gets the current scroll value */
    56       Vector2 getScroll() const { return Vector2(overlay_->getScrollX(), overlay_->getScrollY()); }
     55      /** Gets the current position. */
     56      Vector2 getPosition() const { return this->position_; }
    5757
    5858      /** Scrolls the overlay by the offsets provided. */
    59       void scroll(Vector2 scroll) { overlay_->scroll(scroll.x, scroll.y); }
     59      void scroll(Vector2 scroll) { this->position_ += scroll; this->positionChanged(); }
     60
     61      /** Sets the origin point of this overlay. */
     62      void setOrigin(Vector2 pos) { this->origin_ = pos; this->positionChanged(); }
     63
     64      /** Gets the origin point of this overlay */
     65      Vector2 getOrigin() const { return this->origin_; }
    6066
    6167      /** Sets the rotation applied to this overlay.*/
    62       void setRotation(const Ogre::Radian& angle) { overlay_->setRotate(angle); }
     68      void setRotation(const Ogre::Radian& angle) { this->angle_ = angle; this->angleChanged(); }
    6369
    6470      /** Gets the rotation applied to this overlay, in degrees.*/
    65       const Radian& getRotation() const { return overlay_->getRotate(); }
     71      const Radian& getRotation() const { return this->angle_; }
    6672
    6773      /** Adds the passed in angle to the rotation applied to this overlay. */
    68       void rotate(const Radian& angle) { overlay_->rotate(angle); }
     74      void rotate(const Radian& angle) { this->angle_ += angle; this->angleChanged(); }
    6975
    7076      /** Sets the scaling factor of this overlay. */
     
    8692      virtual void changedVisibility();
    8793      virtual void sizeChanged();
     94      virtual void angleChanged();
     95      virtual void positionChanged();
    8896      float getWindowAspectRatio() { return windowAspectRatio_; }
    8997
     
    97105      Vector2 size_;
    98106      Vector2 sizeCorrection_;
     107      Radian angle_;
     108      Vector2 position_;
     109      Vector2 origin_;
    99110
    100111      static unsigned int hudOverlayCounter_s;
  • code/branches/hud/src/orxonox/hud/Navigation.h

    r1595 r1598  
    5959    protected:
    6060      virtual void sizeChanged();
     61      virtual void angleChanged() { }
     62      virtual void positionChanged() { }
    6163
    6264      private:
Note: See TracChangeset for help on using the changeset viewer.