- Timestamp:
- Oct 27, 2008, 4:08:51 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/orxonox/objects/CameraHandler.cc
r2006 r2019 33 33 34 34 #include "core/ObjectList.h" 35 #include "core/Core.h" 35 36 #include "Camera.h" 36 37 #include "GraphicsEngine.h" … … 38 39 #include <OgreCamera.h> 39 40 40 namespace orxonox { 41 namespace orxonox 42 { 43 CameraHandler::CameraHandler() 44 { 45 // GraphicsEngine::getInstance().getViewport()->setCamera(this->cam_); 46 } 41 47 42 CameraHandler* CameraHandler::singletonRef = NULL; 48 CameraHandler& CameraHandler::getInstance() 49 { 50 static CameraHandler instance; 51 return instance; 52 } 43 53 44 CameraHandler::CameraHandler() 45 { 46 this->cam_ = GraphicsEngine::getInstance().getLevelSceneManager()->createCamera("Cam"); 47 GraphicsEngine::getInstance().getViewport()->setCamera(this->cam_); 48 this->cam_->setNearClipDistance(1); 49 //GraphicsEngine::getInstance().getRenderWindow()->addViewport(this->cam_, 2, 0.4, 0.4, 0.2, 0.2); 50 /*this->activeCamera_ = *ObjectList<Camera>::begin(); 51 this->activeCamera_->cam_ = this->cam_;*/ 52 } 54 Camera* CameraHandler::getActiveCamera() const 55 { 56 if (this->cameraList_.size() > 0) 57 return this->cameraList_.front(); 58 else 59 return 0; 60 } 53 61 54 void CameraHandler::requestFocus(Camera* requestCam) 55 { 56 // notify old camera (if it exists) 57 if(focusList_.size() > 0) 58 focusList_.back()->removeFocus(); 59 // add to list 60 focusList_.push_back(requestCam); 61 // set focus to new camera and update (if necessary) 62 if(!requestCam->hasFocus()) { 63 requestCam->setFocus(this->cam_); 64 requestCam->update(); 62 void CameraHandler::requestFocus(Camera* camera) 63 { 64 if (!Core::showsGraphics()) 65 return; 66 67 // notify old camera (if it exists) 68 if (this->cameraList_.size() > 0) 69 this->cameraList_.front()->removeFocus(); 70 71 // add to list 72 this->cameraList_.push_front(camera); 73 camera->setFocus(GraphicsEngine::getInstance().getViewport()); 65 74 } 66 // delete dublicates67 focusList_.unique();68 }69 75 70 void CameraHandler::releaseFocus(Camera* cam) 71 { 72 // notify the cam of releasing the focus 73 if(cam->hasFocus()) 74 cam->removeFocus(); 75 // delete camera from list 76 focusList_.remove(cam); 77 // set new focus if necessary 78 if(focusList_.size() > 0 && !(focusList_.back()->hasFocus())) 79 focusList_.back()->setFocus(this->cam_); 80 } 81 /* 82 void CameraHandler::changeActiveCamera(Camera* setCam) 83 { 84 cam_->getParentSceneNode()->detachObject(cam_); 85 //setCam->attachCamera(cam_); 86 activeCamera_ = setCam; 87 } 88 */ 89 /* bool isInVector(Camera* cam) 90 { 91 for(std::vector<Camera*>::iterator it = cams_.begin(); it != cams_.end(); it++) 76 void CameraHandler::releaseFocus(Camera* camera) 92 77 { 93 if (*it == cam) return true; 78 if (!Core::showsGraphics()) 79 return; 80 81 // notify the cam of releasing the focus 82 if (this->cameraList_.front() == camera) 83 { 84 camera->removeFocus(); 85 this->cameraList_.pop_front(); 86 87 // set new focus if necessary 88 if (cameraList_.size() > 0) 89 cameraList_.front()->setFocus(GraphicsEngine::getInstance().getViewport()); 90 } 91 else 92 { 93 this->cameraList_.remove(camera); 94 } 94 95 } 95 return false;96 }*/97 96 }
Note: See TracChangeset
for help on using the changeset viewer.