本文整理汇总了C++中ogre::ConfigFile::loadFromResourceSystem方法的典型用法代码示例。如果您正苦于以下问题:C++ ConfigFile::loadFromResourceSystem方法的具体用法?C++ ConfigFile::loadFromResourceSystem怎么用?C++ ConfigFile::loadFromResourceSystem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::ConfigFile
的用法示例。
在下文中一共展示了ConfigFile::loadFromResourceSystem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
//.........这里部分代码省略.........
示例2: init
// -------------------------------------------------------------------------
void Terrain_Demo::init(Ogre::Root *root, Ogre::RenderWindow *win, OgreBulletApplication *application)
{
mCameraMove = 1;
mHelpKeys.clear();
mHelpKeys.push_back(BASIC_HELP_INFO0);
mHelpKeys.push_back(BASIC_HELP_INFO1);
mHelpKeys.push_back(BASIC_HELP_INFO2);
mHelpKeys.push_back(BASIC_HELP_INFO3);
mHelpKeys.push_back(BASIC_HELP_INFO4);
mHelpKeys.push_back(BASIC_HELP_INFO5);
mHelpKeys.push_back(BASIC_HELP_INFO6);
mHelpKeys.push_back("Use Arrow Key to move Car.");
// reset
for (int i = 0; i < 4; i++)
{
mWheelsEngine[i] = 0;
mWheelsSteerable[i] = 0;
}
mWheelsEngineCount = 2;
mWheelsEngine[0] = 0;
mWheelsEngine[1] = 1;
mWheelsEngine[2] = 2;
mWheelsEngine[3] = 3;
mWheelsSteerableCount = 2;
mWheelsSteerable[0] = 0;
mWheelsSteerable[1] = 1;
//mWheelsSteerable[2] = 2;
//mWheelsSteerable[3] = 3;
mWheelEngineStyle = 0;
mWheelSteeringStyle = 0;
mSteeringLeft = false;
mSteeringRight = false;
mEngineForce = 0;
mSteering = 0;
// ------------------------
// Start OgreScene
mSceneMgr = root->createSceneManager("TerrainSceneManager", "BulletTerrain");
mCamera = mSceneMgr->createCamera("Cam");
//mCamera->setFOVy(Degree(90));
mCamera->setNearClipDistance(0.1);
mCamera->setFarClipDistance(1000);
Viewport *vp = win->addViewport(mCamera);
vp->setBackgroundColour(ColourValue(0,0,0));
// Alter the camera aspect ratio to match the viewport
mCamera->setAspectRatio(
Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
mCamera->setPosition(CameraStart + terrain_Shift);
mCamera->lookAt(CarPosition + terrain_Shift);
// Create a terrain
std::string terrain_cfg("terrain.cfg");
mSceneMgr->setWorldGeometry(terrain_cfg);
OgreBulletListener::init(root, win, application);
// ------------------------
// add lights
setBasicLight();
// ------------------------
// Add the Gui
setPhysicGUI();
// ------------------------
// Start Bullet
initWorld();
// ------------------------
// Add the ground
// 0.1, 0.8
//addStaticPlane(0.3, 0.8);
{
Ogre::ConfigFile config;
config.loadFromResourceSystem(terrain_cfg, ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME, "=", true);
unsigned page_size = Ogre::StringConverter::parseUnsignedInt(config.getSetting("PageSize"));
Ogre::Vector3 terrainScale(Ogre::StringConverter::parseReal(config.getSetting("PageWorldX")) / (page_size - 1),
Ogre::StringConverter::parseReal(config.getSetting("MaxHeight")),
Ogre::StringConverter::parseReal(config.getSetting("PageWorldZ")) / (page_size - 1));
Ogre::String terrainfileName = config.getSetting("Heightmap.image");
float *heights = new float[page_size*page_size];
Ogre::Image terrainHeightMap;
terrainHeightMap.load(terrainfileName, Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
//.........这里部分代码省略.........