Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4990 in orxonox.OLD for orxonox


Ignore:
Timestamp:
Aug 12, 2005, 4:54:18 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: preparing for the smoothPNode roatational

Location:
orxonox/trunk/src
Files:
3 edited

Legend:

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

    r4989 r4990  
    113113
    114114  this->toPosition = NULL;
     115  this->toDirection = NULL;
    115116}
    116117
     
    187188
    188189  *this->toPosition = relCoordSoft;
     190}
     191
     192
     193/**
     194 *  set relative coordinates
     195 * @param x x-relative coordinates to its parent
     196 * @param y y-relative coordinates to its parent
     197 * @param z z-relative coordinates to its parent
     198   \see  void PNode::setRelCoor (const Vector& relCoord)
     199 */
     200void PNode::setRelCoorSoft (float x, float y, float z)
     201{
     202  this->setRelCoorSoft(Vector(x, y, z));
    189203}
    190204
     
    277291}
    278292
     293
     294/**
     295 * sets the Relative Direction of this node to its parent in a Smoothed way
     296 * @param relDirSoft the direction to iterate to smoothely.
     297 */
     298void PNode::setRelDirSoft(const Quaternion& relDirSoft)
     299{
     300  if (likely(this->toDirection == NULL))
     301    this->toDirection = new Quaternion();
     302
     303  *this->toDirection = relDirSoft;
     304}
     305
     306/**
     307 * @see void PNode::setRelDirSoft (const Quaternion& relDir)
     308 * @param x the x direction
     309 * @param y the y direction
     310 * @param z the z direction
     311 *
     312 * main difference is, that here you give a directional vector, that will be translated into a Quaternion
     313 */
     314void PNode::setRelDirSoft(float x, float y, float z)
     315{
     316  this->setRelDirSoft(Quaternion(Vector(x,y,z), Vector(0,1,0)));
     317}
     318
     319
    279320/**
    280321 *  sets the absolute direction (0,0,1)
     
    418459}
    419460
     461/**
     462 * does the reparenting in a very smooth way
     463 * @param parentNode the new Node to connect this node to.
     464 */
    420465void PNode::softReparent(PNode* parentNode)
    421466{
     
    426471    *this->toPosition = this->getRelCoor();
    427472  }
    428 
    429 
    430   Vector tmp = this->getAbsCoor();
     473  if (likely(this->toDirection == NULL))
     474  {
     475    this->toDirection = new Quaternion();
     476    *this->toDirection = this->getRelDir();
     477  }
     478
     479
     480  Vector tmpV = this->getAbsCoor();
     481  Quaternion tmpQ = this->getAbsDir();
    431482
    432483  parentNode->addChild(this);
    433484
    434   this->setRelCoor(tmp - parentNode->getAbsCoor());
     485  this->setRelCoor(tmpV - parentNode->getAbsCoor());
     486  this->setRelDir(tmpQ - parentNode->getAbsDir());
    435487}
    436488
     
    511563          PRINTF(5)("SmoothMove of %s finished\n", this->getName());
    512564        }
     565      }
     566      if (unlikely(this->toDirection != NULL))
     567      {
     568        Quaternion rotQuat = (*this->toDirection - this->getRelDir()) *dt;
     569
     570//        if (likely(rotQuat.len() >= .001))
     571        {
     572          this->shiftDir(rotQuat);
     573        }
     574/*        else
     575        {
     576          delete this->toPosition;
     577          this->toPosition = NULL;
     578          PRINTF(5)("SmoothMove of %s finished\n", this->getName());
     579        }*/
    513580      }
    514581
  • orxonox/trunk/src/lib/coord/p_node.h

    r4987 r4990  
    6262  void setRelCoor (const Vector& relCoord);
    6363  void setRelCoor (float x, float y, float z);
    64   void setRelCoorSoft(const Vector& softRelCoord);
     64  void setRelCoorSoft(const Vector& relCoordSoft);
     65  void setRelCoorSoft(float x, float y, float z);
    6566  /** @returns the relative position */
    6667  inline const Vector& getRelCoor () const { return this->relCoordinate; };
     
    7374  void setRelDir (const Quaternion& relDir);
    7475  void setRelDir (float x, float y, float z);
     76  void setRelDirSoft(const Quaternion& relDirSoft);
     77  void setRelDirSoft(float x, float y, float z);
    7578  /** @returns the relative Direction */
    7679  inline const Quaternion& getRelDir () const { return this->relDirection; };
     
    139142
    140143
    141   Vector*         toPosition;         //!< a position to wich to iterate. (This is used in conjunction with softReparent.)
     144  Vector*         toPosition;         //!< a position to which to iterate. (This is used in conjunction with softReparent.and set*CoorSoft)
     145  Quaternion*     toDirection;        //!< a direction to which to iterate. (This is used in conjunction with softReparent and set*DirSoft)
    142146
    143147  PNode*          parent;             //!< a pointer to the parent node
  • orxonox/trunk/src/world_entities/player.cc

    r4986 r4990  
    123123  this->setClassID(CL_PLAYER, "Player");
    124124
    125 //  this->model = (Model*)ResourceManager::getInstance()->load("models/reaplow.obj", OBJ, RP_CAMPAIGN);
     125  //  this->model = (Model*)ResourceManager::getInstance()->load("models/reaplow.obj", OBJ, RP_CAMPAIGN);
    126126  travelSpeed = 15.0;
    127127  velocity = new Vector();
Note: See TracChangeset for help on using the changeset viewer.