Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10593 in orxonox.OLD


Ignore:
Timestamp:
Feb 14, 2007, 7:27:23 PM (17 years ago)
Author:
snellen
Message:

cleaned up the cameramanager, commented all functions, corrected spelling mistakes :-P

Location:
branches/cleanup/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/cleanup/src/story_entities/game_world.cc

    r10591 r10593  
    444444
    445445    // tick camera first
    446     CameraMan* man = State::getCameraman();
    447     (man->getCurrentCam())->tick(this->dtS);
     446    (State::getCamera())->tick(this->dtS);
    448447    // TICK everything
    449448    for (i = 0; i < this->dataTank->tickLists.size(); ++i)
     
    580579void GameWorld::applyCameraSettings()
    581580{
    582   CameraMan* man = State::getCameraman();
    583   Camera* c = man->getCurrentCam();
     581  Camera* c = State::getCamera();
     582
    584583  if( c != NULL)
    585584  {
  • branches/cleanup/src/story_entities/game_world_data.cc

    r10591 r10593  
    101101  PNode::getNullParent();
    102102  Camera* localCamera = new Camera();
    103     localCamera->setName ("GameWorld-Camera");
     103    localCamera->setName ("GameWorldCamera");
    104104  State::setCamera(localCamera, localCamera->getTarget());
    105105  //CameraMan* camMan = new CameraMan();
  • branches/cleanup/src/world_entities/effects/billboard.cc

    r10591 r10593  
    134134  this->material->select();
    135135
    136   const CameraMan* man = State::getCameraman();
    137   const Camera* camera = man->getCurrentCam(); //!< @todo MUST be different
     136  const Camera* camera = State::getCamera();
    138137  Vector cameraPos = camera->getAbsCoor();
    139138  Vector cameraTargetPos = camera->getTarget()->getAbsCoor();
  • branches/cleanup/src/world_entities/effects/wobblegrid.cc

    r10591 r10593  
    201201void Wobblegrid::orient()
    202202{
    203      
    204      CameraMan* cman = State::getCameraman();
    205      Camera* c = cman->getCurrentCam();
     203
     204  Camera* c = State::getCamera();
    206205
    207206  Vector view = this->getAbsCoor() - c->getAbsCoor();
  • branches/cleanup/src/world_entities/particles/sprite_particles.cc

    r10591 r10593  
    141141//     Vector view = cameraTargetPos - cameraPos;
    142142
    143     const CameraMan* man = State::getCameraman();
    144     const Camera* camera = man->getCurrentCam(); //!< @todo MUST be different
     143    Camera* camera = State::getCamera();
    145144    Vector cameraPos = camera->getAbsCoor();
    146145    Vector cameraTargetPos = camera->getTarget()->getAbsCoor();
  • branches/cleanup/src/world_entities/space_ships/space_ship.cc

    r10591 r10593  
    11411141void SpaceShip::setCameraDistance(float dist)
    11421142{
    1143 
    1144   CameraMan* cm = State::getCameraman();
    1145   Camera* c = cm->getCurrentCam();
     1143  Camera* c = State::getCamera();
    11461144  c->setViewTopDistance(dist);
    11471145
     
    11531151{
    11541152
    1155   CameraMan* cm = State::getCameraman();
    1156   Camera* c = cm->getCurrentCam();
     1153  Camera* c = State::getCamera();
    11571154  c->setViewTopFovy(fovy);
    11581155
     
    11631160void SpaceShip::updateTravelDistance()
    11641161{
    1165      CameraMan* cm = State::getCameraman();
    1166      Camera* c = cm->getCurrentCam();
    1167 
     1162
     1163  Camera* c = State::getCamera();
    11681164
    11691165  float x = 1.25 * this->actionWidthPercentage * fabsf(c->getAbsCoor().y) * tan(c->getFovy()*M_PI /360.0);
  • branches/cleanup/src/world_entities/tools/cameraman.cc

    r10591 r10593  
    1   /*
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    1414*/
    1515
    16 #include "shell_command.h"
    1716#include "cameraman.h"
    18 #include "game_world_data.h"
    19 #include "state.h"
     17#include "blackscreen.h"
     18#include "loading/load_param_xml.h"
    2019#include "sound_engine.h"
    21 #include <string>
    2220#include "script_class.h"
    23 #include "loading/load_param_xml.h"
    24 #include "blackscreen.h"
    25 #include "p_node.h"
    26 #include "camera.h"
    2721
    2822ObjectListDefinition(CameraMan);
    2923
    30 SHELL_COMMAND(camerainfo, CameraMan, cameraInfo);
    31 
    32 
    3324CREATE_SCRIPTABLE_CLASS(CameraMan,
    34                         addMethod("changeCurrTarget", Executor2<CameraMan, lua_State*,const std::string&,const std::string&>(&CameraMan::changeCurrTarget))
    35                         ->addMethod("atachCurrCameraToWorldEntity", Executor2<CameraMan, lua_State*,const std::string&,const std::string&>(&CameraMan::atachCurrCameraToWorldEntity))
    36                         ->addMethod("changeTarget", Executor3<CameraMan, lua_State*, const std::string&, const std::string&,const std::string&>(&CameraMan::changeTarget))
    37                         ->addMethod("atachCameraToWorldEntity", Executor3<CameraMan, lua_State*,const std::string&,const std::string&,const std::string&>(&CameraMan::atachCameraToWorldEntity))
    38                         ->addMethod("detachCurrCamera", Executor0<CameraMan, lua_State*>(&CameraMan::detachCurrCamera))
    39                         ->addMethod("setCam", Executor1<CameraMan, lua_State*, const std::string&>(&CameraMan::setCam))
     25                        /// Camera management
     26                        addMethod("changeTarget", Executor3<CameraMan, lua_State*, const std::string&, const std::string&,const std::string&>(&CameraMan::changeTarget))
     27                        ->addMethod("attachCamera", Executor3<CameraMan, lua_State*,const std::string&,const std::string&,const std::string&>(&CameraMan::attachCamera))
     28                        ->addMethod("jumpCam", Executor4<CameraMan, lua_State*,const std::string&,float,float,float>(&CameraMan::jumpCam))
     29                        ->addMethod("moveCam", Executor4<CameraMan, lua_State*,const std::string&,float,float,float>(&CameraMan::moveCam))
     30                        ->addMethod("setRelCoor", Executor4<CameraMan, lua_State*,const std::string&,float,float,float>(&CameraMan::setRelCameraCoor))
     31                        ->addMethod("setRelCoorSoft", Executor5<CameraMan, lua_State*,const std::string&,float,float,float,float>(&CameraMan::setRelCameraCoorSoft))
     32                        ->addMethod("setCam", Executor1<CameraMan, lua_State*, const std::string&>(&CameraMan::setCam))
     33                        /// Current Camera
     34                        ->addMethod("changeCurrTarget", Executor2<CameraMan, lua_State*,const std::string&,const std::string&>(&CameraMan::changeCurrTarget))
     35                        ->addMethod("attachCurrCamera", Executor2<CameraMan, lua_State*,const std::string&,const std::string&>(&CameraMan::attachCurrCamera))
     36                        ->addMethod("jumpCurrCam", Executor3<CameraMan, lua_State*,float,float,float>(&CameraMan::jumpCurrCam))
     37                        ->addMethod("moveCurrCam", Executor3<CameraMan, lua_State*,float,float,float>(&CameraMan::moveCurrCam))
     38                        /// Fading
    4039                        ->addMethod("toggleFade", Executor0<CameraMan, lua_State*>(&CameraMan::togglFade))
    4140                        ->addMethod("initFadeBlack", Executor0<CameraMan, lua_State*>(&CameraMan::initFadeBlack))
     41                        /// Polling
    4242                        ->addMethod("getCurrCameraCoorX", Executor0ret<CameraMan, lua_State*,float>(&CameraMan::getCurrCameraCoorX))
    4343                        ->addMethod("getCurrCameraCoorY", Executor0ret<CameraMan, lua_State*,float>(&CameraMan::getCurrCameraCoorY))
    4444                        ->addMethod("getCurrCameraCoorZ", Executor0ret<CameraMan, lua_State*,float>(&CameraMan::getCurrCameraCoorZ))
    45                         ->addMethod("jumpCurrCam", Executor3<CameraMan, lua_State*,float,float,float>(&CameraMan::jumpCurrCam))
    46                         ->addMethod("jumpCam", Executor4<CameraMan, lua_State*,const std::string&,float,float,float>(&CameraMan::jumpCam))
    47                         //->addMethod("setViewMode", Executor2<CameraMan, lua_State*,const std::string&,const std::string&>(&CameraMan::setViewMode))
    48                         ->addMethod("setRelCoor", Executor4<CameraMan, lua_State*,const std::string&,float,float,float>(&CameraMan::setRelCameraCoor))
    49                         ->addMethod("setRelCoorSoft", Executor5<CameraMan, lua_State*,const std::string&,float,float,float,float>(&CameraMan::setRelCameraCoorSoft))
    50                         ->addMethod("pauseCamera", Executor2<CameraMan, lua_State*, const std::string&, bool>(&CameraMan::pauseCamera))
    5145                       );
    5246
    5347
     48
     49/**
     50 * constructor of the CameraManager
     51 */
    5452CameraMan::CameraMan(const TiXmlElement* root)
    5553{
     
    6159  this->fadeToBlack=new BlackScreen();
    6260
    63   this->setCam( State::getCamera());
     61  this->setCam( State::getCamera() );
    6462
    6563  if (root != NULL)
     
    6765}
    6866
    69 
     67/**
     68 *  Loads the parameters of the CameraManager from the xml file
     69 * @param root reference to the xml root element
     70 */
    7071void CameraMan::loadParams(const TiXmlElement* root)
    7172{
     
    7475}
    7576
    76 
     77/**
     78 *  Creates all the Cameras
     79 * @param root reference to the xml root element
     80 */
    7781void CameraMan::createCameras(const TiXmlElement* camerasTag)
    7882{
    79 
    8083    LOAD_PARAM_START_CYCLE(camerasTag, object);
    8184    {
     
    8386    }
    8487    LOAD_PARAM_END_CYCLE(object);
    85 
    86 }
    87 
    88 
     88}
     89
     90/**
     91 *  Creates a Camera from a xml node
     92 * @param root reference to the xml node
     93 */
    8994void CameraMan::createCam(const TiXmlElement* root)
    9095{
    91   this->cameras.push_back(new Camera(root));
    92   cameras[cameras.size()-1]->setClipRegion(nearClip, farClip);
    93 }
    94 
    95 /*void CameraMan::setViewMode(const std::string& cameraName, const std::string& viewMode)
    96 {
    97      BaseObject* newCam = ObjectListBase::getBaseObject("Camera", cameraName);
    98      
    99      if (!strcmp(viewMode, "ViewNormal"))
    100      {
    101          dynamic_cast<Camera*>(newCam)->setViewMode(Camera::ViewNormal);
    102      }
    103      else if (!strcmp(viewMode, "ViewTop"))
    104      {
    105          dynamic_cast<Camera*>(newCam)->setViewMode(Camera::ViewTop);
    106      }
    107      else if (!strcmp(viewMode, "ViewBehind"))
    108      {
    109          dynamic_cast<Camera*>(newCam)->setViewMode(Camera::ViewBehind);
    110      }
    111      else if (!strcmp(viewMode, "ViewFront"))
    112      {
    113          dynamic_cast<Camera*>(newCam)->setViewMode(Camera::ViewFront);
    114      }
    115      else if (!strcmp(viewMode, "ViewLeft"))
    116      {
    117          dynamic_cast<Camera*>(newCam)->setViewMode(Camera::ViewLeft);
    118      }
    119      else if (!strcmp(viewMode, "ViewRight"))
    120      {
    121          dynamic_cast<Camera*>(newCam)->setViewMode(Camera::ViewRight);
    122      }
    123 }*/
    124 
    125 void CameraMan::setRelCameraCoor(const std::string& camName, float x, float y, float z)
    126 {
    127      BaseObject* newCam = ObjectListBase::getBaseObject("Camera", camName);
    128      dynamic_cast<Camera*>(newCam)->setRelCoor(x,y,z);
    129      dynamic_cast<Camera*>(newCam)->target->setRelCoor(0,0,0);
    130 }
    131 
    132 void CameraMan::setRelCameraCoorSoft(const std::string& camName, float x, float y, float z, float bias)
    133 {
    134      BaseObject* newCam = ObjectListBase::getBaseObject("Camera", camName);
    135      dynamic_cast<Camera*>(newCam)->setRelCoorSoft(x,y,z,bias);
    136      dynamic_cast<Camera*>(newCam)->target->setRelCoorSoft(0,0,0,bias);
    137 }
    138 
    139 void CameraMan::pauseCamera(const std::string& camName, bool stop)
    140 {
    141      BaseObject* newCam = ObjectListBase::getBaseObject("Camera", camName);
    142      dynamic_cast<Camera*>(newCam)->pauseTrack(stop);
    143 }
    144 
    145 void CameraMan::setCam(unsigned int cameraNo)
    146 {
    147   if (cameraNo<cameras.size())
    148   {
    149     this->setCam( cameras[cameraNo]);
    150   }
    151 }
    152 
    153 void CameraMan::setCam(const std::string& camName)
    154 {
    155   BaseObject* object = ObjectListBase::getBaseObject("Camera", camName);
    156 
    157   if(object != NULL)
    158   {
    159     this->setCam(dynamic_cast<Camera*>(object));
     96  Camera* newCam = new Camera(root);
     97  newCam->setClipRegion(nearClip, farClip);
     98}
     99
     100/**
     101 *  Changes the target of a camera. (where the camera looks at)
     102 *
     103 * @param cameraName the name of the camera whose target is changed
     104 * @param className the class of the new target
     105 * @param objectName the name of the new target
     106 */
     107void CameraMan::changeTarget(const std::string& cameraName,const std::string& className, const std::string& objectName)
     108{
     109  BaseObject* object = ObjectListBase::getBaseObject(className, objectName);
     110  Camera* camera = Camera::objectList().getObject(cameraName);
     111
     112  if( object != NULL && camera != NULL && object->isA(PNode::staticClassID()))
     113  {
     114    camera->lookAt(dynamic_cast<PNode*>(object));
     115    State::setCamera( camera,  dynamic_cast<CameraTarget*>(object));
    160116    return;
    161117  }
    162   printf("ERROR CAMERAMANAGER: Couldn't set camera : %s \n", camName.c_str());
    163 }
    164 
    165 
    166 void CameraMan::setCam(Camera* camera)
    167 {
    168   if( camera == NULL)
     118
     119 printf("ERROR CAMERAMANAGER: Couldn't change target for camera %s to: %s %s \n", cameraName.c_str(), className.c_str(),objectName.c_str() );
     120
     121}
     122
     123/**
     124 *  Attaches a camera to a new pnode. (the camera follows the pnode)
     125 *
     126 * @param cameraName the name of the camera
     127 * @param className the class of the new parent node
     128 * @param objectName the name of the new parent node
     129 */
     130void CameraMan::attachCamera(const std::string& cameraName, const std::string& className, const std::string& targetEntity)
     131{
     132  BaseObject* object = ObjectListBase::getBaseObject(className, targetEntity);
     133  Camera* camera = Camera::objectList().getObject(cameraName);
     134
     135  if( object != NULL && camera != NULL && object->isA(PNode::staticClassID()) )
     136  {
     137    camera->target->atach(dynamic_cast<PNode*>(object));
     138    camera->setViewMode(Camera::ViewNormal);
     139    State::setCamera( camera,  dynamic_cast<CameraTarget*>(object));
     140    return;
     141  }
     142
     143  printf("ERROR CAMERAMANAGER: Couldn't attach camera %s to: %s %s \n", cameraName.c_str(), className.c_str(),targetEntity.c_str() );
     144
     145}
     146
     147
     148/**
     149 *  Sets a camera to a new position
     150 *
     151 * @param cameraName the name of the camera
     152 * @param x the new x coordinate
     153 * @param y the new y coordinate
     154 * @param z the new z coordinate
     155 */
     156void CameraMan::jumpCam(const std::string& cameraName, float x, float y, float z)
     157{
     158  Camera* camera = Camera::objectList().getObject(cameraName);
     159  if( camera != NULL )
     160  {
     161    camera->target->jump( x, y, z );
     162  }
     163}
     164
     165/**
     166 *  Moves a camera slowly to a new position
     167 *
     168 * @param cameraName the name of the camera
     169 * @param x the new x coordinate
     170 * @param y the new y coordinate
     171 * @param z the new z coordinate
     172 */
     173void CameraMan::moveCam(const std::string& cameraName, float x, float y, float z)
     174{
     175  Camera* camera = Camera::objectList().getObject(cameraName);
     176  if( camera != NULL )
     177  {
     178    camera->target->trans( x, y, z );
     179  }
     180}
     181
     182/**
     183 *  Sets the coordinate of a camera relative to its target.
     184 *
     185 * @param cameraName the name of the camera
     186 * @param x the new x coordinate
     187 * @param y the new y coordinate
     188 * @param z the new z coordinate
     189 */
     190void CameraMan::setRelCameraCoor(const std::string& cameraName, float x, float y, float z)
     191{
     192  Camera* camera = Camera::objectList().getObject(cameraName);
     193  camera->setRelCoor(x,y,z);
     194  camera->target->setRelCoor(0,0,0);
     195}
     196
     197/**
     198 *  Sets the coordinate of a camera relative to its target. (softly)
     199 *
     200 * @param cameraName the name of the camera
     201 * @param x the new x coordinate
     202 * @param y the new y coordinate
     203 * @param z the new z coordinate
     204 */
     205void CameraMan::setRelCameraCoorSoft(const std::string& cameraName, float x, float y, float z, float bias)
     206{
     207  Camera* newCam = Camera::objectList().getObject(cameraName);
     208  newCam->setRelCoor(x,y,z);
     209  newCam->target->setRelCoorSoft(0,0,0);
     210}
     211
     212/**
     213 *  Sets a new camera as the current one.
     214 *
     215 * @param cameraName the name of the new camera
     216 */
     217void CameraMan::setCam(const std::string& cameraName)
     218{
     219  Camera* camera = Camera::objectList().getObject(cameraName);
     220
     221  if(camera != NULL)
     222  {
     223    this->setCam(camera);
     224    return;
     225  }
     226  printf("ERROR CAMERAMANAGER: Couldn't set camera : %s \n", cameraName.c_str());
     227}
     228
     229/**
     230 *  Sets a new camera as the current one.
     231 *
     232 * @param camera a pointer to the new camera
     233 */
     234void CameraMan::setCam(Camera* newCamera)
     235{
     236  if( newCamera == NULL)
    169237  {
    170238    PRINTF(0)("trying to add a zero camera! uiuiui!\n");
     
    172240  }
    173241 
    174   this->currentCam = camera;
    175 
    176   State::setCamera(currentCam, currentCam->getTarget());
    177   OrxSound::SoundEngine::getInstance()->setListener(currentCam);
    178 
    179   // check if it is already added
    180   if( ! this->cameraIsInVector(currentCam) )
    181     this->cameras.push_back(currentCam);
     242  State::setCamera(newCamera, newCamera->getTarget());
     243  OrxSound::SoundEngine::getInstance()->setListener(newCamera);
    182244
    183245  this->fadeToBlack->setRelCoor(0., 0., 0.);
    184   this->fadeToBlack->setParent(this->currentCam);
    185 }
    186 
    187 
    188 void CameraMan::moveCurrCam(int x, int y, int z)
    189 {
    190   currentCam->target->trans(x,y,z);
    191 }
    192 
    193 
     246  this->fadeToBlack->setParent(newCamera);
     247
     248}
     249
     250/**
     251 *  Sets the clipregion of all the cameras
     252 *
     253 * @param nearClip the new near clip
     254 * @param nearClip the new far clip
     255 */
     256void CameraMan::setClipRegion(float nearClip, float farClip)
     257{
     258  this->nearClip=nearClip;
     259  this->farClip=farClip;
     260
     261  for (ObjectList<Camera>::const_iterator it = Camera::objectList().begin();
     262       it != Camera::objectList().end();
     263       ++it)
     264  {
     265     (*it)->setClipRegion(this->nearClip, this->farClip);
     266  }
     267}
     268
     269/**
     270 *  Changes the target of the current camera. (where the camera looks at)
     271 *
     272 * @param className the class of the new target
     273 * @param objectName the name of the new target
     274 */
    194275void CameraMan::changeCurrTarget(const std::string& className, const std::string& objectName)
    195276{
    196   BaseObject* object = ObjectListBase::getBaseObject(className, objectName);
    197   if( object != NULL && object->isA(PNode::staticClassID()))
    198   {
    199     currentCam->lookAt(dynamic_cast<PNode*>(object));
    200     State::setCamera(this->currentCam,  dynamic_cast<CameraTarget*>(object));
    201   }
    202 }
    203 
    204 
    205 void CameraMan::atachCurrCameraToWorldEntity(const std::string& className, const std::string& targetEntity)
    206 {
    207   BaseObject* object = ObjectListBase::getBaseObject(className, targetEntity);
    208 
    209   if(object != NULL && object->isA(PNode::staticClassID()))
    210   {
    211    this->atachTarget(this->currentCam, dynamic_cast<PNode*>(object));
    212    return;
    213   }
    214 
    215 printf("ERROR CAMERAMANAGER: Couldn't set camera to: %s %s \n", className.c_str(),targetEntity.c_str() );
    216 }
    217 
    218 
    219 
    220 void CameraMan::detachCurrCamera()
    221 {
    222   currentCam->target->detach();
    223 }
    224 
    225 
    226 
     277  this->changeTarget( (State::getCamera())->getName() , className, objectName);
     278}
     279
     280/**
     281 *  Attaches the current camera to a new pnode. (the camera follows the pnode)
     282 *
     283 * @param className the class of the new parent node
     284 * @param objectName the name of the new parent node
     285 */
     286void CameraMan::attachCurrCamera(const std::string& className, const std::string& targetEntity)
     287{
     288  this->attachCamera( (State::getCamera())->getName(), className,  targetEntity);
     289}
     290
     291/**
     292 *  Sets the current camera to a new position
     293 *
     294 * @param x the new x coordinate
     295 * @param y the new y coordinate
     296 * @param z the new z coordinate
     297 */
    227298void CameraMan::jumpCurrCam(float x, float y, float z)
    228299{
    229   currentCam->target->jump(x, y, z);
    230 }
    231 
     300  this->jumpCam((State::getCamera())->getName(), x, y, z);
     301}
     302
     303/**
     304 *  Moves the current camera slowly to a new position
     305 *
     306 * @param x the new x coordinate
     307 * @param y the new y coordinate
     308 * @param z the new z coordinate
     309 */
     310void CameraMan::moveCurrCam(float x, float y, float z)
     311{
     312  this->moveCam( (State::getCamera())->getName(), x, y, z);
     313}
     314
     315/**
     316 *  Toggles the fadestate (from in to out and via versa)
     317 */
    232318void CameraMan::togglFade()
    233319{
    234   if( this->fadeToBlack)
     320 if( this->fadeToBlack)
    235321    fadeToBlack->toggleFade();
    236322}
    237323
    238 
     324/**
     325 *  Sets the fadestate immediately to black (fade out)
     326 */
    239327void CameraMan::initFadeBlack()
    240328{
     
    242330    fadeToBlack->initFadeBlack();
    243331}
    244 
    245 
    246 void CameraMan::moveCam(int x, int y, int z, int camNo)
    247 {
    248   cameras[camNo]->target->trans(x,y,z);
    249 }
    250 
    251 
    252 void CameraMan::changeTarget(int camNo,const std::string& className, const std::string& objectName)
    253 {
    254   BaseObject* object = ObjectListBase::getBaseObject(className, objectName);
    255   if( object != NULL && object->isA(PNode::staticClassID()))
    256   {
    257     cameras[camNo]->lookAt(dynamic_cast<PNode*>(object));
    258   }
    259 }
    260 
    261 
    262 void CameraMan::changeTarget(const std::string& camName,const std::string& className, const std::string& objectName)
    263 {
    264   BaseObject* object = ObjectListBase::getBaseObject(className, objectName);
    265   BaseObject* newCam = ObjectListBase::getBaseObject("Camera", camName);
    266   if( object != NULL && newCam != NULL && object->isA(PNode::staticClassID()))
    267   {
    268     dynamic_cast<Camera*>(newCam)->lookAt(dynamic_cast<PNode*>(object));
    269     State::setCamera( dynamic_cast<Camera*>(newCam),  dynamic_cast<CameraTarget*>(object));
    270   }
    271 }
    272 
    273 
    274 void CameraMan::atachCameraToWorldEntity(const std::string& cameraName, const std::string& className, const std::string& targetEntity)
    275 {
    276   BaseObject* object = ObjectListBase::getBaseObject(className, targetEntity);
    277   BaseObject* targetCam = ObjectListBase::getBaseObject("Camera", cameraName);
    278 
    279   if( object != NULL && targetCam != NULL && object->isA(PNode::staticClassID()) )
    280   {
    281     this->atachTarget(dynamic_cast<Camera*>(targetCam), dynamic_cast<PNode*>( object ));
    282     return;
    283   }
    284 
    285   printf("ERROR CAMERAMANAGER: Couldn't set camera %s to: %s %s \n", cameraName.c_str(), className.c_str(),targetEntity.c_str() );
    286 }
    287 
    288 
    289 
    290 void CameraMan::jumpCam(int x, int y, int z, int camNo)
    291 {
    292   cameras[camNo]->target->jump(x, y, z);
    293 }
    294 
    295 
    296 void CameraMan::jumpCam(const std::string& cameraName, float x, float y, float z)
    297 {
    298   BaseObject* targetCam = ObjectListBase::getBaseObject("Camera", cameraName);
    299   if( targetCam != NULL )
    300   {
    301     dynamic_cast<Camera*>(targetCam)->target->jump( x, y, z );
    302   }
    303 
    304 }
    305 
    306 
    307 void CameraMan::setClipRegion(float nearCli, float farCli)
    308 {
    309   this->nearClip=nearCli;
    310   this->farClip=farCli;
    311 
    312   for(unsigned int i = 0; i < this->cameras.size(); i++)
    313     cameras[i]->setClipRegion(nearCli, farCli);
    314 }
    315 
    316 
    317 
    318 bool CameraMan::cameraIsInVector(Camera* camera)
    319 {
    320 
    321   for(std::vector<Camera*>::const_iterator it = cameras.begin(); it != cameras.end(); it++ )
    322   {
    323     if( (*it) == camera)
    324     {
    325       return true;
    326     }
    327   }
    328   return false;
    329 
    330 
    331 }
    332 
    333 
    334 void CameraMan::cameraInfo()
    335 {
    336   bool sameCam = (this->currentCam == State::getCamera());
    337 
    338 
    339   PRINT(0)("==== CameraMan::cameraInfo ===\n");
    340   PRINT(0)("=  Camera Name: %s\n", this->currentCam->getName().c_str());
    341   PRINT(0)("=  Tests:\n");
    342   PRINT(0)("==  State::Cam == this::Cam  %i\n", sameCam);
    343   PRINT(0)("==  Parenting Informations:\n");
    344   this->currentCam->debugNode(10);
    345   PRINT(0)("==============================\n");
    346 }
    347 
    348 
    349 float CameraMan::getCurrCameraCoorX()
    350 { return this->currentCam->getAbsCoorX(); }
    351 
    352 float CameraMan::getCurrCameraCoorY()
    353 { return this->currentCam->getAbsCoorY(); }
    354 
    355 float CameraMan::getCurrCameraCoorZ()
    356 { return this->currentCam->getAbsCoorZ(); }
    357 
    358 
    359 
    360 void CameraMan::atachTarget(Camera* cam ,PNode* target)
    361 {
    362   cam->target->atach(target);
    363   cam->setViewMode(Camera::ViewNormal);
    364   State::setCamera( cam,  dynamic_cast<CameraTarget*>(target));
    365 
    366 }
    367 
    368 //how to get a class fkt pointer
    369 
    370 //BaseObject* object = ObjectListBase::getBaseObject(className, objectName);
    371 
    372 
    373 
    374 
    375 
    376 
    377 
    378 
    379 
    380 
    381 
    382 
    383 
    384 
  • branches/cleanup/src/world_entities/tools/cameraman.h

    r10591 r10593  
    22#define _CAMERAMAN_H
    33
    4 
    5 #include <vector>
    64#include "base_object.h"
     5#include "state.h"
     6#include "camera.h"
    77
    88class BlackScreen;
     
    1111
    1212class CameraMan : public BaseObject {
     13
    1314  ObjectListDeclaration(CameraMan);
    1415
    15   private:
    16     Camera* currentCam;
    17     float nearClip;
    18     float farClip;
    19     BlackScreen* fadeToBlack;
    20 
    2116  public:
    22     std::vector<Camera*> cameras;
    2317    CameraMan(const TiXmlElement* root = NULL);
    24     void setCam(unsigned int CameraNo);
    25     void setCam(const std::string& camName);
    26     void setCam(Camera* camera);
    27 
    28     /// LOADING
     18 
     19    /// Loading
    2920    virtual void loadParams(const TiXmlElement* root);
    3021    void createCameras(const TiXmlElement* camerasTag);
    3122    void createCam(const TiXmlElement* root);
    3223
    33     /// POLLING
    34     float getCurrCameraCoorX();
    35     float getCurrCameraCoorY();
    36     float getCurrCameraCoorZ();
    37     const Camera* getCurrentCam() const { return this->currentCam; }
    38     Camera* getCurrentCam() { return this->currentCam; }
     24    /// Camera management
     25    void changeTarget(const std::string& cameraName,const std::string& className, const std::string& objectName);
     26    void attachCamera(const std::string& cameraName, const std::string& className, const std::string& targetEntity);
    3927
    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 atachCurrCameraToWorldEntity(const std::string& className, const std::string& targetEntity);
    45     void detachCurrCamera();
    46     void jumpCurrCam(float x, float y, float z);
    47     void togglFade();
    48     void initFadeBlack();
    49    
    50     /// Camera
    51     void moveCam(int x, int y, int z,  int camNo);
    52     void changeTarget(int camNo, const std::string& className,const std::string& objectName);
    53     void changeTarget(const std::string& camName,const std::string& className, const std::string& objectName);
    54     void atachCameraToWorldEntity(const std::string& cameraName, const std::string& className, const std::string& targetEntity);
    55     void jumpCam(int x, int y, int z, int camNo);
    5628    void jumpCam(const std::string& cameraName, float x, float y, float z);
     29    void moveCam(const std::string& cameraName, float x, float y, float z);
    5730    void setRelCameraCoor(const std::string& cameraName, float x, float y, float z);
    5831    void setRelCameraCoorSoft(const std::string& cameraName, float x, float y, float z, float bias);
    59     //void setViewMode(const std::string& camName, const std::string& viewMode);
    60     void pauseCamera(const std::string& camName, bool stop);
    61    
    62     void changeSpeed(float speed);
     32
     33    void setCam(const std::string& cameraName);
     34    void setCam(Camera* newCamera);
    6335    void setClipRegion(float nearClip, float farClip);
    64     void cameraInfo();
    65    
     36   
     37    /// Managing the current camera
     38    void changeCurrTarget(const std::string& className, const std::string& objectName);
     39    void attachCurrCamera(const std::string& className, const std::string& targetEntity);
     40    void jumpCurrCam(float x, float y, float z);
     41    void moveCurrCam(float x, float y, float z);
     42
     43    /// Fading
     44    void togglFade();
     45    void initFadeBlack();
     46
     47    /// Polling
     48    float getCurrCameraCoorX(){return (State::getCamera())->getAbsCoorX();}
     49    float getCurrCameraCoorY(){return (State::getCamera())->getAbsCoorY();}
     50    float getCurrCameraCoorZ(){return (State::getCamera())->getAbsCoorZ();}
     51    const std::string& getCurrCamName(){ return (State::getCamera())->getName(); }
     52
    6653  private:
    67     bool cameraIsInVector(Camera* camera);
    68     void atachTarget(Camera* cam, PNode* pnode);
     54    float nearClip;
     55    float farClip;
     56    BlackScreen* fadeToBlack;
    6957   
    7058
     
    7260
    7361#endif /* _CAMERAMAN_H */
     62 
  • branches/cleanup/src/world_entities/tools/scrolling_screen.cc

    r10591 r10593  
    257257    return;
    258258
    259   CameraMan* cm = State::getCameraman();
    260   const Camera* cam = cm->getCurrentCam();
     259  Camera* cam = State::getCamera();
    261260  PNode* tar = cam->getTargetNode();
    262261
Note: See TracChangeset for help on using the changeset viewer.