Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

turning implemented, collision reaction disabled

Location:
branches/single_player_map/src/world_entities/npcs
Files:
2 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
  • branches/single_player_map/src/world_entities/npcs/generic_npc.h

    r8823 r8824  
    6363  /* some oriantation functions */
    6464  float lookAt(WorldEntity* worldEntity);
     65  bool turnTo(float qu, float qx, float qy, float qz);
    6566
    6667  /* talking funcitons*/
Note: See TracChangeset for help on using the changeset viewer.