Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Oct 21, 2005, 9:45:54 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: new functionality in PNode and Element2D
they now support setAbsCoordSofy*
and setAbsDirSoft*

these functions are used in the new Turret, for smooth iteration, so it does not just snap to place

Location:
trunk/src/lib/graphics/render2D
Files:
2 edited

Legend:

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

    r5404 r5414  
    367367
    368368/**
     369 * @param absCoordSoft set absolute coordinate
     370 * @param bias how fast to iterato to the new Coordinate
     371 */
     372void Element2D::setAbsCoorSoft2D (const Vector& absCoordSoft, float bias)
     373{
     374  if (this->toCoordinate == NULL)
     375    this->toCoordinate = new Vector();
     376
     377  if( likely(this->parentMode & E2D_PARENT_MOVEMENT))
     378  {
     379    /* if you have set the absolute coordinates this overrides all other changes */
     380    if (likely(this->parent != NULL))
     381      *this->toCoordinate = absCoordSoft - parent->getAbsCoor2D ();
     382    else
     383      *this->toCoordinate = absCoordSoft;
     384  }
     385  if( this->parentMode & E2D_PARENT_ROTATE_MOVEMENT)
     386  {
     387    if (likely(this->parent != NULL))
     388      *this->toCoordinate = absCoordSoft - parent->getAbsCoor2D ();
     389    else
     390      *this->toCoordinate = absCoordSoft;
     391  }
     392
     393  this->bias = bias;
     394}
     395
     396/**
     397 * @param x x-coordinate.
     398 * @param y y-coordinate.
     399 * @param z z-coordinate.
     400 * @see void PNode::setAbsCoor (const Vector& absCoord)
     401 */
     402void Element2D::setAbsCoorSoft2D (float x, float y, float depth, float bias)
     403{
     404  this->setAbsCoorSoft2D(Vector(x, y, depth), bias);
     405}
     406
     407/**
    369408 *  shift coordinate ralative
    370409 * @param shift shift vector
     
    439478
    440479  this->bRelDirChanged = true;
     480}
     481
     482/**
     483 *  sets the absolute direction softly
     484 * @param absDir absolute coordinates
     485 */
     486void Element2D::setAbsDirSoft2D (float absDirSoft, float bias)
     487{
     488  if (this->toDirection == NULL)
     489    this->toDirection = new float;
     490
     491  if (likely(this->parent != NULL))
     492    *this->toDirection = absDirSoft - this->parent->getAbsDir2D();
     493  else
     494    *this->toDirection = absDirSoft;
     495
     496  this->bias = bias;
    441497}
    442498
  • trunk/src/lib/graphics/render2D/element_2d.h

    r5404 r5414  
    134134    void setAbsCoor2D (float x, float y, float depth = 1.0);
    135135    void setAbsCoor2Dpx (int x, int y);
     136    void setAbsCoorSoft2D (const Vector& absCoordSoft, float bias = 1.0);
     137    void setAbsCoorSoft2D (float x, float y, float depth = 1.0, float bias = 1.0);
    136138    /** @returns the absolute position */
    137139    inline const Vector& getAbsCoor2D () const { return this->absCoordinate; };
     
    148150    inline float getRelDirSoft2D() const { return (this->toDirection)?*this->toDirection:this->relDirection; };
    149151    void setAbsDir2D (float absDir);
     152    void setAbsDirSoft2D (float absDirSoft, float bias = 1.0);
    150153    /** @returns the absolute Direction */
    151154    inline float getAbsDir2D () const { return this->absDirection; };
Note: See TracChangeset for help on using the changeset viewer.