Changeset 6724 in orxonox.OLD for trunk/src/world_entities
- Timestamp:
- Jan 25, 2006, 5:35:49 PM (19 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 10 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 -
trunk/src/world_entities/weapons/aim.cc
r6637 r6724 73 73 this->source = NULL; 74 74 75 this->range = 0; 76 this->angle = 0; 75 this->range = 10000; 76 this->angle = M_PI_4; 77 this->group = OM_GROUP_01; 77 78 this->anim = new tAnimation<Aim>(this, &Aim::setSize); 78 79 this->anim->setInfinity(ANIM_INF_CONSTANT); … … 106 107 { 107 108 std::list<WorldEntity*>::iterator entity; 108 Vector diffVec(0.0, 0.0, 0.0); 109 diffVec = ( this->getAbsCoor() - this->source->getAbsCoor() ); 110 111 //only look for target if the aim hasn`t locked a target yet or if the actual target is out of range 112 if( this == PNode::getNullParent() || diffVec.len() > range || ( acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) > angle)) 113 for (entity = State::getObjectManager()->getObjectList(OM_GROUP_00).begin(); 114 entity != State::getObjectManager()->getObjectList(OM_GROUP_00).end(); 109 110 for (entity = State::getObjectManager()->getObjectList(group).begin(); 111 entity != State::getObjectManager()->getObjectList(group).end(); 115 112 entity ++) 116 113 { … … 119 116 if ( diffVec.len() < range && acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) < angle) 120 117 { 121 if (this->getParent() != (*entity))118 //if (this->getParent() != (*entity)) 122 119 { 123 120 this->anim->replay(); … … 127 124 } 128 125 } 129 //if no target found: 130 this->setParent(PNode::getNullParent()); 126 127 //if no target found: 128 this->setParent(PNode::getNullParent()); 129 130 131 131 132 } 132 133 … … 165 166 166 167 // if (this->source->getAbsCoor().x > this->getAbsCoor().x ) 168 diffVec = ( this->getAbsCoor() - this->source->getAbsCoor() ); 169 //only look for target if the aim hasn`t locked a target yet or if the actual target is out of range 170 if(this->getParent() == PNode::getNullParent() || 171 diffVec.len() > range || 172 ( acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) > angle)) 173 { 167 174 this->searchTarget(); 175 } 176 168 177 // float z = 0.0f; 169 178 // glReadPixels ((int)this->getAbsCoor2D().x, … … 196 205 { 197 206 207 if( this->getParent() != PNode::getNullParent() ) 208 { 198 209 glPushMatrix(); 199 210 glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); … … 212 223 glEnd(); 213 224 glPopMatrix(); 214 215 } 225 } 226 227 } -
trunk/src/world_entities/weapons/aim.h
r6637 r6724 9 9 #include "p_node.h" 10 10 #include "element_2d.h" 11 #include "object_manager.h" 11 12 12 13 // FORWARD DECLARATION … … 42 43 void setRange(float range){this->range = range;}; 43 44 void setAngle(float angle){this->angle = angle;}; 45 void setGroup(OM_LIST group){this->group = group;}; 44 46 45 47 void setSize(float size); … … 58 60 float range; //!< 59 61 float angle; //!< 62 Vector diffVec; 63 OM_LIST group; 60 64 61 65 PNode* source; //!< Where this Shot has come from. -
trunk/src/world_entities/weapons/aiming_turret.cc
r6671 r6724 98 98 this->target = new Aim(this); 99 99 this->target->setVisibility(false); 100 this->target->setRange(100 );101 this->target->setAngle(M_PI );100 this->target->setRange(1000); 101 this->target->setAngle(M_PI_4); 102 102 } 103 103 … … 148 148 pj->setAbsDir(this->getAbsDir()); 149 149 pj->activate(); 150 this->target->searchTarget();151 150 } 152 151 -
trunk/src/world_entities/weapons/targeting_turret.cc
r6695 r6724 94 94 this->target->setVisibility(false); 95 95 this->target->setRange(100); 96 this->target->setAngle(M_PI_4/ 2);96 this->target->setAngle(M_PI_4/16); 97 97 this->lockedTime = 0; 98 98 this->neededLockTime = 2; … … 148 148 /*target->getAbsCoor() - this->getAbsCoor()*/)*.5);//this->getVelocity()); 149 149 150 pj->setTarget( this->target->getParent());150 pj->setTarget(lockedTarget); 151 151 pj->setParent(PNode::getNullParent()); 152 152 pj->setAbsCoor(this->getEmissionPoint()); 153 153 pj->setAbsDir(this->getAbsDir()); 154 154 pj->activate(); 155 this->target->searchTarget();155 156 156 } 157 157 -
trunk/src/world_entities/weapons/turret.cc
r6671 r6724 116 116 void Turret::tick(float dt) 117 117 { 118 /* 118 119 119 Quaternion quat; 120 Vector direction = this->getAbsCoor();/*this->getWeaponManager()->getFixedTarget()->getAbsCoor() - this->getAbsCoor(); 120 Vector direction = this->getAbsCoor();/*this->getWeaponManager()->getFixedTarget()->getAbsCoor() - this->getAbsCoor();*/ 121 121 122 122 direction.normalize(); … … 127 127 quat = Quaternion(direction, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0)) ; 128 128 129 this->setAbsDirSoft(quat, 5); */129 this->setAbsDirSoft(quat, 5); 130 130 } 131 131
Note: See TracChangeset
for help on using the changeset viewer.