- Timestamp:
- May 15, 2010, 2:57:51 PM (15 years ago)
- Location:
- code/branches/rocket/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/rocket/src/modules/weapons/RocketController.cc
r6902 r6903 64 64 65 65 SimpleRocket *rocket = static_cast<SimpleRocket*>(this->getControllableEntity()); 66 rocket->rotatePitch(0.005); 67 rocket->setVelocity(rocket->getVelocity()*1.02); 66 if (this->target_) { 67 rocket->rotatePitch(0.5); 68 rocket->rotateYaw(0.5); 69 } 70 rocket->setVelocity(rocket->getVelocity()*1.03); 68 71 69 72 } … … 77 80 78 81 82 void RocketController::setTarget(Pawn* target) { 83 this->target_ = target; 84 } 85 86 87 79 88 80 89 } -
code/branches/rocket/src/modules/weapons/RocketController.h
r6863 r6903 53 53 virtual void tick(float dt); 54 54 SimpleRocket* getRocket(){return this->rocket;}; 55 void setTarget(Pawn* target); 55 56 protected: 56 57 … … 60 61 WeakPtr<PlayerInfo> player_; 61 62 int haha; 63 WeakPtr<Pawn> target_; 62 64 63 65 -
code/branches/rocket/src/orxonox/controllers/DroneController.cc
r6778 r6903 72 72 73 73 myDrone->rotateYaw(0.2); 74 myDrone->moveFrontBack(2);75 74 76 75 } -
code/branches/rocket/src/orxonox/controllers/NewHumanController.cc
r6502 r6903 574 574 } 575 575 } 576 577 Pawn* NewHumanController::getRocketTarget() { 578 579 580 Ogre::RaySceneQuery * rsq = HumanController::localController_s->getControllableEntity()->getScene()->getSceneManager()->createRayQuery(Ogre::Ray()); 581 582 Ogre::Ray mouseRay = HumanController::localController_s->getControllableEntity()->getCamera()->getOgreCamera()->getCameraToViewportRay(static_cast<float>(this->currentYaw_)/2*-1+.5f, static_cast<float>(this->currentPitch_)/2*-1+.5f); 583 584 rsq->setRay(mouseRay); 585 rsq->setSortByDistance(true); 586 587 /* 588 Distance of objects: 589 ignore everything under 200 maybe even take 1000 as min distance to shoot at 590 591 shots are regularly traced and are entities!!!!!!!!! this is the biggest problem 592 they vanish only after a distance of 10'000 593 */ 594 595 596 Ogre::RaySceneQueryResult& result = rsq->execute(); 597 Pawn* pawn = orxonox_cast<Pawn*>(this->getControllableEntity()); 598 599 Ogre::RaySceneQueryResult::iterator itr; 600 for (itr = result.begin(); itr != result.end(); ++itr) 601 { 602 if (itr->movable->isInScene() && itr->movable->getMovableType() == "Entity" && itr->distance > 500) 603 { 604 // Try to cast the user pointer 605 WorldEntity* wePtr = dynamic_cast<WorldEntity*>(Ogre::any_cast<OrxonoxClass*>(itr->movable->getUserAny())); 606 if (wePtr) 607 { 608 // go through all parents of object and look whether they are sightable or not 609 bool isSightable = false; 610 WorldEntity* parent = wePtr->getParent(); 611 while (parent) 612 { 613 if (this->targetMask_.isExcluded(parent->getIdentifier())) 614 { 615 parent = parent->getParent(); 616 continue; 617 } 618 else 619 { 620 isSightable = true; 621 break; 622 } 623 } 624 if (!isSightable) 625 continue; 626 } 627 628 return dynamic_cast<Pawn*> (wePtr); 629 } 630 } 631 } 632 633 634 635 636 576 637 } -
code/branches/rocket/src/orxonox/controllers/NewHumanController.h
r6417 r6903 67 67 virtual void doResumeControl(); 68 68 69 Pawn* getRocketTarget(); 70 71 69 72 protected: 70 73 void updateTarget();
Note: See TracChangeset
for help on using the changeset viewer.