Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 11, 2009, 5:39:53 PM (15 years ago)
Author:
wirthmi
Message:

First implementation of direction shooting.

Location:
code/branches/steering/src/orxonox/controllers
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/steering/src/orxonox/controllers/Controller.cc

    r5781 r6045  
    2929#include "Controller.h"
    3030#include "core/CoreIncludes.h"
     31#include "worldentities/ControllableEntity.h"
    3132
    3233namespace orxonox
     
    4546    {
    4647    }
     48
     49    Vector3 Controller::getTarget() {
     50        return this->controllableEntity_->getPosition() + (this->controllableEntity_->getOrientation() * Vector3::UNIT_Z);
     51    }
    4752}
  • code/branches/steering/src/orxonox/controllers/Controller.h

    r5993 r6045  
    5858            virtual void changedControllableEntity() {}
    5959
     60            virtual Vector3 getTarget();
     61
    6062        protected:
    6163            PlayerInfo* player_;
  • code/branches/steering/src/orxonox/controllers/NewHumanController.cc

    r6033 r6045  
    5757        overlaySize = 0.08;
    5858
     59        controlMode = 0;
     60
    5961        CrossHairOverlay = new OrxonoxOverlay(this);
    6062        CrossHairOverlay->setBackgroundMaterial("Orxonox/Crosshair3");
     
    110112*/
    111113
     114            HumanController::localController_s->getControllableEntity()->fire(firemode);
     115        //}
     116//}
     117    }
     118
     119    Vector3 NewHumanController::getTarget() {
    112120            Ogre::RaySceneQuery * rsq = HumanController::localController_s->getControllableEntity()->getScene()->getSceneManager()->createRayQuery(Ogre::Ray());
    113121
    114 std::cout << "X: " << static_cast<float>(this->currentYaw_)/2*-1+.5 << "  Y: " << static_cast<float>(this->currentPitch_)/2*-1+.5 << endl;
     122//std::cout << "X: " << static_cast<float>(this->currentYaw_)/2*-1+.5 << "  Y: " << static_cast<float>(this->currentPitch_)/2*-1+.5 << endl;
    115123
    116124            Ogre::Ray mouseRay = HumanController::localController_s->getControllableEntity()->getCamera()->getCamera()->getCameraToViewportRay(static_cast<float>(this->currentYaw_)/2*-1+.5, static_cast<float>(this->currentPitch_)/2*-1+.5);
     
    119127            rsq->setSortByDistance(true);
    120128
     129/*
     130Distance of objects:
     131ignore everything under 200 maybe even take 1000 as min distance to shoot at
     132
     133shots are regularly traced and are entities!!!!!!!!! this is the biggest problem
     134they vanish only after a distance of 10'000
     135*/
     136
    121137
    122138            Ogre::RaySceneQueryResult &result = rsq->execute();
    123139
    124140            Ogre::RaySceneQueryResult::iterator itr;
    125 for ( itr = result.begin(); itr != result.end(); itr++ )
    126  {
    127      std::cout << "distance: " << itr->distance << "  name: " << itr->movable->getName() << " type: " << itr->movable->getMovableType() << endl;
    128 if (itr->movable->isInScene() && itr->movable->getMovableType() == "Entity") {
    129 std::cout << " in scene" << endl;
    130         itr->movable->getParentSceneNode()->showBoundingBox(true);
    131 }
    132  }
     141            for ( itr = result.begin(); itr != result.end(); itr++ )
     142            {
     143                //std::cout << "distance: " << itr->distance << "  name: " << itr->movable->getName() << " type: " << itr->movable->getMovableType();
     144                if (itr->movable->isInScene() && itr->movable->getMovableType() == "Entity" && itr->distance > 500) {
     145                    //std::cout << "  TAGGED";
     146                    itr->movable->getParentSceneNode()->showBoundingBox(true);
     147std::cout << itr->movable->getParentSceneNode()->_getDerivedPosition() << endl;
     148return itr->movable->getParentSceneNode()->_getDerivedPosition();
     149                }
     150                //std::cout << endl;
     151            }
    133152
    134153//if (result.front().movable->isInScene()) std::cout << "in scene" << endl;
     
    136155//result.front().movable->setVisible(false);
    137156
    138 std::cout << endl;
     157            //std::cout << endl;
    139158/*
    140159            if (!result.empty()) {
     
    143162            }
    144163*/
    145 
    146 
    147             HumanController::localController_s->getControllableEntity()->fire(firemode);
    148         //}
    149 //}
     164        return this->controllableEntity_->getWorldPosition() + (this->controllableEntity_->getWorldOrientation() * Vector3::NEGATIVE_UNIT_Z);
     165//return this->controllableEntity_->getWorldPosition() + (this->controllableEntity_->getCamera()->getCamera()->getOrientation() * Vector3::NEGATIVE_UNIT_Z);
    150166    }
    151167
  • code/branches/steering/src/orxonox/controllers/NewHumanController.h

    r6033 r6045  
    4545
    4646            virtual void tick(float dt);
    47            
     47
    4848            virtual void yaw(const Vector2& value);
    4949            virtual void pitch(const Vector2& value);
    5050
    5151            virtual void doFire(unsigned int firemode);
     52
     53            void changeMode(unsigned int controleMode);
     54
     55            virtual Vector3 getTarget();
    5256
    5357        private:
     
    5660            OrxonoxOverlay              *CrossHairOverlay;
    5761            float                       overlaySize;
     62            unsigned int                controlMode;
    5863    };
    5964}
Note: See TracChangeset for help on using the changeset viewer.