本文整理汇总了C++中ogre::ConfigFile::loadDirect方法的典型用法代码示例。如果您正苦于以下问题:C++ ConfigFile::loadDirect方法的具体用法?C++ ConfigFile::loadDirect怎么用?C++ ConfigFile::loadDirect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::ConfigFile
的用法示例。
在下文中一共展示了ConfigFile::loadDirect方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadSettings
void loadSettings()
{
Ogre::ConfigFile cfg;
if (Util::pathExists(SETTINGS_FILE))
cfg.loadDirect(SETTINGS_FILE);
else
cfg.loadDirect(DEFAULT_SETTINGS_FILE);
//--- Ogre -------------------------------------------------------------------------
GlbVar.settings.ogre.pluginDirectory = cfg.getSetting("pluginDirectory", "ogre", ".");
GlbVar.settings.ogre.plugins = Ogre::StringConverter::parseStringVector(
cfg.getSetting("plugins", "ogre", "Plugin_CgProgramManager Plugin_ParticleFX Plugin_OctreeSceneManager")
);
GlbVar.settings.ogre.renderer = cfg.getSetting("renderer", "ogre", "OpenGL") == "Direct3D"
? Globals::Settings::OgreSettings::DIRECT3D
: Globals::Settings::OgreSettings::OPENGL;
GlbVar.settings.ogre.winWidth = Ogre::StringConverter::parseReal(cfg.getSetting("width", "ogre", "1024"));
GlbVar.settings.ogre.winHeight = Ogre::StringConverter::parseReal(cfg.getSetting("height", "ogre", "768"));
GlbVar.settings.ogre.winFullscreen = Ogre::StringConverter::parseBool(cfg.getSetting("fullscreen", "ogre", "no"));
GlbVar.settings.ogre.FSAA = cfg.getSetting("FSAA", "ogre", "0");
GlbVar.settings.ogre.vsync = cfg.getSetting("vsync", "ogre", "no");
//--- Graphics ---------------------------------------------------------------------
GlbVar.settings.graphics.lighting = Ogre::StringConverter::parseBool(cfg.getSetting("lighting", "graphics", "yes"));
GlbVar.settings.graphics.shadows = Ogre::StringConverter::parseBool(cfg.getSetting("shadows", "graphics", "yes"));
GlbVar.settings.graphics.normalMapping = Ogre::StringConverter::parseBool(cfg.getSetting("normalMapping", "graphics", "yes"));
GlbVar.settings.graphics.parallaxMapping = Ogre::StringConverter::parseBool(cfg.getSetting("parallaxMapping", "graphics", "yes"));
//--- Controls ---------------------------------------------------------------------
GlbVar.settings.controls.turningSensitivity = Ogre::StringConverter::parseReal(cfg.getSetting("turningSensitivity", "controls", "0.2"));
GlbVar.settings.controls.upDownSensitivity = Ogre::StringConverter::parseReal(cfg.getSetting("upDownSensitivity", "controls", "1"));
GlbVar.settings.controls.invertMouse = Ogre::StringConverter::parseBool(cfg.getSetting("invertMouse", "controls", "1"));
GlbVar.settings.controls.keys["forward"] = GlbVar.keyMap->stringToKey(cfg.getSetting("forward", "controls", "W"), OIS::KC_W);
GlbVar.settings.controls.keys["backward"] = GlbVar.keyMap->stringToKey(cfg.getSetting("backward", "controls", "S"), OIS::KC_W);
GlbVar.settings.controls.keys["left"] = GlbVar.keyMap->stringToKey(cfg.getSetting("left", "controls", "A"), OIS::KC_W);
GlbVar.settings.controls.keys["right"] = GlbVar.keyMap->stringToKey(cfg.getSetting("right", "controls", "D"), OIS::KC_W);
GlbVar.settings.controls.keys["dimensionSwitch"] = GlbVar.keyMap->stringToKey(cfg.getSetting("dimensionSwitch", "controls", "SPACE"), OIS::KC_W);
GlbVar.settings.controls.keys["gravitySwitch"] = GlbVar.keyMap->stringToKey(cfg.getSetting("gravitySwitch", "controls", "G"), OIS::KC_W);
GlbVar.settings.controls.keys["selfDestruct"] = GlbVar.keyMap->stringToKey(cfg.getSetting("selfDestruct", "controls", "Z"), OIS::KC_W);
GlbVar.settings.controls.keys["peepLeft"] = GlbVar.keyMap->stringToKey(cfg.getSetting("peepLeft", "controls", "Q"), OIS::KC_W);
GlbVar.settings.controls.keys["peepRight"] = GlbVar.keyMap->stringToKey(cfg.getSetting("peepRight", "controls", "E"), OIS::KC_W);
//--- Misc. ------------------------------------------------------------------------
GlbVar.settings.misc.fixCameraObstruction = Ogre::StringConverter::parseBool(cfg.getSetting("fixCameraObstruction", "misc", "yes"));
//----------------------------------------------------------------------------------
}
示例2: createRenderWindow
void createRenderWindow()
{
mRoot->initialise(false);
{
Ogre::String lWindowTitle = "Ballz";
Ogre::ConfigFile cfgFile;
cfgFile.loadDirect("config.ini");
std::string wString = cfgFile.getSetting("width", "renderer");
std::string hString = cfgFile.getSetting("height", "renderer");
std::string fsString = cfgFile.getSetting("fullscreen", "renderer");
int lSizeX = Ogre::StringConverter::parseInt(wString);
int lSizeY = Ogre::StringConverter::parseInt(hString);
int lFullscreen = Ogre::StringConverter::parseBool(fsString);
Ogre::NameValuePairList lParams;
// we use our own FXAA
lParams["FSAA"] = "0";
lParams["vsync"] = "false";
lParams["useNVPerfHUD"] = "true";
mWindow = mRoot->createRenderWindow(lWindowTitle, lSizeX, lSizeY, lFullscreen, &lParams);
}
}
示例3: loadRecord
void loadRecord()
{
Ogre::ConfigFile cfg;
try
{
cfg.loadDirect(RECORD_FILE);
}
catch (Ogre::FileNotFoundException &)
{
std::ofstream out(RECORD_FILE);
out << std::endl;
out.close();
cfg.loadDirect(RECORD_FILE);
}
GlbVar.records.firstTime = Ogre::StringConverter::parseBool(cfg.getSetting("firstTime", Ogre::StringUtil::BLANK, "yes"));
Ogre::String highestLevelStr = cfg.getSetting("highestLevelIndex", Ogre::StringUtil::BLANK, "n");
if (highestLevelStr != "n")
{
GlbVar.records.highestLevelIndex = Ogre::StringConverter::parseInt(highestLevelStr);
if (GlbVar.records.highestLevelIndex >= GlbVar.woMgr->getNumWorlds())
GlbVar.records.highestLevelIndex = GlbVar.firstLevel;
}
else
GlbVar.records.highestLevelIndex = GlbVar.firstLevel;
//Deserialise recordMap from string.
Ogre::String recordMapStr = cfg.getSetting("records", Ogre::StringUtil::BLANK, "n");
if (recordMapStr != "n")
{
std::stringstream recordMapStream(std::stringstream::in | std::stringstream::out);
recordMapStream << recordMapStr;
boost::archive::text_iarchive ia(recordMapStream);
ia >> GlbVar.records.recordMap;
}
示例4: mFilePath
SettingsFileParser::SettingsFileParser(Ogre::String filePath)
: mFilePath(filePath)
{
// Set default settings
mRestoreConfig = false;
mLockMouse = true;
mDebugDraw = true;
mHumanChars = true;
mObstacles = true;
mSingleNavmesh = false;
mRaycastScene = false;
mTempObstacleSteering = true;
mComplexObstacles = true;
mTerrain = false;
mPaged = false;
mTerrainTilesX = 1;
mTerrainTilesZ = 1;
mTerrainTileSize = 12000.0f;
mTerrainTileResolution = 513;
mTerrainHeightScale = 1.0f;
// Load settings from config file
Ogre::ConfigFile settingsFile = Ogre::ConfigFile();
settingsFile.loadDirect(filePath);
Ogre::ConfigFile::SectionIterator sectIt = settingsFile.getSectionIterator();
Ogre::String sectionName, optionName, optionValue;
while(sectIt.hasMoreElements())
{
sectionName = sectIt.peekNextKey();
Ogre::ConfigFile::SettingsMultiMap *sectSettings = sectIt.getNext();
Ogre::ConfigFile::SettingsMultiMap::iterator it;
for(it = sectSettings->begin(); it != sectSettings->end(); it++) {
optionName = it->first;
optionValue = it->second;
addOption(sectionName, optionName, optionValue);
}
}
}
示例5: loadConfig
int Landusemap::loadConfig(Ogre::String filename)
{
Vector3 mapsize = gEnv->terrainManager->getMaxTerrainSize();
std::map<unsigned int, String> usemap;
String textureFilename = "";
LOG("Parsing landuse config: '"+filename+"'");
String group = "";
try
{
group = ResourceGroupManager::getSingleton().findGroupContainingResource(filename);
}catch(...)
{
// we wont catch anything, since the path could be absolute as well, then the group is not found
}
Ogre::ConfigFile cfg;
try
{
// try to load directly otherwise via resource group
if (group == "")
cfg.loadDirect(filename);
else
cfg.loadFromResourceSystem(filename, group, "\x09:=", true);
} catch(Ogre::Exception& e)
{
ErrorUtils::ShowError(_L("Error while loading landuse config"), e.getFullDescription());
return 1;
}
Ogre::ConfigFile::SectionIterator seci = cfg.getSectionIterator();
Ogre::String secName, kname, kvalue;
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)
{
kname = i->first;
kvalue = i->second;
// we got all the data available now, processing now
if (secName == "general" || secName == "config")
{
// set some class properties accoring to the information in this section
if (kname == "texture")
textureFilename = kvalue;
else if (kname == "frictionconfig" || kname == "loadGroundModelsConfig")
gEnv->collisions->loadGroundModelsConfigFile(kvalue);
else if (kname == "defaultuse")
default_ground_model = gEnv->collisions->getGroundModelByString(kvalue);
} else if (secName == "use-map")
{
if (kname.size() != 10)
{
LOG("invalid color in landuse line in " + filename);
continue;
}
char *ptr; //not used
unsigned int color = strtoul(kname.c_str(), &ptr, 16);
usemap[color] = kvalue;
}
}
}
#ifdef USE_PAGED
// process the config data and load the buffers finally
try
{
Forests::ColorMap *colourMap = Forests::ColorMap::load(textureFilename, Forests::CHANNEL_COLOR);
colourMap->setFilter(Forests::MAPFILTER_NONE);
/*
// debug things below
printf("found ground use definitions:\n");
for (std::map < uint32, String >::iterator it=usemap.begin(); it!=usemap.end(); it++)
{
printf(" 0x%Lx : %s\n", it->first, it->second.c_str());
}
*/
bool bgr = colourMap->getPixelBox().format == PF_A8B8G8R8;
Ogre::TRect<Ogre::Real> bounds = Forests::TBounds(0, 0, mapsize.x, mapsize.z);
// now allocate the data buffer to hold pointers to ground models
data = new ground_model_t*[(int)(mapsize.x * mapsize.z)];
ground_model_t **ptr = data;
//std::map < String, int > counters;
for (int z=0; z<mapsize.z; z++)
{
for (int x=0; x<mapsize.x; x++)
{
unsigned int col = colourMap->getColorAt(x, z, bounds);
if (bgr)
{
// Swap red and blue values
unsigned int cols = col & 0xFF00FF00;
//.........这里部分代码省略.........
示例6: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
// ------------------------- Check for command line argument -------------------------------------------
if (! argv[1])
{
printf("\n");
printf("Missing argument.\nExample: \"Converter.exe job1.cfg\"");
return 0;
}
// ------------------------- Basic Ogre Engine initialization -------------------------------------------
Ogre::Root* root = new Ogre::Root;
Ogre::RenderSystem* rendersys = root->getRenderSystemByName("Direct3D9 Rendering Subsystem");
rendersys->setConfigOption("Full Screen", "No");
rendersys->setConfigOption("Video Mode", "800 x 600 @ 32-bit colour");
root->setRenderSystem(rendersys);
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("resource", "FileSystem", "General");
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
root->initialise(false);
Ogre::RenderWindow* window = root->createRenderWindow("RAW2OGT", 800, 600, false);
Ogre::SceneManager* scenemgr = root->createSceneManager(Ogre::SceneType::ST_GENERIC);
Ogre::Camera* camera = scenemgr->createCamera("camera");
Ogre::Viewport* viewport = window->addViewport(camera);
/*Ogre::Vector3 lightdir(0, -0.3, 0.75);
lightdir.normalise();
Ogre::Light* l = scenemgr->createLight("tstLight");
l->setType(Ogre::Light::LT_DIRECTIONAL);
l->setDirection(lightdir);
l->setDiffuseColour(Ogre::ColourValue(1.0, 1.0, 1.0));
l->setSpecularColour(Ogre::ColourValue(0.4, 0.4, 0.4));*/
scenemgr->setAmbientLight(Ogre::ColourValue(0.7, 0.7, 0.7));
// --------------------------------- Start convert ----------------------------------------------------
// Load job config
Ogre::ConfigFile* terrainconfig = OGRE_NEW Ogre::ConfigFile();
terrainconfig->loadDirect(argv[1]);
// Load info from [general] block
Ogre::String heightmapfile = terrainconfig->getSetting("heightmap", "general");
Ogre::Real heightmapscale = Ogre::StringConverter::parseReal(terrainconfig->getSetting("heightmapscale", "general"));
Ogre::Real heightmapoffset = Ogre::StringConverter::parseReal(terrainconfig->getSetting("heightmapoffset", "general"));
Ogre::uint16 terrainsize = Ogre::StringConverter::parseUnsignedInt(terrainconfig->getSetting("terrainsize", "general"));
Ogre::Real worldsize = Ogre::StringConverter::parseReal(terrainconfig->getSetting("worldsize", "general"));
Ogre::uint16 layercount = Ogre::StringConverter::parseUnsignedInt(terrainconfig->getSetting("layercount", "general"));
// initialise stream to heightmapfile
Ogre::DataStreamPtr stream = Ogre::ResourceGroupManager::getSingleton().openResource(heightmapfile, "General");
size_t size = stream.get()->size();
// verify size
if(size != terrainsize * terrainsize * 4)
OGRE_EXCEPT( Ogre::Exception::ERR_INTERNAL_ERROR, "Size of stream does not match terrainsize!", "TerrainPage" );
// load to buffer
float* buffer = OGRE_ALLOC_T(float, size, Ogre::MEMCATEGORY_GENERAL);
stream->read(buffer, size);
// apply scale and offset
for(int i=0;i<terrainsize*terrainsize;i++)
{
buffer[i] = (buffer[i] + heightmapoffset) * heightmapscale;
}
// Terrain initialization
Ogre::TerrainGlobalOptions* terrainglobals = OGRE_NEW Ogre::TerrainGlobalOptions();
terrainglobals->setMaxPixelError(1);
//terrainglobals->setCompositeMapDistance(30000);
//terrainglobals->setLightMapDirection(lightdir);
//terrainglobals->setCompositeMapAmbient(scenemgr->getAmbientLight());
//terrainglobals->setCompositeMapDiffuse(l->getDiffuseColour());
Ogre::TerrainMaterialGeneratorA::SM2Profile* pMatProfile =
static_cast<Ogre::TerrainMaterialGeneratorA::SM2Profile*>(terrainglobals->getDefaultMaterialGenerator()->getActiveProfile());
pMatProfile->setLightmapEnabled(false);
pMatProfile->setCompositeMapEnabled(false);
Ogre::TerrainGroup* terraingroup = OGRE_NEW Ogre::TerrainGroup(scenemgr, Ogre::Terrain::ALIGN_X_Z, terrainsize, worldsize);
terraingroup->setFilenameConvention(Ogre::String("terrain"), Ogre::String("ogt"));
terraingroup->setOrigin(Ogre::Vector3::ZERO);
Ogre::Terrain* terrain = OGRE_NEW Ogre::Terrain(scenemgr);
// terrainsettings
Ogre::Terrain::ImportData& imp = terraingroup->getDefaultImportSettings();
imp.terrainSize = terrainsize;
imp.worldSize = worldsize;
imp.minBatchSize = 33;
imp.maxBatchSize = 65;
//.........这里部分代码省略.........