Changeset 9869 in orxonox.OLD for trunk/src/world_entities/space_ships/space_ship.cc
- Timestamp:
- Oct 3, 2006, 12:19:30 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/space_ships/space_ship.cc
r9656 r9869 26 26 #include "weapons/cannon.h" 27 27 28 #include " dot_emitter.h"29 #include " sprite_particles.h"28 #include "particles/dot_emitter.h" 29 #include "particles/sprite_particles.h" 30 30 31 31 #include "util/loading/factory.h" … … 53 53 54 54 55 56 CREATE_FACTORY(SpaceShip, CL_SPACE_SHIP); 55 #include "class_id_DEPRECATED.h" 56 ObjectListDefinitionID(SpaceShip, CL_SPACE_SHIP); 57 CREATE_FACTORY(SpaceShip); 58 57 59 #include "script_class.h" 58 CREATE_SCRIPTABLE_CLASS(SpaceShip, CL_SPACE_SHIP,59 addMethod("hasPlayer", Executor Lua0ret<Playable,bool>(&Playable::hasPlayer))60 ->addMethod("fire", Executor Lua1<Playable, bool>(&Playable::fire))61 ->addMethod("loadModel", Executor Lua2<WorldEntity,const std::string& ,float>(&WorldEntity::loadModel2))62 ->addMethod("setName", Executor Lua1<BaseObject,const std::string&>(&BaseObject::setName))63 ->addMethod("hide", Executor Lua0<WorldEntity>(&WorldEntity::hide))64 ->addMethod("unhide", Executor Lua0<WorldEntity>(&WorldEntity::unhide))65 //Coordinates66 ->addMethod("setAbsCoor", Executor Lua3<PNode,float,float,float>(&PNode::setAbsCoor))67 ->addMethod("getAbsCoorX", Executor Lua0ret<PNode, float>(&PNode::getAbsCoorX))68 ->addMethod("getAbsCoorY", Executor Lua0ret<PNode, float>(&PNode::getAbsCoorY))69 ->addMethod("getAbsCoorZ", Executor Lua0ret<PNode, float>(&PNode::getAbsCoorZ))60 CREATE_SCRIPTABLE_CLASS(SpaceShip, 61 addMethod("hasPlayer", Executor0ret<Playable, lua_State*,bool>(&Playable::hasPlayer)) 62 ->addMethod("fire", Executor1<Playable, lua_State*, bool>(&Playable::fire)) 63 ->addMethod("loadModel", Executor2<WorldEntity, lua_State*,const std::string& ,float>(&WorldEntity::loadModel2)) 64 ->addMethod("setName", Executor1<BaseObject, lua_State*,const std::string&>(&BaseObject::setName)) 65 ->addMethod("hide", Executor0<WorldEntity, lua_State*>(&WorldEntity::hide)) 66 ->addMethod("unhide", Executor0<WorldEntity, lua_State*>(&WorldEntity::unhide)) 67 //Coordinates 68 ->addMethod("setAbsCoor", Executor3<PNode, lua_State*,float,float,float>(&PNode::setAbsCoor)) 69 ->addMethod("getAbsCoorX", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorX)) 70 ->addMethod("getAbsCoorY", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorY)) 71 ->addMethod("getAbsCoorZ", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorZ)) 70 72 ); 71 73 … … 116 118 void SpaceShip::init() 117 119 { 118 // this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));119 this-> setClassID(CL_SPACE_SHIP, "SpaceShip");120 // this->setRelDir(Quaternion(M_PI, Vector(1,0,0))); 121 this->registerObject(this, SpaceShip::_objectList); 120 122 121 123 PRINTF(4)("SPACESHIP INIT\n"); … … 145 147 controlVelocityY = 150; 146 148 shipInertia = 1.5; 147 // cycle = 0.0;149 // cycle = 0.0; 148 150 149 151 this->setHealthMax(100); … … 156 158 this->pitchDir = this->getAbsDir(); 157 159 158 // GLGuiButton* button = new GLGuiPushButton();159 // button->show();160 // button->setLabel("orxonox");161 // button->setBindNode(this);162 // GLGuiBar* bar = new GLGuiBar();163 // bar->show();164 // bar->setValue(7.0);165 // bar->setMaximum(10);166 // bar->setSize2D( 20, 100);167 // bar->setAbsCoor2D( 10, 200);160 // GLGuiButton* button = new GLGuiPushButton(); 161 // button->show(); 162 // button->setLabel("orxonox"); 163 // button->setBindNode(this); 164 // GLGuiBar* bar = new GLGuiBar(); 165 // bar->show(); 166 // bar->setValue(7.0); 167 // bar->setMaximum(10); 168 // bar->setSize2D( 20, 100); 169 // bar->setAbsCoor2D( 10, 200); 168 170 169 171 //add events to the eventlist … … 200 202 this->getWeaponManager().setSlotPosition(5, Vector(-1.5, -.5, -.5)); 201 203 this->getWeaponManager().setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0))); 202 //203 204 205 206 // this->getWeaponManager().setSlotPosition(8, Vector(-2.5, -0.3, -2.0));207 // this->getWeaponManager().setSlotDirection(8, Quaternion(-M_PI, Vector(1,0,0)));208 //209 // this->getWeaponManager().setSlotPosition(9, Vector(-2.5, -0.3, 2.0));210 // this->getWeaponManager().setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0)));:204 // 205 this->getWeaponManager().setSlotPosition(6, Vector(-1, 0.0, 0)); 206 this->getWeaponManager().setSlotCapability(6, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 207 // 208 // this->getWeaponManager().setSlotPosition(8, Vector(-2.5, -0.3, -2.0)); 209 // this->getWeaponManager().setSlotDirection(8, Quaternion(-M_PI, Vector(1,0,0))); 210 // 211 // this->getWeaponManager().setSlotPosition(9, Vector(-2.5, -0.3, 2.0)); 212 // this->getWeaponManager().setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0)));: 211 213 212 214 this->getWeaponManager().getFixedTarget()->setParent(this); … … 310 312 void SpaceShip::collidesWith(WorldEntity* entity, const Vector& location) 311 313 { 312 313 314 } 314 315 … … 332 333 333 334 if( ( xMouse != 0 || yMouse != 0 ) && this->getOwner() == SharedNetworkData::getInstance()->getHostID() ) 334 335 { 335 336 if (xMouse > controlVelocityX) xMouse = controlVelocityX; 336 337 else if (xMouse < -controlVelocityX) xMouse = -controlVelocityX; … … 342 343 mouseDir *= (Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity*yInvert, Vector(0,0,1))*pitchDir); 343 344 xMouse = yMouse = 0; 344 345 346 347 // if( this != State::getPlayer()->getControllable())348 // return;345 } 346 347 348 // if( this != State::getPlayer()->getControllable()) 349 // return; 349 350 350 351 // spaceship controlled movement fire(bool bF){ this->bFire = bF;} 351 352 //if (this->getOwner() == this->getHostID()) 352 353 this->calculateVelocity(time); 353 354 354 355 … … 363 364 364 365 //orient the spaceship in direction of the mouse 365 366 366 rotQuat = Quaternion::quatSlerp( this->getAbsDir(), mouseDir, 0.5);//fabsf(time)*shipInertia); 367 if (this->getAbsDir().distance(rotQuat) > 0.00000000000001) 367 368 this->setAbsDir( rotQuat); 368 369 //this->setAbsDirSoft(mouseDir,5); 369 370 370 371 // this is the air friction (necessary for a smooth control) … … 388 389 this->shiftCoor(move); 389 390 390 // PRINTF(0)("id of %s is: %i\n", this->getName(), this->getOMListNumber());391 // PRINTF(0)("id of %s is: %i\n", this->getName(), this->getOMListNumber()); 391 392 392 393 } … … 409 410 410 411 if( this->bUp ) 411 412 413 414 415 416 412 { 413 //this->shiftCoor(this->getAbsDirX()); 414 //accel += (this->getAbsDirX())*2; 415 accel += (this->getAbsDirX())*acceleration; 416 417 } 417 418 418 419 if( this->bDown ) 419 420 421 420 { 421 //this->shiftCoor((this->getAbsDirX())*-1); 422 //accel -= (this->getAbsDirX())*2; 422 423 //if(velocity.len() > 50) 423 424 425 426 427 424 accel -= (this->getAbsDirX())*0.5*acceleration; 425 426 427 428 } 428 429 429 430 if( this->bLeft/* > -this->getRelCoor().z*2*/) 430 431 { 431 432 this->shiftDir(Quaternion(time, Vector(0,1,0))); 432 // accel -= rightDirection;433 // accel -= rightDirection; 433 434 //velocityDir.normalize(); 434 435 //rot +=Vector(1,0,0); … … 449 450 { 450 451 mouseDir *= Quaternion(-time*2, Vector(1,0,0)); 451 // accel -= rightDirection;452 // accel -= rightDirection; 452 453 //velocityDir.normalize(); 453 454 //rot +=Vector(1,0,0); … … 467 468 this->shiftDir(Quaternion(time, Vector(0,0,1))); 468 469 469 // accel += upDirection;470 // accel += upDirection; 470 471 //velocityDir.normalize(); 471 472 //rot += Vector(0,0,1); … … 495 496 496 497 if( event.type == KeyMapper::PEV_LEFT) 497 498 this->bRollL = event.bPressed; 498 499 else if( event.type == KeyMapper::PEV_RIGHT) 499 500 this->bRollR = event.bPressed; 500 501 else if( event.type == KeyMapper::PEV_FORWARD) 501 502 this->bUp = event.bPressed; //this->shiftCoor(0,.1,0);
Note: See TracChangeset
for help on using the changeset viewer.