本文整理汇总了C++中ogre::String::data方法的典型用法代码示例。如果您正苦于以下问题:C++ String::data方法的具体用法?C++ String::data怎么用?C++ String::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::String
的用法示例。
在下文中一共展示了String::data方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initialize
bool AudioResourceManager::initialize()
{
srand(time(NULL));
Ogre::String path = Ogre::macBundlePath() + "/Contents/Resources/media/config/audio_events.xml";
//xml_document<> doc; // character type defaults to char
FILE *audioConfigFile = fopen(path.data(), "r");
std::vector<char> buffer;
int c;
while (EOF !=(c=getc(audioConfigFile))){
buffer.push_back(c);
}
char buf[buffer.size()];
for (int i = 0; i < buffer.size(); i++){
buf[i] = buffer[i];
}
XMLDocument doc;
doc.Parse(buf);
XMLElement *eventIter = doc.FirstChildElement()->FirstChildElement();
unsigned int currentHandle = 0;
while (eventIter != NULL)
{
XMLNode *unitIter = eventIter->FirstChildElement()->NextSiblingElement();
std::string eventName = eventIter->FirstChildElement()->GetText();
while (unitIter != NULL) {
AudioResource unit;
unit.filename = unitIter->FirstChildElement("filename")->GetText();// first_node("filename")->value();
printf("filename: %s\n", unit.filename.c_str());
unit.panning = atof(unitIter->FirstChildElement("panning")->GetText());
unit.pitch = atof(unitIter->FirstChildElement("pitch")->GetText());
unit.looping = atoi(unitIter->FirstChildElement("looping")->GetText());
unit.gain = atof(unitIter->FirstChildElement("gain")->GetText());
unit.bufferHandle = -1;
unit.sourceHandle = -1;
if ( eventName == "apply_force_left" || eventName == "apply_force_right" || eventName=="fall_off") unit.canStop = false;
else unit.canStop = true;
alGenSources(1, &unit.sourceHandle);
resources[eventName].push_back(unit);
unitIter = unitIter->NextSibling();
}
eventIter = eventIter->NextSiblingElement();
}
return true;
}
示例2: saveAll
bool OgreDetourTileCache::saveAll(Ogre::String filename)
{
if (!m_tileCache) {
Ogre::LogManager::getSingletonPtr()->logMessage("Error: OgreDetourTileCache::saveAll("+filename+"). Could not save tilecache, no tilecache to save.");
return false;
}
FILE* fp = fopen(filename.data(), "wb");
if (!fp) {
Ogre::LogManager::getSingletonPtr()->logMessage("Error: OgreDetourTileCache::saveAll("+filename+"). Could not save file.");
return false;
}
// Store header.
TileCacheSetHeader header;
header.magic = TILECACHESET_MAGIC;
header.version = TILECACHESET_VERSION;
header.numTiles = 0;
for (int i = 0; i < m_tileCache->getTileCount(); ++i)
{
const dtCompressedTile* tile = m_tileCache->getTile(i);
if (!tile || !tile->header || !tile->dataSize) continue;
header.numTiles++;
}
memcpy(&header.cacheParams, m_tileCache->getParams(), sizeof(dtTileCacheParams));
memcpy(&header.meshParams, m_recast->m_navMesh->getParams(), sizeof(dtNavMeshParams));
memcpy(&header.recastConfig, &m_cfg, sizeof(rcConfig));
fwrite(&header, sizeof(TileCacheSetHeader), 1, fp);
// Store tiles.
for (int i = 0; i < m_tileCache->getTileCount(); ++i)
{
const dtCompressedTile* tile = m_tileCache->getTile(i);
if (!tile || !tile->header || !tile->dataSize) continue;
TileCacheTileHeader tileHeader;
tileHeader.tileRef = m_tileCache->getTileRef(tile);
tileHeader.dataSize = tile->dataSize;
fwrite(&tileHeader, sizeof(tileHeader), 1, fp);
fwrite(tile->data, tile->dataSize, 1, fp);
}
fclose(fp);
return true;
}
示例3: createMaterial
Ogre::MaterialPtr AssetLoader::createMaterial(Ogre::String name, int index, aiMaterial* mat)
{
Ogre::MaterialManager* omatMgr = Ogre::MaterialManager::getSingletonPtr();
std::ostringstream matname;
matname << name.data() << "_mat";
matname.widen(4);
matname.fill('0');
matname << index;
Ogre::String matName = matname.str();
Ogre::ResourceManager::ResourceCreateOrRetrieveResult status = omatMgr->createOrRetrieve(matName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true);
Ogre::MaterialPtr omat = status.first;
aiColor4D clr(1.0, 1.0, 1.0, 1.0);
aiGetMaterialColor(mat, AI_MATKEY_COLOR_DIFFUSE, &clr);
omat->getTechnique(0)->getPass(0)->setDiffuse(clr.r, clr.g, clr.b, clr.a);
aiGetMaterialColor(mat, AI_MATKEY_COLOR_SPECULAR, &clr);
omat->getTechnique(0)->getPass(0)->setSpecular(clr.r, clr.g, clr.b, clr.a);
aiGetMaterialColor(mat, AI_MATKEY_COLOR_AMBIENT, &clr);
omat->getTechnique(0)->getPass(0)->setAmbient(clr.r, clr.g, clr.b);
aiGetMaterialColor(mat, AI_MATKEY_COLOR_EMISSIVE, &clr);
omat->getTechnique(0)->getPass(0)->setSelfIllumination(clr.r, clr.g, clr.b);
omat->getTechnique(0)->getPass(0)->setShadingMode(Ogre::SO_GOURAUD);
omat->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
omat->getTechnique(0)->getPass(0)->setLightingEnabled(true);
omat->getTechnique(0)->getPass(0)->setDepthCheckEnabled(true);
//omat->getTechnique(0)->getPass(0)->setVertexColourTracking(Ogre::TVC_DIFFUSE);
aiString path;
aiReturn res = mat->GetTexture(aiTextureType_DIFFUSE, 0, &path);
if (res == AI_SUCCESS) {
Ogre::TextureUnitState* stateBase = omat->getTechnique(0)->getPass(0)->createTextureUnitState();
stateBase->setColourOperation(Ogre::LBO_MODULATE);
stateBase->setTextureName(path.data);
}
return omat;
}
示例4: loadAll
bool OgreDetourTileCache::loadAll(Ogre::String filename)
{
FILE* fp = fopen(filename.data(), "rb");
if (!fp) {
Ogre::LogManager::getSingletonPtr()->logMessage("Error: OgreDetourTileCache::loadAll("+filename+"). Could not open file.");
return false;
}
// Read header.
TileCacheSetHeader header;
fread(&header, sizeof(TileCacheSetHeader), 1, fp);
if (header.magic != TILECACHESET_MAGIC)
{
fclose(fp);
Ogre::LogManager::getSingletonPtr()->logMessage("Error: OgreDetourTileCache::loadAll("+filename+"). File does not appear to contain valid tilecache data.");
return false;
}
if (header.version != TILECACHESET_VERSION)
{
fclose(fp);
Ogre::LogManager::getSingletonPtr()->logMessage("Error: OgreDetourTileCache::loadAll("+filename+"). File contains a different version of the tilecache data format ("+Ogre::StringConverter::toString(header.version)+" instead of "+Ogre::StringConverter::toString(TILECACHESET_VERSION)+").");
return false;
}
m_recast->m_navMesh = dtAllocNavMesh();
if (!m_recast->m_navMesh)
{
fclose(fp);
Ogre::LogManager::getSingletonPtr()->logMessage("Error: OgreDetourTileCache::loadAll("+filename+"). Could not allocate navmesh.");
return false;
}
dtStatus status = m_recast->m_navMesh->init(&header.meshParams);
if (dtStatusFailed(status))
{
fclose(fp);
Ogre::LogManager::getSingletonPtr()->logMessage("Error: OgreDetourTileCache::loadAll("+filename+"). Could not init navmesh.");
return false;
}
m_tileCache = dtAllocTileCache();
if (!m_tileCache)
{
fclose(fp);
Ogre::LogManager::getSingletonPtr()->logMessage("Error: OgreDetourTileCache::loadAll("+filename+"). Could not allocate tilecache.");
return false;
}
status = m_tileCache->init(&header.cacheParams, m_talloc, m_tcomp, m_tmproc);
if (dtStatusFailed(status))
{
fclose(fp);
Ogre::LogManager::getSingletonPtr()->logMessage("Error: OgreDetourTileCache::loadAll("+filename+"). Could not init tilecache.");
return false;
}
memcpy(&m_cfg, &header.recastConfig, sizeof(rcConfig));
// Read tiles.
for (int i = 0; i < header.numTiles; ++i)
{
TileCacheTileHeader tileHeader;
fread(&tileHeader, sizeof(tileHeader), 1, fp);
if (!tileHeader.tileRef || !tileHeader.dataSize)
break;
unsigned char* data = (unsigned char*)dtAlloc(tileHeader.dataSize, DT_ALLOC_PERM);
if (!data) break;
memset(data, 0, tileHeader.dataSize);
fread(data, tileHeader.dataSize, 1, fp);
dtCompressedTileRef tile = 0;
m_tileCache->addTile(data, tileHeader.dataSize, DT_COMPRESSEDTILE_FREE_DATA, &tile);
if (tile)
m_tileCache->buildNavMeshTile(tile, m_recast->m_navMesh);
}
fclose(fp);
// Init recast navmeshquery with created navmesh (in OgreRecast component)
m_recast->m_navQuery = dtAllocNavMeshQuery();
m_recast->m_navQuery->init(m_recast->m_navMesh, 2048);
// Config
// TODO handle this nicer, also inputGeom is not inited, making some functions crash
m_cellSize = m_cfg.cs;
m_tileSize = m_cfg.tileSize;
// cache bounding box
const float* bmin = m_cfg.bmin;
const float* bmax = m_cfg.bmax;
// Copy loaded config back to recast module
memcpy(&m_recast->m_cfg, &m_cfg, sizeof(rcConfig));
m_tileSize = m_cfg.tileSize;
m_cellSize = m_cfg.cs;
m_tcparams = header.cacheParams;
//.........这里部分代码省略.........