Changeset 9061 in orxonox.OLD for trunk/src/world_entities
- Timestamp:
- Jul 3, 2006, 6:39:10 PM (19 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 11 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/WorldEntities.am
r9003 r9061 44 44 world_entities/space_ships/hover.cc \ 45 45 world_entities/space_ships/turbine_hover.cc \ 46 world_entities/space_ships/spacecraft_2d.cc \ 46 47 world_entities/space_ships/collision_probe.cc \ 48 world_entities/space_ships/cruizer.cc \ 47 49 world_entities/creatures/md2_creature.cc \ 48 50 world_entities/creatures/fps_player.cc \ … … 107 109 space_ships/hover.h \ 108 110 space_ships/turbine_hover.h \ 109 space_ships/collision_probe.cc \ 111 space_ships/spacecraft_2d.h \ 112 space_ships/collision_probe.h \ 113 space_ships/cruizer.h \ 110 114 creatures/md2_creature.h \ 111 115 creatures/fps_player.h \ -
trunk/src/world_entities/npcs/generic_npc.cc
r9027 r9061 40 40 ->addMethod("turnTo", ExecutorLua1<GenericNPC,float>(&GenericNPC::turnTo)) 41 41 ->addMethod("finalGoalReached", ExecutorLua0ret<GenericNPC,bool>(&GenericNPC::finalGoalReached)) 42 ->addMethod("stop", ExecutorLua0<GenericNPC>(&GenericNPC::stop)) 43 ->addMethod("resume", ExecutorLua0<GenericNPC>(&GenericNPC::resume)) 44 ->addMethod("playAnimation", ExecutorLua2<GenericNPC,int,int>(&GenericNPC::playAnimation)) 42 45 // Display 43 46 ->addMethod("hide", ExecutorLua0<WorldEntity>(&WorldEntity::hide)) … … 49 52 ->addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor)) 50 53 ->addMethod("setAbsDir", ExecutorLua4<PNode,float,float,float,float>(&PNode::setAbsDir)) 51 52 54 ); 53 55 … … 88 90 time = 30.0f; 89 91 92 this->behaviourList = new std::list<GenericNPC::Anim>; 93 90 94 // collision reaction registration 91 95 // this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY); … … 170 174 * @param filename: name of the file 171 175 */ 172 void GenericNPC::playSound( std::stringfilename)176 void GenericNPC::playSound(const std::string& filename) 173 177 {} 174 178 … … 179 183 */ 180 184 void GenericNPC::stop() 181 {} 182 183 184 185 { 186 this->animationStack.push(this->behaviourList); 187 this->behaviourList = new std::list<GenericNPC::Anim>; 188 } 189 190 191 /** 192 * continue the generic animation 193 */ 194 void GenericNPC::resume() 195 { 196 //if() 197 delete this->behaviourList; 198 this->behaviourList = this->animationStack.top(); 199 this->animationStack.pop(); 200 } 201 202 203 /** 204 * each animation has to be initialized here 205 */ 185 206 void GenericNPC::initNPC() 186 207 { 187 188 this->unsubscribeReaction(); 189 190 if (!this->behaviourList.empty()) 191 { 192 GenericNPC::Anim currentAnimation = this->behaviourList.front(); 193 194 switch(this->behaviourList.front().type) 208 if (!this->behaviourList->empty()) 209 { 210 GenericNPC::Anim currentAnimation = this->behaviourList->front(); 211 212 switch(this->behaviourList->front().type) 195 213 { 196 214 case Walk: … … 213 231 214 232 Vector dir = (currentAnimation.v - this->getAbsCoor()).getNormalized(); 233 dir.y = 0.0f; 234 dir.getNormalized(); 215 235 this->setAbsDir(Quaternion(dir, Vector(0.0, 1.0, 0.0)) * Quaternion(-M_PI_2, Vector(0.0, 1.0, 0.0))); 216 236 … … 224 244 225 245 Vector dir = (currentAnimation.v - this->getAbsCoor()).getNormalized(); 246 dir.y = 0.0f; 247 dir.getNormalized(); 226 248 this->setAbsDir(Quaternion(dir, Vector(0.0, 1.0, 0.0)) * Quaternion(-M_PI_2, Vector(0.0, 1.0, 0.0))); 227 249 … … 250 272 void GenericNPC::nextStep() 251 273 { 252 if (!this->behaviourList .empty())253 this->behaviourList .pop_front();274 if (!this->behaviourList->empty()) 275 this->behaviourList->pop_front(); 254 276 else 255 277 return; 256 278 257 279 258 if (!this->behaviourList .empty())259 { 260 GenericNPC::Anim currentAnimation = this->behaviourList .front();280 if (!this->behaviourList->empty()) 281 { 282 GenericNPC::Anim currentAnimation = this->behaviourList->front(); 261 283 262 284 switch( currentAnimation.type) … … 266 288 if( this->getAnimation() != RUN) 267 289 this->setAnimation(RUN, MD2_ANIM_LOOP); 290 268 291 269 292 Vector dir = (currentAnimation.v - this->getAbsCoor()); … … 281 304 282 305 Vector dir = (currentAnimation.v - this->getAbsCoor()).getNormalized(); 306 dir.y = 0.0f; 307 dir.getNormalized(); 283 308 this->setAbsDirSoft(Quaternion(dir, Vector(0.0, 1.0, 0.0)) * Quaternion(-M_PI_2, Vector(0.0, 1.0, 0.0)), 4.0); 284 309 … … 292 317 293 318 Vector dir = (currentAnimation.v - this->getAbsCoor()).getNormalized(); 319 dir.y = 0.0f; 320 dir.getNormalized(); 294 321 this->setAbsDirSoft(Quaternion(dir, Vector(0.0, 1.0, 0.0)) * Quaternion(-M_PI_2, Vector(0.0, 1.0, 0.0)), 4.0); 295 322 … … 332 359 anim.speed = 30.0f; 333 360 334 if( this->behaviourList .empty())335 { 336 this->behaviourList .push_back(anim);361 if( this->behaviourList->empty()) 362 { 363 this->behaviourList->push_back(anim); 337 364 this->initNPC(); 338 365 } 339 366 else 340 this->behaviourList .push_back(anim);367 this->behaviourList->push_back(anim); 341 368 } 342 369 … … 356 383 anim.speed = 60.0f; 357 384 358 if( this->behaviourList .empty())359 { 360 this->behaviourList .push_back(anim);385 if( this->behaviourList->empty()) 386 { 387 this->behaviourList->push_back(anim); 361 388 this->initNPC(); 362 389 } 363 390 else 364 this->behaviourList .push_back(anim);391 this->behaviourList->push_back(anim); 365 392 } 366 393 … … 377 404 anim.type = Crouch; 378 405 379 if( this->behaviourList .empty())380 { 381 this->behaviourList .push_back(anim);406 if( this->behaviourList->empty()) 407 { 408 this->behaviourList->push_back(anim); 382 409 this->initNPC(); 383 410 } 384 411 else 385 this->behaviourList .push_back(anim);412 this->behaviourList->push_back(anim); 386 413 } 387 414 void GenericNPC::crouchTo(float x, float y, float z) … … 398 425 anim.type = TurnTo; 399 426 400 if( this->behaviourList .empty())401 { 402 this->behaviourList .push_back(anim);427 if( this->behaviourList->empty()) 428 { 429 this->behaviourList->push_back(anim); 403 430 this->initNPC(); 404 431 } 405 432 else 406 this->behaviourList .push_back(anim);433 this->behaviourList->push_back(anim); 407 434 } 408 435 … … 419 446 anim.type = LookAt; 420 447 421 if( this->behaviourList .empty())422 { 423 this->behaviourList .push_back(anim);448 if( this->behaviourList->empty()) 449 { 450 this->behaviourList->push_back(anim); 424 451 this->initNPC(); 425 452 } 426 453 else 427 this->behaviourList .push_back(anim);454 this->behaviourList->push_back(anim); 428 455 } 429 456 … … 466 493 467 494 468 if (!this->behaviourList .empty())469 { 470 GenericNPC::Anim currentAnimation = this->behaviourList .front();495 if (!this->behaviourList->empty()) 496 { 497 GenericNPC::Anim currentAnimation = this->behaviourList->front(); 471 498 472 499 switch( currentAnimation.type) … … 475 502 { 476 503 Vector dest = currentAnimation.v - this->getAbsCoor(); 504 dest.y = 0.0f; 477 505 if (dest.len() < .5) 478 506 { … … 481 509 else 482 510 { 483 dest.y = 0.0f;484 this->shiftCoor( dest.getNormalized() * currentAnimation.speed * dt);511 Vector move = dest.getNormalized() * currentAnimation.speed * dt; 512 this->shiftCoor(move); 485 513 } 486 514 } … … 528 556 529 557 // physical falling of the player 530 // if( !this->isOnGround()) 531 // { 532 // this->fallVelocity += 300.0f * dt; 533 // velocity -= Vector(0.0, 1.0, 0.0) * this->fallVelocity; 534 // // PRINTF(0)("%s is not on ground\n", this->getName()); 535 // this->shiftCoor(Vector(0, -this->fallVelocity * dt,0)); 536 // } 537 // else 538 // { 539 // this->fallVelocity = 0.0f; 540 // } 541 542 558 if( !this->isOnGround()) 559 { 560 this->fallVelocity += 300.0f * dt; 561 //velocity -= Vector(0.0, 1.0, 0.0) * this->fallVelocity; 562 // PRINTF(0)("%s is not on ground\n", this->getName()); 563 this->shiftCoor(Vector(0, -this->fallVelocity * dt,0)); 564 565 } 566 else 567 { 568 this->fallVelocity = 0.0f; 569 } 543 570 544 571 } -
trunk/src/world_entities/npcs/generic_npc.h
r9003 r9061 12 12 13 13 #include "sound_source.h" 14 15 #include <stack> 16 14 17 15 18 namespace OrxSound{ class SoundSource; } … … 35 38 36 39 37 bool finalGoalReached() { return this->behaviourList .empty(); };40 bool finalGoalReached() { return this->behaviourList->empty(); }; 38 41 39 42 /* npc controlling functions to be Queued */ … … 52 55 /* stopping the movement */ 53 56 void stop(); 57 void resume(); 54 58 void nextStep(); 55 59 … … 68 72 /* some generic control funtions */ 69 73 void playAnimation(int animationIndex, int animPlaybackMode); 70 void playSound(std::string filename); 71 void playSound(int i); 74 void playSound(const std::string& filename); 72 75 73 76 virtual void tick (float time); … … 123 126 float soundVolume; 124 127 125 std::list<GenericNPC::Anim> behaviourList; 128 std::list<GenericNPC::Anim>* behaviourList; 129 std::stack<std::list<GenericNPC::Anim>*> animationStack; 126 130 Vector destCoor; 127 131 Quaternion destDir; -
trunk/src/world_entities/playable.cc
r9008 r9061 63 63 this->score = 0; 64 64 this->collider = NULL; 65 this->enterRadius = 10.0f; 65 66 66 67 this->bDead = false; … … 94 95 95 96 LoadParam(root, "abs-dir", this, Playable, setPlayDirection); 97 LoadParam(root, "enter-radius", this, Playable, setEnterRadius) 98 .describe("The Distance one can enter the ship from."); 96 99 } 97 100 -
trunk/src/world_entities/playable.h
r8724 r9061 56 56 57 57 // Player Settup 58 bool hasPlayer(){return !(this->currentPlayer == NULL);} 58 59 bool setPlayer(Player* player); 59 60 Player* getCurrentPlayer() const { return this->currentPlayer; }; … … 74 75 inline int getScore() { return this->score; } 75 76 77 void setEnterRadius(float radius) { this->enterRadius = radius; }; 78 /** @returns the EnterRadius (how far away a Player must be to enter this entity) */ 79 inline float getEnterRadius() const { return this->enterRadius; }; 76 80 77 81 // WorldEntity Extensions … … 116 120 Playable::Playmode playmode; //!< The current playmode. 117 121 122 float enterRadius; //!< How far one can be away from the Playable to enter it. 123 118 124 WorldEntity* collider; 119 125 }; -
trunk/src/world_entities/player.cc
r9019 r9061 32 32 Player::Player() 33 33 { 34 // this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));34 // this->setRelDir(Quaternion(M_PI, Vector(1,0,0))); 35 35 this->setClassID(CL_PLAYER, "Player"); 36 36 … … 74 74 { 75 75 PRINTF(4)("Enter new Playable\n"); 76 77 this->_hud.setEnergyWidget(this->playable->getHealthWidget());78 this->_hud.setWeaponManager(&this->playable->getWeaponManager());76 this->playable = playable; 77 this->hud.setEnergyWidget(this->playable->getHealthWidget()); 78 this->hud.setWeaponManager(&this->playable->getWeaponManager()); 79 79 80 81 80 this->playable->setPlayer(this); 81 return true; 82 82 } 83 83 … … 89 89 90 90 bool Player::eject() 91 92 93 91 { 92 return this->setPlayable(NULL); 93 } 94 94 95 95 … … 99 99 } 100 100 101 void Player::process(const Event &event)102 {103 if (event.type == KeyMapper::PEV_CHANGE_SHIP && event.bPressed)104 {105 /// FIXME this should be in the ObjectManager106 const std::list<BaseObject*>* objectList = ClassList::getList(CL_PLAYABLE);107 if (objectList != NULL)108 {109 std::list<BaseObject*>::const_iterator node;110 for (node = objectList->begin(); node != objectList->end(); node++)111 if (this->playable != (*node) && (dynamic_cast<PNode*>(*node)->getAbsCoor() - this->playable->getAbsCoor()).len() < 10.0)112 {113 101 114 this->setPlayable(dynamic_cast<Playable*>(*node)); 102 void Player::enterNewPlayable() 103 { 104 /// FIXME this should be in the ObjectManager 105 const std::list<BaseObject*>* objectList = ClassList::getList(CL_PLAYABLE); 106 if (objectList != NULL) 107 { 108 std::list<BaseObject*>::const_iterator node; 109 for (node = objectList->begin(); node != objectList->end(); node++) 110 if (this->playable != (*node) && 111 (dynamic_cast<PNode*>(*node)->getAbsCoor() - this->playable->getAbsCoor()).len() < (dynamic_cast<Playable*>(*node)->getEnterRadius())) 112 { 115 113 116 break; 117 } 118 } 119 } 114 this->setPlayable(dynamic_cast<Playable*>(*node)); 120 115 121 if (likely(this->playable != NULL)) 122 this->playable->process(event); 123 } 116 break; 117 } 118 } 119 } 124 120 121 122 void Player::process(const Event &event) 123 { 124 if (event.type == KeyMapper::PEV_CHANGE_SHIP && event.bPressed) 125 { 126 this->enterNewPlayable(); 127 } 128 129 if (likely(this->playable != NULL)) 130 this->playable->process(event); 131 } 132 -
trunk/src/world_entities/player.h
r9059 r9061 38 38 39 39 void weaponConfigChanged(); 40 void enterNewPlayable(); 40 41 41 42 // eventListener extension. -
trunk/src/world_entities/projectiles/laser.cc
r8362 r9061 140 140 void Laser::draw () const 141 141 { 142 glMatrixMode(GL_MODELVIEW);143 glPushMatrix();144 142 glPushAttrib(GL_ENABLE_BIT); 145 143 glDisable(GL_LIGHTING); 144 145 WorldEntity::draw(); 146 /* glMatrixMode(GL_MODELVIEW); 147 glPushMatrix(); 146 148 147 149 float matrix[4][4]; … … 151 153 glScalef(2.0, 2.0, 2.0); 152 154 this->getModel()->draw(); 155 glPopMatrix();*/ 156 153 157 glPopAttrib(); 154 glPopMatrix();155 158 } 156 159 -
trunk/src/world_entities/script_trigger.cc
r9006 r9061 23 23 24 24 CREATE_SCRIPTABLE_CLASS(ScriptTrigger, CL_SCRIPT_TRIGGER, 25 addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor)) 26 ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX)) 27 ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY)) 28 ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ)) 29 ); 25 // Coordinates 26 addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor)) 27 ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX)) 28 ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY)) 29 ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ)) 30 //Properties 31 ->addMethod("setTarget", ExecutorLua1<ScriptTrigger, const std::string&>(&ScriptTrigger::setTarget)) 32 ->addMethod("setTriggerParent", ExecutorLua1<ScriptTrigger, const std::string&>(&ScriptTrigger::setTriggerParent)) 33 ->addMethod("setTriggerLasts", ExecutorLua1<ScriptTrigger, bool>(&ScriptTrigger::setTriggerLasts)) 34 ->addMethod("setInvert", ExecutorLua1<ScriptTrigger, bool>(&ScriptTrigger::setInvert)) 35 ->addMethod("setRadius", ExecutorLua1<ScriptTrigger, float>(&ScriptTrigger::setRadius)) 36 ->addMethod("setScript", ExecutorLua1<ScriptTrigger, const std::string&>(&ScriptTrigger::setScript)) 37 ->addMethod("setFunction", ExecutorLua1<ScriptTrigger, const std::string&>(&ScriptTrigger::setFunction)) 38 ->addMethod("setDebugDraw", ExecutorLua1<ScriptTrigger, bool>(&ScriptTrigger::setDebugDraw)) 39 ->addMethod("setAddToScript", ExecutorLua1<ScriptTrigger, bool>(&ScriptTrigger::setAddToScript)) 40 ); 30 41 31 42 -
trunk/src/world_entities/space_ships/space_ship.cc
r9008 r9061 55 55 56 56 CREATE_FACTORY(SpaceShip, CL_SPACE_SHIP); 57 57 #include "script_class.h" 58 CREATE_SCRIPTABLE_CLASS(SpaceShip, CL_SPACE_SHIP, 59 addMethod("hasPlayer", ExecutorLua0ret<Playable,bool>(&Playable::hasPlayer)) 60 ); 58 61 59 62 /** -
trunk/src/world_entities/world_entity.cc
r9059 r9061 82 82 83 83 // registering default reactions: 84 this->subscribeReaction(CREngine::CR_OBJECT_DAMAGE, CL_WORLD_ENTITY);84 this->subscribeReaction(CREngine::CR_OBJECT_DAMAGE, /*CL_WORLD_ENTITY*/ CL_PROJECTILE); 85 85 86 86 this->toList(OM_NULL);
Note: See TracChangeset
for help on using the changeset viewer.