Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10237 in orxonox.OLD for branches/playability


Ignore:
Timestamp:
Jan 15, 2007, 11:51:37 PM (18 years ago)
Author:
muellmic
Message:

changed camera handling for the vertical-scroller playmode. the top-down view in vertical scroller is now a proper camera-viewmode. also added a bool-state in the camera class to override the camera's event-listener and handle the camera-events (view buttons) in other classes. i used this to handle the camera parenting with the space-ship class, so other views as the top-down get useful and nice-looking again…. *taking-a-look-at-the-watch* oops damnit… i hope i won't forget the last tram ;-)

Location:
branches/playability/src/world_entities
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/playability/src/world_entities/camera.cc

    r9869 r10237  
    4444
    4545  this->setParentMode(PNODE_ALL);
     46  this->eventHandling = true;
     47
     48
    4649}
    4750
     
    100103    default:
    101104    case Camera::ViewNormal:
     105    {
    102106      this->toFovy = 60.0;
    103107      this->setRelCoorSoft(-10, 5, 0);
    104108      this->target->setRelCoorSoft(0,0,0);
    105109      break;
     110    }
    106111    case Camera::ViewBehind:
    107112      break;
    108113    case Camera::ViewFront:
     114    {
    109115      this->toFovy = 120.0;
    110116      this->setRelCoorSoft(4, 0, 0, 5);
    111117      this->target->setRelCoorSoft(Vector(10,0,0), 5);
    112118      break;
     119    }
    113120    case Camera::ViewLeft:
     121    {
    114122      this->toFovy = 90;
    115123      this->setRelCoorSoft(0, 1, -10, .5);
    116124      this->target->setRelCoorSoft(0,0,0);
    117125      break;
     126    }
    118127    case Camera::ViewRight:
     128    {
    119129      this->toFovy = 90;
    120130      this->setRelCoorSoft(Vector(0, 1, 10));
    121131      this->target->setRelCoorSoft(0,0,0);
    122132      break;
     133    }
    123134    case Camera::ViewTop:
     135    {
    124136      this->toFovy= 120;
    125       this->setRelCoorSoft(Vector(30, 50, 0));
    126       this->target->setRelCoorSoft(35,0,0);
     137      this->setRelCoor(Vector(-0.05, 40, 0));
     138      this->target->setRelCoor(0,0,0);
     139    }
    127140  }
    128141}
     
    192205void Camera::process(const Event &event)
    193206{
    194   if( event.type == KeyMapper::PEV_VIEW0)
     207  if (eventHandling == true)
    195208  {
    196     this->setViewMode(Camera::ViewNormal);
    197   }
    198   else if( event.type == KeyMapper::PEV_VIEW1)
    199   {
    200     this->setViewMode(Camera::ViewBehind);
    201   }
    202   else if( event.type == KeyMapper::PEV_VIEW2)
    203   {
    204     this->setViewMode(Camera::ViewFront);
    205   }
    206   else if( event.type == KeyMapper::PEV_VIEW3)
    207   {
    208     this->setViewMode(Camera::ViewLeft);
    209   }
    210   else if( event.type == KeyMapper::PEV_VIEW4)
    211   {
    212     this->setViewMode(Camera::ViewRight);
    213   }
    214   else if( event.type == KeyMapper::PEV_VIEW5)
    215   {
    216     this->setViewMode(Camera::ViewTop);
     209    if( event.type == KeyMapper::PEV_VIEW0)
     210    {
     211      this->setViewMode(Camera::ViewNormal);
     212    }
     213    else if( event.type == KeyMapper::PEV_VIEW1)
     214    {
     215      this->setViewMode(Camera::ViewBehind);
     216    }
     217    else if( event.type == KeyMapper::PEV_VIEW2)
     218    {
     219      this->setViewMode(Camera::ViewFront);
     220    }
     221    else if( event.type == KeyMapper::PEV_VIEW3)
     222    {
     223      this->setViewMode(Camera::ViewLeft);
     224    }
     225    else if( event.type == KeyMapper::PEV_VIEW4)
     226    {
     227      this->setViewMode(Camera::ViewRight);
     228    }
     229    else if( event.type == KeyMapper::PEV_VIEW5)
     230    {
     231      this->setViewMode(Camera::ViewTop);
     232    }
    217233  }
    218234}
  • branches/playability/src/world_entities/camera.h

    r9869 r10237  
    5858  inline float distance(const PNode* node) const { return distance(node->getAbsCoor()); }
    5959
     60  inline void setEventHandling(bool b) {this->eventHandling = b;}
     61  inline bool getEventHandling() {return this->eventHandling;}
     62
    6063  void tick(float dt);
    6164  void apply ();
     
    6669private:
    6770  CameraTarget*     target;          //!< The Target of the Camera (where this Camera Looks at)
     71
     72  bool              eventHandling;    //!< True, if the Camera handles the processing of events itself. Set false to overwrite the standard handling.
    6873
    6974  float             fovy;            //!< The field of view Angle (in degrees).
  • branches/playability/src/world_entities/space_ships/space_ship.cc

    r10235 r10237  
    5858#include "state.h"
    5959#include "player.h"
     60#include "camera.h"
    6061
    6162
     
    436437  this->toList( OM_GROUP_00);
    437438  State::getPlayer()->hud().setOverlayActive(false);
     439  State::getCamera()->setEventHandling(true);
    438440  //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( false);
    439441  //this->detachCamera();
     
    619621    this->previousWeaponConfig();
    620622
     623  if (!(State::getCamera()->getEventHandling()))
     624  {
     625    if( event.type == KeyMapper::PEV_VIEW0)
     626    {
     627      State::getCamera()->setViewMode(Camera::ViewNormal);
     628      State::getCameraTargetNode()->setParent(this);
     629      State::getCamera()->setParent(this);
     630    }
     631    else if( event.type == KeyMapper::PEV_VIEW1)
     632    {
     633      State::getCamera()->setViewMode(Camera::ViewBehind);
     634      State::getCameraTargetNode()->setParent(this);
     635      State::getCamera()->setParent(this);
     636    }
     637    else if( event.type == KeyMapper::PEV_VIEW2)
     638    {
     639      State::getCamera()->setViewMode(Camera::ViewFront);
     640      State::getCameraTargetNode()->setParent(this);
     641      State::getCamera()->setParent(this);
     642    }
     643    else if( event.type == KeyMapper::PEV_VIEW3)
     644    {
     645      State::getCamera()->setViewMode(Camera::ViewLeft);
     646      State::getCameraTargetNode()->setParent(this);
     647      State::getCamera()->setParent(this);
     648    }
     649    else if( event.type == KeyMapper::PEV_VIEW4)
     650    {
     651      State::getCamera()->setViewMode(Camera::ViewRight);
     652      State::getCameraTargetNode()->setParent(this);
     653      State::getCamera()->setParent(this);
     654    }
     655    else if( event.type == KeyMapper::PEV_VIEW5)
     656    {
     657      State::getCamera()->setViewMode(Camera::ViewTop);
     658      State::getCameraTargetNode()->setParent(this->travelNode);
     659      State::getCamera()->setParent(this->travelNode);
     660    }
     661  }
     662
    621663
    622664  /*
     
    837879        State::getCameraNode()->setParentSoft(this->travelNode);
    838880        //State::getCameraNode()->setParentSoft(this);
    839         State::getCameraNode()->setRelCoorSoft(-0.01, 40, 0);
     881        //State::getCameraNode()->setRelCoorSoft(-0.01, 40, 0);
    840882        State::getCameraTargetNode()->setParentSoft(this->travelNode);
    841883        //State::getCameraTargetNode()->setParentSoft(this);
    842         State::getCameraTargetNode()->setRelCoorSoft(0,0,0);
     884        //State::getCameraTargetNode()->setRelCoorSoft(0,0,0);
     885        this->setCameraMode(Camera::ViewTop);
     886        State::getCamera()->setEventHandling(false);
     887        registerEvent(KeyMapper::PEV_VIEW0);
     888        registerEvent(KeyMapper::PEV_VIEW1);
     889        registerEvent(KeyMapper::PEV_VIEW2);
     890        registerEvent(KeyMapper::PEV_VIEW3);
     891        registerEvent(KeyMapper::PEV_VIEW4);
     892        registerEvent(KeyMapper::PEV_VIEW5);
     893
     894        State::getCamera()->setParentMode(PNODE_MOVEMENT);
    843895
    844896        this->debugNode(1);
Note: See TracChangeset for help on using the changeset viewer.