Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10480 in orxonox.OLD for trunk/src


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

little cleanup and bugfix in cameraman.*

Location:
trunk/src/world_entities
Files:
2 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
  • trunk/src/world_entities/cameraman.h

    r10473 r10480  
    2222    std::vector<Camera*> cameras;
    2323    CameraMan(const TiXmlElement* root = NULL);
    24     void setCam(int CameraNo);
     24    void setCam(unsigned int CameraNo);
    2525    void setCam(const std::string& camName);
    2626    void setCam(Camera* camera);
    2727
     28    /// LOADING
     29    virtual void loadParams(const TiXmlElement* root);
    2830    void createCameras(const TiXmlElement* camerasTag);
    2931    void createCam(const TiXmlElement* root);
    30     void moveCam(int x, int y, int z,  int camNo);
    31     void moveCurrCam(int x, int y, int z);
    32     void changeTarget(int camNo, const std::string& className,const std::string& objectName);
    33     void changeTarget(const std::string& camName,const std::string& className, const std::string& objectName);
    34     void changeCurrTarget(const std::string& className, const std::string& objectName);
    35     void atachCurrTarget(PNode* target);
    36     void atachCurrCameraToWorldEntity(const std::string& className, const std::string& targetEntity);
    37     void atachCameraToWorldEntity(const std::string& cameraName, const std::string& className, const std::string& targetEntity);
    38     void detachCurrCamera();
    39     void jumpCam(int x, int y, int z, int camNo);
    40     void jumpCurrCam(float x, float y, float z);
    41     void changeSpeed(float speed);
    42     void setClipRegion(float nearClip, float farClip);
    43     void togglFade();
    44     void initFadeBlack();
    45 
    46     void cameraInfo();
    47 
    48     /// LOADING
    49     virtual void loadParams(const TiXmlElement* root);
    5032
    5133    /// POLLING
     
    5537    const Camera* getCurrentCam() const { return this->currentCam; }
    5638    Camera* getCurrentCam() { return this->currentCam; }
     39
     40   
     41    /// Current camera
     42    void moveCurrCam(int x, int y, int z);
     43    void changeCurrTarget(const std::string& className, const std::string& objectName);
     44    void atachCurrTarget(PNode* target);
     45    void atachCurrCameraToWorldEntity(const std::string& className, const std::string& targetEntity);
     46    void detachCurrCamera();
     47    void jumpCurrCam(float x, float y, float z);
     48    void togglFade();
     49    void initFadeBlack();
     50   
     51    /// Camera
     52    void moveCam(int x, int y, int z,  int camNo);
     53    void changeTarget(int camNo, const std::string& className,const std::string& objectName);
     54    void changeTarget(const std::string& camName,const std::string& className, const std::string& objectName);
     55    void atachCameraToWorldEntity(const std::string& cameraName, const std::string& className, const std::string& targetEntity);
     56    void jumpCam(int x, int y, int z, int camNo);
     57   
     58    void changeSpeed(float speed);
     59    void setClipRegion(float nearClip, float farClip);
     60    void cameraInfo();
     61   
     62  private:
    5763    bool cameraIsInVector(Camera* camera);
     64   
    5865
    5966};
Note: See TracChangeset for help on using the changeset viewer.