本文整理汇总了C++中ogre::ConfigFile::load方法的典型用法代码示例。如果您正苦于以下问题:C++ ConfigFile::load方法的具体用法?C++ ConfigFile::load怎么用?C++ ConfigFile::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::ConfigFile
的用法示例。
在下文中一共展示了ConfigFile::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupResources
//-------------------------------------------------------------------------------------
void BaseApplication::setupResources(void)
{
// Load resource paths from config file
Ogre::ConfigFile cf;
cf.load("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;
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
archName, typeName, secName);
}
}
}
示例2: 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;
}
示例3: UpdateControls
void CLASS::UpdateControls()
{
int valuecounter = 0; // Going to be usefull for selections
//Lang (Still not done)
if (!IsLoaded)
{
m_lang->addItem("English (U.S.)");
}
m_lang->setIndexSelected(0); //TODO
if (!IsLoaded)
{
m_gearbox_mode->addItem("Automatic shift");
m_gearbox_mode->addItem("Manual shift - Auto clutch");
m_gearbox_mode->addItem("Fully Manual: sequential shift");
m_gearbox_mode->addItem("Fully Manual: stick shift");
m_gearbox_mode->addItem("Fully Manual: stick shift with ranges");
}
//Gearbox
Ogre::String gearbox_mode = GameSettingsMap["GearboxMode"];
if (gearbox_mode == "Manual shift - Auto clutch")
m_gearbox_mode->setIndexSelected(1);
else if (gearbox_mode == "Fully Manual: sequential shift")
m_gearbox_mode->setIndexSelected(2);
else if (gearbox_mode == "Fully Manual: stick shift")
m_gearbox_mode->setIndexSelected(3);
else if (gearbox_mode == "Fully Manual: stick shift with ranges")
m_gearbox_mode->setIndexSelected(4);
else
m_gearbox_mode->setIndexSelected(0);
Ogre::RenderSystem* rs = Ogre::Root::getSingleton().getRenderSystem();
// add all rendersystems to the list
if (m_render_sys->getItemCount() == 0)
{
const Ogre::RenderSystemList list = Application::GetOgreSubsystem()->GetOgreRoot()->getAvailableRenderers();
int selection = 0;
for (Ogre::RenderSystemList::const_iterator it = list.begin(); it != list.end(); it++, valuecounter++)
{
if (rs && rs->getName() == (*it)->getName())
{
ExOgreSettingsMap["Render System"] = rs->getName();
selection = valuecounter;
}
else if (!rs) {
LOG("Error: No Ogre Render System found");
}
if (!IsLoaded)
{
m_render_sys->addItem(Ogre::String((*it)->getName()));
}
}
m_render_sys->setIndexSelected(selection);
}
Ogre::ConfigFile cfg;
cfg.load(SSETTING("ogre.cfg", "ogre.cfg"));
//Few GameSettingsMap
Ogre::String bFullScreen = cfg.getSetting("Full Screen", rs->getName());
if (bFullScreen == "Yes")
{
ExOgreSettingsMap["Full Screen"] = "Yes";
m_fullscreen->setStateCheck(true);
}
else
{
ExOgreSettingsMap["Full Screen"] = "No";
m_fullscreen->setStateCheck(false);
}
Ogre::String bVsync = cfg.getSetting("VSync", rs->getName());
if (bVsync == "Yes")
{
ExOgreSettingsMap["VSync"] = "Yes";
m_vsync->setStateCheck(true);
}
else
{
ExOgreSettingsMap["VSync"] = "No";
m_vsync->setStateCheck(false);
}
// store available rendering devices and available resolutions
Ogre::ConfigOptionMap& CurrentRendererOptions = rs->getConfigOptions();
Ogre::ConfigOptionMap::iterator configItr = CurrentRendererOptions.begin();
Ogre::StringVector mFoundResolutions;
Ogre::StringVector mFoundFSAA;
while (configItr != CurrentRendererOptions.end())
{
if ((configItr)->first == "Video Mode")
{
// Store Available Resolutions
mFoundResolutions = ((configItr)->second.possibleValues);
}
if ((configItr)->first == "FSAA")
//.........这里部分代码省略.........
示例4: 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_pViewport = m_pRenderWnd->addViewport(0);
m_pViewport->setBackgroundColour(ColourValue(0.5f, 0.5f, 0.5f, 1.0f));
m_pViewport->setCamera(0);
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_pTrayMgr = new OgreBites::SdkTrayManager("AOFTrayMgr", m_pRenderWnd, m_pMouse, 0);
m_pTimer = new Ogre::Timer();
m_pTimer->reset();
m_pRenderWnd->setActive(true);
return true;
}
示例5: while
bool
AppDemarrage::start(const Ogre::String& pluginFile, const Ogre::String& ogreFile,
const Ogre::String& logFile, const Ogre::String& resourceFile)
{
mRoot = OGRE_NEW Ogre::Root(pluginFile, ogreFile, logFile);
Ogre::ConfigFile configFile;
configFile.load(resourceFile);
Ogre::ConfigFile::SectionIterator seci = configFile.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(secName == "TileResourceID")
{
resourceIdMapper[Ogre::StringConverter::parseInt(typeName)] = archName;
}else
{
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
archName, typeName, secName);
}
}
}
//if(!(mRoot->restoreConfig() || mRoot->showConfigDialog()))
if(!mRoot->showConfigDialog())
{
return false;
}
mWindow = mRoot->initialise(true, APP_WIN_NAME);
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
mSceneMgr = mRoot->createSceneManager("DefaultSceneManager", "Mon Scene Manager");
mSceneMgr->setAmbientLight(Ogre::ColourValue(0.0f, 0.0f, 0.0f));
mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
// Ogre::Light* pointLight = mSceneMgr->createLight("pointLight");
// pointLight->setType(Ogre::Light::LT_POINT);
// pointLight->setPosition(Ogre::Vector3(10*1.5f, 1*1.5f, 10*1.5f));
// pointLight->setDiffuseColour(0.7, 0.7, 0.7);
// pointLight->setSpecularColour(0.7, 0.7, 0.7);
mCamera = mSceneMgr->createCamera(APP_MAIN_CAM_NAME);
#define MYTILESIZE 1.5f
mCamera->setPosition(5*MYTILESIZE,8,10*MYTILESIZE);
//mCamera->setDirection(Ogre::Vector3::)
//mCamera->setOrientation();
mCamera->lookAt(5*MYTILESIZE,0,10*MYTILESIZE);
mCamera->setDirection(0,0,0);
mCamera->setProjectionType(Ogre::PT_ORTHOGRAPHIC);
mCamera->setNearClipDistance(0.5);
mCamera->setFarClipDistance(15);
mCamera->setOrthoWindow(20 * MYTILESIZE, 20 * MYTILESIZE / 2.7f);
//mCamera->setOrthoWindow(15.f, 6.f);//50 * 20
Ogre::Viewport* vp = mWindow->addViewport(mCamera);
vp->setBackgroundColour(Ogre::ColourValue(0,0,0));
//mCamera->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));
//mCamera->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));
std::cout << "vp->getActualWidth(): " << vp->getActualWidth() << "\n";
std::cout << "vp->getActualHeight(): " << vp->getActualHeight() << std::endl;
//mCamera->setOrthoWindow(Ogre::Real(vp->getActualWidth()), Ogre::Real(vp->getActualHeight()));
//mCamera->setPolygonMode(Ogre::PM_WIREFRAME);
//m_battleground = new Battleground("plop", mSceneMgr, &resourceIdMapper);
//m_battleground->load("battlegnd.png");
//m_battleground Battleground(const xml_node &xmlBattlefieldNode, Ogre::SceneManager* mSceneMgr, std::map<int, Ogre::String>* resourceIdMapper);
mFrameListener= new InputListener(mSceneMgr, &resourceIdMapper, m_battleground);
mRoot->addFrameListener(mFrameListener);
mWindow->setDeactivateOnFocusChange(false);
while(true)
{
//.........这里部分代码省略.........
示例6: SetupOgre
// This function will set up everything required by Ogre
// and it will ask the user for display settings
// At the end of this function Ogre is ready to render.
// This function is mostly taken from tutorials and sample programs.
int CUIMain::SetupOgre(void)
{
//=================
//Ogre defaultly logs to console
// To prevent this the LogManager has to be created
// before the Root object.
//=================
Ogre::LogManager* logMgr = OGRE_NEW Ogre::LogManager;
logMgr->createLog("Ogre.log", true, false, false);
//=================
//Create the Ogre root object
// It's possible to specify as parameters the paths to the:
// plugin file (what render systems it has to load), config file (screen resolution etc) and log file
//=================
if( !mRoot ) mRoot = OGRE_NEW Ogre::Root();
//=================
// Tell Ogre where all the needed resources are (rendersystems and so on)
//=================
Ogre::ConfigFile cf;
cf.load("resources.cfg");
Ogre::String secName, typeName, archName;
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);
}
}
//=================
// Set up the render system.
// Ogre will ask the user for display settings
//=================
if( !mRoot->showConfigDialog() )
return 0; //The user probably clicked cancel
mWindow = mRoot->initialise(true, "NNYv3");
//=================
// Load all the resources. For now, just load all resources at once. The following is from a tutorial:
// In a very large game or application, we may have hundreds or even thousands of resources
// that our game uses - everything from meshes to textures to scripts. At any given time though,
// we probably will only be using a small subset of these resources. To keep down memory requirements,
// we can load only the resources that our application is using. We do this by dividing the resources
// into sections and only initializing them as we go.
//=================
Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
//=================
// Preparing the scene
//=================
mSceneMgr = mRoot->createSceneManager(Ogre::ST_EXTERIOR_CLOSE); //ST_EXTERIOR_CLOSE allows rendering terrain
mCamera.Initialize(mSceneMgr);
Ogre::Viewport* vp = mWindow->addViewport(mCamera.GetCamera());
vp->setBackgroundColour(Ogre::ColourValue(0.9,0.9,0.9));
//Fog will not work with sky ;)
//mSceneMgr->setFog(Ogre::FOG_LINEAR, Ogre::ColourValue(0.9,0.9,0.9), 0.0, 50, 500);
mCamera.GetCamera()->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));
//Set a moving cloud texture as background
mSceneMgr->setSkyDome(true, "CloudySky", 5, 8);
//Get a RaySceneQuery object. A SceneQuery object is a class that can query all
//objects in a region or scene. RaySceneQuery has it as a base class. RaySceneQuery
//can get all objects that intersect a ray.
mQueryMouseMovement = mSceneMgr->createRayQuery(Ogre::Ray(), QUERY_MASK_MOUSE_MOVEMENT);
mQueryMouseSelection = mSceneMgr->createRayQuery(Ogre::Ray(), QUERY_MASK_MOUSE_SELECTING);
LoadWorld();
//=================
// Set up the CEGUI system
//=================
mGUIHandler = new CGUIHandler(mWindow, mSceneMgr);
//=================
// Create the input handler
//=================
mInputHandler = new CInputHandler(mWorld, mCamera, mWindow, mSceneMgr);
mRoot->addFrameListener(mInputHandler);
mRoot->addFrameListener(this);
//=================
//.........这里部分代码省略.........
示例7: ApplicationPath
CEngine::CEngine(void)
: m_Root(NULL)
{
TCHAR szPath[MAX_PATH];
CString ApplicationName = "SceneEditor.exe";
GetModuleFileName(NULL, szPath, MAX_PATH);
Ogre::ConfigFile OgreConfigFile;
CString ApplicationPath(szPath);
ApplicationPath = ApplicationPath.Left(ApplicationPath.GetLength() - ApplicationName.GetLength());
m_Root = new Ogre::Root("", "", Ogre::String(ApplicationPath + "SceneEditor.log"));
OgreConfigFile.load(Ogre::String(ApplicationPath + "ogre.cfg"), "\t:=", false);
Ogre::String RenderSystemName;
RenderSystemName = OgreConfigFile.getSetting("Render System");
if (RenderSystemName == "Direct3D9 Rendering Subsystem")
{
#ifdef _DEBUG
m_Root->loadPlugin("RenderSystem_Direct3D9_d");
#else
m_Root->loadPlugin("RenderSystem_Direct3D9");
#endif
}
else
if(RenderSystemName == "OpenGL Rendering Subsystem")
{
#ifdef _DEBUG
m_Root->loadPlugin("RenderSystem_GL_d");
#else
m_Root->loadPlugin("RenderSystem_GL");
#endif
}
else
{
#ifdef _DEBUG
m_Root->loadPlugin("RenderSystem_Direct3D9_d");
#else
m_Root->loadPlugin("RenderSystem_Direct3D9");
#endif
}
#ifdef _DEBUG
m_Root->loadPlugin("Plugin_ParticleFX_d");
#else
m_Root->loadPlugin("Plugin_ParticleFX");
#endif
Ogre::RenderSystemList RendersList = m_Root->getAvailableRenderers();
m_Root->setRenderSystem(RendersList[0]);
//
// Initialize the system, but don't create a render window.
//
// Load resource paths from config file
Ogre::ConfigFile cf;
Ogre::String ResourcePath = ApplicationPath + "resources_d.cfg";
cf.load(ResourcePath);
// 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;
archName = Ogre::String(ApplicationPath) + archName;
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName);
}
}
m_Root->initialise(false);
}
示例8: init
/**
* @internal
* @brief Initializes the Resource Manager, which makes ogre aware of all resources directories
* @note This method does not actually load the resources, each subsystem of the library is in charche
* of loading the actual resources that they need.
* @note Ogre Root object is created here (to acces the resources management features), so this manager should be
* initialized before the rest of Ogre related managers
*/
void ResourceManager::init()
{
// Obtain the user execution directory
extractUserAppPath();
// Init Ogre Root
LOG( "Creating Ogre Root. Plugins path: %s", (resourcesPathInBundle + pluginsPath).c_str() );
new Ogre::Root( resourcesPathInBundle + pluginsPath );
// Store user data path in globals
dataFolder = userDataPath;
LOG("User Data Folder: %s", dataFolder.c_str() );
// Load Cing Config file
XMLElement xml;
xml.load( "CingConfig.xml" );
// Get cing data folder (the root is CingConfig)
if ( xml.isValid() )
{
XMLElement cingDataFolderXMLElement = xml.getChild("Cing_Data_Folder");
cingDataFolder = cingDataFolderXMLElement.getStringAttribute("relativePath");
}
else
LOG_ERROR( "CingConfig.xml not found in data folder -> using default paths" );
// Get Cing data path
LOG( "Cing Data Folder: %s", cingDataFolder.c_str());
if ( cingDataFolder != "" )
{
libDataPath = cingDataFolder;
}
else
LOG_ERROR( "Cing Data Folder is empty: libDataPath will use default value: %s", libDataPath.c_str() );
// Load resource paths from config file
Ogre::ConfigFile cf;
std::string resourcesFileAbsPath = libDataPath + resourcesFileName ;
LOG( "Trying to load Ogre Resources file (resources.cfg) at: %s", resourcesFileAbsPath.c_str() );
cf.load( resourcesFileAbsPath.c_str() );
// Go through all sections & settings in the file to add all library resource locations
Ogre::String secName, typeName, archName;
Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
while (seci.hasMoreElements())
{
// Get section name and data
secName = seci.peekNextKey();
Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
// Iterate through section elements
Ogre::ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); ++i)
{
typeName = i->first;
archName = i->second;
// Add the resource location to the manager
Ogre::ResourceGroupManager::getSingleton().addResourceLocation( libDataPath + archName, typeName, secName );
}
}
m_bIsValid = true;
}
示例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");
#ifdef OGRE_STATIC_LIB
m_StaticPluginLoader.load();
#endif
m_pRoot->initialise(false, "");
Ogre::NameValuePairList params;
params["externalWindowHandle"] = Ogre::StringConverter::toString((unsigned long)uiWindow);
params["externalViewHandle"] = Ogre::StringConverter::toString((unsigned long)uiView);
params["contentScalingFactor"] = Ogre::StringConverter::toString((unsigned long)getScalingFactor()); // 2 for non-retina
m_pRenderWnd = m_pRoot->createRenderWindow("", width, height, false, ¶ms);
m_pSceneMgrMain = m_pRoot->createSceneManager(ST_GENERIC, "SceneManagerMain");
m_pSceneMgrMain->setAmbientLight(Ogre::ColourValue(0.0, 0.0, 0.0));
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_pCameraMain->setProjectionType(Ogre::PT_ORTHOGRAPHIC);
m_pCameraMain->setOrthoWindow(25.0, 25.0);
m_pViewportMain = m_pRenderWnd->addViewport(m_pCameraMain, 1,
0.0,
0.0,
1.0,
1.0);
m_pViewportMain->setCamera(m_pCameraMain);
Ogre::OverlaySystem* m_pOverlaySystem = new Ogre::OverlaySystem();
m_pSceneMgrMain->addRenderQueueListener(m_pOverlaySystem);
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
archName = Ogre::String(m_ResourcePath + archName);
#endif
m_pResourceGroupMgr->addResourceLocation(archName, typeName, secName);
}
}
Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("Bootstrap");
m_pSoundMgr = OgreOggSound::OgreOggSoundManager::getSingletonPtr();
m_pSoundMgr->init();
m_pSoundMgr->createSound("SoundGreatFeedback", "ding3up2fast.wav", false, false, true);
m_pSoundMgr->createSound("SoundBadFeedback", "negativebeep.wav", false, false, true);
Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
m_pTimer = OGRE_NEW Ogre::Timer();
m_pTimer->reset();
requestResize();
m_pRenderWnd->setActive(true);
//.........这里部分代码省略.........
示例10: 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
//.........这里部分代码省略.........
示例11: 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);
}
}
}
}
//.........这里部分代码省略.........
示例12: 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
//.........这里部分代码省略.........
示例13: initialize
//.........这里部分代码省略.........
}
//-------------------------------------------------------------------------------------
void OgreManager::initialize(void)
{
// Create dummy CompositorPassProvider (see http://www.ogre3d.org/forums/viewtopic.php?f=11&t=84816&p=525752&hilit=CompositorPassProvider#p525752)
// If one of the resource locations contains a compositor with a custom pass, the editor doesn't work anymore. This is to prevent it
Ogre::MyCompositorPassProvider* mCompositorPassProvider = OGRE_NEW Ogre::MyCompositorPassProvider;
Ogre::CompositorManager2* compositorManager = mRoot->getCompositorManager2();
compositorManager->setCompositorPassProvider(mCompositorPassProvider);
// After resources have been setup and renderwindows created (in ogre widget), the Hlms managers are registered
registerHlms();
// Initialise, parse scripts etc
try
{
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(false);
}
catch (Ogre::Exception e){}
mPause = false;
try
{
mRoot->renderOneFrame(); // Render first
}
catch (Ogre::Exception e) {}
}
//-------------------------------------------------------------------------------------
void OgreManager::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();
if( secName != "Hlms" )
{
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 );
}
}
}
}
//****************************************************************************/
bool OgreManager::isRenderSystemGL(void)
{
if (mCurrentRenderSystem)
return (mCurrentRenderSystem->getName() == OGRE_RENDERSYSTEM_OPENGL3PLUS);
return false;
}
示例14: 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;
}
示例15: 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) );
}
}