Changeset 6724 in orxonox.OLD for trunk/src/world_entities/space_ships
- Timestamp:
- Jan 25, 2006, 5:35:49 PM (19 years ago)
- Location:
- trunk/src/world_entities/space_ships
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/space_ships/helicopter.cc
r6637 r6724 36 36 37 37 /** 38 * creates the controlable Spaceship38 * creates the controlable Helicopter 39 39 */ 40 40 Helicopter::Helicopter() … … 44 44 45 45 /** 46 * destructs the spaceship, deletes alocated memory46 * destructs the helicopter, deletes alocated memory 47 47 */ 48 48 Helicopter::~Helicopter () … … 51 51 52 52 /** 53 * loads a Spaceshipsinformation from a specified file.54 * @param fileName the name of the File to load the spaceshipfrom (absolute path)53 * loads a Helicopter information from a specified file. 54 * @param fileName the name of the File to load the helicopter from (absolute path) 55 55 */ 56 56 Helicopter::Helicopter(const char* fileName) … … 108 108 this->setClassID(CL_HELICOPTER, "Helicopter"); 109 109 110 PRINTF(4)(" SPACESHIPINIT\n");110 PRINTF(4)("HELICOPTER INIT\n"); 111 111 112 112 this->loadModel("models/ships/helicopter_#.obj", 1.0); … … 118 118 xMouse = yMouse = 0; 119 119 mouseSensitivity = 0.05; 120 controlVelocityX = 100; 121 controlVelocityY = 100; 120 122 //rotorspeed = 1; 121 123 //tailrotorspeed = 0; 122 124 123 125 //cycle = 0.0; 126 127 // cameraissue 128 this->cameraNode.setParent(this); 129 this->cameraNode.setParentMode(PNODE_ALL); 130 131 132 // rotors 133 this->topRotor.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); 134 this->tailRotor.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); 135 136 this->topRotor.setParent(this); 137 this->tailRotor.setParent(this); 138 139 this->topRotor.setRelCoor(Vector(-0.877,0.627,0)); 140 this->tailRotor.setRelCoor(Vector(-4.43,0.297,0.068)); 141 this->tailRotor.setAbsDir(Quaternion(M_PI_2,Vector(1,0,0))); 142 143 this->loadModel("models/ships/rotor.obj",1.0,3); 144 this->loadModel("models/ships/rotor.obj",0.2,4); 124 145 125 146 … … 127 148 this->velocity = Vector(0.0,0.0,0.0); 128 149 this->velocityDir = Vector(1.0,0.0,0.0); 129 130 150 // GLGuiButton* button = new GLGuiPushButton(); 131 151 // button->show(); … … 177 197 // this->getWeaponManager()->setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0)));: 178 198 179 this->getWeaponManager()->getFixedTarget()->setParent( this);180 this->getWeaponManager()->getFixedTarget()->setRelCoor( 100000,0,0);199 this->getWeaponManager()->getFixedTarget()->setParent(&(this->cameraNode)); 200 this->getWeaponManager()->getFixedTarget()->setRelCoor(0,0,0); 181 201 182 202 dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( false); … … 193 213 } 194 214 195 215 void Helicopter::attachCamera() 216 { 217 State::getCamera()->setParentSoft(this->getWeaponManager()->getFixedTarget()); 218 State::getCameraTarget()->setParentSoft(this->getWeaponManager()->getFixedTarget()); 219 220 } 196 221 197 222 … … 221 246 222 247 /** 223 * the action occuring if the spaceshipleft the game248 * the action occuring if the helicopter left the game 224 249 */ 225 250 void Helicopter::leftWorld () … … 249 274 void Helicopter::tick (float time) 250 275 { 251 /* 252 tailrotorspeed += xMouse/20; 253 if (tailrotorspeed >= 0.07) tailrotorspeed = 0.07; 254 else if (tailrotorspeed <= -0.07) tailrotorspeed = -0.07; 255 256 if (tailrotorspeed > 0.0008) tailrotorspeed -= 0.001; 257 else if (tailrotorspeed < -0.0008) tailrotorspeed += 0.001; 258 if (tailrotorspeed <= 0.001 && tailrotorspeed >= -0.001) tailrotorspeed = 0; 259 */ 276 if( xMouse != 0 || yMouse != 0) 277 { 278 if (xMouse > controlVelocityX) xMouse = controlVelocityX; 279 else if (xMouse < -controlVelocityX) xMouse = -controlVelocityX; 280 if (yMouse > controlVelocityY) yMouse = controlVelocityY; 281 else if (yMouse < -controlVelocityY) yMouse = -controlVelocityY; 282 } 283 284 // rotorrotation 285 this->topRotor.shiftDir(Quaternion(time*10, Vector(0,1,0))); 286 this->tailRotor.shiftDir(Quaternion(time*10, Vector(0,1,0))); 260 287 261 288 // spaceship controlled movement … … 419 446 { 420 447 WorldEntity::draw(); 448 449 glMatrixMode(GL_MODELVIEW); 450 glPushMatrix(); 451 452 /* translate */ 453 glTranslatef (this->topRotor.getAbsCoor ().x, 454 this->topRotor.getAbsCoor ().y, 455 this->topRotor.getAbsCoor ().z); 456 Vector tmpRot = this->topRotor.getAbsDir().getSpacialAxis(); 457 glRotatef (this->topRotor.getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); 458 this->getModel(3)->draw(); 459 460 glPopMatrix (); 461 glPushMatrix(); 462 463 /* translate */ 464 glTranslatef (this->tailRotor.getAbsCoor ().x, 465 this->tailRotor.getAbsCoor ().y, 466 this->tailRotor.getAbsCoor ().z); 467 tmpRot = this->tailRotor.getAbsDir().getSpacialAxis(); 468 glRotatef (this->tailRotor.getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); 469 this->getModel(4)->draw(); 470 471 glPopMatrix (); 421 472 422 473 this->getWeaponManager()->draw(); … … 465 516 this->yMouse = event.yRel*mouseSensitivity; 466 517 467 this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))/*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1))*/); 468 } 518 this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))); 519 520 Quaternion yDir = Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1)); 521 522 523 if ((this->cameraNode.getAbsDirY()).y < 0.5) 524 { 525 if((this->cameraNode.getAbsDirX()).y > 0) 526 { 527 if(yMouse > 0) this->cameraNode.shiftDir(yDir); 528 } 529 else 530 { 531 if(yMouse < 0) this->cameraNode.shiftDir(yDir); 532 } 533 } 534 else this->cameraNode.shiftDir(yDir);; 535 } 469 536 } 470 537 -
trunk/src/world_entities/space_ships/helicopter.h
r6637 r6724 26 26 virtual void enter(); 27 27 virtual void leave(); 28 virtual void attachCamera(); 28 29 29 30 virtual void postSpawn(); … … 59 60 int yInvert; 60 61 float mouseSensitivity; //!< the mouse sensitivity 62 int controlVelocityX; 63 int controlVelocityY; 61 64 //float cycle; //!< hovercycle 65 66 PNode topRotor; 67 PNode tailRotor; 68 69 PNode cameraNode; 62 70 63 71 Vector velocity; //!< the velocity of the player. -
trunk/src/world_entities/space_ships/hover.cc
r6637 r6724 110 110 PRINTF(4)("HOVER INIT\n"); 111 111 112 this->loadModel("models/ships/ fighter.obj", 1.0);112 this->loadModel("models/ships/nimrod#.obj", 1.0); 113 113 114 114 EventHandler::getInstance()->grabEvents(true); … … 118 118 xMouse = yMouse = 0; 119 119 mouseSensitivity = 0.05; 120 controlVelocityX = 100; 121 controlVelocityY = 100; 120 122 121 123 … … 241 243 void Hover::tick (float time) 242 244 { 243 244 245 if( xMouse != 0 || yMouse != 0) 246 { 247 if (xMouse > controlVelocityX) xMouse = controlVelocityX; 248 else if (xMouse < -controlVelocityX) xMouse = -controlVelocityX; 249 if (yMouse > controlVelocityY) yMouse = controlVelocityY; 250 else if (yMouse < -controlVelocityY) yMouse = -controlVelocityY; 251 } 252 245 253 Quaternion xDir = Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0)); 246 254 Quaternion yDir = Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1)); … … 261 269 else this->shiftDir(xDir*yDir); 262 270 263 if((this->getAbsDirZ()).y > 0.1) this->shiftDir(Quaternion(0.01,Vector(1,0,0))); 264 else if((this->getAbsDirZ()).y < -0.1) this->shiftDir(Quaternion(-0.01,Vector(1,0,0))); 265 271 if((this->getAbsDirZ()).y > 0.05) this->shiftDir(Quaternion(0.02,Vector(1,0,0))); 272 else if((this->getAbsDirZ()).y < -0.05) this->shiftDir(Quaternion(-0.02,Vector(1,0,0))); 266 273 267 274 // spaceship controlled movement -
trunk/src/world_entities/space_ships/hover.h
r6637 r6724 58 58 float yMouse; //!< mouse moved in y-Direction 59 59 float mouseSensitivity; //!< the mouse sensitivity 60 int controlVelocityX; 61 int controlVelocityY; 60 62 61 63 Vector velocity; //!< the velocity of the player. -
trunk/src/world_entities/space_ships/space_ship.cc
r6710 r6724 373 373 //this->shiftCoor((this->getAbsDirX())*-1); 374 374 //accel -= (this->getAbsDirX())*2; 375 //if(velocity.len() > 50) 375 376 accel -= (this->getAbsDirX())*0.5*acceleration; 377 378 379 376 380 } 377 381
Note: See TracChangeset
for help on using the changeset viewer.