Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 27, 2006, 2:31:12 PM (18 years ago)
Author:
patrick
Message:

turning implemented, collision reaction disabled

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/single_player_map/src/world_entities/npcs/generic_npc.cc

    r8823 r8824  
    401401float GenericNPC::lookAt(WorldEntity* worldEntity)
    402402{}
     403
     404
     405/**
     406 * turns to a given direction
     407 */
     408bool GenericNPC::turnTo(float qu, float qx, float qy, float qz)
     409{
     410  Quaternion destDir = Quaternion(Vector(qx, qy, qz), qu);
     411
     412  // check if this is the current goal
     413  if( this->destDir != destDir)
     414  {
     415    this->destCoor = destCoor;
     416
     417    float time = 5.0f;
     418
     419    if( this->currentAnim != NULL)
     420      delete this->currentAnim;
     421
     422    this->currentAnim = new Animation3D(this);
     423    this->currentAnim->addKeyFrame(this->getAbsCoor(), this->getAbsDir(), time, ANIM_LINEAR, ANIM_LINEAR);
     424    this->currentAnim->addKeyFrame(this->getAbsCoor(), this->destDir, time, ANIM_LINEAR, ANIM_LINEAR);
     425
     426    this->currentAnim->setInfinity(ANIM_INF_CONSTANT);
     427    this->currentAnim->play();
     428
     429    this->setAnimation(CROUCH_STAND, MD2_ANIM_LOOP);
     430  }
     431
     432  // calculate the distance
     433  Vector distance = this->getAbsCoor() - this->destCoor;
     434  return distance.len();
     435}
     436
    403437
    404438
Note: See TracChangeset for help on using the changeset viewer.