Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 15, 2010, 6:12:13 PM (14 years ago)
Author:
gnadler
Message:

rockets get target but moveToPosition function does not work correctly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/rocket/src/orxonox/controllers/NewHumanController.cc

    r6903 r6905  
    574574        }
    575575    }
    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         }
    632576               
    633577
Note: See TracChangeset for help on using the changeset viewer.