Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5414 in orxonox.OLD


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
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/coord/p_node.cc

    r5406 r5414  
    415415  this->setAbsDir(Quaternion(Vector(x,y,z), Vector(0,1,0)));
    416416}
     417
     418/**
     419 *  sets the absolute direction
     420 * @param absDir absolute coordinates
     421 */
     422void PNode::setAbsDirSoft (const Quaternion& absDirSoft, float bias)
     423{
     424  if (this->toDirection == NULL)
     425    this->toDirection = new Quaternion();
     426
     427  if (likely(this->parent != NULL))
     428    *this->toDirection = absDirSoft / this->parent->getAbsDir();
     429  else
     430   *this->toDirection = absDirSoft;
     431
     432  this->bias = bias;
     433}
     434
     435/**
     436 * @see void PNode::setAbsDir (const Quaternion& relDir)
     437 * @param x the x direction
     438 * @param y the y direction
     439 * @param z the z direction
     440 *
     441 * main difference is, that here you give a directional vector, that will be translated into a Quaternion
     442 */
     443void PNode::setAbsDirSoft (float x, float y, float z, float bias)
     444{
     445  this->setAbsDirSoft(Quaternion(Vector(x,y,z), Vector(0,1,0)), bias);
     446}
     447
    417448
    418449/**
  • trunk/src/lib/coord/p_node.h

    r5406 r5414  
    8383  void setAbsDir (const Quaternion& absDir);
    8484  void setAbsDir (float x, float y, float z);
     85  void setAbsDirSoft(const Quaternion& absDirSoft, float bias = 1.0);
     86  void setAbsDirSoft(float x, float y, float z, float bias = 1.0);
    8587  /** @returns the absolute Direction */
    8688  inline const Quaternion& getAbsDir () const { return this->absDirection; };
  • 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; };
  • trunk/src/world_entities/weapons/turret.cc

    r5357 r5414  
    127127    quat = Quaternion(direction, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0)) ;
    128128
    129   this->setAbsDir(quat);
     129  this->setAbsDirSoft(quat, 5);
    130130}
    131131
     
    140140  if (target != NULL)
    141141  {
    142     pj->setVelocity(this->getVelocity()+(target->getAbsCoor() - this->getAbsCoor())*.5);//this->getVelocity());
    143     pj->setAbsDir(this->getAbsDir());
     142    pj->setVelocity(this->getVelocity()+(this->getAbsDir().apply(Vector(1,0,0))*100.0   /*target->getAbsCoor() - this->getAbsCoor()*/)*.5);//this->getVelocity());
    144143  }
    145144  else
Note: See TracChangeset for help on using the changeset viewer.