Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5090 in orxonox.OLD for trunk/src/lib/graphics/render2D


Ignore:
Timestamp:
Aug 21, 2005, 8:50:22 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: math should be easy…

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/render2D/element_2d.cc

    r5089 r5090  
    194194void Element2D::setRelCoor2Dpx (int x, int y)
    195195{
    196   this->setRelCoor2D(Vector((float)GraphicsEngine::getInstance()->getResolutionX()/(float)x,
    197                      (float)GraphicsEngine::getInstance()->getResolutionY()/(float)y,
     196  this->setRelCoor2D(Vector((float)x/(float)GraphicsEngine::getInstance()->getResolutionX(),
     197                     (float)y/(float)GraphicsEngine::getInstance()->getResolutionY(),
    198198                     0
    199199                           ));
     
    212212void Element2D::setRelCoorSoft2Dpx (int x, int y, float bias)
    213213{
    214   this->setRelCoorSoft2D(Vector((float)GraphicsEngine::getInstance()->getResolutionX()/(float)x,
    215                          (float)GraphicsEngine::getInstance()->getResolutionY()/(float)y,
     214  this->setRelCoorSoft2D(Vector((float)x/(float)GraphicsEngine::getInstance()->getResolutionX(),
     215                         (float)y/(float)GraphicsEngine::getInstance()->getResolutionY(),
    216216                         0),
    217217                         bias);
     
    253253void Element2D::setAbsCoor2Dpx (int x, int y)
    254254{
    255   this->setAbsCoor2D(Vector((float)GraphicsEngine::getInstance()->getResolutionX()/(float)x,
    256                      (float)GraphicsEngine::getInstance()->getResolutionY()/(float)y,
     255  this->setAbsCoor2D(Vector((float)x/(float)GraphicsEngine::getInstance()->getResolutionX(),
     256                     (float)y/(float)GraphicsEngine::getInstance()->getResolutionY(),
    257257                     0
    258258                           ));
     
    269269void Element2D::shiftCoor2Dpx (int x, int y)
    270270{
    271   this->shiftCoor2D(Vector((float)GraphicsEngine::getInstance()->getResolutionX()/(float)x,
    272                      (float)GraphicsEngine::getInstance()->getResolutionY()/(float)y,
     271  this->shiftCoor2D(Vector((float)x/(float)GraphicsEngine::getInstance()->getResolutionX(),
     272                    (float)y/(float)GraphicsEngine::getInstance()->getResolutionY(),
    273273                     0));
    274274}
     
    453453    {
    454454      /* update the current absDirection - remember * means rotation around sth.*/
    455       this->prevRelCoordinate = this->relCoordinate;
     455      this->prevRelDirection = this->relDirection;
    456456      this->absDirection = this->relDirection + parent->getAbsDir2D();;
    457457    }
     
    493493        /* update the current absCoordinate */
    494494        this->prevRelCoordinate = this->relCoordinate;
     495        float sine = sin(this->parent->getAbsDir2D());
     496        float cose = cos(this->parent->getAbsDir2D());
     497//        this->absCoordinate.x = this->relCoordinate.x*cose - this->relCoordinate.y*sine + this->parent->getRelCoor2D().x*(1-cose) +this->parent->getRelCoor2D().y*sine;
     498//        this->absCoordinate.y = this->relCoordinate.x*sine + this->relCoordinate.y*cose + this->parent->getRelCoor2D().y*(1-cose) +this->parent->getRelCoor2D().x*sine;
     499
    495500        this->absCoordinate.x = this->parent->getAbsCoor2D().x + (this->relCoordinate.x*cos(this->parent->getAbsDir2D()) - this->relCoordinate.y * sin(this->parent->getAbsDir2D()));
    496501        this->absCoordinate.y = this->parent->getAbsCoor2D().y + (this->relCoordinate.x*sin(this->parent->getAbsDir2D()) + this->relCoordinate.y * cos(this->parent->getAbsDir2D()));
Note: See TracChangeset for help on using the changeset viewer.