Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4414 in orxonox.OLD for orxonox/trunk


Ignore:
Timestamp:
May 31, 2005, 1:29:44 AM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: connected the viewport change functions in the camera system with the event handling system - works great

Location:
orxonox/trunk/src/world_entities
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/world_entities/camera.cc

    r4320 r4414  
    2121#include "world_entity.h"
    2222#include "vector.h"
     23#include "event.h"
     24#include "event_handler.h"
    2325
    2426using namespace std;
     
    3537  this->setClassID(CL_CAMERA, "Camera");
    3638  this->target = new CameraTarget();
     39
     40  EventHandler::getInstance()->subscribe(this, ES_GAME, KeyMapper::PEV_VIEW0);
     41  EventHandler::getInstance()->subscribe(this, ES_GAME, KeyMapper::PEV_VIEW1);
     42  EventHandler::getInstance()->subscribe(this, ES_GAME, KeyMapper::PEV_VIEW2);
     43  EventHandler::getInstance()->subscribe(this, ES_GAME, KeyMapper::PEV_VIEW3);
     44  EventHandler::getInstance()->subscribe(this, ES_GAME, KeyMapper::PEV_VIEW4);
     45  EventHandler::getInstance()->subscribe(this, ES_GAME, KeyMapper::PEV_VIEW5);
    3746
    3847  this->setFovy(90);
     
    182191
    183192
     193void Camera::process(const Event &event)
     194{
     195  if( event.type == KeyMapper::PEV_VIEW0)
     196    {
     197      this->setViewMode(VIEW_NORMAL);
     198    }
     199  else if( event.type == KeyMapper::PEV_VIEW1)
     200    {
     201      this->setViewMode(VIEW_BEHIND);
     202    }
     203  else if( event.type == KeyMapper::PEV_VIEW2)
     204    {
     205      this->setViewMode(VIEW_FRONT);
     206    }
     207  else if( event.type == KeyMapper::PEV_VIEW3)
     208    {
     209      this->setViewMode(VIEW_LEFT);
     210    }
     211  else if( event.type == KeyMapper::PEV_VIEW4)
     212    {
     213      this->setViewMode(VIEW_RIGHT);
     214    }
     215  else if( event.type == KeyMapper::PEV_VIEW5)
     216    {
     217      this->setViewMode(VIEW_TOP);
     218    }
     219}
     220
    184221
    185222///////////////////
  • orxonox/trunk/src/world_entities/camera.h

    r4338 r4414  
    99#include "p_node.h"
    1010#include "vector.h"
     11#include "event_listener.h"
    1112
    1213class World;
    1314class CameraTarget;
     15class Event;
    1416
    1517enum ViewMode{VIEW_NORMAL, VIEW_BEHIND, VIEW_FRONT, VIEW_LEFT, VIEW_RIGHT, VIEW_TOP};
     
    1921   This class controls the viewpoint from which the World is rendered.
    2022*/
    21 class Camera : public PNode
     23class Camera : public PNode, public EventListener
    2224{
    2325 private:
     
    4648  void tick(float dt);
    4749  void apply (void);
     50
     51  void process(const Event &event);
    4852};
    4953
  • orxonox/trunk/src/world_entities/player.cc

    r4413 r4414  
    284284void Player::process(const Event &event)
    285285{
    286   PRINTF(0)("Player got command!!!!!!!!!!!!!!!!!\n");
    287286  if( event.type == KeyMapper::PEV_UP)
    288287    {
Note: See TracChangeset for help on using the changeset viewer.