Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6903


Ignore:
Timestamp:
May 15, 2010, 2:57:51 PM (14 years ago)
Author:
gnadler
Message:

Cant assign Pawn* to WeakPtr<Pawn>.

Location:
code/branches/rocket/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/rocket/src/modules/weapons/RocketController.cc

    r6902 r6903  
    6464
    6565        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);
    6871       
    6972        }
     
    7780
    7881
     82        void RocketController::setTarget(Pawn* target) {
     83                this->target_ = target;
     84        }
     85
     86
     87
    7988
    8089}
  • code/branches/rocket/src/modules/weapons/RocketController.h

    r6863 r6903  
    5353            virtual void tick(float dt);
    5454                        SimpleRocket* getRocket(){return this->rocket;};
     55                        void setTarget(Pawn* target);
    5556        protected:
    5657
     
    6061                        WeakPtr<PlayerInfo> player_;
    6162                                                int haha;
     63                        WeakPtr<Pawn> target_;
    6264
    6365
  • code/branches/rocket/src/orxonox/controllers/DroneController.cc

    r6778 r6903  
    7272
    7373                myDrone->rotateYaw(0.2);
    74                 myDrone->moveFrontBack(2);
    7574
    7675    }
  • code/branches/rocket/src/orxonox/controllers/NewHumanController.cc

    r6502 r6903  
    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        }
     632               
     633
     634       
     635
     636
    576637}
  • code/branches/rocket/src/orxonox/controllers/NewHumanController.h

    r6417 r6903  
    6767            virtual void doResumeControl();
    6868
     69                        Pawn* getRocketTarget();
     70
     71
    6972        protected:
    7073            void updateTarget();
Note: See TracChangeset for help on using the changeset viewer.