Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8817 in orxonox.OLD for branches/single_player_map


Ignore:
Timestamp:
Jun 27, 2006, 1:02:56 AM (18 years ago)
Author:
patrick
Message:

generic npc work

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

    r8816 r8817  
    153153    this->destDir = destDir;
    154154
    155     float time = 5.0f;
     155    float time = 10.0f;
    156156
    157157    if( this->currentAnim != NULL)
     
    160160    this->currentAnim = new Animation3D(this);
    161161    this->currentAnim->addKeyFrame(this->getAbsCoor(), this->getAbsDir(), 0.1f, ANIM_LINEAR, ANIM_LINEAR);
     162    this->currentAnim->addKeyFrame(this->destCoor, this->destDir, time, ANIM_LINEAR, ANIM_LINEAR);
     163    this->currentAnim->addKeyFrame(this->getAbsCoor(), this->getAbsDir(), time, ANIM_LINEAR, ANIM_LINEAR);
    162164    this->currentAnim->addKeyFrame(this->destCoor, this->destDir, time, ANIM_LINEAR, ANIM_LINEAR);
    163165
     
    221223}
    222224
    223 
    224 
    225 /**
    226  * run to a specific place with direction
    227  *
    228  * @param coor: vector place
    229  * @param dir: direction
    230  *
    231  */
    232 float GenericNPC::runTo(const Vector& coordinate, const Quaternion& dir)
    233 {}
    234225
    235226
     
    247238 */
    248239float GenericNPC::runTo(float x, float y, float z, float qu, float qx, float qy, float qz)
    249 {}
     240{
     241  Vector destCoor = Vector(x, y, z);
     242  Quaternion destDir = Quaternion(Vector(qx, qy, qz), qu);
     243
     244  // check if this is the current goal
     245  if( this->destCoor != destCoor || this->destDir != destDir)
     246  {
     247    this->destCoor = destCoor;
     248    this->destDir = destDir;
     249
     250    float time = 5.0f;
     251
     252    if( this->currentAnim != NULL)
     253      delete this->currentAnim;
     254
     255    this->currentAnim = new Animation3D(this);
     256    this->currentAnim->addKeyFrame(this->getAbsCoor(), this->getAbsDir(), 0.1f, ANIM_LINEAR, ANIM_LINEAR);
     257    this->currentAnim->addKeyFrame(this->destCoor, this->destDir, time, ANIM_LINEAR, ANIM_LINEAR);
     258    this->currentAnim->addKeyFrame(this->getAbsCoor(), this->getAbsDir(), time, ANIM_LINEAR, ANIM_LINEAR);
     259    this->currentAnim->addKeyFrame(this->destCoor, this->destDir, time, ANIM_LINEAR, ANIM_LINEAR);
     260
     261    this->currentAnim->setInfinity(ANIM_INF_CONSTANT);
     262    this->currentAnim->play();
     263
     264    this->setAnimation(RUN, MD2_ANIM_LOOP);
     265  }
     266
     267  // calculate the distance
     268  Vector distance = this->getAbsCoor() - this->destCoor;
     269  return distance.len();
     270}
    250271
    251272
     
    262283 */
    263284float GenericNPC::runTo(float x, float y, float qu, float qx, float qy, float qz)
    264 {}
    265 
    266 
    267 
    268 /**
    269  * crouch to a specific place with direction
     285{
     286  this->runTo(x, y, 0.0f, qu, qx, qy, qz);
     287}
     288
     289
     290/**
     291 * run to a specific place with direction
    270292 *
    271293 * @param coor: vector place
     
    273295 *
    274296 */
     297float GenericNPC::runTo(const Vector& coordinate, const Quaternion& dir)
     298{
     299  this->runTo(coordinate.x, coordinate.y, coordinate.z, dir.w, dir.v.x, dir.v.y, dir.v.z);
     300}
     301
     302
     303/**
     304 * crouch to a specific place with direction
     305 *
     306 * @param coor: vector place
     307 * @param dir: direction
     308 *
     309 */
    275310float GenericNPC::crouchTo(const Vector& coordinate, const Quaternion& dir)
    276 {}
     311{
     312}
    277313
    278314
     
    307343{}
    308344
     345
     346
     347/**
     348 * stops the generic animation
     349 */
     350void GenericNPC::stop()
     351{}
    309352
    310353
  • branches/single_player_map/src/world_entities/npcs/generic_npc.h

    r8813 r8817  
    5858  float crouchTo(float x, float y, float qu, float qx, float qy, float qz);
    5959
     60  /* stopping the movement */
     61  void stop();
     62
    6063  /* some oriantation functions */
    6164  float lookAt(WorldEntity* worldEntity);
Note: See TracChangeset for help on using the changeset viewer.