Changeset 8802 in orxonox.OLD for trunk/src/world_entities/npcs
- Timestamp:
- Jun 26, 2006, 4:46:25 PM (19 years ago)
- Location:
- trunk/src/world_entities/npcs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/npcs/generic_npc.cc
r8783 r8802 30 30 #include "generic_npc.h" 31 31 32 #include "animation/animation3d.h" 33 32 34 using namespace std; 33 35 … … 55 57 */ 56 58 GenericNPC::~GenericNPC () 57 {} 59 { 60 if( this->currentAnim != NULL) 61 delete this->currentAnim; 62 } 58 63 59 64 … … 138 143 float GenericNPC::walkTo(float x, float y, float z, float qu, float qx, float qy, float qz) 139 144 { 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 */ 182 float 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); 142 185 } 143 186 -
trunk/src/world_entities/npcs/generic_npc.h
r8796 r8802 22 22 23 23 class TiXmlElement; 24 class Animation3D; 24 25 25 26 … … 71 72 Vector destCoor; 72 73 Quaternion destDir; 74 75 Animation3D* currentAnim; 73 76 }; 74 77
Note: See TracChangeset
for help on using the changeset viewer.