Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8951 in orxonox.OLD


Ignore:
Timestamp:
Jun 30, 2006, 2:00:16 PM (18 years ago)
Author:
patrick
Message:

generic_npc now sets the animation and moves

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

    r8936 r8951  
    115115
    116116
     117
     118/**
     119 * @returns the current animation number
     120 */
     121int GenericNPC::getAnimation()
     122{
     123  if( likely(this->getModel(0) != NULL))
     124    return ((InteractiveModel*)this->getModel(0))->getAnimation();
     125  else
     126    return -1;
     127}
     128
     129
     130
     131/**
     132 * @returns true if animation is finished
     133 */
     134bool GenericNPC::isAnimationFinished()
     135{
     136  if( likely(this->getModel(0) != NULL))
     137    return ((InteractiveModel*)this->getModel(0))->isAnimationFinished();
     138  else
     139    return false;
     140}
     141
     142
     143
    117144/**
    118145 * sets the animation of this npc
     
    190217  anim.v = coordinate;
    191218  anim.type = Walk;
     219  anim.speed = 10.0f;
    192220
    193221  this->behaviourList.push_back(anim);
     
    296324  if (!this->behaviourList.empty())
    297325  {
    298     switch(this->behaviourList.front().type)
     326    GenericNPC::Anim currentAnimation = this->behaviourList.front();
     327    switch( currentAnimation.type)
    299328    {
    300329      case Walk:
    301330        {
    302           Vector dir = this->getAbsCoor() - this->behaviourList.front().v;
     331          if( this->getAnimation() != RUN)
     332            this->setAnimation(RUN, MD2_ANIM_LOOP);
     333
     334          Vector dir = this->getAbsCoor() - currentAnimation.v;
    303335          if (dir.len() < .5)
    304336            this->nextStep();
    305337          else
    306338          {
    307             this->shiftCoor(dir.getNormalized() * dt);
     339            this->shiftCoor(dir.getNormalized() * currentAnimation.speed dt);
    308340          }
    309341        }
    310342        break;
     343
    311344      case Run:
    312345        break;
     346
    313347      case Crouch:
    314348        break;
     349
    315350      case TurnTo:
    316351        //Quaternion direction = this->
    317352        break;
     353
    318354      case LookAt:
    319355        break;
     356
    320357      case Shoot:
    321358        break;
  • branches/single_player_map/src/world_entities/npcs/generic_npc.h

    r8917 r8951  
    3030  virtual void loadParams(const TiXmlElement* root);
    3131
    32   void setAnimation(int animationIndex, int animPlaybackMode);
    3332  /** sets the sound volume to @param vol: volume of the sound */
    3433  inline void setVolume(float vol) { this->soundVolume = vol; }
     
    8079    void init();
    8180
     81    void setAnimation(int animationIndex, int animPlaybackMode);
     82    int getAnimation();
     83    bool isAnimationFinished();
     84
    8285
    8386 private:
Note: See TracChangeset for help on using the changeset viewer.