Changeset 8951 in orxonox.OLD for branches/single_player_map/src
- Timestamp:
- Jun 30, 2006, 2:00:16 PM (18 years ago)
- 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 115 115 116 116 117 118 /** 119 * @returns the current animation number 120 */ 121 int 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 */ 134 bool 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 117 144 /** 118 145 * sets the animation of this npc … … 190 217 anim.v = coordinate; 191 218 anim.type = Walk; 219 anim.speed = 10.0f; 192 220 193 221 this->behaviourList.push_back(anim); … … 296 324 if (!this->behaviourList.empty()) 297 325 { 298 switch(this->behaviourList.front().type) 326 GenericNPC::Anim currentAnimation = this->behaviourList.front(); 327 switch( currentAnimation.type) 299 328 { 300 329 case Walk: 301 330 { 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; 303 335 if (dir.len() < .5) 304 336 this->nextStep(); 305 337 else 306 338 { 307 this->shiftCoor(dir.getNormalized() * dt);339 this->shiftCoor(dir.getNormalized() * currentAnimation.speed dt); 308 340 } 309 341 } 310 342 break; 343 311 344 case Run: 312 345 break; 346 313 347 case Crouch: 314 348 break; 349 315 350 case TurnTo: 316 351 //Quaternion direction = this-> 317 352 break; 353 318 354 case LookAt: 319 355 break; 356 320 357 case Shoot: 321 358 break; -
branches/single_player_map/src/world_entities/npcs/generic_npc.h
r8917 r8951 30 30 virtual void loadParams(const TiXmlElement* root); 31 31 32 void setAnimation(int animationIndex, int animPlaybackMode);33 32 /** sets the sound volume to @param vol: volume of the sound */ 34 33 inline void setVolume(float vol) { this->soundVolume = vol; } … … 80 79 void init(); 81 80 81 void setAnimation(int animationIndex, int animPlaybackMode); 82 int getAnimation(); 83 bool isAnimationFinished(); 84 82 85 83 86 private:
Note: See TracChangeset
for help on using the changeset viewer.