本文整理汇总了C++中ogre::configfile::SectionIterator::getNext方法的典型用法代码示例。如果您正苦于以下问题:C++ SectionIterator::getNext方法的具体用法?C++ SectionIterator::getNext怎么用?C++ SectionIterator::getNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::configfile::SectionIterator
的用法示例。
在下文中一共展示了SectionIterator::getNext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupResources
//-------------------------------------------------------------------------------------
void BaseApplication::setupResources(void)
{
// Load resource paths from config file
Ogre::ConfigFile cf;
cf.load(mResourcesCfg);
// Go through all sections & settings in the file
Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
Ogre::String secName, typeName, archName;
while (seci.hasMoreElements())
{
secName = seci.peekNextKey();
Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
Ogre::ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); ++i)
{
typeName = i->first;
archName = i->second;
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
archName, typeName, secName);
}
}
}
示例2: setupResources
void RenderPump::setupResources()
{
Ogre::ConfigFile cf;
#if OGRE_DEBUG_MODE
cf.load("resources_d.cfg");
#else
cf.load("resources.cfg");
#endif
Ogre::ConfigFile::SectionIterator secIter = cf.getSectionIterator();
Ogre::String secName, typeName, archName;
while(secIter.hasMoreElements())
{
secName = secIter.peekNextKey();
Ogre::ConfigFile::SettingsMultiMap *settings = secIter.getNext();
Ogre::ConfigFile::SettingsMultiMap::iterator i;
for(i=settings->begin(); i!=settings->end(); i++)
{
typeName = i->first;
archName = i->second;
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
archName, typeName, secName);
}
}
}
示例3: initOgre
bool OgreFramework::initOgre(Ogre::String wndTitle, OIS::KeyListener *pKeyListener, OIS::MouseListener *pMouseListener)
{
// PTR TuanNA [Create and initiate the Log- 10/7/2016]
Ogre::LogManager* logMgr = new Ogre::LogManager();
m_pLog = Ogre::LogManager::getSingleton().createLog("OgreLogfile.log", true, true, false);
m_pLog->setDebugOutputEnabled(true);
// PTR TuanNA [Create an Ogre Root- 10/7/2016]
m_pRoot = new Ogre::Root();
//PTR TuanNA begin comment
//[Add icon to app- 10/7/2016]
if(m_pRoot->showConfigDialog())
{
// If returned true, user clicked OK so initialise
// Here we choose to let the system create a default rendering window by passing 'true'
m_pRenderWnd = m_pRoot->initialise(true, "OgreFramework Render Window");
// Let's add a nice window icon
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
HWND hwnd;
m_pRenderWnd->getCustomAttribute("WINDOW", (void*)&hwnd);
LONG iconID = (LONG)LoadIcon( GetModuleHandle(0), MAKEINTRESOURCE(IDI_APPICON) );
SetClassLong( hwnd, GCL_HICON, iconID );
#endif
//PTR TuanNA end comment
// PTR TuanNA [Remove CM m_pRenderWnd- 10/7/2016] m_pRenderWnd = m_pRoot->initialise(true, wndTitle);
// PTR TuanNA [Add a viewport the to Render window- 11/7/2016]
m_pViewport = m_pRenderWnd->addViewport(0);
m_pViewport->setBackgroundColour(ColourValue(0.5f, 0.5f, 0.5f, 1.0f));
m_pViewport->setCamera(0);
//PTR TuanNA- Init Ogre Render Window... [16:37:20 4/9/2016 by TNA]
size_t hWnd = 0;
OIS::ParamList paramList;
m_pRenderWnd->getCustomAttribute("WINDOW", &hWnd);
paramList.insert(OIS::ParamList::value_type("WINDOW", Ogre::StringConverter::toString(hWnd)));
// PTR TuanNA [Create Input System- 11/7/2016]
m_pInputMgr = OIS::InputManager::createInputSystem(paramList);
m_pKeyboard = static_cast<OIS::Keyboard*>(m_pInputMgr->createInputObject(OIS::OISKeyboard, true));
m_pMouse = static_cast<OIS::Mouse*>(m_pInputMgr->createInputObject(OIS::OISMouse, true));
m_pMouse->getMouseState().height = m_pRenderWnd->getHeight();
m_pMouse->getMouseState().width = m_pRenderWnd->getWidth();
if(pKeyListener == 0)
m_pKeyboard->setEventCallback(this);
else
m_pKeyboard->setEventCallback(pKeyListener);
if(pMouseListener == 0)
m_pMouse->setEventCallback(this);
else
m_pMouse->setEventCallback(pMouseListener);
Ogre::String secName, typeName, archName;
Ogre::ConfigFile cf;
#ifdef _DEBUG
cf.load("resources_d.cfg");
#else
cf.load("resources.cfg");
#endif
Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
while (seci.hasMoreElements())
{
secName = seci.peekNextKey();
Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
Ogre::ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); ++i)
{
typeName = i->first;
archName = i->second;
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName);
}
}
// PTR TuanNA [Configure the amount of MipMaps per texture(to avoid aliasing).- 11/7/2016]
Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
/*
//PTR TuanNA begin comment
////Load cursor resources
Ogre::ResourceGroupManager::getSingleton().createResourceGroup("Cursor");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../Media/Cursor.zip","Zip","Cursor");
Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("Cursor");
//Create the GUI handler
mpGui = new GuiHandler(mpRenderWnd);
#ifdef DEBUG
loadDebugResources();
mpGui->initDebugGui();
#endif
//.........这里部分代码省略.........
示例4: go
bool BasicWindow::go(void) {
// 1. define the root object:
mRoot = new Ogre::Root(mPluginsFileName);
// 2. define the resources that ogre will use:
Ogre::ConfigFile configFile;
configFile.load(mResourcesFileName);
Ogre::ConfigFile::SectionIterator sectionsIter = configFile.getSectionIterator();
Ogre::ConfigFile::SettingsMultiMap::iterator settingsIter;
Ogre::ConfigFile::SettingsMultiMap* settings;
Ogre::String secName, typeName, archName;
while(sectionsIter.hasMoreElements()) {
secName = sectionsIter.peekNextKey();
settings = sectionsIter.getNext();
for (settingsIter=settings->begin(); settingsIter!=settings->end(); ++settingsIter) {
typeName = settingsIter->first;
archName = settingsIter->second;
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName);
}
}
// 3. choose and setup the render system:
if (!(mRoot->restoreConfig() || mRoot->showConfigDialog())) {
return false;
}
// 4. create the render window:
mWindow = mRoot->initialise(true, "Testing");
// 5. initialise the required resources:
Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
// 6. setup scene:
mSceneMgr = mRoot->createSceneManager("DefaultSceneManager");
mCamera = mSceneMgr->createCamera("mCamera");
mCamera->setNearClipDistance(1);
//mCamera->setFarClipDistance(10000);
mCameraMan = new OgreBites::SdkCameraMan(mCamera);
Ogre::Viewport* vp = mWindow->addViewport(mCamera);
//vp->setBackgroundColour(Ogre::ColourValue(1, 1, 1));
mCamera->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));
mCameraNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("cameraNode");
mCameraNode->attachObject(mCamera);
createGUI();
createScene();
// 7. setup 3rd party libraries and plugins:
Utils::log("*** Initialising OIS ***");
OIS::ParamList paramList;
size_t windowHandle = 0;
std::ostringstream windowHandleString;
mWindow->getCustomAttribute("WINDOW", &windowHandle);
windowHandleString << windowHandle;
paramList.insert(std::make_pair(std::string("WINDOW"), windowHandleString.str()));
mInputManager = OIS::InputManager::createInputSystem(paramList);
mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, true));
mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject(OIS::OISMouse, true));
windowResized(mWindow); //<- sets mouse clipping size
// 8. add listeners and callbacks:
Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this);
mRoot->addFrameListener(this);
mMouse->setEventCallback(this);
mKeyboard->setEventCallback(this);
// 9. start the render loop
mRoot->startRendering();
return true;
}
示例5: InitOgre
BOOL InitOgre()
{
using namespace Ogre;
#ifdef _DEBUG
mOgreRoot = new Ogre::Root("plugins_d.cfg", "OgreMFC.cfg", "OgreMFC.log");
#else
mOgreRoot = new Ogre::Root("plugins.cfg", "OgreMFC.cfg", "OgreMFC.log");
#endif
//
// Setup paths to all resources
//
Ogre::ConfigFile cf;
cf.load("resources_d.cfg");
// Go through all sections & settings in the file
Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
String secName, typeName, archName;
while (seci.hasMoreElements())
{
secName = seci.peekNextKey();
ConfigFile::SettingsMultiMap *settings = seci.getNext();
ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); ++i)
{
typeName = i->first;
archName = i->second;
ResourceGroupManager::getSingleton().addResourceLocation( archName, typeName, secName);
}
}
const RenderSystemList& render = mOgreRoot->getAvailableRenderers();
RenderSystemList::const_iterator pRend = render.begin();
while (pRend != render.end())
{
Ogre::String rName = (*pRend)->getName();
//if (rName == "OpenGL Rendering Subsystem") //
if (rName == "Direct3D9 Rendering Subsystem") //Direct3D9 Rendering Subsystem
break;
pRend++;
}
if (pRend == render.end())
{
// Unrecognised render system
//MessageBox("Unable to locate OpenGL rendering system. Application is terminating");
return FALSE;
}
Ogre::RenderSystem *rsys = *pRend;
rsys->setConfigOption("Full Screen", "No");
rsys->setConfigOption("VSync", "Yes");
// Set the rendering system.
mOgreRoot->setRenderSystem(rsys);
//
// Initialize the system, but don't create a render window.
//
mOgreRoot->initialise(false);
return TRUE;
}
示例6: go
bool MinimalOgre::go(void)
{
#ifdef _DEBUG
mResourcesCfg = "resources_d.cfg";
mPluginsCfg = "plugins_d.cfg";
#else
mResourcesCfg = "resources.cfg";
mPluginsCfg = "plugins.cfg";
#endif
// construct Ogre::Root
mRoot = new Ogre::Root(mPluginsCfg);
//-------------------------------------------------------------------------------------
// setup resources
// Load resource paths from config file
Ogre::ConfigFile cf;
cf.load(mResourcesCfg);
// Go through all sections & settings in the file
Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
Ogre::String secName, typeName, archName;
while (seci.hasMoreElements())
{
secName = seci.peekNextKey();
Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
Ogre::ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); ++i)
{
typeName = i->first;
archName = i->second;
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
archName, typeName, secName);
}
}
//-------------------------------------------------------------------------------------
// configure
// Show the configuration dialog and initialise the system
// You can skip this and use root.restoreConfig() to load configuration
// settings if you were sure there are valid ones saved in ogre.cfg
if(mRoot->restoreConfig() || mRoot->showConfigDialog())
{
// If returned true, user clicked OK so initialise
// Here we choose to let the system create a default rendering window by passing 'true'
mWindow = mRoot->initialise(true, "MinimalOgre Render Window");
}
else
{
return false;
}
//new addition to 1.9, needs to be created for singleton instance.
overlaySystem = new Ogre::OverlaySystem();
//-------------------------------------------------------------------------------------
// choose scenemanager
// Get the SceneManager, in this case a generic one
mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC);
mSceneMgr->addRenderQueueListener(overlaySystem);
//-------------------------------------------------------------------------------------
// create camera
// Create the camera
mCamera = mSceneMgr->createCamera("PlayerCam");
// Position it at 500 in Z direction
mCamera->setPosition(Ogre::Vector3(0,0,80));
// Look back along -Z
mCamera->lookAt(Ogre::Vector3(0,0,-300));
mCamera->setNearClipDistance(5);
mCameraMan = new OgreBites::SdkCameraMan(mCamera); // create a default camera controller
//-------------------------------------------------------------------------------------
// create viewports
// Create one viewport, entire window
Ogre::Viewport* vp = mWindow->addViewport(mCamera);
vp->setBackgroundColour(Ogre::ColourValue(0,0,0));
// Alter the camera aspect ratio to match the viewport
mCamera->setAspectRatio(
Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));
//-------------------------------------------------------------------------------------
// Set default mipmap level (NB some APIs ignore this)
Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
//-------------------------------------------------------------------------------------
// Create any resource listeners (for loading screens)
//createResourceListener();
//-------------------------------------------------------------------------------------
// load resources
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
//-------------------------------------------------------------------------------------
// Create the scene
Ogre::Entity* ogreHead = mSceneMgr->createEntity("Head", "cube.mesh");
//Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
//headNode->attachObject(ogreHead);
// Set ambient light
mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5));
//.........这里部分代码省略.........
示例7: initOgre
bool OgreFramework::initOgre(Ogre::String wndTitle, OIS::KeyListener *pKeyListener, OIS::MouseListener *pMouseListener)
#endif
{
new Ogre::LogManager();
m_pLog = Ogre::LogManager::getSingleton().createLog("OgreLogfile.log", true, true, false);
m_pLog->setDebugOutputEnabled(true);
String pluginsPath;
// only use plugins.cfg if not static
#ifndef OGRE_STATIC_LIB
pluginsPath = m_ResourcePath + "plugins.cfg";
#endif
m_pRoot = new Ogre::Root(pluginsPath, Ogre::macBundlePath() + "/ogre.cfg");
#ifdef OGRE_STATIC_LIB
m_StaticPluginLoader.load();
#endif
if(!m_pRoot->showConfigDialog())
return false;
m_pRenderWnd = m_pRoot->initialise(true, wndTitle);
m_pSceneMgr = m_pRoot->createSceneManager(ST_GENERIC, "SceneManager");
m_pSceneMgr->setAmbientLight(Ogre::ColourValue(0.7f, 0.7f, 0.7f));
m_pCamera = m_pSceneMgr->createCamera("Camera");
m_pCamera->setPosition(Vector3(0, 60, 60));
m_pCamera->lookAt(Vector3(0, 0, 0));
m_pCamera->setNearClipDistance(1);
m_pViewport = m_pRenderWnd->addViewport(m_pCamera);
m_pViewport->setBackgroundColour(ColourValue(0.8f, 0.7f, 0.6f, 1.0f));
m_pCamera->setAspectRatio(Real(m_pViewport->getActualWidth()) / Real(m_pViewport->getActualHeight()));
m_pViewport->setCamera(m_pCamera);
unsigned long hWnd = 0;
OIS::ParamList paramList;
m_pRenderWnd->getCustomAttribute("WINDOW", &hWnd);
paramList.insert(OIS::ParamList::value_type("WINDOW", Ogre::StringConverter::toString(hWnd)));
m_pInputMgr = OIS::InputManager::createInputSystem(paramList);
#if !defined(OGRE_IS_IOS)
m_pKeyboard = static_cast<OIS::Keyboard*>(m_pInputMgr->createInputObject(OIS::OISKeyboard, true));
m_pMouse = static_cast<OIS::Mouse*>(m_pInputMgr->createInputObject(OIS::OISMouse, true));
m_pMouse->getMouseState().height = m_pRenderWnd->getHeight();
m_pMouse->getMouseState().width = m_pRenderWnd->getWidth();
#else
m_pMouse = static_cast<OIS::MultiTouch*>(m_pInputMgr->createInputObject(OIS::OISMultiTouch, true));
#endif
#if !defined(OGRE_IS_IOS)
if(pKeyListener == 0)
m_pKeyboard->setEventCallback(this);
else
m_pKeyboard->setEventCallback(pKeyListener);
#endif
if(pMouseListener == 0)
m_pMouse->setEventCallback(this);
else
m_pMouse->setEventCallback(pMouseListener);
Ogre::String secName, typeName, archName;
Ogre::ConfigFile cf;
cf.load(m_ResourcePath + "resources.cfg");
Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
while (seci.hasMoreElements())
{
secName = seci.peekNextKey();
Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
Ogre::ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); ++i)
{
typeName = i->first;
archName = i->second;
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE || defined(OGRE_IS_IOS)
// OS X does not set the working directory relative to the app,
// In order to make things portable on OS X we need to provide
// the loading with it's own bundle path location
if (!Ogre::StringUtil::startsWith(archName, "/", false)) // only adjust relative dirs
archName = Ogre::String(m_ResourcePath + archName);
#endif
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName);
}
}
Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
m_pTimer = OGRE_NEW Ogre::Timer();
m_pTimer->reset();
/*
//.........这里部分代码省略.........
示例8: main
int main(int argc, char **argv)
#endif
{
try
{
//Iniciem el nostre carregador de classes
ClassLoader::init();
//Iniciem OGRE
#ifdef NO_LOGS
Ogre::Root *lRoot = new Ogre::Root("", "", "");
#else
Ogre::Root *lRoot = new Ogre::Root("", "", "skbl.log");
#endif
lRoot->loadPlugin("Plugin_OctreeSceneManager");
//provem de carregar els plugins de DirectX o OpenGL
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
try
{
lRoot->loadPlugin("RenderSystem_Direct3D9");
}catch (Ogre::Exception &e)
{
MessageBox( NULL, "Get it in our web page",
"Couldn't find shared library \"RenderSystem_Direct3D9\"\n",
MB_OK | MB_ICONERROR | MB_TASKMODAL);
}
#else //Win32
try
{
lRoot->loadPlugin("RenderSystem_GL");
}catch (Ogre::Exception &ee)
{
std::cerr << "Couldn't find shared library \"RenderSystem_GL\". Get it in our web page\n" << std::endl;
}
#endif //Win32
//ara seleccionem un render system d'entre els disponibles
const Ogre::RenderSystemList& lRenderSystemList = lRoot->getAvailableRenderers();
for(unsigned int i=0; i<lRenderSystemList.size(); i++)
{
Ogre::String rsysnm = lRenderSystemList[i]->getName();
//l'ordre d'ifs es el de preferencia
if(rsysnm=="Direct3D9 Rendering Subsystem")
{
lRoot->setRenderSystem(lRenderSystemList[i]);
break;
}
if(rsysnm=="OpenGL Rendering Subsystem")
{
lRoot->setRenderSystem(lRenderSystemList[i]);
break;
}
}
//Inicialitzem Root sense crear finestra
lRoot->initialise(false);
//TODO: Llegir fitxer de configuracio
Ogre::RenderWindow *lWindow;
Ogre::NameValuePairList lParams;
lParams["vsync"] = "true";
lWindow = lRoot->createRenderWindow("De-geso~~~", 1280, 720, false, &lParams);
// Load resource paths from config file
Ogre::ConfigFile cf;
cf.load("configScripts/resources.cfg");
// Go through all sections & settings in the file
Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
Ogre::String secName, typeName, archName;
while (seci.hasMoreElements())
{
secName = seci.peekNextKey();
Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
Ogre::ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); ++i)
{
typeName = i->first;
archName = i->second;
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
// OS X does not set the working directory relative to the app,
// In order to make things portable on OS X we need to provide
// the loading with it's own bundle path location
if (!Ogre::StringUtil::startsWith(archName, "/", false)) // only adjust relative dirs
archName = Ogre::String(Ogre::macBundlePath() + archName);
#endif
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
archName, typeName, secName);
}
}
//Creem un GameSetup --provisional
GameSetup *lGameSetup = ClassLoader::makeGameSetupLocalProva(lRoot, lWindow, "pl_Boxejador", "lv_Prova");
delete lGameSetup;
ClassLoader::unloadGameSetupLocalProva();
//.........这里部分代码省略.........
示例9: initOgre
bool OgreFramework::initOgre(OIS::KeyListener *pKeyListener, OIS::MouseListener *pMouseListener)
#endif
{
new Ogre::LogManager();
m_pLog = Ogre::LogManager::getSingleton().createLog("OgreLogfile.log", true, true, false);
m_pLog->setDebugOutputEnabled(true);
String pluginsPath;
// only use plugins.cfg if not static
#ifndef OGRE_STATIC_LIB
pluginsPath = m_ResourcePath + "plugins.cfg";
#endif
m_pRoot = new Ogre::Root(pluginsPath, Ogre::macBundlePath() + "/ogre.cfg");
// OgreOggSound is still a dynamic library (dylib)
// OgreOggSound::OgreOggSoundPlugin* mOgreOggSoundPlugin = OGRE_NEW OgreOggSound::OgreOggSoundPlugin();
// m_pRoot->installPlugin(mOgreOggSoundPlugin);
#ifdef OGRE_STATIC_LIB
m_StaticPluginLoader.load();
#endif
if(m_pRoot->restoreConfig() || m_pRoot->showConfigDialog())
m_pRenderWnd = m_pRoot->initialise(true, "");
else
return false;
//m_pRenderWnd->resize(800, 600);
//m_pRenderWnd->setFullscreen(true, 1024, 800);
globals.screenWidth = m_pRenderWnd->getWidth();
globals.screenHeight = m_pRenderWnd->getHeight();
globals.set();
m_pSceneMgrMain = m_pRoot->createSceneManager(ST_GENERIC, "SceneManagerMain");
m_pSceneMgrMain->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5));
m_pCameraMain = m_pSceneMgrMain->createCamera("CameraMain");
m_pCameraMain->setPosition(Vector3(0, 0, 50));
m_pCameraMain->lookAt(Vector3(0, 0, 0));
m_pCameraMain->setNearClipDistance(0.1);
m_pViewportMain = m_pRenderWnd->addViewport(m_pCameraMain);
m_pViewportMain->setCamera(m_pCameraMain);
Ogre::OverlaySystem* m_pOverlaySystem = new Ogre::OverlaySystem();
m_pSceneMgrMain->addRenderQueueListener(m_pOverlaySystem);
unsigned long hWnd = 0;
OIS::ParamList paramList;
m_pRenderWnd->getCustomAttribute("WINDOW", &hWnd);
paramList.insert(OIS::ParamList::value_type("WINDOW", Ogre::StringConverter::toString(hWnd)));
m_pInputMgr = OIS::InputManager::createInputSystem(paramList);
#if !defined(OGRE_IS_IOS)
m_pKeyboard = static_cast<OIS::Keyboard*>(m_pInputMgr->createInputObject(OIS::OISKeyboard, true));
m_pMouse = static_cast<OIS::Mouse*>(m_pInputMgr->createInputObject(OIS::OISMouse, true));
m_pMouse->getMouseState().height = m_pRenderWnd->getHeight();
m_pMouse->getMouseState().width = m_pRenderWnd->getWidth();
if(pKeyListener == 0)
m_pKeyboard->setEventCallback(this);
else
m_pKeyboard->setEventCallback(pKeyListener);
if(pMouseListener == 0)
m_pMouse->setEventCallback(this);
else
m_pMouse->setEventCallback(pMouseListener);
#endif
Ogre::String secName, typeName, archName;
Ogre::ConfigFile cf;
cf.load(m_ResourcePath + "resources.cfg");
m_pResourceGroupMgr = Ogre::ResourceGroupManager::getSingletonPtr();
m_pOverlayMgr = Ogre::OverlayManager::getSingletonPtr();
m_pFontMgr = Ogre::FontManager::getSingletonPtr();
m_pMeshMgr = Ogre::MeshManager::getSingletonPtr();
m_pMaterialMgr = Ogre::MaterialManager::getSingletonPtr();
m_pTextureMgr = Ogre::TextureManager::getSingletonPtr();
m_pCompositeMgr = CompositorManager::getSingletonPtr();
Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
while (seci.hasMoreElements())
{
secName = seci.peekNextKey();
Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
Ogre::ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); ++i)
{
typeName = i->first;
archName = i->second;
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE || defined(OGRE_IS_IOS)
// OS X does not set the working directory relative to the app,
// In order to make things portable on OS X we need to provide
// the loading with it's own bundle path location
if (!Ogre::StringUtil::startsWith(archName, "/", false)) // only adjust relative dirs
//.........这里部分代码省略.........
示例10: initEmemyFormat
//-----------------------------------------------------------------------
void WarModeTwo::initEmemyFormat()
{
Ogre::DataStreamPtr pDataStream=Ogre::ResourceGroupManager::getSingleton().openResource("EnemyFormatMode2.cfg","General");
if(pDataStream.isNull())
{
OGRE_EXCEPT(0,"can't find warmode1 enemyFormat file","WarModeOne::initEmemyFormat()");
}
m_EnemyFormatCollect.clear();
Ogre::ConfigFile cf;
cf.load(pDataStream);
///循环取出所有的队列和位置信息
Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
Ogre::String sec, type, arch;
//获取所有阵型
while (seci.hasMoreElements())
{
sec = seci.peekNextKey();
Ogre::ConfigFile::SettingsMultiMap* settings = seci.getNext();
Ogre::ConfigFile::SettingsMultiMap::iterator i;
if(settings->empty())
continue;
if(sec.find("Format")!=Ogre::String::npos)
{
EnemyFormat enemyFormat;
m_EnemyFormatCollect.push_back(enemyFormat);
}
for (i = settings->begin(); i != settings->end(); i++)
{
type = i->first;
arch = i->second;
///如果是设置范围大小的
if(sec=="Enemylimits")
{
if(type=="Minx")
{
m_Minx=Ogre::StringConverter::parseReal(arch);
}else if(type=="Maxx")
{
m_Maxx=Ogre::StringConverter::parseReal(arch);
}else if(type=="Miny")
{
m_Miny=Ogre::StringConverter::parseReal(arch);
}else if(type=="Maxy")
{
m_Maxy=Ogre::StringConverter::parseReal(arch);
}else if(type=="Minz")
{
m_Minz=Ogre::StringConverter::parseReal(arch);
}else if(type=="Maxz")
{
m_Maxz=Ogre::StringConverter::parseReal(arch);
}else if(type=="LeftTime")
{
m_EnemyLeftTime=Ogre::StringConverter::parseReal(arch);
}
}else
{
Ogre::Vector3 Pos=Ogre::StringConverter::parseVector3(arch);
if(type=="Enemy")
{
m_EnemyFormatCollect.back().m_EnemyCollect.push_back(Pos);
}else if(type=="Friend")
{
m_EnemyFormatCollect.back().m_FriendCollect.push_back(Pos);
}
}
}
}
//.........这里部分代码省略.........
示例11: initOgre
void App::initOgre()
{
// Config file class is an utility that parses and stores values from a .cfg file
Ogre::ConfigFile cf;
std::string configFilePathPrefix = "cfg/"; // configuration files default location when app is installed
#ifdef _DEBUG
std::string pluginsFileName = "plugins_d.cfg"; // plugins config file name (Debug mode)
#else
std::string pluginsFileName = "plugins.cfg"; // plugins config file name (Release mode)
#endif
std::string resourcesFileName = "resources.cfg"; // resources config file name (Debug/Release mode)
// LOAD OGRE PLUGINS
// Try to load load up a valid config file (and don't start the program if none is found)
try
{
//This will work ONLY when application is installed (only Release application)!
cf.load(configFilePathPrefix + pluginsFileName);
}
catch (Ogre::FileNotFoundException &e)
{
try
{
// if no existing config, or could not restore it, try to load from a different location
configFilePathPrefix = "../cfg/";
//This will work ONLY when application is in development (Debug/Release configuration)
cf.load(configFilePathPrefix + pluginsFileName);
}
catch (Ogre::FileNotFoundException &e)
{
// launch exception if no valid config file is found! - PROGRAM WON'T START!
throw e;
}
}
// INSTANCIATE OGRE ROOT (IT INSTANCIATES ALSO ALL OTHER OGRE COMPONENTS)
// In Ogre, the singletons are instanciated explicitly (with new) the first time,
// then it can be accessed with Ogre::Root::getSingleton()
// Plugins are passed as argument to the "Root" constructor
mRoot = new Ogre::Root(configFilePathPrefix + pluginsFileName, configFilePathPrefix + "ogre.cfg", "ogre.log");
// No Ogre::FileNotFoundException is thrown by this, that's why we tried to open it first with ConfigFile::load()
// LOAD OGRE RESOURCES
// Load up resources according to resources.cfg ("cf" variable is reused)
try
{
//This will work ONLY when application is installed!
cf.load("cfg/resources.cfg");
}
catch (Ogre::FileNotFoundException &e) // It works, no need to change anything
{
try
{
//This will work ONLY when application is in development (Debug/Release configuration)
cf.load("../cfg/resources.cfg");
}
catch (Ogre::FileNotFoundException &e)
{
// launch exception if no valid config file is found! - PROGRAM WON'T START!
throw e;
}
}
// Go through all sections & settings in the file
Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
Ogre::String secName, typeName, archName;
while (seci.hasMoreElements())
{
secName = seci.peekNextKey(); Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
Ogre::ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); ++i)
{
typeName = i->first;
archName = i->second;
//For each section/key-value, add a resource to ResourceGroupManager
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
archName, typeName, secName);
}
}
// Then setup THIS CLASS INSTANCE as a frame listener
// This means that Ogre will call frameStarted(), frameRenderingQueued() and frameEnded()
// automatically and periodically if defined in this class
mRoot->addFrameListener(this);
// SELECT AND CUSTOMIZE OGRE RENDERING (OpenGL)
// Get a reference of the RenderSystem in Ogre that I want to customize
Ogre::RenderSystem* pRS = mRoot->getRenderSystemByName("OpenGL Rendering Subsystem");
// Get current config RenderSystem options in a ConfigOptionMap
Ogre::ConfigOptionMap cfgMap = pRS->getConfigOptions();
// Modify them
cfgMap["Full Screen"].currentValue = "No";
cfgMap["VSync"].currentValue = "Yes";
#ifdef _DEBUG
//.........这里部分代码省略.........
示例12: Init
bool COgreManager::Init(bool bEditor, HWND externalHwnd, HWND hwndParent,int width, int height)
{
//资源配置文件和插件配置文件
String ResourceCfg, PluginCfg;
#ifdef _DEBUG
if (bEditor)
ResourceCfg = "resources_editor_d.cfg";
else
ResourceCfg = "resources_d.cfg";
PluginCfg = "plugins_d.cfg";
#else
if (bEditor)
ResourceCfg = "resources_editor.cfg";
else
ResourceCfg = "resources.cfg";
PluginCfg = "plugins.cfg";
#endif
mRoot = new Ogre::Root(PluginCfg);
Ogre::ConfigFile cf;
cf.load(ResourceCfg);
// Go through all sections & settings in the file
Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
Ogre::String secName, typeName, archName;
while (seci.hasMoreElements())
{
secName = seci.peekNextKey();
Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
Ogre::ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); ++i)
{
typeName = i->first;
archName = i->second;
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName);
}
}
if (bEditor)
{
RenderSystem* rs = mRoot->getRenderSystemByName("Direct3D9 Rendering Subsystem");
assert(rs);
mRoot->setRenderSystem(rs);
mRoot->initialise(false);
NameValuePairList params;
params["externalWindowHandle"] = StringConverter::toString((unsigned int)externalHwnd);
params["parentWindowHandle"] = StringConverter::toString((unsigned int)hwndParent);
params["vsync"] = "true";
mWindow = mRoot->createRenderWindow("MainWindow", width, height, false, ¶ms);
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
}
else
{
if(mRoot->restoreConfig() || mRoot->showConfigDialog())
mWindow = mRoot->initialise(true, "Game : MiniCraft");
else
return false;
}
if(!checkHardwareSupport())
return false;
m_pSceneMgr = mRoot->createSceneManager(ST_GENERIC, "DefaultSceneMgr");
m_pMainCamera = m_pSceneMgr->createCamera("MainCamera");
m_pMainCamera->setNearClipDistance(1);
m_pMainCamera->setFarClipDistance(500);
m_pViewport = mWindow->addViewport(m_pMainCamera);
m_pViewport->setBackgroundColour(Ogre::ColourValue(0,0,0));
m_pMainCamera->setAspectRatio(
(Ogre::Real)m_pViewport->getActualWidth()/(Ogre::Real)m_pViewport->getActualHeight());
Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
//Set initial mouse clipping size
windowResized(mWindow);
Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this);
m_pDS = new DeferredShadingSystem(m_pViewport, m_pSceneMgr, m_pMainCamera);
if(bEditor)
m_pDS->initialize();
mLightMaterialGenerator = new LightMaterialGenerator;
PSSMShadowCameraSetup* pssmSetup = new PSSMShadowCameraSetup;
mPSSMSetup.bind(pssmSetup);
m_pSceneMgr->setShadowCameraSetup(mPSSMSetup);
m_pSceneMgr->getRenderQueue()->getQueueGroup(RENDER_QUEUE_OVERLAY)->setShadowsEnabled(false);
m_Timer = new Ogre::Timer();
m_Timer->reset();
mWindow->setActive(true);
mWindow->setDeactivateOnFocusChange(false);
m_bHasInit = true;
return true;
}
示例13: parseTerrainTypeConfigFile
//-----------------------------------------------------------------------
void TerrainTypeInfos::parseTerrainTypeConfigFile(const Ogre::String& filename)
{
mTextureNameTerrainTypeMap.clear();
mTerrainTypeEffectMap.clear();
Ogre::ConfigFile cf;
cf.load(filename);
// Go through all sections & settings in the file
Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
Ogre::String secName, texNames, effectNames;
while (seci.hasMoreElements())
{
secName = seci.peekNextKey();
seci.getNext();
if (secName.empty())
continue;
TerrainTypeMap::const_iterator terrainTypeIterator =
mTerrainTypeMap.find(secName);
if (terrainTypeIterator == mTerrainTypeMap.end())
{
Ogre::LogManager::getSingleton().logMessage("can't find the terrain type! TerrainTypeInfos::parseTerrainTypeConfigFile");
continue;
}
TerrainType terrainType = terrainTypeIterator->second;
texNames = cf.getSetting("texture", secName);
effectNames = cf.getSetting("effect", secName);
//if (texNames.empty())
//{
// Ogre::LogManager::getSingleton().logMessage("texture names is empty! TerrainTypeInfos::parseTerrainTypeConfigFile");
//// continue;
//}
//else
// 如果有纹理名称,就解析(像liquid这种是不需要定义纹理名称的)
if (false == texNames.empty())
{
Ogre::StringVector texNameArray = Ogre::StringUtil::split(texNames);
for (size_t texNameIndex = 0; texNameIndex < texNameArray.size(); ++texNameIndex)
{
mTextureNameTerrainTypeMap.insert(
TextureNameTerrainTypeMap::value_type(texNameArray[texNameIndex], terrainType) );
}
}
// 解析特效描述
if (effectNames.empty())
{
Ogre::LogManager::getSingleton().logMessage("effect names is empty! TerrainTypeInfos::parseTerrainTypeConfigFile");
continue;
}
EffectTemplateList effectTemplateList;
Ogre::StringVector effectNameArray = Ogre::StringUtil::split(effectNames);
for (size_t effectNameIndex = 0; effectNameIndex < effectNameArray.size(); ++effectNameIndex)
{
Ogre::String str = effectNameArray[effectNameIndex];
Ogre::StringVector effectDefine =
Ogre::StringUtil::split(str,":");
if (effectDefine.size() != 2)
{
Ogre::LogManager::getSingleton().logMessage("the effect define line is wrong! TerrainTypeInfos::parseTerrainTypeConfigFile");
continue;
}
EffectTemplate effectTemplate;
effectTemplate.mEffectName = effectDefine[0];
effectTemplate.mTemplateName = effectDefine[1];
effectTemplateList.push_back(effectTemplate);
}
// 插入这种地形所对应的特效名称
mTerrainTypeEffectMap.insert( TerrainTypeEffectMap::value_type(terrainType, effectTemplateList) );
}
}
示例14: initOgre
bool Core::initOgre(Ogre::String wndTitle, OIS::KeyListener *pKeyListener, OIS::MouseListener *pMouseListener)
{
//init GFX
Ogre::LogManager* logMgr = new Ogre::LogManager();
mLog = Ogre::LogManager::getSingleton().createLog("GFX.log", true, true, false);
mLog->setDebugOutputEnabled(true);
mRoot = new Ogre::Root("plugins.cfg","config.cfg");
if(!mRoot->restoreConfig()){
if(!mRoot->showConfigDialog())
return false;
}
//add renderwndw
mRenderWindow = mRoot->initialise(true, wndTitle);
//set default viewport
mViewport = mRenderWindow->addViewport(0);
mViewport->setBackgroundColour(ColourValue(0.5f, 0.5f, 0.5f, 1.0f));
mViewport->setCamera(0);
mOverlaySystem = new Ogre::OverlaySystem();
size_t hWnd = 0;
OIS::ParamList paramList;
//--------WIN32 parameters ?-------------
//TODO: see if in linux works
mRenderWindow->getCustomAttribute("WINDOW", &hWnd);
paramList.insert(OIS::ParamList::value_type("WINDOW", Ogre::StringConverter::toString(hWnd)));
//-------------------------------------
mInputManager = OIS::InputManager::createInputSystem(paramList);
mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, true));
mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject(OIS::OISMouse, true));
mMouse->getMouseState().height = mRenderWindow->getHeight();
mMouse->getMouseState().width = mRenderWindow->getWidth();
if(pKeyListener == 0)mKeyboard->setEventCallback(this);
else mKeyboard->setEventCallback(pKeyListener);
if(pMouseListener == 0)mMouse->setEventCallback(this);
else mMouse->setEventCallback(pMouseListener);
//init Resource files
Ogre::String secName, typeName, archName;
Ogre::ConfigFile cf;
cf.load("..\\resources.cfg");
Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
while (seci.hasMoreElements())
{
secName = seci.peekNextKey();
Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
Ogre::ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); ++i)
{
typeName = i->first;
archName = i->second;
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName);
}
}
Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
//init Input
OgreBites::InputContext inputContext;
inputContext.mMouse = mMouse;
inputContext.mKeyboard = mKeyboard;
//init Timer
mTimer = new Ogre::Timer();
mTimer->reset();
//init Window
mRenderWindow->setActive(true);
//init MyGUI OgrePlatform
Core::getSingletonPtr()->mPlatform = new MyGUI::OgrePlatform();
Core::getSingletonPtr()->mPlatform->initialise(Core::getSingletonPtr()->mRenderWindow, NULL,"GUI","GUI.txt"); // mWindow is Ogre::RenderWindow*, mSceneManager is Ogre::SceneManager*
//Init MyGUI
Core::getSingletonPtr()->mGUI = new MyGUI::Gui();
Core::getSingletonPtr()->mGUI->initialise("Core.xml");
return true;
}
示例15: initOgre
bool OgreFramework::initOgre(Ogre::String wndTitle, OIS::KeyListener *pKeyListener, OIS::MouseListener *pMouseListener)
{
Ogre::LogManager* logMgr = new Ogre::LogManager();
m_pLog = Ogre::LogManager::getSingleton().createLog("OgreLogfile.log", true, true, false);
m_pLog->setDebugOutputEnabled(true);
m_pRoot = new Ogre::Root();
if(!m_pRoot->showConfigDialog())
return false;
m_pRenderWnd = m_pRoot->initialise(true, wndTitle);
m_pSceneMgr = m_pRoot->createSceneManager(ST_GENERIC, "SceneManager");
m_pSceneMgr->setAmbientLight(Ogre::ColourValue(0.7f, 0.7f, 0.7f));
m_pCamera = m_pSceneMgr->createCamera("Camera");
m_pCamera->setPosition(Vector3(0, 360, -300));
m_pCamera->lookAt(Vector3(0, 310, 0));
m_pCamera->setNearClipDistance(1);
m_pCamera->setFarClipDistance(50000);
if (m_pRoot->getRenderSystem()->getCapabilities()->hasCapability(Ogre::RSC_INFINITE_FAR_PLANE))
{
m_pCamera->setFarClipDistance(0); // enable infinite far clip distance if we can
}
m_pViewport = m_pRenderWnd->addViewport(m_pCamera);
m_pViewport->setBackgroundColour(ColourValue(0.8f, 0.7f, 0.6f, 1.0f));
m_pCamera->setAspectRatio(Real(m_pViewport->getActualWidth()) / Real(m_pViewport->getActualHeight()));
m_pViewport->setCamera(m_pCamera);
size_t hWnd = 0;
OIS::ParamList paramList;
m_pRenderWnd->getCustomAttribute("WINDOW", &hWnd);
paramList.insert(OIS::ParamList::value_type("WINDOW", Ogre::StringConverter::toString(hWnd)));
m_pInputMgr = OIS::InputManager::createInputSystem(paramList);
m_pKeyboard = static_cast<OIS::Keyboard*>(m_pInputMgr->createInputObject(OIS::OISKeyboard, true));
m_pMouse = static_cast<OIS::Mouse*>(m_pInputMgr->createInputObject(OIS::OISMouse, true));
m_pMouse->getMouseState().height = m_pRenderWnd->getHeight();
m_pMouse->getMouseState().width = m_pRenderWnd->getWidth();
if(pKeyListener == 0)
m_pKeyboard->setEventCallback(this);
else
m_pKeyboard->setEventCallback(pKeyListener);
if(pMouseListener == 0)
m_pMouse->setEventCallback(this);
else
m_pMouse->setEventCallback(pMouseListener);
Ogre::String secName, typeName, archName;
Ogre::ConfigFile cf;
cf.load("resources.cfg");
Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
while (seci.hasMoreElements())
{
secName = seci.peekNextKey();
Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
Ogre::ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); ++i)
{
typeName = i->first;
archName = i->second;
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName);
}
}
Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
m_pTimer = new Ogre::Timer();
m_pTimer->reset();
m_pTrayMgr = new OgreBites::SdkTrayManager("TrayMgr", m_pRenderWnd, m_pMouse, this);
m_pTrayMgr->showFrameStats(OgreBites::TL_BOTTOMLEFT);
m_pTrayMgr->showLogo(OgreBites::TL_BOTTOMRIGHT);
m_pTrayMgr->hideCursor();
m_pRenderWnd->setActive(true);
return true;
}