Changeset 1479
- Timestamp:
- May 29, 2008, 10:36:49 AM (17 years ago)
- Location:
- code/branches/network/src/orxonox
- Files:
-
- 4 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/orxonox/CMakeLists.txt
r1406 r1479 25 25 objects/NPC.cc 26 26 objects/Projectile.cc 27 objects/RotatingProjectile.cc 27 28 objects/Skybox.cc 28 29 objects/SpaceShip.cc 30 objects/SpaceShipAI.cc 29 31 objects/WorldEntity.cc 30 32 -
code/branches/network/src/orxonox/OrxonoxPrereqs.h
r1414 r1479 74 74 class Skybox; 75 75 class SpaceShip; 76 class SpaceShipAI; 76 77 class WorldEntity; 77 78 -
code/branches/network/src/orxonox/objects/Projectile.h
r1454 r1479 50 50 void setColour(const ColourValue& colour); 51 51 52 static float getSpeed() 53 { return Projectile::speed_; } 54 55 protected: 56 SpaceShip* owner_; 57 52 58 private: 53 SpaceShip* owner_;54 59 BillboardSet billboard_; 55 60 static float speed_; -
code/branches/network/src/orxonox/objects/SpaceShip.cc
r1454 r1479 45 45 #include "particle/ParticleInterface.h" 46 46 #include "Projectile.h" 47 #include "RotatingProjectile.h" 47 48 #include "core/XMLPort.h" 48 49 #include "core/ConsoleCommand.h" … … 78 79 79 80 SpaceShip::SpaceShip() : 80 teamNr_(0),81 health_(100),82 81 //testvector_(0,0,0), 83 82 //bInvertYAxis_(false), … … 112 111 mouseY_(0.0f), 113 112 emitterRate_(0.0f), 114 myShip_(false) 113 myShip_(false), 114 teamNr_(0), 115 health_(100) 115 116 { 116 117 RegisterObject(SpaceShip); … … 125 126 initialOrth_ = Vector3(0.0, 0.0, 1.0); 126 127 currentOrth_ = initialOrth_; 128 129 this->camName_ = this->getName() + "CamNode"; 127 130 128 131 this->setRotationAxis(1, 0, 0); … … 209 212 // END CREATING BLINKING LIGHTS 210 213 211 // START of testing crosshair 212 this->crosshairNear_.setBillboardSet("Orxonox/Crosshair", ColourValue(1.0, 1.0, 0.0), 1); 213 this->crosshairFar_.setBillboardSet("Orxonox/Crosshair", ColourValue(1.0, 1.0, 0.0), 1); 214 215 this->chNearNode_ = this->getNode()->createChildSceneNode(this->getName() + "near", Vector3(50.0, 0.0, 0.0)); 216 this->chNearNode_->setInheritScale(false); 217 this->chFarNode_ = this->getNode()->createChildSceneNode(this->getName() + "far", Vector3(200.0, 0.0, 0.0)); 218 this->chFarNode_->setInheritScale(false); 219 220 this->chNearNode_->attachObject(this->crosshairNear_.getBillboardSet()); 221 this->chNearNode_->setScale(0.2, 0.2, 0.2); 222 223 this->chFarNode_->attachObject(this->crosshairFar_.getBillboardSet()); 224 this->chFarNode_->setScale(0.4, 0.4, 0.4); 214 if (this->isExactlyA(Class(SpaceShip))) 215 { 216 // START of testing crosshair 217 this->crosshairNear_.setBillboardSet("Orxonox/Crosshair", ColourValue(1.0, 1.0, 0.0), 1); 218 this->crosshairFar_.setBillboardSet("Orxonox/Crosshair", ColourValue(1.0, 1.0, 0.0), 1); 219 220 this->chNearNode_ = this->getNode()->createChildSceneNode(this->getName() + "near", Vector3(50.0, 0.0, 0.0)); 221 this->chNearNode_->setInheritScale(false); 222 this->chFarNode_ = this->getNode()->createChildSceneNode(this->getName() + "far", Vector3(200.0, 0.0, 0.0)); 223 this->chFarNode_->setInheritScale(false); 224 225 this->chNearNode_->attachObject(this->crosshairNear_.getBillboardSet()); 226 this->chNearNode_->setScale(0.2, 0.2, 0.2); 227 228 this->chFarNode_->attachObject(this->crosshairFar_.getBillboardSet()); 229 this->chFarNode_->setScale(0.4, 0.4, 0.4); 230 } 225 231 226 232 createCamera(); … … 362 368 { 363 369 364 Projectile *p = new Projectile(this); 370 Projectile *p; 371 if (this->isExactlyA(Class(SpaceShip))) 372 p = new RotatingProjectile(this); 373 else 374 p = new Projectile(this); 375 p->setColour(this->getProjectileColour()); 365 376 p->create(); 366 377 if(p->classID==0) … … 463 474 COUT(4) << "not steering ship: " << objectID << " our ship: " << network::Client::getSingleton()->getShipID() << std::endl;*/ 464 475 } 476 465 477 void SpaceShip::movePitch(float val) 466 { 467 SpaceShip* this_ = getLocalShip(); 468 val = -val * val * sgn(val) * this_->rotationAcceleration_; 469 if (val > this_->maxRotation_) 470 val = this_->maxRotation_; 471 if (val < -this_->maxRotation_) 472 val = -this_->maxRotation_; 473 this_->mouseYRotation_ = Radian(val); 474 } 475 478 { getLocalShip()->setMovePitch(val); } 476 479 void SpaceShip::moveYaw(float val) 477 { 478 SpaceShip* this_ = getLocalShip(); 479 val = -val * val * sgn(val) * this_->rotationAcceleration_; 480 if (val > this_->maxRotation_) 481 val = this_->maxRotation_; 482 if (val < -this_->maxRotation_) 483 val = -this_->maxRotation_; 484 this_->mouseXRotation_ = Radian(val); 485 } 486 480 { getLocalShip()->setMoveYaw(val); } 487 481 void SpaceShip::moveRoll(float val) 488 { 489 SpaceShip* this_ = getLocalShip(); 490 this_->momentum_ = Radian(-this_->rotationAccelerationRadian_ * val); 491 //COUT(3) << "rotating val: " << val << " acceleration: " << this_->rotationAccelerationRadian_.valueDegrees() << std::endl; 492 } 493 482 { getLocalShip()->setMoveRoll(val); } 494 483 void SpaceShip::moveLongitudinal(float val) 495 { 496 SpaceShip* this_ = getLocalShip(); 497 this_->acceleration_.x = this_->translationAcceleration_ * val; 498 } 499 484 { getLocalShip()->setMoveLongitudinal(val); } 500 485 void SpaceShip::moveLateral(float val) 501 { 502 SpaceShip* this_ = getLocalShip(); 503 this_->acceleration_.y = -this_->translationAcceleration_ * val; 504 } 505 486 { getLocalShip()->setMoveLateral(val); } 506 487 void SpaceShip::fire() 507 { 508 SpaceShip* this_ = getLocalShip(); 509 this_->bLMousePressed_ = true; 488 { getLocalShip()->doFire(); } 489 490 void SpaceShip::setMovePitch(float val) 491 { 492 val = -val * val * sgn(val) * this->rotationAcceleration_; 493 if (val > this->maxRotation_) 494 val = this->maxRotation_; 495 if (val < -this->maxRotation_) 496 val = -this->maxRotation_; 497 this->mouseYRotation_ = Radian(val); 498 } 499 500 void SpaceShip::setMoveYaw(float val) 501 { 502 val = -val * val * sgn(val) * this->rotationAcceleration_; 503 if (val > this->maxRotation_) 504 val = this->maxRotation_; 505 if (val < -this->maxRotation_) 506 val = -this->maxRotation_; 507 this->mouseXRotation_ = Radian(val); 508 } 509 510 void SpaceShip::setMoveRoll(float val) 511 { 512 this->momentum_ = Radian(-this->rotationAccelerationRadian_ * val); 513 //COUT(3) << "rotating val: " << val << " acceleration: " << this->rotationAccelerationRadian_.valueDegrees() << std::endl; 514 } 515 516 void SpaceShip::setMoveLongitudinal(float val) 517 { 518 this->acceleration_.x = this->translationAcceleration_ * val; 519 } 520 521 void SpaceShip::setMoveLateral(float val) 522 { 523 this->acceleration_.y = -this->translationAcceleration_ * val; 524 } 525 526 void SpaceShip::doFire() 527 { 528 this->bLMousePressed_ = true; 510 529 } 511 530 } -
code/branches/network/src/orxonox/objects/SpaceShip.h
r1454 r1479 76 76 static void moveLateral(float value); 77 77 static void fire(); 78 void setMovePitch(float value); 79 void setMoveYaw(float value); 80 void setMoveRoll(float value); 81 void setMoveLongitudinal(float value); 82 void setMoveLateral(float value); 83 void doFire(); 78 84 79 85 float getMaxSpeed(); … … 82 88 Camera* getCamera(); 83 89 90 int getTeamNr() const 91 { return this->teamNr_; } 92 int getHealth() const 93 { return this->health_; } 94 84 95 bool getMyShip(){return myShip_;} 85 96 86 97 protected: 87 int teamNr_;88 int health_;98 void setTeamNr(int teamNr) 99 { this->teamNr_ = teamNr; } 89 100 90 101 private: 91 102 void createCamera(); 103 virtual ColourValue getProjectileColour() const 104 { return ColourValue(1.0, 1.0, 0.5); } 92 105 93 106 Vector3 testvector_; … … 143 156 bool myShip_; 144 157 158 int teamNr_; 159 int health_; 160 145 161 static SpaceShip* instance_s; 146 162 };
Note: See TracChangeset
for help on using the changeset viewer.