Changeset 862 for code/branches/tutorial
- Timestamp:
- Mar 6, 2008, 3:06:59 PM (17 years ago)
- Location:
- code/branches/tutorial/src/orxonox
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/tutorial/src/orxonox/CMakeLists.txt
r859 r862 16 16 objects/NPC.cc 17 17 objects/Projectile.cc 18 objects/RotatingProjectile.cc 18 19 objects/Skybox.cc 19 20 objects/SpaceShip.cc -
code/branches/tutorial/src/orxonox/core/Identifier.h
r859 r862 315 315 { 316 316 this->identifier_ = ClassIdentifier<T>::getIdentifier(); 317 } 318 319 SubclassIdentifier(Identifier* identifier) 320 { 321 this->identifier_ = identifier; 317 322 } 318 323 -
code/branches/tutorial/src/orxonox/objects/Projectile.cc
r859 r862 39 39 CreateFactory(Projectile); 40 40 41 Projectile::Projectile( SpaceShip* owner)41 Projectile::Projectile() 42 42 { 43 43 RegisterObject(Projectile); … … 45 45 this->setConfigValues(); 46 46 47 this->owner_ = owner;48 49 47 this->billboard_.setBillboardSet("Examples/Flare", ColourValue(1.0, 1.0, 0.5), 1); 50 48 this->attachObject(this->billboard_.getBillboardSet()); 51 49 this->scale(0.5); 50 51 this->destroyTimer_.setTimer(this->lifetime_, false, this, &Projectile::destroyObject); 52 } 53 54 Projectile::~Projectile() 55 { 56 } 57 58 void Projectile::setOwner(SpaceShip* owner) 59 { 60 this->owner_ = owner; 52 61 53 62 if (this->owner_) … … 59 68 this->setVelocity(Vector3(1, 0, 0) * this->speed_); 60 69 } 61 62 this->destroyTimer_.setTimer(this->lifetime_, false, this, &Projectile::destroyObject);63 }64 65 Projectile::~Projectile()66 {67 70 } 68 71 -
code/branches/tutorial/src/orxonox/objects/Projectile.h
r859 r862 15 15 { 16 16 public: 17 Projectile( SpaceShip* owner = 0);17 Projectile(); 18 18 virtual ~Projectile(); 19 19 void setConfigValues(); 20 20 void destroyObject(); 21 21 virtual void tick(float dt); 22 void setOwner(SpaceShip* owner = 0); 23 24 protected: 25 BillboardSet billboard_; 26 float speed_; 22 27 23 28 private: 24 29 SpaceShip* owner_; 25 BillboardSet billboard_;26 float speed_;27 30 float lifetime_; 28 31 Timer<Projectile> destroyTimer_; -
code/branches/tutorial/src/orxonox/objects/SpaceShip.cc
r859 r862 87 87 this->setRotationAxis(1, 0, 0); 88 88 this->setStatic(false); 89 /* 90 this->moveForward_ = 0; 91 this->rotateUp_ = 0; 92 this->rotateDown_ = 0; 93 this->rotateRight_ = 0; 94 this->rotateLeft_ = 0; 95 this->loopRight_ = 0; 96 this->loopLeft_ = 0; 97 this->brakeForward_ = 0; 98 this->brakeRotate_ = 0; 99 this->brakeLoop_ = 0; 100 this->speedForward_ = 0; 101 this->speedRotateUpDown_ = 0; 102 this->speedRotateRightLeft_ = 0; 103 this->speedLoopRightLeft_ = 0; 104 this->maxSpeedForward_ = 0; 105 this->maxSpeedRotateUpDown_ = 0; 106 this->maxSpeedRotateRightLeft_ = 0; 107 this->maxSpeedLoopRightLeft_ = 0; 108 this->accelerationForward_ = 0; 109 this->accelerationRotateUpDown_ = 0; 110 this->accelerationRotateRightLeft_ = 0; 111 this->accelerationLoopRightLeft_ = 0; 112 113 this->speed = 250; 114 this->loop = 100; 115 this->rotate = 10; 116 this->mouseX = 0; 117 this->mouseY = 0; 118 this->maxMouseX = 0; 119 this->minMouseX = 0; 120 this->moved = false; 121 122 this->brakeRotate(rotate*10); 123 this->brakeLoop(loop); 124 */ 89 125 90 COUT(3) << "Info: SpaceShip was loaded" << std::endl; 126 91 } … … 136 101 SetConfigValue(bInvertYAxis_, false).description("Set this to true for joystick-like mouse behaviour (mouse up = ship down)."); 137 102 SetConfigValue(reloadTime_, 0.125).description("The reload time of the weapon in seconds"); 138 SetConfigValue( testvector_, Vector3()).description("asdfblah");103 SetConfigValue(projectileName_, "Projectile").description("Projectile of the ship-weapon."); 139 104 } 140 105 … … 142 107 { 143 108 Model::loadParams(xmlElem); 144 145 109 146 110 // START CREATING THRUSTER … … 148 112 this->tt_->getParticleSystem()->setParameter("local_space","true"); 149 113 this->tt_->newEmitter(); 150 /* 151 this->tt_->setDirection(Vector3(0,0,1)); 152 this->tt_->setPositionOfEmitter(0, Vector3(20,-1,-15)); 153 this->tt_->setPositionOfEmitter(1, Vector3(-20,-1,-15)); 154 */ 114 155 115 this->tt_->setDirection(Vector3(-1,0,0)); 156 116 this->tt_->setPositionOfEmitter(0, Vector3(-15,20,-1)); … … 198 158 // END of testing crosshair 199 159 200 /*201 if (xmlElem->Attribute("forward") && xmlElem->Attribute("rotateupdown") && xmlElem->Attribute("rotaterightleft") && xmlElem->Attribute("looprightleft"))202 {203 std::string forwardStr = xmlElem->Attribute("forward");204 std::string rotateupdownStr = xmlElem->Attribute("rotateupdown");205 std::string rotaterightleftStr = xmlElem->Attribute("rotaterightleft");206 std::string looprightleftStr = xmlElem->Attribute("looprightleft");207 208 String2Number<float>(this->maxSpeedForward_, forwardStr);209 String2Number<float>(this->maxSpeedRotateUpDown_, rotateupdownStr);210 String2Number<float>(this->maxSpeedRotateRightLeft_, rotaterightleftStr);211 String2Number<float>(this->maxSpeedLoopRightLeft_, looprightleftStr);212 213 COUT(4) << "Loader: Initialized spaceship steering with values " << maxSpeedForward_ << " " << maxSpeedRotateUpDown_ << " " << maxSpeedRotateRightLeft_ << " " << maxSpeedLoopRightLeft_ << " " << std::endl;214 }215 */216 160 if (xmlElem->Attribute("maxSpeed") && xmlElem->Attribute("maxSideAndBackSpeed") && xmlElem->Attribute("maxRotation") && xmlElem->Attribute("transAcc") && xmlElem->Attribute("rotAcc") && xmlElem->Attribute("transDamp") && xmlElem->Attribute("rotDamp")) 217 161 { … … 244 188 Ogre::Camera *cam = Orxonox::getSingleton()->getSceneManager()->createCamera("ShipCam"); 245 189 this->camNode_ = this->getNode()->createChildSceneNode("CamNode"); 246 /*247 // node->setInheritOrientation(false);248 cam->setPosition(Vector3(0,50,-150));249 cam->lookAt(Vector3(0,20,0));250 cam->roll(Degree(0));251 */252 190 253 191 cam->setPosition(Vector3(-200,0,35)); 254 // cam->setPosition(Vector3(0,-350,0));255 192 cam->lookAt(Vector3(0,0,35)); 256 193 cam->roll(Degree(-90)); … … 271 208 bool SpaceShip::mouseMoved(const OIS::MouseEvent &e) 272 209 { 273 /*274 this->mouseX += e.state.X.rel;275 if (this->bInvertMouse_)276 this->mouseY += e.state.Y.rel;277 else278 this->mouseY -= e.state.Y.rel;279 280 // if(mouseX>maxMouseX) maxMouseX = mouseX;281 // if(mouseX<minMouseX) minMouseX = mouseX;282 // cout << "mouseX: " << mouseX << "\tmouseY: " << mouseY << endl;283 284 this->moved = true;285 */286 210 if (this->bRMousePressed_) 287 211 { … … 379 303 if (this->bLMousePressed_ && this->timeToReload_ <= 0) 380 304 { 381 new Projectile(this); 305 SubclassIdentifier<Projectile> projectile = ID(this->projectileName_); 306 Projectile* newProjectile = projectile.fabricate(); 307 newProjectile->setOwner(this); 308 382 309 this->timeToReload_ = this->reloadTime_; 383 310 } … … 488 415 else 489 416 this->tt_->setRate(0); 490 491 /* 492 if (mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W)) 493 this->moveForward(speed); 494 else 495 this->moveForward(0); 496 497 if(mKeyboard->isKeyDown(OIS::KC_DOWN) || mKeyboard->isKeyDown(OIS::KC_S)) 498 this->brakeForward(speed); 499 else 500 this->brakeForward(speed/10); 501 502 if (mKeyboard->isKeyDown(OIS::KC_RIGHT) || mKeyboard->isKeyDown(OIS::KC_D)) 503 this->loopRight(loop); 504 else 505 this->loopRight(0); 506 507 if (mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A)) 508 this->loopLeft(loop); 509 else 510 this->loopLeft(0); 511 512 if(moved) 513 { 514 if (mouseY<=0) 515 this->rotateUp(-mouseY*rotate); 516 if (mouseY>0) 517 this->rotateDown(mouseY*rotate); 518 if (mouseX>0) 519 this->rotateRight(mouseX*rotate); 520 if (mouseX<=0) 521 this->rotateLeft(-mouseX*rotate); 522 523 mouseY = 0; 524 mouseX = 0; 525 moved = false; 526 }*/ 527 /* else 528 { 529 this->rotateUp(0); 530 this->rotateDown(0); 531 this->rotateRight(0); 532 this->rotateLeft(0); 533 }*/ 534 /* 535 if(moveForward_ > 0) 536 { 537 accelerationForward_ = moveForward_; 538 if(speedForward_ < maxSpeedForward_) 539 speedForward_ += accelerationForward_*dt; 540 if(speedForward_ > maxSpeedForward_) 541 speedForward_ = maxSpeedForward_; 542 } 543 544 if(moveForward_ <= 0) 545 { 546 accelerationForward_ = -brakeForward_; 547 if(speedForward_ > 0) 548 speedForward_ += accelerationForward_*dt; 549 if(speedForward_ < 0) 550 speedForward_ = 0; 551 } 552 553 if(rotateUp_ > 0) 554 { 555 accelerationRotateUpDown_ = rotateUp_; 556 if(speedRotateUpDown_ < maxSpeedRotateUpDown_) 557 speedRotateUpDown_ += accelerationRotateUpDown_*dt; 558 if(speedRotateUpDown_ > maxSpeedRotateUpDown_) 559 speedRotateUpDown_ = maxSpeedRotateUpDown_; 560 } 561 562 if(rotateDown_ > 0) 563 { 564 accelerationRotateUpDown_ = rotateDown_; 565 if(speedRotateUpDown_ > -maxSpeedRotateUpDown_) 566 speedRotateUpDown_ -= accelerationRotateUpDown_*dt; 567 if(speedRotateUpDown_ < -maxSpeedRotateUpDown_) 568 speedRotateUpDown_ = -maxSpeedRotateUpDown_; 569 } 570 571 if(rotateUp_ == 0 && rotateDown_ == 0) 572 { 573 accelerationRotateUpDown_ = brakeRotate_; 574 if(speedRotateUpDown_ > 0) 575 speedRotateUpDown_ -= accelerationRotateUpDown_*dt; 576 if(speedRotateUpDown_ < 0) 577 speedRotateUpDown_ += accelerationRotateUpDown_*dt; 578 if(fabs(speedRotateUpDown_) < accelerationRotateUpDown_*dt) 579 speedRotateUpDown_ = 0; 580 } 581 582 if(rotateRight_ > 0) 583 { 584 accelerationRotateRightLeft_ = rotateRight_; 585 if(speedRotateRightLeft_ > -maxSpeedRotateRightLeft_) 586 speedRotateRightLeft_ -= accelerationRotateRightLeft_*dt; 587 if(speedRotateRightLeft_ < -maxSpeedRotateRightLeft_) 588 speedRotateRightLeft_ = -maxSpeedRotateRightLeft_; 589 } 590 591 if(rotateLeft_ > 0) 592 { 593 accelerationRotateRightLeft_ = rotateLeft_; 594 if(speedRotateRightLeft_ < maxSpeedRotateRightLeft_) 595 speedRotateRightLeft_ += accelerationRotateRightLeft_*dt; 596 if(speedRotateRightLeft_ > maxSpeedRotateRightLeft_) 597 speedRotateRightLeft_ = maxSpeedRotateRightLeft_; 598 } 599 600 if(rotateRight_ == 0 && rotateLeft_ == 0) 601 { 602 accelerationRotateRightLeft_ = brakeRotate_; 603 if(speedRotateRightLeft_ > 0) 604 speedRotateRightLeft_ -= accelerationRotateRightLeft_*dt; 605 if(speedRotateRightLeft_ < 0) 606 speedRotateRightLeft_ += accelerationRotateRightLeft_*dt; 607 if(fabs(speedRotateRightLeft_) < accelerationRotateRightLeft_*dt) 608 speedRotateRightLeft_ = 0; 609 } 610 611 if(loopRight_ > 0) 612 { 613 accelerationLoopRightLeft_ = loopRight_; 614 if(speedLoopRightLeft_ < maxSpeedLoopRightLeft_) 615 speedLoopRightLeft_ += accelerationLoopRightLeft_*dt; 616 if(speedLoopRightLeft_ > maxSpeedLoopRightLeft_) 617 speedLoopRightLeft_ = maxSpeedLoopRightLeft_; 618 } 619 620 if(loopLeft_ > 0) 621 { 622 accelerationLoopRightLeft_ = loopLeft_; 623 if(speedLoopRightLeft_ > -maxSpeedLoopRightLeft_) 624 speedLoopRightLeft_ -= accelerationLoopRightLeft_*dt; 625 if(speedLoopRightLeft_ < -maxSpeedLoopRightLeft_) 626 speedLoopRightLeft_ = -maxSpeedLoopRightLeft_; 627 } 628 629 if(loopLeft_ == 0 && loopRight_ == 0) 630 { 631 accelerationLoopRightLeft_ = brakeLoop_; 632 if(speedLoopRightLeft_ > 0) 633 speedLoopRightLeft_ -= accelerationLoopRightLeft_*dt; 634 if(speedLoopRightLeft_ < 0) 635 speedLoopRightLeft_ += accelerationLoopRightLeft_*dt; 636 if(fabs(speedLoopRightLeft_) < accelerationLoopRightLeft_*dt) 637 speedLoopRightLeft_ = 0; 638 } 639 640 Vector3 transVector = Vector3::ZERO; 641 */ 642 /* 643 transVector.z = 1; 644 this->translate(transVector*speedForward_*dt, Ogre::Node::TS_LOCAL); 645 this->pitch(Degree(speedRotateUpDown_*dt), Ogre::Node::TS_LOCAL); 646 this->yaw(Degree(speedRotateRightLeft_*dt), Ogre::Node::TS_LOCAL); 647 this->roll(Degree(speedLoopRightLeft_*dt), Ogre::Node::TS_LOCAL); 648 */ 649 /* 650 transVector.x = 1; 651 this->translate(transVector*speedForward_*dt, Ogre::Node::TS_LOCAL); 652 this->yaw(Degree(speedRotateUpDown_*dt), Ogre::Node::TS_LOCAL); 653 this->roll(Degree(speedRotateRightLeft_*dt), Ogre::Node::TS_LOCAL); 654 this->pitch(Degree(speedLoopRightLeft_*dt), Ogre::Node::TS_LOCAL); 655 */ 656 } 657 /* 658 void SpaceShip::moveForward(float moveForward) { 659 moveForward_ = moveForward; 660 } 661 662 void SpaceShip::rotateUp(float rotateUp) { 663 rotateUp_ = rotateUp; 664 } 665 666 void SpaceShip::rotateDown(float rotateDown) { 667 rotateDown_ = rotateDown; 668 } 669 670 void SpaceShip::rotateLeft(float rotateLeft) { 671 rotateLeft_ = rotateLeft; 672 } 673 674 void SpaceShip::rotateRight(float rotateRight) { 675 rotateRight_ = rotateRight; 676 } 677 678 void SpaceShip::loopLeft(float loopLeft) { 679 loopLeft_ = loopLeft; 680 } 681 682 void SpaceShip::loopRight(float loopRight) { 683 loopRight_ = loopRight; 684 } 685 686 void SpaceShip::brakeForward(float brakeForward) { 687 brakeForward_ = brakeForward; 688 } 689 690 void SpaceShip::brakeRotate(float brakeRotate) { 691 brakeRotate_ = brakeRotate; 692 } 693 694 void SpaceShip::brakeLoop(float brakeLoop) { 695 brakeLoop_ = brakeLoop; 696 } 697 698 void SpaceShip::maxSpeedForward(float maxSpeedForward) { 699 maxSpeedForward_ = maxSpeedForward; 700 } 701 702 void SpaceShip::maxSpeedRotateUpDown(float maxSpeedRotateUpDown) { 703 maxSpeedRotateUpDown_ = maxSpeedRotateUpDown; 704 } 705 706 void SpaceShip::maxSpeedRotateRightLeft(float maxSpeedRotateRightLeft) { 707 maxSpeedRotateRightLeft_ = maxSpeedRotateRightLeft; 708 } 709 710 void SpaceShip::maxSpeedLoopRightLeft(float maxSpeedLoopRightLeft) { 711 maxSpeedLoopRightLeft_ = maxSpeedLoopRightLeft; 712 } 713 */ 417 } 714 418 } -
code/branches/tutorial/src/orxonox/objects/SpaceShip.h
r859 r862 31 31 32 32 private: 33 Vector3 testvector_; 33 std::string projectileName_; 34 34 35 bool bInvertYAxis_; 35 36 bool setMouseEventCallback_;
Note: See TracChangeset
for help on using the changeset viewer.