Changeset 2023 for code/branches/objecthierarchy/src/orxonox/objects
- Timestamp:
- Oct 27, 2008, 10:56:51 PM (16 years ago)
- Location:
- code/branches/objecthierarchy/src/orxonox/objects
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/orxonox/objects/Camera.cc
r2019 r2023 29 29 #include "OrxonoxStableHeaders.h" 30 30 #include "Camera.h" 31 #include "CameraHandler.h"32 31 33 32 #include <string> 34 33 #include <cassert> 35 34 35 #include <OgreCamera.h> 36 36 #include <OgreSceneManager.h> 37 37 #include <OgreSceneNode.h> 38 #include <OgreRenderWindow.h>39 38 #include <OgreViewport.h> 40 39 41 #include "tinyxml/tinyxml.h"42 #include "util/SubString.h"43 #include "util/Math.h"44 #include "util/String.h"45 #include "util/Debug.h"46 40 #include "core/CoreIncludes.h" 47 41 #include "core/ConfigValueIncludes.h" 48 #include "GraphicsEngine.h"49 42 #include "objects/Scene.h" 43 #include "objects/CameraHandler.h" 50 44 51 45 namespace orxonox -
code/branches/objecthierarchy/src/orxonox/objects/Camera.h
r2019 r2023 30 30 #define _Camera_H__ 31 31 32 #include "OrxonoxPrereqs.h" 33 32 34 #include <OgrePrerequisites.h> 33 #include <OgreSceneNode.h>34 #include <OgreCamera.h>35 36 #include "OrxonoxPrereqs.h"37 35 #include "objects/worldentities/PositionableEntity.h" 38 36 #include "objects/Tickable.h" -
code/branches/objecthierarchy/src/orxonox/objects/CameraHandler.cc
r2019 r2023 29 29 #include "CameraHandler.h" 30 30 31 #include <OgreSceneManager.h> 32 #include <OgreRenderWindow.h> 31 #include <OgreViewport.h> 33 32 34 #include "core/ObjectList.h"35 33 #include "core/Core.h" 36 34 #include "Camera.h" 37 #include "GraphicsEngine.h"38 35 39 #include <OgreCamera.h>40 36 41 37 namespace orxonox 42 38 { 43 CameraHandler::CameraHandler() 39 CameraHandler* CameraHandler::singletonRef_s = 0; 40 41 CameraHandler::CameraHandler(Ogre::Viewport* viewport) 42 : viewport_(viewport) 44 43 { 45 // GraphicsEngine::getInstance().getViewport()->setCamera(this->cam_); 44 assert(singletonRef_s == 0); 45 singletonRef_s = this; 46 46 } 47 47 48 CameraHandler & CameraHandler::getInstance()48 CameraHandler::~CameraHandler() 49 49 { 50 static CameraHandler instance;51 return instance;50 assert(singletonRef_s != 0); 51 singletonRef_s = 0; 52 52 } 53 53 … … 71 71 // add to list 72 72 this->cameraList_.push_front(camera); 73 camera->setFocus( GraphicsEngine::getInstance().getViewport());73 camera->setFocus(this->viewport_); 74 74 } 75 75 … … 87 87 // set new focus if necessary 88 88 if (cameraList_.size() > 0) 89 cameraList_.front()->setFocus( GraphicsEngine::getInstance().getViewport());89 cameraList_.front()->setFocus(this->viewport_); 90 90 } 91 91 else -
code/branches/objecthierarchy/src/orxonox/objects/CameraHandler.h
r2019 r2023 38 38 #include "OrxonoxPrereqs.h" 39 39 40 #include <cassert> 40 41 #include <list> 41 #include <OgreCamera.h> 42 43 #include "core/BaseObject.h" 42 #include <OgrePrerequisites.h> 44 43 45 44 namespace orxonox … … 48 47 { 49 48 public: 50 static CameraHandler& getInstance(); 49 CameraHandler(Ogre::Viewport* viewport); 50 ~CameraHandler(); 51 51 52 52 Camera* getActiveCamera() const; … … 55 55 void releaseFocus(Camera* camera); 56 56 57 static CameraHandler& getInstance() { assert(singletonRef_s); return *singletonRef_s; } 58 57 59 private: 58 CameraHandler(); 59 ~CameraHandler() {} 60 CameraHandler(const CameraHandler&); 60 61 61 62 std::list<Camera*> cameraList_; 63 Ogre::Viewport* viewport_; 64 65 static CameraHandler* singletonRef_s; 62 66 }; 63 67 } -
code/branches/objecthierarchy/src/orxonox/objects/Scene.cc
r2019 r2023 31 31 32 32 #include <OgreRoot.h> 33 #include <OgreSceneManager .h>33 #include <OgreSceneManagerEnumerator.h> 34 34 #include <OgreSceneNode.h> 35 35 #include <OgreLight.h> 36 36 37 37 #include "core/CoreIncludes.h" 38 #include "core/Core.h" 38 39 #include "core/XMLPort.h" 39 40 … … 49 50 this->bShadows_ = false; 50 51 51 if ( Ogre::Root::getSingletonPtr())52 if (Core::showsGraphics()) 52 53 { 53 this->sceneManager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC); 54 this->rootSceneNode_ = this->sceneManager_->getRootSceneNode(); 54 if (Ogre::Root::getSingletonPtr()) 55 { 56 this->sceneManager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC); 57 this->rootSceneNode_ = this->sceneManager_->getRootSceneNode(); 58 } 59 else 60 { 61 this->sceneManager_ = 0; 62 this->rootSceneNode_ = 0; 63 } 55 64 } 56 65 else 57 66 { 58 this->sceneManager_ = 0; 59 this->rootSceneNode_ = 0; 67 // create a dummy SceneManager of our own since we don't have Ogre::Root. 68 this->sceneManager_ = new Ogre::DefaultSceneManager(""); 69 this->rootSceneNode_ = this->sceneManager_->getRootSceneNode(); 60 70 } 61 71 62 72 // test test test 63 if ( this->sceneManager_)73 if (Core::showsGraphics() && this->sceneManager_) 64 74 { 65 75 Ogre::Light* light; … … 80 90 Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_); 81 91 } 82 else 92 else if (!Core::showsGraphics()) 83 93 { 94 delete this->sceneManager_; 84 95 } 85 96 } … … 104 115 void Scene::setSkybox(const std::string& skybox) 105 116 { 106 if ( this->sceneManager_)117 if (Core::showsGraphics() && this->sceneManager_) 107 118 this->sceneManager_->setSkyBox(true, skybox); 108 119 … … 112 123 void Scene::setAmbientLight(const ColourValue& colour) 113 124 { 114 if ( this->sceneManager_)125 if (Core::showsGraphics() && this->sceneManager_) 115 126 this->sceneManager_->setAmbientLight(colour); 116 127 … … 120 131 void Scene::setShadow(bool bShadow) 121 132 { 122 if ( this->sceneManager_)133 if (Core::showsGraphics() && this->sceneManager_) 123 134 { 124 135 if (bShadow) -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/WorldEntity.cc
r2019 r2023 37 37 #include "util/Convert.h" 38 38 39 #include "GraphicsEngine.h"40 39 #include "objects/Scene.h" 41 40
Note: See TracChangeset
for help on using the changeset viewer.