Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6045 for code/branches


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
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • code/branches/steering/src/modules/weapons/weaponmodes/HsW01.cc

    r5929 r6045  
    3939#include "weaponsystem/WeaponPack.h"
    4040#include "weaponsystem/WeaponSystem.h"
     41#include "worldentities/WorldEntity.h"
    4142
    4243namespace orxonox
     
    110111        model->setScale(5);
    111112
    112         projectile->setOrientation(this->getMuzzleOrientation());
     113        //projectile->setOrientation(this->getMuzzleOrientation());
     114        projectile->lookAt(this->getTarget(), WorldEntity::World);
    113115        projectile->setPosition(this->getMuzzlePosition());
    114         projectile->setVelocity(this->getMuzzleDirection() * this->speed_);
     116        projectile->setVelocity((projectile->getOrientation() * Vector3::UNIT_Z) * this->speed_); //getWorldOrientation??
     117        //projectile->setVelocity(this->getMuzzleDirection() * this->speed_);
    115118
    116119        projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
  • 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}
  • code/branches/steering/src/orxonox/infos/PlayerInfo.cc

    r5993 r6045  
    138138        assert(this->controller_);
    139139        this->controller_->setPlayer(this);
    140         if (this->controllableEntity_)
     140        if (this->controllableEntity_) {
    141141            this->controller_->setControllableEntity(this->controllableEntity_);
     142            this->controllableEntity_->setController(this->controller_);
     143        }
    142144        this->changedController();
    143145    }
     
    158160        this->bReadyToSpawn_ &= (!this->bSetUnreadyAfterSpawn_);
    159161
    160         if (this->controller_)
     162        if (this->controller_) {
    161163            this->controller_->setControllableEntity(entity);
     164            this->controllableEntity_->setController(this->controller_);
     165        }
    162166
    163167        this->changedControllableEntity();
     
    171175            return;
    172176
     177        this->controllableEntity_->setController(0);
    173178        this->controllableEntity_ = 0;
    174179        this->controllableEntityID_ = OBJECTID_UNKNOWN;
  • code/branches/steering/src/orxonox/weaponsystem/WeaponMode.h

    r5929 r6045  
    3838#include "core/SubclassIdentifier.h"
    3939#include "tools/Timer.h"
     40
     41#include "weaponsystem/Weapon.h"
     42#include "weaponsystem/WeaponPack.h"
     43#include "weaponsystem/WeaponSystem.h"
     44#include "worldentities/pawns/Pawn.h"
     45#include "controllers/Controller.h"
    4046
    4147namespace orxonox
     
    125131                { return this->mode_; }
    126132
     133            inline Vector3 getTarget()
     134                { return this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getController()->getTarget(); }
     135
    127136        protected:
    128137            virtual void fire() = 0;
  • code/branches/steering/src/orxonox/worldentities/ControllableEntity.cc

    r5929 r6045  
    6262        this->camera_ = 0;
    6363        this->xmlcontroller_ = 0;
     64        this->controller_ = 0;
    6465        this->reverseCamera_ = 0;
    6566        this->bDestroyWhenPlayerLeft_ = false;
  • code/branches/steering/src/orxonox/worldentities/ControllableEntity.h

    r5929 r6045  
    139139            inline Controller* getXMLController() const
    140140                { return this->xmlcontroller_; }
     141
     142            inline Controller* getController() const
     143                { return this->controller_; }
     144            inline void setController(Controller* c)
     145                { this->controller_ = c; }
    141146
    142147        protected:
     
    201206            std::string cameraPositionTemplate_;
    202207            Controller* xmlcontroller_;
     208            Controller* controller_;
    203209            CameraPosition* reverseCamera_;
    204210    };
Note: See TracChangeset for help on using the changeset viewer.