- Timestamp:
- Jun 27, 2006, 1:11:41 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/single_player_map/src/world_entities/npcs/generic_npc.cc
r8817 r8818 304 304 * crouch to a specific place with direction 305 305 * 306 * @param coor: vector place307 * @param dir: direction308 *309 */310 float GenericNPC::crouchTo(const Vector& coordinate, const Quaternion& dir)311 {312 }313 314 315 /**316 * crouch to a specific place with direction317 *318 306 * @param x: x coordinate to go to 319 307 * @param y: y coordinate to go to … … 326 314 */ 327 315 float GenericNPC::crouchTo(float x, float y, float z, float qu, float qx, float qy, float qz) 328 {} 316 { 317 Vector destCoor = Vector(x, y, z); 318 Quaternion destDir = Quaternion(Vector(qx, qy, qz), qu); 319 320 // check if this is the current goal 321 if( this->destCoor != destCoor || this->destDir != destDir) 322 { 323 this->destCoor = destCoor; 324 this->destDir = destDir; 325 326 float time = 5.0f; 327 328 if( this->currentAnim != NULL) 329 delete this->currentAnim; 330 331 this->currentAnim = new Animation3D(this); 332 this->currentAnim->addKeyFrame(this->getAbsCoor(), this->getAbsDir(), 0.1f, ANIM_LINEAR, ANIM_LINEAR); 333 this->currentAnim->addKeyFrame(this->destCoor, this->destDir, time, ANIM_LINEAR, ANIM_LINEAR); 334 this->currentAnim->addKeyFrame(this->getAbsCoor(), this->getAbsDir(), time, ANIM_LINEAR, ANIM_LINEAR); 335 this->currentAnim->addKeyFrame(this->destCoor, this->destDir, time, ANIM_LINEAR, ANIM_LINEAR); 336 337 this->currentAnim->setInfinity(ANIM_INF_CONSTANT); 338 this->currentAnim->play(); 339 340 this->setAnimation(CROUCH_WALK, MD2_ANIM_LOOP); 341 } 342 343 // calculate the distance 344 Vector distance = this->getAbsCoor() - this->destCoor; 345 return distance.len(); 346 } 329 347 330 348 … … 341 359 */ 342 360 float GenericNPC::crouchTo(float x, float y, float qu, float qx, float qy, float qz) 343 {} 344 361 { 362 this->crouchTo(x, y, 0.0f, qu, qx, qy, qz); 363 } 364 365 366 367 /** 368 * crouch to a specific place with direction 369 * 370 * @param coor: vector place 371 * @param dir: direction 372 * 373 */ 374 float GenericNPC::crouchTo(const Vector& coordinate, const Quaternion& dir) 375 { 376 this->crouchTo(coordinate.x, coordinate.y, coordinate.z, dir.w, dir.v.x, dir.v.y, dir.v.z); 377 } 345 378 346 379 … … 349 382 */ 350 383 void GenericNPC::stop() 351 {} 384 { 385 if( this->currentAnim != NULL) 386 { 387 this->currentAnim->stop(); 388 delete this->currentAnim; 389 this->currentAnim = NULL; 390 391 this->setAnimation(STAND, MD2_ANIM_LOOP); 392 } 393 } 352 394 353 395
Note: See TracChangeset
for help on using the changeset viewer.