Changeset 6903 for code/branches/rocket/src/orxonox/controllers
- Timestamp:
- May 15, 2010, 2:57:51 PM (15 years ago)
- Location:
- code/branches/rocket/src/orxonox/controllers
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
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.