Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jan 29, 2007, 1:53:29 PM (18 years ago)
Author:
snellen
Message:

little cleanup and bugfix in cameraman.*

File:
1 edited

Legend:

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

    r10476 r10480  
    8282
    8383
    84 
    8584void CameraMan::createCam(const TiXmlElement* root)
    8685{
    87   //Camera* newCamera=new Camera(root);
    8886  this->cameras.push_back(new Camera(root));
    89  // cameras[cameras.size()-1]->target->detach();
    9087  cameras[cameras.size()-1]->setClipRegion(nearClip, farClip);
    91 
    92 }
    93 
    94 void CameraMan::setCam(int cameraNo)
     88}
     89
     90
     91
     92
     93void CameraMan::setCam(unsigned int cameraNo)
    9594{
    9695  if (cameraNo<cameras.size())
     
    106105  if(object != NULL)
    107106  {
    108     Camera* currentCam = dynamic_cast<Camera*>(object) ;
    109 
    110     this->setCam(currentCam);
     107    this->setCam(dynamic_cast<Camera*>(object));
    111108    return;
    112109  }
     
    120117  {
    121118    PRINTF(0)("trying to add a zero camera! uiuiui!\n");
    122   }
     119    return;
     120  }
     121 
    123122  this->currentCam = camera;
    124123
     
    141140
    142141
     142void CameraMan::changeCurrTarget(const std::string& className, const std::string& objectName)
     143{
     144  BaseObject* object = ObjectListBase::getBaseObject(className, objectName);
     145  if( object != NULL && object->isA(PNode::staticClassID()))
     146  {
     147    currentCam->lookAt(dynamic_cast<PNode*>(object));
     148    State::setCamera(this->currentCam,  dynamic_cast<CameraTarget*>(object));
     149  }
     150}
     151
     152void CameraMan::atachCurrTarget(PNode* target)
     153{
     154  currentCam->target->atach(target);
     155  State::setCamera(this->currentCam,  dynamic_cast<CameraTarget*>(target));
     156
     157}
     158
     159void CameraMan::atachCurrCameraToWorldEntity(const std::string& className, const std::string& targetEntity)
     160{
     161  BaseObject* object = ObjectListBase::getBaseObject(className, targetEntity);
     162
     163  if(object != NULL && object->isA(PNode::staticClassID()))
     164  {
     165   this->atachCurrTarget(dynamic_cast<PNode*>(object));
     166   return;
     167  }
     168
     169printf("ERROR CAMERAMANAGER: Couldn't set camera to: %s %s \n", className.c_str(),targetEntity.c_str() );
     170}
     171
     172
     173
     174void CameraMan::detachCurrCamera()
     175{
     176  currentCam->target->detach();
     177}
     178
     179
     180
     181void CameraMan::jumpCurrCam(float x, float y, float z)
     182{
     183  currentCam->target->jump(x, y, z);
     184}
     185
     186void CameraMan::togglFade()
     187{
     188  if( this->fadeToBlack)
     189    fadeToBlack->toggleFade();
     190}
     191
     192void CameraMan::initFadeBlack()
     193{
     194  if( this->fadeToBlack)
     195    fadeToBlack->initFadeBlack();
     196}
     197
     198
    143199void CameraMan::moveCam(int x, int y, int z, int camNo)
    144200{
     
    164220  {
    165221    dynamic_cast<Camera*>(newCam)->lookAt(dynamic_cast<PNode*>(object));
    166     this->setCam( dynamic_cast<Camera*>(newCam));
    167222    State::setCamera( dynamic_cast<Camera*>(newCam),  dynamic_cast<CameraTarget*>(object));
    168223  }
    169 }
    170 
    171 void CameraMan::changeCurrTarget(const std::string& className, const std::string& objectName)
    172 {
    173   BaseObject* object = ObjectListBase::getBaseObject(className, objectName);
    174   if( object != NULL && object->isA(PNode::staticClassID()))
    175   {
    176     currentCam->lookAt(dynamic_cast<PNode*>(object));
    177     State::setCamera(this->currentCam,  dynamic_cast<CameraTarget*>(object));
    178   }
    179 }
    180 
    181 void CameraMan::atachCurrTarget(PNode* target)
    182 {
    183   currentCam->target->atach(target);
    184   State::setCamera(this->currentCam,  dynamic_cast<CameraTarget*>(target));
    185 
    186 }
    187 
    188 void CameraMan::atachCurrCameraToWorldEntity(const std::string& className, const std::string& targetEntity)
    189 {
    190   BaseObject* object = ObjectListBase::getBaseObject(className, targetEntity);
    191 
    192   if(object != NULL)
    193   {
    194    this->atachCurrTarget(dynamic_cast<PNode*>(object));
    195    //State::setCamera(this->currentCam,  dynamic_cast<CameraTarget*>(object));
    196    return;
    197   }
    198 
    199 printf("ERROR CAMERAMANAGER: Couldn't set camera to: %s %s \n", className.c_str(),targetEntity.c_str() );
    200224}
    201225
     
    206230  BaseObject* targetCam = ObjectListBase::getBaseObject("Camera", cameraName);
    207231
    208   if(object != NULL && targetCam != NULL)
    209   {
    210    dynamic_cast<Camera*>(targetCam)->target->atach(dynamic_cast<PNode*>(object));
    211    State::setCamera(this->currentCam,  dynamic_cast<CameraTarget*>(object));
    212    return;
    213   }
    214 
    215 printf("ERROR CAMERAMANAGER: Couldn't set camera %s to: %s %s \n", cameraName.c_str(), className.c_str(),targetEntity.c_str() );
    216 }
    217 
    218 
    219 void CameraMan::detachCurrCamera()
    220 {
    221   currentCam->target->detach();
    222 }
     232  if( object != NULL && targetCam != NULL && object->isA(PNode::staticClassID()) )
     233  {
     234    dynamic_cast<Camera*>(targetCam)->target->atach(dynamic_cast<PNode*>(object));
     235    State::setCamera(dynamic_cast<Camera*>(targetCam),  dynamic_cast<CameraTarget*>(object));
     236    return;
     237  }
     238
     239  printf("ERROR CAMERAMANAGER: Couldn't set camera %s to: %s %s \n", cameraName.c_str(), className.c_str(),targetEntity.c_str() );
     240}
     241
     242
    223243
    224244void CameraMan::jumpCam(int x, int y, int z, int camNo)
     
    234254  this->farClip=farCli;
    235255
    236   for(int i = 0; i < this->cameras.size(); i++)
     256  for(unsigned int i = 0; i < this->cameras.size(); i++)
    237257    cameras[i]->setClipRegion(nearCli, farCli);
    238258}
    239259
    240 
    241 void CameraMan::jumpCurrCam(float x, float y, float z)
    242 {
    243   currentCam->target->jump(x, y, z);
    244 }
    245 
    246 
    247 
    248 
    249 void CameraMan::togglFade()
    250 {
    251   if( this->fadeToBlack)
    252     fadeToBlack->toggleFade();
    253 }
    254 
    255 void CameraMan::initFadeBlack()
    256 {
    257   if( this->fadeToBlack)
    258     fadeToBlack->initFadeBlack();
    259 }
    260260
    261261
Note: See TracChangeset for help on using the changeset viewer.