Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.