Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10393 in orxonox.OLD for trunk/src/world_entities


Ignore:
Timestamp:
Jan 26, 2007, 7:36:16 PM (18 years ago)
Author:
snellen
Message:

made cameraman xml-loadable second try, added method setCamera(const std::string& camera)

Location:
trunk/src/world_entities
Files:
2 edited

Legend:

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

    r10390 r10393  
    2929                        addMethod("changeCurrTarget", Executor2<CameraMan, lua_State*,const std::string&,const std::string&>(&CameraMan::changeCurrTarget))
    3030                        ->addMethod("changeTarget", Executor3<CameraMan, lua_State*, int, const std::string&,const std::string&>(&CameraMan::changeTarget))
    31                         ->addMethod("setCamera", Executor1<CameraMan, lua_State*, int>(&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))
     
    6060  LOAD_PARAM_START_CYCLE(root, object);
    6161  {
    62     this->createCam(root);
     62    this->createCam(object);
    6363  }
    6464  LOAD_PARAM_END_CYCLE(object);
    6565
    66  
    67  
    68 
    6966}
    7067
     
    7269void CameraMan::createCam(const TiXmlElement* root)
    7370{
    74  // Camera* newCamera=new Camera();
     71  //Camera* newCamera=new Camera(root);
    7572  this->cameras.push_back(new Camera(root));
    7673  cameras[cameras.size()-1]->target->detach();
     
    9390}
    9491
     92void CameraMan::setCam(const std::string& camName)
     93{
     94  BaseObject* object = ObjectListBase::getBaseObject("Camera", camName);
     95 
     96  if(object != NULL)
     97  {
     98    currentCam = dynamic_cast<Camera*>(object) ;
     99   
     100    if( ! this->cameraIsInVector(currentCam) )
     101      this->cameras.push_back(currentCam);
     102   
     103    State::setCamera(currentCam, currentCam->getTarget());
     104    OrxSound::SoundEngine::getInstance()->setListener(currentCam);
     105    this->fadeToBlack->setParent(this->currentCam);
     106    this->fadeToBlack->setRelCoor(3., 0., 0.);
     107 
     108  }
     109
     110}
     111
    95112
    96113
     
    160177
    161178
     179bool CameraMan::cameraIsInVector(Camera* camera)
     180{
     181
     182  for(std::vector<Camera*>::const_iterator it = cameras.begin(); it != cameras.end(); it++ )
     183  {
     184    if( (*it) == camera)
     185    {
     186      return true;
     187    }
     188  }
     189  return false;
     190
     191
     192}
     193
     194
    162195//how to get a class fkt pointer
    163196
  • trunk/src/world_entities/cameraman.h

    r10390 r10393  
    2121    CameraMan(const TiXmlElement* root = NULL);
    2222    void setCam(int CameraNo);
     23    void setCam(const std::string& camName);
    2324    void createCam(const TiXmlElement* root);
    2425    void moveCam(int x, int y, int z,  int camNo);
     
    3637    virtual void loadParams(const TiXmlElement* root);
    3738   
    38     /// Polling (to be used in scripts)
     39    /// POLLING
    3940    float getCurrCameraCoorX(){ return this->currentCam->getAbsCoorX(); }
    4041    float getCurrCameraCoorY(){ return this->currentCam->getAbsCoorY(); }
    4142    float getCurrCameraCoorZ(){ return this->currentCam->getAbsCoorZ(); }
     43    bool cameraIsInVector(Camera* camera);
    4244
    4345};
Note: See TracChangeset for help on using the changeset viewer.