Changeset 8823 in orxonox.OLD for branches/single_player_map/src/world_entities/npcs
- Timestamp:
- Jun 27, 2006, 2:24:30 PM (19 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
r8822 r8823 42 42 //addMethod("walkTo", ExecutorLua7ret<GenericNPC,float, float, float, float, float, float, float, float>(&GenericNPC::walkTo)) 43 43 addMethod("walkTo", ExecutorLua3ret<GenericNPC,float,float,float,float>(&GenericNPC::walkTo)) 44 ->addMethod("setTime", ExecutorLua1<GenericNPC,float>(&GenericNPC::setTime)) 44 45 ); 45 46 … … 87 88 this->soundBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/rain.wav", WAV); 88 89 90 time = 30.0f; 89 91 // collision reaction registration 90 92 // this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY); … … 153 155 this->destDir = destDir; 154 156 155 float time = 10.0f; 157 float time = 100.0f; 158 159 if( this->currentAnim != NULL) 160 delete this->currentAnim; 161 162 this->currentAnim = new Animation3D(this); 163 this->currentAnim->addKeyFrame(this->getAbsCoor(), this->getAbsDir(), 0.0f, ANIM_LINEAR, ANIM_LINEAR); 164 this->currentAnim->addKeyFrame(this->getAbsCoor(), this->getAbsDir(),time, ANIM_LINEAR, ANIM_LINEAR); 165 this->currentAnim->addKeyFrame(this->destCoor, this->destDir, time, ANIM_LINEAR, ANIM_LINEAR); 166 // this->currentAnim->addKeyFrame(this->getAbsCoor(), this->getAbsDir(), time, ANIM_LINEAR, ANIM_LINEAR); 167 // this->currentAnim->addKeyFrame(this->destCoor, this->destDir, time, ANIM_LINEAR, ANIM_LINEAR); 168 169 this->currentAnim->setInfinity(ANIM_INF_CONSTANT); 170 this->currentAnim->play(); 171 172 this->setAnimation(RUN, MD2_ANIM_LOOP); 173 } 174 175 // calculate the distance 176 Vector distance = this->getAbsCoor() - this->destCoor; 177 return distance.len(); 178 } 179 180 181 /** 182 * walk to a specific place with direction 183 * 184 * @param x: x coordinate to go to 185 * @param y: y coordinate to go to 186 * @param z: z coordinate to go to 187 * 188 * without turning itself 189 */ 190 float GenericNPC::walkTo(float x, float y, float z) 191 { 192 Quaternion q = this->getAbsDir(); 193 194 //printf("%s moving to %f, %f, %f \n",this->getName(),x,y,z); 195 196 return this->walkTo(x, y, z, q.w, q.v.x, q.v.y, q.v.z); 197 } 198 199 /** 200 * walk to a specific place with direction 201 * 202 * @param x: x coordinate to go to 203 * @param y: y coordinate to go to 204 * @param qu: angle to rotate 205 * @param qx: x coordinate of rotation vector 206 * @param qy: y coordinate of rotation vector 207 * @param qz: z coordinate of rotation vector 208 * 209 */ 210 float GenericNPC::walkTo(float x, float y, float qu, float qx, float qy, float qz) 211 { 212 return this->walkTo(x, y, 0.0f, qu, qx, qy, qz); 213 } 214 215 216 /** 217 * walk to a specific place with direction 218 * 219 * @param coor: vector place 220 * @param dir: direction 221 * 222 */ 223 float GenericNPC::walkTo(const Vector& coor, const Quaternion& dir) 224 { 225 return this->walkTo(coor.x, coor.y, coor.z, dir.w, dir.v.x, dir.v.y, dir.v.z); 226 } 227 228 229 230 /** 231 * run to a specific place with direction 232 * 233 * @param x: x coordinate to go to 234 * @param y: y coordinate to go to 235 * @param z: z coordinate to go to 236 * @param qu: angle to rotate 237 * @param qx: x coordinate of rotation vector 238 * @param qy: y coordinate of rotation vector 239 * @param qz: z coordinate of rotation vector 240 * 241 */ 242 float GenericNPC::runTo(float x, float y, float z, float qu, float qx, float qy, float qz) 243 { 244 Vector destCoor = Vector(x, y, z); 245 Quaternion destDir = Quaternion(Vector(qx, qy, qz), qu); 246 247 // check if this is the current goal 248 if( this->destCoor != destCoor || this->destDir != destDir) 249 { 250 this->destCoor = destCoor; 251 this->destDir = destDir; 252 253 float time = 5.0f; 156 254 157 255 if( this->currentAnim != NULL) … … 177 275 178 276 /** 179 * walk to a specific place with direction 180 * 181 * @param x: x coordinate to go to 182 * @param y: y coordinate to go to 183 * @param z: z coordinate to go to 184 * 185 * without turning itself 186 */ 187 float GenericNPC::walkTo(float x, float y, float z) 188 { 189 Quaternion q = this->getAbsDir(); 190 191 //printf("%s moving to %f, %f, %f \n",this->getName(),x,y,z); 192 193 return this->walkTo(x, y, z, q.w, q.v.x, q.v.y, q.v.z); 194 } 195 196 /** 197 * walk to a specific place with direction 277 * run to a specific place with direction 198 278 * 199 279 * @param x: x coordinate to go to … … 205 285 * 206 286 */ 207 float GenericNPC:: walkTo(float x, float y, float qu, float qx, float qy, float qz)208 { 209 return this->walkTo(x, y, 0.0f, qu, qx, qy, qz);210 } 211 212 213 /** 214 * walkto a specific place with direction287 float GenericNPC::runTo(float x, float y, float qu, float qx, float qy, float qz) 288 { 289 this->runTo(x, y, 0.0f, qu, qx, qy, qz); 290 } 291 292 293 /** 294 * run to a specific place with direction 215 295 * 216 296 * @param coor: vector place … … 218 298 * 219 299 */ 220 float GenericNPC::walkTo(const Vector& coor, const Quaternion& dir) 221 { 222 return this->walkTo(coor.x, coor.y, coor.z, dir.w, dir.v.x, dir.v.y, dir.v.z); 223 } 224 225 226 227 /** 228 * run to a specific place with direction 300 float GenericNPC::runTo(const Vector& coordinate, const Quaternion& dir) 301 { 302 this->runTo(coordinate.x, coordinate.y, coordinate.z, dir.w, dir.v.x, dir.v.y, dir.v.z); 303 } 304 305 306 /** 307 * crouch to a specific place with direction 229 308 * 230 309 * @param x: x coordinate to go to … … 237 316 * 238 317 */ 239 float GenericNPC:: runTo(float x, float y, float z, float qu, float qx, float qy, float qz)318 float GenericNPC::crouchTo(float x, float y, float z, float qu, float qx, float qy, float qz) 240 319 { 241 320 Vector destCoor = Vector(x, y, z); … … 248 327 this->destDir = destDir; 249 328 250 float time = 5.0f;251 329 252 330 if( this->currentAnim != NULL) … … 254 332 255 333 this->currentAnim = new Animation3D(this); 256 this->currentAnim->addKeyFrame(this->getAbsCoor(), this->getAbsDir(), 0.1f, ANIM_LINEAR, ANIM_LINEAR);257 this->currentAnim->addKeyFrame(this->destCoor, this->destDir, time, ANIM_LINEAR, ANIM_LINEAR);258 334 this->currentAnim->addKeyFrame(this->getAbsCoor(), this->getAbsDir(), time, ANIM_LINEAR, ANIM_LINEAR); 259 335 this->currentAnim->addKeyFrame(this->destCoor, this->destDir, time, ANIM_LINEAR, ANIM_LINEAR); 260 336 261 this->currentAnim->setInfinity(ANIM_INF_CONSTANT);262 this->currentAnim->play();263 264 this->setAnimation(RUN, MD2_ANIM_LOOP);265 }266 267 // calculate the distance268 Vector distance = this->getAbsCoor() - this->destCoor;269 return distance.len();270 }271 272 273 /**274 * run to a specific place with direction275 *276 * @param x: x coordinate to go to277 * @param y: y coordinate to go to278 * @param qu: angle to rotate279 * @param qx: x coordinate of rotation vector280 * @param qy: y coordinate of rotation vector281 * @param qz: z coordinate of rotation vector282 *283 */284 float GenericNPC::runTo(float x, float y, float qu, float qx, float qy, float qz)285 {286 this->runTo(x, y, 0.0f, qu, qx, qy, qz);287 }288 289 290 /**291 * run to a specific place with direction292 *293 * @param coor: vector place294 * @param dir: direction295 *296 */297 float GenericNPC::runTo(const Vector& coordinate, const Quaternion& dir)298 {299 this->runTo(coordinate.x, coordinate.y, coordinate.z, dir.w, dir.v.x, dir.v.y, dir.v.z);300 }301 302 303 /**304 * crouch to a specific place with direction305 *306 * @param x: x coordinate to go to307 * @param y: y coordinate to go to308 * @param z: z coordinate to go to309 * @param qu: angle to rotate310 * @param qx: x coordinate of rotation vector311 * @param qy: y coordinate of rotation vector312 * @param qz: z coordinate of rotation vector313 *314 */315 float GenericNPC::crouchTo(float x, float y, float z, float qu, float qx, float qy, float qz)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 goal321 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 337 338 this->currentAnim->setInfinity(ANIM_INF_CONSTANT); -
branches/single_player_map/src/world_entities/npcs/generic_npc.h
r8817 r8823 76 76 void playSound(int i); 77 77 78 78 void setTime(float newTime){ this->time = newTime; }; 79 79 80 virtual void tick (float time); 80 81 … … 91 92 92 93 Animation3D* currentAnim; 94 float time; //!< Duration of the action 93 95 }; 94 96
Note: See TracChangeset
for help on using the changeset viewer.