Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 21, 2009, 12:33:37 AM (15 years ago)
Author:
scheusso
Message:

made some changes in NewHumanController, Pawn, CE, Controller and WeaponMode preparing the synchronisation of clients target and aimPosition

Location:
code/branches/presentation2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2

  • code/branches/presentation2/src/orxonox/controllers/Controller.h

    r6108 r6111  
    5454            virtual void changedControllableEntity() {}
    5555
    56             virtual bool canFindTarget()
    57                 { return false; }
    58             virtual Vector3 getTarget()
    59                 { return Vector3::ZERO; }
    60 
    6156        protected:
    6257            // don't use this directly, use getPlayer()->startControl(entity) (unless you know exactly what you do)
  • code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc

    r6108 r6111  
    3737#include "core/ConsoleCommand.h"
    3838#include "worldentities/ControllableEntity.h"
     39#include "worldentities/pawns/Pawn.h"
    3940#include "infos/PlayerInfo.h"
    4041#include "overlays/OrxonoxOverlay.h"
     
    8081    void NewHumanController::tick(float dt)
    8182    {
    82         crossHairOverlay_->setPosition(Vector2(static_cast<float>(this->currentYaw_)/2*-1+.5-overlaySize_/2, static_cast<float>(this->currentPitch_)/2*-1+.5-overlaySize_/2));
     83        if( !this->controllableEntity_->isInMouseLook() )
     84        {
     85            this->crossHairOverlay_->setPosition(Vector2(static_cast<float>(this->currentYaw_)/2*-1+.5-overlaySize_/2, static_cast<float>(this->currentPitch_)/2*-1+.5-overlaySize_/2));
     86            this->crossHairOverlay_->show();
     87        }
     88        else
     89            this->crossHairOverlay_->hide();
     90        // TODO: update aimPosition of Pawn
    8391
    8492        HumanController::tick(dt);
     
    117125        }
    118126*/
     127        if( !NewHumanController::localController_s->getControllableEntity()->isInMouseLook() )
     128            this->updateTarget();
    119129
    120130        HumanController::localController_s->getControllableEntity()->fire(firemode);
    121131    }
    122132
    123     Vector3 NewHumanController::getTarget()
     133    void NewHumanController::updateTarget()
    124134    {
    125135        Ogre::RaySceneQuery * rsq = HumanController::localController_s->getControllableEntity()->getScene()->getSceneManager()->createRayQuery(Ogre::Ray());
     
    140150
    141151        Ogre::RaySceneQueryResult& result = rsq->execute();
     152        Pawn* pawn = orxonox_cast<Pawn*>(this->getControllableEntity());
    142153
    143154        Ogre::RaySceneQueryResult::iterator itr;
     
    154165                        continue;
    155166                }
     167               
     168                this->getControllableEntity()->setTarget(wePtr);
    156169
    157170                itr->movable->getParentSceneNode()->showBoundingBox(true);
    158171                //std::cout << itr->movable->getParentSceneNode()->_getDerivedPosition() << endl;
    159                 return mouseRay.getOrigin() + mouseRay.getDirection() * itr->distance; //or itr->movable->getParentSceneNode()->_getDerivedPosition()
     172                //return mouseRay.getOrigin() + mouseRay.getDirection() * itr->distance; //or itr->movable->getParentSceneNode()->_getDerivedPosition()
     173                if ( pawn )
     174                {
     175                    pawn->setAimPosition( mouseRay.getOrigin() + mouseRay.getDirection() * itr->distance ); // or itr->movable->getParentSceneNode()->_getDerivedPosition()
     176                    pawn->setTarget( wePtr );
     177                }
     178                return;
    160179            }
    161180
    162181        }
    163 
    164         return mouseRay.getOrigin() + mouseRay.getDirection() * 1200;
     182        if ( pawn )
     183        {
     184            pawn->setAimPosition( mouseRay.getOrigin() + mouseRay.getDirection() * 1200 );
     185            pawn->setTarget( 0 );
     186        }
     187
     188    //return mouseRay.getOrigin() + mouseRay.getDirection() * 1200;
     189   
    165190
    166191        //return this->controllableEntity_->getWorldPosition() + (this->controllableEntity_->getWorldOrientation() * Vector3::NEGATIVE_UNIT_Z * 2000);
     
    189214
    190215    void NewHumanController::changeMode() {
    191         if (NewHumanController::localController_s->controlMode_ == 0)
    192             NewHumanController::localController_s->controlMode_ = 1;
     216        if (NewHumanController::localController_s && NewHumanController::localController_s->controlMode_ == 0)
     217        {
     218            if (NewHumanController::localController_s->controllableEntity_ && !NewHumanController::localController_s->controllableEntity_->isInMouseLook() )
     219                NewHumanController::localController_s->controlMode_ = 1;
     220        }
    193221        else
    194222            NewHumanController::localController_s->controlMode_ = 0;
  • code/branches/presentation2/src/orxonox/controllers/NewHumanController.h

    r6108 r6111  
    5252            static void changeMode();
    5353
    54             virtual bool canFindTarget() { return true; }
    55             virtual Vector3 getTarget();
    56 
    5754        protected:
     55            void updateTarget();
     56           
    5857            unsigned int                controlMode_;
    5958            static NewHumanController* localController_s;
Note: See TracChangeset for help on using the changeset viewer.