Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8802 in orxonox.OLD for trunk/src/world_entities/npcs


Ignore:
Timestamp:
Jun 26, 2006, 4:46:25 PM (19 years ago)
Author:
patrick
Message:

merged the network branche back to trunk

Location:
trunk/src/world_entities/npcs
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/npcs/generic_npc.cc

    r8783 r8802  
    3030#include "generic_npc.h"
    3131
     32#include "animation/animation3d.h"
     33
    3234using namespace std;
    3335
     
    5557 */
    5658GenericNPC::~GenericNPC ()
    57 {}
     59{
     60  if( this->currentAnim != NULL)
     61    delete this->currentAnim;
     62}
    5863
    5964
     
    138143float GenericNPC::walkTo(float x, float y, float z, float qu, float qx, float qy, float qz)
    139144{
    140 
    141   return true;
     145  Vector destCoor = Vector(x, y, z);
     146  Quaternion destDir = Quaternion(Vector(qx, qy, qz), qu);
     147
     148  // check if this is the current goal
     149  if( this->destCoor != destCoor && this->destDir != destDir)
     150  {
     151    this->destCoor = Vector(x, y, 0.0f);
     152    this->destDir = Quaternion(Vector(qx, qy, qz), qu);
     153
     154    float time = 5.0f;
     155
     156    if( this->currentAnim != NULL)
     157      delete this->currentAnim;
     158
     159    this->currentAnim = new Animation3D(this);
     160    this->currentAnim->addKeyFrame(this->getAbsCoor(), this->getAbsDir(), 0.0f);
     161    this->currentAnim->addKeyFrame(this->destCoor, this->destDir, time);
     162  }
     163
     164  // calculate the distance
     165  Vector distance = this->getAbsCoor() - this->destCoor;
     166  return distance.len();
     167}
     168
     169
     170
     171/**
     172 * walk to a specific place with direction
     173 *
     174 * @param x: x coordinate to go to
     175 * @param y: y coordinate to go to
     176 * @param qu: angle to rotate
     177 * @param qx: x coordinate of rotation vector
     178 * @param qy: y coordinate of rotation vector
     179 * @param qz: z coordinate of rotation vector
     180 *
     181 */
     182float GenericNPC::walkTo(float x, float y, float qu, float qx, float qy, float qz)
     183{
     184  return this->walkTo(x, y, 0.0f, qu, qx, qy, qz);
    142185}
    143186
  • trunk/src/world_entities/npcs/generic_npc.h

    r8796 r8802  
    2222
    2323class TiXmlElement;
     24class Animation3D;
    2425
    2526
     
    7172   Vector                                  destCoor;
    7273   Quaternion                              destDir;
     74
     75   Animation3D*                            currentAnim;
    7376};
    7477
Note: See TracChangeset for help on using the changeset viewer.