Gwagle::OCDocument::OCDocument() : Gwagle::Document() { // Init 3D Engine and GUI this->initOgre(); this->initCEGUI(); // ... } Gwagle::OCDocument::~OCDocument() { // ... } //============================================================================= // Init components void Gwagle::OCDocument::initOgre() { // --- Init engine + resources --- this->mRoot = new Ogre::Root("plugins.cfg", "display.cfg", "log.txt"); mRoot->addResourceLocation("meshes", "FileSystem"); mRoot->addResourceLocation("materials", "FileSystem"); mRoot->addResourceLocation("textures", "FileSystem"); mRoot->addResourceLocation("gui", "FileSystem"); Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); // --- Choose config --- if (! this->noConfig() ) return; //this->showConfig(); // --- Create window + scene --- this->mWindow = mRoot->initialise(true, WIN_TITLE); this->mSceneMgr = mRoot->getSceneManager(Ogre::ST_GENERIC); mSceneMgr->setAmbientLight( Ogre::ColourValue(1.0, 1.0, 1.0) ); // --- FrameListener --- mRoot->addFrameListener(this); // --- Processing events --- Ogre::EventProcessor* mEventProcessor = new Ogre::EventProcessor(); mEventProcessor->initialise(mWindow); mEventProcessor->startProcessingEvents(); mEventProcessor->addKeyListener(this); mEventProcessor->addMouseListener(this); mEventProcessor->addMouseMotionListener(this); // --- Add input reader --- mInputDevice = Ogre::PlatformManager::getSingleton().createInputReader(); mInputDevice->initialise(mWindow, true, true); // --- Create camera --- this->mCamera = mSceneMgr->createCamera("Cam"); this->resetCamera(); // --- Create viewport --- Ogre::Viewport* vp = mWindow->addViewport(mCamera); vp->setBackgroundColour( Ogre::ColourValue(0,0,0) ); mCamera->setAspectRatio( Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()) ); // --- SceneQuery related --- mRayQuery = mSceneMgr->createRayQuery( Ogre::Ray() ); // ... } void Gwagle::OCDocument::initCEGUI() { // ... } void Gwagle::OCDocument::initModel() { // Clear scene manager mSceneMgr->clearScene(); // Main object (ought to. TODO) node = mSceneMgr->getRootSceneNode()->createChildSceneNode("modular"); // Boring default position Ogre::Vector3 pos = Ogre::Vector3::ZERO; // ... // Just a test Ogre::ParticleSystem* partSys = mSceneMgr->createParticleSystem("TestParticle", "MemePart/1"); Ogre::SceneNode* partSN = mSceneMgr->getRootSceneNode()->createChildSceneNode("Particle"); partSN->attachObject(partSys); } //============================================================================= // Startup options bool Gwagle::OCDocument::showConfig() { return mRoot->showConfigDialog(); } // UGLY bool Gwagle::OCDocument::noConfig() { Ogre::RenderSystemList *rsList = mRoot->getAvailableRenderers(); int c=0; bool foundit = false; Ogre::RenderSystem *selectedRenderSystem=0; while(c < (int) rsList->size()){ selectedRenderSystem = rsList->at(c); Ogre::String rname = selectedRenderSystem->getName(); if(rname.compare(OGRE_RENDERER) == 0){ foundit=true; break; } c++; // <-- oh how clever } if(!foundit) return false; //we didn't find it... //we found it, we might as well use it! mRoot->setRenderSystem(selectedRenderSystem); selectedRenderSystem->setConfigOption("Full Screen", "No"); selectedRenderSystem->setConfigOption("Video Mode", "800 x 600 @ 16-bit colour"); //retrieve the config option map Ogre::ConfigOptionMap comap = selectedRenderSystem->getConfigOptions(); Ogre::ConfigOptionMap::const_iterator start = comap.begin(); Ogre::ConfigOptionMap::const_iterator end = comap.end(); while(start != end){ Ogre::String OptionName = start->first; Ogre::String CurrentValue = start->second.currentValue; Ogre::StringVector PossibleValues = start->second.possibleValues; int c=0; while (c < (int) PossibleValues.size()){ Ogre::String OneValue = PossibleValues.at(c); c++; } start++; } return (true); }