Changeset 926 for code/branches/network/src/orxonox
- Timestamp:
- Mar 26, 2008, 1:44:51 PM (17 years ago)
- Location:
- code/branches/network/src/orxonox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/orxonox/GraphicsEngine.cc
r919 r926 37 37 #include <OgreRenderWindow.h> 38 38 39 #include "core/CoreIncludes.h" 39 40 #include "core/Debug.h" 40 41 #include "GraphicsEngine.h" … … 47 48 GraphicsEngine::GraphicsEngine() 48 49 { 50 RegisterObject(GraphicsEngine); 51 //this->bOverwritePath_ = false; 52 this->setConfigValues(); 49 53 // set to standard values 50 54 this->configPath_ = ""; 51 this->dataPath_ = "";52 55 this->root_ = 0; 53 56 this->scene_ = 0; … … 58 61 GraphicsEngine::~GraphicsEngine() 59 62 { 63 } 64 65 void GraphicsEngine::setConfigValues() 66 { 67 SetConfigValue(dataPath_, dataPath_).description("relative path to media data"); 68 60 69 } 61 70 … … 90 99 } 91 100 92 bool GraphicsEngine::load( )101 bool GraphicsEngine::load(std::string dataPath) 93 102 { 103 // temporary overwrite of dataPath, change ini file for permanent change 104 if( dataPath != "" ) 105 dataPath_ = dataPath; 94 106 loadRessourceLocations(this->dataPath_); 95 107 if (!root_->restoreConfig() && !root_->showConfigDialog()) … … 103 115 this->renderWindow_ = root_->getAutoCreatedWindow(); 104 116 TextureManager::getSingleton().setDefaultNumMipmaps(5); 117 //TODO: Do NOT load all the groups, why are we doing that? And do we really do that? initialise != load... 105 118 ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); 106 119 } -
code/branches/network/src/orxonox/GraphicsEngine.h
r919 r926 14 14 15 15 #include "OrxonoxPrereqs.h" 16 #include "core/BaseObject.h" 16 17 17 18 … … 21 22 * graphics engine manager class 22 23 */ 23 class _OrxonoxExport GraphicsEngine { 24 class _OrxonoxExport GraphicsEngine : public BaseObject 25 { 24 26 public: 25 27 GraphicsEngine(); … … 27 29 // find a better way for this 28 30 inline Ogre::Root* getRoot() { return root_; }; 31 void setConfigValues(); 29 32 void setup(); 30 bool load( );33 bool load(std::string path); 31 34 void loadRessourceLocations(std::string path); 32 35 Ogre::SceneManager* getSceneManager(); … … 45 48 Ogre::SceneManager* scene_; //!< scene manager of the game 46 49 Ogre::RenderWindow* renderWindow_;//!< the current render window 50 //bool bOverwritePath_; //!< overwrites path 47 51 48 52 }; -
code/branches/network/src/orxonox/Orxonox.cc
r923 r926 35 35 36 36 //****** OGRE ****** 37 #include <OgreException.h>37 //#include <OgreException.h> 38 38 #include <OgreFrameListener.h> 39 39 #include <OgreRoot.h> 40 #include <OgreRenderWindow.h>41 #include <OgreTextureManager.h>42 #include <OgreResourceGroupManager.h>43 #include <OgreConfigFile.h>44 40 #include <OgreOverlay.h> 45 41 #include <OgreOverlayManager.h> … … 47 43 #include <OgreWindowEventUtilities.h> 48 44 49 //****** OIS *******50 #include <OIS/OIS.h>51 52 45 //****** STD ******* 53 #include <iostream> 54 #include <exception> 46 //#include <iostream> 47 //#include <exception> 48 #include <deque> 55 49 56 50 //***** ORXONOX **** 57 51 //misc 58 #include "util/Sleep.h"52 //#include "util/Sleep.h" 59 53 60 54 // audio … … 68 62 69 63 // objects 70 #include "tools/Timer.h"71 64 #include "core/ArgReader.h" 72 65 #include "core/Debug.h" … … 75 68 #include "core/Tickable.h" 76 69 #include "hud/HUD.h" 70 #include "tools/Timer.h" 77 71 #include "objects/weapon/BulletManager.h" 78 72 … … 83 77 namespace orxonox 84 78 { 85 /// init static singleton reference of Orxonox86 Orxonox* Orxonox::singletonRef_ = NULL;87 88 79 /** 89 80 * create a new instance of Orxonox … … 94 85 this->dataPath_ = ""; 95 86 this->auMan_ = 0; 96 this->singletonRef_ = 0;97 //this->keyboard_ = 0;98 //this->mouse_ = 0;99 //this->inputManager_ = 0;100 87 this->inputHandler_ = 0; 101 this->frameListener_ = 0;102 88 this->root_ = 0; 103 // turn frame smoothing onby setting a value different from 089 // turn on frame smoothing by setting a value different from 0 104 90 this->frameSmoothingTime_ = 0.0f; 105 91 this->bAbort_ = false; … … 126 112 //TODO: give config file to Ogre 127 113 std::string mode; 128 129 114 130 115 ArgReader ar = ArgReader(argc, argv); 131 116 ar.checkArgument("mode", mode, false); … … 197 182 Factory::createClassHierarchy(); 198 183 createScene(); 199 setupScene();200 184 setupInputSystem(); 201 185 … … 211 195 Factory::createClassHierarchy(); 212 196 createScene(); 213 setupScene();214 197 setupInputSystem(); 215 198 … … 222 205 Orxonox* Orxonox::getSingleton() 223 206 { 224 if (!singletonRef_) 225 singletonRef_ = new Orxonox(); 226 return singletonRef_; 207 static Orxonox theOnlyInstance; 208 return &theOnlyInstance; 227 209 } 228 210 … … 252 234 ogre_->setup(); 253 235 root_ = ogre_->getRoot(); 254 if(!ogre_->load( )) die(/* unable to load */);236 if(!ogre_->load(this->dataPath_)) die(/* unable to load */); 255 237 256 238 server_g = new network::Server(); … … 267 249 else 268 250 client_g = new network::Client(serverIp_, NETWORK_PORT); 269 if(!ogre_->load( )) die(/* unable to load */);251 if(!ogre_->load(this->dataPath_)) die(/* unable to load */); 270 252 } 271 253 … … 277 259 ogre_->setup(); 278 260 root_ = ogre_->getRoot(); 279 if(!ogre_->load()) die(/* unable to load */); 280 } 281 282 void Orxonox::defineResources() 283 { 284 std::string secName, typeName, archName; 285 Ogre::ConfigFile cf; 286 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE 287 cf.load(macBundlePath() + "/Contents/Resources/resources.cfg"); 288 #else 289 cf.load(dataPath_ + "resources.cfg"); 290 #endif 291 292 Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator(); 293 while (seci.hasMoreElements()) 294 { 295 secName = seci.peekNextKey(); 296 Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext(); 297 Ogre::ConfigFile::SettingsMultiMap::iterator i; 298 for (i = settings->begin(); i != settings->end(); ++i) 299 { 300 typeName = i->first; 301 archName = i->second; 302 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE 303 Ogre::ResourceGroupManager::getSingleton().addResourceLocation( std::string(macBundlePath() + "/" + archName), typeName, secName); 304 #else 305 Ogre::ResourceGroupManager::getSingleton().addResourceLocation( archName, typeName, secName); 306 #endif 307 } 308 } 309 } 310 311 void Orxonox::setupRenderSystem() 312 { 313 if (!root_->restoreConfig() && !root_->showConfigDialog()) 314 throw Ogre::Exception(52, "User canceled the config dialog!", "OrxApplication::setupRenderSystem()"); 315 } 316 317 void Orxonox::createRenderWindow() 318 { 319 root_->initialise(true, "OrxonoxV2"); 320 } 321 322 void Orxonox::initializeResourceGroups() 323 { 324 Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5); 325 Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); 261 if(!ogre_->load(this->dataPath_)) die(/* unable to load */); 326 262 } 327 263 328 264 void Orxonox::createScene(void) 329 265 { 330 // Init audio266 // Init audio 331 267 auMan_ = new audio::AudioManager(); 332 268 … … 334 270 335 271 // load this file from config 336 // loader_ = new loader::LevelLoader("sample.oxw");337 // loader_->loadLevel();338 272 Level* startlevel = new Level("levels/sample.oxw"); 339 273 Loader::open(startlevel); 340 274 341 275 Ogre::Overlay* hudOverlay = Ogre::OverlayManager::getSingleton().getByName("Orxonox/HUD1.2"); 342 //HUD* orxonoxHud;343 276 orxonoxHUD_ = new HUD(); 344 277 orxonoxHUD_->setEnergyValue(20); … … 350 283 auMan_->ambientAdd("a2"); 351 284 auMan_->ambientAdd("a3"); 352 285 //auMan->ambientAdd("ambient1"); 353 286 auMan_->ambientStart();*/ 354 }355 356 357 void Orxonox::setupScene()358 {359 // SceneManager *mgr = ogre_->getSceneManager();360 361 362 // SceneNode* node = (SceneNode*)mgr->getRootSceneNode()->getChild("OgreHeadNode");363 // SceneNode *node = mgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode", Vector3(0,0,0));364 365 366 /*367 particle::ParticleInterface *e = new particle::ParticleInterface(mgr,"engine","Orxonox/strahl");368 e->particleSystem_->setParameter("local_space","true");369 e->setPositionOfEmitter(0, Vector3(0,-10,0));370 e->setDirection(Vector3(0,0,-1));371 e->addToSceneNode(node);372 */373 287 } 374 288 -
code/branches/network/src/orxonox/Orxonox.h
r922 r926 9 9 10 10 #include <string> 11 #include <deque>12 11 13 12 #include <OgrePrerequisites.h> 14 #include <OIS/OISPrereqs.h>13 //#include <OIS/OISPrereqs.h> 15 14 16 15 #include "OrxonoxPrereqs.h" … … 43 42 inline GraphicsEngine* getOgrePointer() { return ogre_; }; 44 43 inline audio::AudioManager* getAudioManagerPointer() { return auMan_; }; 45 //inline OIS::Keyboard* getKeyboard() { return this->keyboard_; }46 //inline OIS::Mouse* getMouse() { return this->mouse_; }47 44 inline BulletManager* getBulletMgr() { return this->bulletMgr_; } 48 45 … … 58 55 void clientStart(); 59 56 void standaloneStart(); 60 void defineResources(); 61 void setupRenderSystem(); 62 void createRenderWindow(); 63 void initializeResourceGroups(); 57 64 58 void createScene(void); 65 void setupScene();66 59 void setupInputSystem(); 67 60 void startRenderLoop(); 68 void updateTimers(float);69 61 float calculateEventTime(unsigned long, std::deque<unsigned long>&); 70 62 … … 74 66 GraphicsEngine* ogre_; //!< our dearest graphics engine <3 75 67 std::string dataPath_; //!< path to data 76 // loader::LevelLoader* loader_; //!< level loader builds the scene77 68 audio::AudioManager* auMan_; //!< audio manager 78 69 BulletManager* bulletMgr_; //!< Keeps track of the thrown bullets 79 static Orxonox* singletonRef_;80 70 InputHandler* inputHandler_; 81 //OIS::Keyboard* keyboard_;82 //OIS::Mouse* mouse_;83 //OIS::InputManager* inputManager_;84 OrxListener* frameListener_;85 71 Ogre::Root* root_; 86 72 // TODO: make this a config-value by creating a config class for orxonox … … 88 74 // little hack to actually show something dynamic in the HUD 89 75 HUD* orxonoxHUD_; 90 bool bAbort_; 76 bool bAbort_; //!< aborts the render loop if true 91 77 92 78 // this is used to identify the mode (server/client/...) we're in
Note: See TracChangeset
for help on using the changeset viewer.