Changeset 9746 in orxonox.OLD for branches/new_class_id/src/world_entities/space_ships/space_ship.cc
- Timestamp:
- Sep 16, 2006, 3:34:04 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/world_entities/space_ships/space_ship.cc
r9716 r9746 59 59 #include "script_class.h" 60 60 CREATE_SCRIPTABLE_CLASS(SpaceShip, SpaceShip::classID(), 61 addMethod("hasPlayer", Executor Lua0ret<Playable,bool>(&Playable::hasPlayer))62 ->addMethod("fire", Executor Lua1<Playable, bool>(&Playable::fire))63 ->addMethod("loadModel", Executor Lua2<WorldEntity,const std::string& ,float>(&WorldEntity::loadModel2))64 ->addMethod("setName", Executor Lua1<BaseObject,const std::string&>(&BaseObject::setName))65 ->addMethod("hide", Executor Lua0<WorldEntity>(&WorldEntity::hide))66 ->addMethod("unhide", Executor Lua0<WorldEntity>(&WorldEntity::unhide))67 //Coordinates68 ->addMethod("setAbsCoor", Executor Lua3<PNode,float,float,float>(&PNode::setAbsCoor))69 ->addMethod("getAbsCoorX", Executor Lua0ret<PNode, float>(&PNode::getAbsCoorX))70 ->addMethod("getAbsCoorY", Executor Lua0ret<PNode, float>(&PNode::getAbsCoorY))71 ->addMethod("getAbsCoorZ", Executor Lua0ret<PNode, float>(&PNode::getAbsCoorZ))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)) 72 72 ); 73 73 … … 118 118 void SpaceShip::init() 119 119 { 120 // this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));120 // this->setRelDir(Quaternion(M_PI, Vector(1,0,0))); 121 121 this->registerObject(this, SpaceShip::_objectList); 122 122 … … 147 147 controlVelocityY = 150; 148 148 shipInertia = 1.5; 149 // cycle = 0.0;149 // cycle = 0.0; 150 150 151 151 this->setHealthMax(100); … … 158 158 this->pitchDir = this->getAbsDir(); 159 159 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);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); 170 170 171 171 //add events to the eventlist … … 202 202 this->getWeaponManager().setSlotPosition(5, Vector(-1.5, -.5, -.5)); 203 203 this->getWeaponManager().setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0))); 204 //205 206 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)));: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)));: 213 213 214 214 this->getWeaponManager().getFixedTarget()->setParent(this); … … 312 312 void SpaceShip::collidesWith(WorldEntity* entity, const Vector& location) 313 313 { 314 315 314 } 316 315 … … 334 333 335 334 if( ( xMouse != 0 || yMouse != 0 ) && this->getOwner() == SharedNetworkData::getInstance()->getHostID() ) 336 335 { 337 336 if (xMouse > controlVelocityX) xMouse = controlVelocityX; 338 337 else if (xMouse < -controlVelocityX) xMouse = -controlVelocityX; … … 344 343 mouseDir *= (Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity*yInvert, Vector(0,0,1))*pitchDir); 345 344 xMouse = yMouse = 0; 346 347 348 349 // if( this != State::getPlayer()->getControllable())350 // return;345 } 346 347 348 // if( this != State::getPlayer()->getControllable()) 349 // return; 351 350 352 351 // spaceship controlled movement fire(bool bF){ this->bFire = bF;} 353 352 //if (this->getOwner() == this->getHostID()) 354 353 this->calculateVelocity(time); 355 354 356 355 … … 365 364 366 365 //orient the spaceship in direction of the mouse 367 368 366 rotQuat = Quaternion::quatSlerp( this->getAbsDir(), mouseDir, 0.5);//fabsf(time)*shipInertia); 367 if (this->getAbsDir().distance(rotQuat) > 0.00000000000001) 369 368 this->setAbsDir( rotQuat); 370 369 //this->setAbsDirSoft(mouseDir,5); 371 370 372 371 // this is the air friction (necessary for a smooth control) … … 390 389 this->shiftCoor(move); 391 390 392 // 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()); 393 392 394 393 } … … 411 410 412 411 if( this->bUp ) 413 414 415 416 417 418 412 { 413 //this->shiftCoor(this->getAbsDirX()); 414 //accel += (this->getAbsDirX())*2; 415 accel += (this->getAbsDirX())*acceleration; 416 417 } 419 418 420 419 if( this->bDown ) 421 422 423 420 { 421 //this->shiftCoor((this->getAbsDirX())*-1); 422 //accel -= (this->getAbsDirX())*2; 424 423 //if(velocity.len() > 50) 425 426 427 428 429 424 accel -= (this->getAbsDirX())*0.5*acceleration; 425 426 427 428 } 430 429 431 430 if( this->bLeft/* > -this->getRelCoor().z*2*/) 432 431 { 433 432 this->shiftDir(Quaternion(time, Vector(0,1,0))); 434 // accel -= rightDirection;433 // accel -= rightDirection; 435 434 //velocityDir.normalize(); 436 435 //rot +=Vector(1,0,0); … … 451 450 { 452 451 mouseDir *= Quaternion(-time*2, Vector(1,0,0)); 453 // accel -= rightDirection;452 // accel -= rightDirection; 454 453 //velocityDir.normalize(); 455 454 //rot +=Vector(1,0,0); … … 469 468 this->shiftDir(Quaternion(time, Vector(0,0,1))); 470 469 471 // accel += upDirection;470 // accel += upDirection; 472 471 //velocityDir.normalize(); 473 472 //rot += Vector(0,0,1); … … 497 496 498 497 if( event.type == KeyMapper::PEV_LEFT) 499 498 this->bRollL = event.bPressed; 500 499 else if( event.type == KeyMapper::PEV_RIGHT) 501 500 this->bRollR = event.bPressed; 502 501 else if( event.type == KeyMapper::PEV_FORWARD) 503 502 this->bUp = event.bPressed; //this->shiftCoor(0,.1,0);
Note: See TracChangeset
for help on using the changeset viewer.