Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10403 in orxonox.OLD for trunk/src/world_entities/cameraman.cc


Ignore:
Timestamp:
Jan 27, 2007, 12:21:10 AM (17 years ago)
Author:
patrick
Message:

fading now works

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/cameraman.cc

    r10400 r10403  
    2929                        addMethod("changeCurrTarget", Executor2<CameraMan, lua_State*,const std::string&,const std::string&>(&CameraMan::changeCurrTarget))
    3030                        ->addMethod("changeTarget", Executor3<CameraMan, lua_State*, const std::string&, const std::string&,const std::string&>(&CameraMan::changeTarget))
    31                         ->addMethod("setCam", Executor1<CameraMan, lua_State*, const std::string&>(&CameraMan::setCam)) 
     31                        ->addMethod("setCam", Executor1<CameraMan, lua_State*, const std::string&>(&CameraMan::setCam))
    3232                        ->addMethod("togglFade", Executor0<CameraMan, lua_State*>(&CameraMan::togglFade))
    3333                        ->addMethod("getCurrCameraCoorX", Executor0ret<CameraMan, lua_State*,float>(&CameraMan::getCurrCameraCoorX))
     
    4444  this->farClip = 1000.0;
    4545
    46   currentCam=State::getCamera();
    47   this->cameras.push_back(currentCam);
    48 
    49   State::setCamera(currentCam, currentCam->getTarget());
    5046  this->fadeToBlack=new BlackScreen();
    51   this->fadeToBlack->setParent(this->currentCam);
    52   this->fadeToBlack->setRelCoor(3., 0., 0.);
    53  
     47
     48  this->setCam( State::getCamera());
     49
    5450  if (root != NULL)
    5551    this->loadParams(root);
     
    6056{
    6157  BaseObject::loadParams(root);
    62  
     58
    6359  LOAD_PARAM_START_CYCLE(root, object);
    6460  {
     
    8379  if (cameraNo<cameras.size())
    8480  {
    85   currentCam=cameras[cameraNo];
     81    this->setCam( cameras[cameraNo]);
     82  }
     83}
     84
     85void CameraMan::setCam(const std::string& camName)
     86{
     87  BaseObject* object = ObjectListBase::getBaseObject("Camera", camName);
     88
     89  if(object != NULL)
     90  {
     91    Camera* currentCam = dynamic_cast<Camera*>(object) ;
     92
     93    this->setCam(currentCam);
     94    return;
     95  }
     96  printf("ERROR CAMERAMANAGER: Couldn't set camera : %s \n", camName.c_str());
     97}
     98
     99
     100void CameraMan::setCam(Camera* camera)
     101{
     102  if( camera == NULL)
     103  {
     104    PRINTF(0)("trying to add a zero camera! uiuiui!\n");
     105  }
     106  this->currentCam = camera;
     107
    86108  State::setCamera(currentCam, currentCam->getTarget());
    87109  OrxSound::SoundEngine::getInstance()->setListener(currentCam);
    88110
     111  // check if it is already added
     112  if( ! this->cameraIsInVector(currentCam) )
     113    this->cameras.push_back(currentCam);
     114
     115  this->fadeToBlack->setRelCoor(0., 0., 0.);
    89116  this->fadeToBlack->setParent(this->currentCam);
    90   this->fadeToBlack->setRelCoor(3., 0., 0.);
    91   }
    92 
    93 }
    94 
    95 void CameraMan::setCam(const std::string& camName)
    96 {
    97   BaseObject* object = ObjectListBase::getBaseObject("Camera", camName);
    98  
    99   if(object != NULL)
    100   {
    101    
    102     currentCam = dynamic_cast<Camera*>(object) ;
    103    
    104     if( ! this->cameraIsInVector(currentCam) )
    105       this->cameras.push_back(currentCam);
    106    
    107     State::setCamera(currentCam, currentCam->getTarget());
    108     OrxSound::SoundEngine::getInstance()->setListener(currentCam);
    109     this->fadeToBlack->setParent(this->currentCam);
    110     this->fadeToBlack->setRelCoor(3., 0., 0.);
    111     return;
    112   }
    113   printf("ERROR CAMERAMANAGER: Couldn't set camera : %s \n", camName.c_str());
    114  
    115 }
     117}
     118
    116119
    117120void CameraMan::moveCurrCam(int x, int y, int z)
    118121{
    119 currentCam->target->trans(x,y,z);
     122  currentCam->target->trans(x,y,z);
    120123}
    121124
     
    123126void CameraMan::moveCam(int x, int y, int z, int camNo)
    124127{
    125 cameras[camNo]->target->trans(x,y,z);
     128  cameras[camNo]->target->trans(x,y,z);
    126129}
    127130
Note: See TracChangeset for help on using the changeset viewer.