Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 25, 2007, 3:05:01 AM (17 years ago)
Author:
patrick
Message:

merged playability. but got strange bug

Location:
branches/playability.new
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/playability.new

    • Property svn:ignore
      •  

        old new  
        1010autom4te.cache
        1111aclocal.m4
         12tags
         13test.bmp
         14config.sub
         15config.guess
         16OrxonoxPlayability.kdevses
         17OrxonoxPlayability.kdevelop.pcs
  • branches/playability.new/src/world_entities/camera.cc

    r9869 r10362  
    1818#include "key_mapper.h"
    1919#include "glincl.h"
     20//#include "util/loading/load_param.h"
     21#include "world_entity.h"
    2022
    2123ObjectListDefinition(Camera);
     
    2729{
    2830  this->registerObject(this, Camera::_objectList);
     31  this->init();
     32}
     33
     34/*
     35Camera::Camera(const TiXmlElement* root)
     36{
     37  this->registerObject(this, Camera::_objectList);
     38  this->init();
     39  this->loadParams(root);
     40}
     41*/
     42
     43/**
     44 *  default destructor
     45*/
     46Camera::~Camera()
     47{}
     48
     49void Camera::init()
     50{
    2951  this->setName("camera");
    3052  this->target = new CameraTarget();
     
    3759  this->subscribeEvent(ES_GAME, KeyMapper::PEV_VIEW5);
    3860
    39   this->setFovy(90);
    40   this->setAspectRatio(1.2f);
     61  //this->setFovy(90);
     62  this->setAspectRatio(1.33f);
    4163  this->setClipRegion(.1, 10000);
     64 
     65  this->viewTopFovy = 60;
     66  this->viewNormalFovy = 90;
     67  this->viewFrontFovy = 120;
     68  this->viewRightFovy = 90;
     69  this->viewLeftFovy = 90;
     70
     71  this->viewTopDistance = 70;
     72  this->viewNormalDistance = 10;
     73  this->viewFrontDistance = 4;
     74  this->viewRightDistance = 10;
     75  this->viewLeftDistance = 10;
     76
     77  //this->loadParams(doc.RootElement());
    4278
    4379  this->setViewMode(Camera::ViewNormal);
    4480
    4581  this->setParentMode(PNODE_ALL);
    46 }
    47 
    48 /**
    49  *  default destructor
    50 */
    51 Camera::~Camera()
    52 {}
     82  this->eventHandling = true;
     83}
    5384
    5485/**
     
    100131    default:
    101132    case Camera::ViewNormal:
    102       this->toFovy = 60.0;
    103       this->setRelCoorSoft(-10, 5, 0);
     133    {
     134      this->fovy = viewNormalFovy;
     135      this->toFovy = viewNormalFovy;
     136      //this->fovy = 60;
     137      //this->toFovy = 60;
     138      this->setRelCoorSoft(-2.0/3.0 * this->viewNormalDistance, 1.0/3.0 * this->viewNormalDistance, 0);
    104139      this->target->setRelCoorSoft(0,0,0);
    105140      break;
     141    }
    106142    case Camera::ViewBehind:
    107143      break;
    108144    case Camera::ViewFront:
    109       this->toFovy = 120.0;
    110       this->setRelCoorSoft(4, 0, 0, 5);
     145    {
     146      this->fovy = viewFrontFovy;
     147      this->toFovy = viewFrontFovy;
     148      this->setRelCoorSoft(this->viewFrontDistance, 0, 0, 5);
    111149      this->target->setRelCoorSoft(Vector(10,0,0), 5);
    112150      break;
     151    }
    113152    case Camera::ViewLeft:
    114       this->toFovy = 90;
    115       this->setRelCoorSoft(0, 1, -10, .5);
     153    {
     154      this->fovy = viewLeftFovy;
     155      this->toFovy = viewLeftFovy;
     156      this->setRelCoorSoft(0, 1, -viewLeftDistance, .5);
    116157      this->target->setRelCoorSoft(0,0,0);
    117158      break;
     159    }
    118160    case Camera::ViewRight:
    119       this->toFovy = 90;
    120       this->setRelCoorSoft(Vector(0, 1, 10));
     161    {
     162      this->fovy = viewRightFovy;
     163      this->toFovy = viewRightFovy;
     164      this->setRelCoorSoft(Vector(0, 1, viewRightDistance), 0.5);
    121165      this->target->setRelCoorSoft(0,0,0);
    122166      break;
     167    }
    123168    case Camera::ViewTop:
    124       this->toFovy= 120;
    125       this->setRelCoorSoft(Vector(30, 50, 0));
    126       this->target->setRelCoorSoft(35,0,0);
     169    {
     170      this->fovy= viewTopFovy;
     171      this->toFovy = viewTopFovy;
     172      this->setRelCoor(Vector(-0.05, this->viewTopDistance , 0));
     173      this->target->setRelCoor(0,0,0);
     174    }
    127175  }
    128176}
     
    143191
    144192  float tmpFovy = (this->toFovy - this->fovy);
    145   if (tmpFovy > 0.01)
     193  if (fabsf(tmpFovy) > 0.01)
    146194    this->fovy += tmpFovy * fabsf(dt);
    147195}
     
    192240void Camera::process(const Event &event)
    193241{
    194   if( event.type == KeyMapper::PEV_VIEW0)
     242  if (eventHandling == true)
    195243  {
    196     this->setViewMode(Camera::ViewNormal);
     244    if( event.type == KeyMapper::PEV_VIEW0)
     245    {
     246      this->setViewMode(Camera::ViewNormal);
     247    }
     248    else if( event.type == KeyMapper::PEV_VIEW1)
     249    {
     250      this->setViewMode(Camera::ViewBehind);
     251    }
     252    else if( event.type == KeyMapper::PEV_VIEW2)
     253    {
     254      this->setViewMode(Camera::ViewFront);
     255    }
     256    else if( event.type == KeyMapper::PEV_VIEW3)
     257    {
     258      this->setViewMode(Camera::ViewLeft);
     259    }
     260    else if( event.type == KeyMapper::PEV_VIEW4)
     261    {
     262      this->setViewMode(Camera::ViewRight);
     263    }
     264    else if( event.type == KeyMapper::PEV_VIEW5)
     265    {
     266      this->setViewMode(Camera::ViewTop);
     267    }
    197268  }
    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);
    217   }
     269}
     270
     271/*
     272void Camera::loadParams(const TiXmlElement* root)
     273{
     274  // Do the PNode loading stuff
     275  PNode::loadParams(root);
     276
     277  LoadParam(root, "viewTopFovy", this, Camera, setViewTopFovy);
     278  LoadParam(root, "viewFrontFovy", this, Camera, setViewFrontFovy);
     279  LoadParam(root, "viewLeftFovy", this, Camera, setViewLeftFovy);
     280  LoadParam(root, "viewRightFovy", this, Camera, setViewRightFovy);
     281  LoadParam(root, "viewBehindFovy", this, Camera, setViewBehindFovy);
     282  LoadParam(root, "viewNormalFovy", this, Camera, setViewNormalFovy);
     283
     284  LoadParam(root, "viewTopDistance", this, Camera, setViewTopDistance);
     285  LoadParam(root, "viewFrontDistance", this, Camera, setViewFrontDistance);
     286  LoadParam(root, "viewLeftDistance", this, Camera, setViewLeftDistance);
     287  LoadParam(root, "viewRightDistance", this, Camera, setViewRightDistance);
     288  LoadParam(root, "viewBehindDistance", this, Camera, setViewBehindDistance);
     289  LoadParam(root, "viewNormalDistance", this, Camera, setViewNormalDistance);
     290}
     291*/
     292
     293void Camera::setViewTopFovy(float fovy)
     294{
     295  this->viewTopFovy = fovy;
     296}
     297
     298void Camera::setViewFrontFovy(float fovy)
     299{
     300  this->viewFrontFovy = fovy;
     301}
     302
     303void Camera::setViewLeftFovy(float fovy)
     304{
     305  this->viewLeftFovy = fovy;
     306}
     307
     308void Camera::setViewRightFovy(float fovy)
     309{
     310  this->viewRightFovy = fovy;
     311}
     312
     313void Camera::setViewBehindFovy(float fovy)
     314{
     315  this->viewBehindFovy = fovy;
     316}
     317
     318void Camera::setViewNormalFovy(float fovy)
     319{
     320  this->viewNormalFovy = fovy;
     321}
     322
     323void Camera::setViewTopDistance(float Distance)
     324{
     325  this->viewTopDistance = Distance;
     326}
     327
     328void Camera::setViewFrontDistance(float Distance)
     329{
     330  this->viewFrontDistance = Distance;
     331}
     332
     333void Camera::setViewLeftDistance(float Distance)
     334{
     335  this->viewLeftDistance = Distance;
     336}
     337
     338void Camera::setViewRightDistance(float Distance)
     339{
     340  this->viewRightDistance = Distance;
     341}
     342
     343void Camera::setViewBehindDistance(float Distance)
     344{
     345  this->viewBehindDistance = Distance;
     346}
     347
     348void Camera::setViewNormalDistance(float Distance)
     349{
     350  this->viewNormalDistance = Distance;
    218351}
    219352
Note: See TracChangeset for help on using the changeset viewer.