本文整理汇总了C++中ogre::String类的典型用法代码示例。如果您正苦于以下问题:C++ String类的具体用法?C++ String怎么用?C++ String使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了String类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeFlag
//----------------------------------------------------------------------------------
bool GameObject::removeFlag(Ogre::String flag)
{
std::string::size_type pos1 = mFlags.find("|" + flag + "|");
if (pos1 == Ogre::String::npos)
{
return false;
}
++pos1;
std::string::size_type pos2 = flag.length() + 1;
mFlags.erase(pos1, pos2);
return true;
}
示例2: SaveSoundInfoFromFile
void SoundEditDialog::SaveSoundInfoFromFile(const Ogre::String& filename)
{
if (mSoundInfoFileChanged)
{
char buf[1024];
FILE* pFile = NULL;
pFile = ::fopen(filename.c_str(), "w");
if(NULL == pFile)
{
wxMessageBox("Can't open the file, Maybe the file is missing or it is read only!");
return;
}
memset(buf, 0, sizeof(buf));
sprintf(buf, "INT\tINT\tINT\tINT\tINT\tINT\tINT\tINT\n");
::fwrite(buf, strlen(buf), 1, pFile);
memset(buf, 0, sizeof(buf));
sprintf(buf, "ID\t声音ID\t声源位置X\t声源位置Z\t有效距离\t连播次数\t间隔时间(ms)\t下一次连播间隔时间(ms)\n");
::fwrite(buf, strlen(buf), 1, pFile);
memset(buf, 0, sizeof(buf));
for(size_t i=0; i<mSoundItems.size(); ++i)
{
SoundItem* soundItem = mSoundItems[i];
if (soundItem->mRepeatTime == 0)
{
sprintf(buf, "%d\t%d\t%d\t%d\t%d\n",
i, soundItem->mSoundID, soundItem->mXPos, soundItem->mZPos, soundItem->mRadius);
}
else
{
sprintf(buf, "%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n",
i, soundItem->mSoundID, soundItem->mXPos, soundItem->mZPos, soundItem->mRadius,
soundItem->mRepeatTime, soundItem->mRepeatIntervalTime, soundItem->mNextRepeatTime);
}
::fwrite(buf, strlen(buf), 1, pFile);
}
::fclose(pFile);
mSoundInfoFileChanged = false;
}
}
示例3: tryLoadResource
Ogre::ResourcePtr
loadCorrelativeResource(const Ogre::String& resourceName, const Ogre::String& groupName,
const Ogre::String& baseResourceName, const Ogre::String& baseGroupName,
Ogre::ResourceManager& resourceManager)
{
Ogre::ResourcePtr res;
Ogre::String name, path;
Ogre::StringUtil::splitFilename(resourceName, name, path);
bool existsPath = !path.empty();
// First, load in correlatived group and path if resource name doesn't exists path
if (!existsPath)
{
Ogre::StringUtil::splitFilename(baseResourceName, name, path);
if (!path.empty())
{
name = path + resourceName;
res = tryLoadResource(resourceManager, name, baseGroupName);
if (!res.isNull())
return res;
}
}
// Second, load in correlatived group
res = tryLoadResource(resourceManager, resourceName, baseGroupName);
if (!res.isNull())
return res;
// Three, load in user given group
if (!groupName.empty())
{
res = tryLoadResource(resourceManager, resourceName, groupName);
if (!res.isNull())
return res;
}
// Four, load in global default group
if (groupName != DEFAULT_RESOURCE_GROUP_NAME)
{
res = tryLoadResource(resourceManager, resourceName, groupName);
if (!res.isNull())
return res;
}
return res;
}
示例4: _writeFile
//-----------------------------------------------------------------------------
int COFSSceneSerializer::_writeFile(Ogre::String exportfile, const bool forceSave)
{
if (exportfile.empty())
return SCF_ERRUNKNOWN;
OgitorsRoot *ogRoot = OgitorsRoot::getSingletonPtr();
// Open a stream to output our XML Content and write the general headercopyFile
std::stringstream outfile;
outfile << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
outfile << "<OGITORSCENE version=\"" << Globals::OGSCENE_FORMAT_VERSION << "\">\n";
PROJECTOPTIONS *pOpt = ogRoot->GetProjectOptions();
pOpt->CameraSpeed = ogRoot->GetViewport()->GetCameraSpeed();
ogRoot->WriteProjectOptions(outfile, pOpt);
ObjectVector ObjectList;
OgitorsPropertyValueMap theList;
OgitorsPropertyValueMap::iterator ni;
// Start from 1, since 0 means all objects
for(unsigned int i = 1; i < LAST_EDITOR; i++)
{
ogRoot->GetObjectList(i, ObjectList);
for(unsigned int ob = 0; ob < ObjectList.size(); ob++)
{
/// If Object does not have a parent, then it is not part of the scene
if(ObjectList[ob]->getParent())
{
ObjectList[ob]->onSave(forceSave);
if(ObjectList[ob]->isSerializable())
{
outfile << OgitorsUtils::GetObjectSaveStringV2(ObjectList[ob], 2, true, true).c_str();
outfile << "\n";
}
}
}
}
outfile << "</OGITORSCENE>\n";
if (OgitorsUtils::SaveStreamOfs(outfile, exportfile)) {
return SCF_OK;
}
return SCF_ERRFILE;
}
示例5: GetObjectListByCustomProperty
//-----------------------------------------------------------------------------------------
void OgitorsRoot::GetObjectListByCustomProperty(unsigned int type, const Ogre::String& nameregexp, bool inverse, ObjectVector& list)
{
list.clear();
try
{
const boost::regex e(nameregexp.c_str());
NameObjectPairList::iterator list_st, list_ed;
if(type == 0)
{
list_st = mNameList.begin();
list_ed = mNameList.end();
}
else
{
list_st = mNamesByType[type].begin();
list_ed = mNamesByType[type].end();
}
OgitorsPropertyVector pvec;
while(list_st != list_ed)
{
pvec = list_st->second->getCustomProperties()->getPropertyVector();
bool add_list = false;
for(unsigned int k = 0;k < pvec.size();k++)
{
if(regex_match(pvec[k]->getName().c_str(), e))
{
add_list = true;
break;
}
}
if(add_list != inverse)
list.push_back(list_st->second);
list_st++;
}
}
catch(...)
{
list.clear();
}
}
示例6: save
void Cube::save(Ogre::String file)
{
if (rndCounter == 0)
{
std::ofstream output(file.c_str());
// Write cube size
output << size << std::endl;
for (int i = 0; i < size; ++i)
for (int j = 0; j < size; ++j)
for (int k = 0; k < size; ++k)
{
CubeElement *e = data[i][j][k];
Ogre::Entity *ent = static_cast<Ogre::Entity*>(e->node->getAttachedObject(0));
Ogre::SceneNode *node = e->node;
// Write name, indexes and position
output << node->getName() << "\n"
<< "\t" << i << " " << j << " " << k << "\n" // index in data array
<< "\t" << node->getPosition().x << " " << node->getPosition().y << " " << node->getPosition().z << "\n"; // position
// Write orientation
Ogre::Vector3 orient_axis;
Ogre::Degree orient_angle;
node->getOrientation().ToAngleAxis(orient_angle, orient_axis);
output << "\t" << orient_axis.x << " " << orient_axis.y << " " << orient_axis.z << " " // orientation axis
<< orient_angle.valueDegrees() << "\n"; // orientation angle
output << "\t" << ent->getSubEntity(0)->getMaterialName() << "\n"
<< "\t" << ent->getSubEntity(1)->getMaterialName() << "\n"
<< "\t" << ent->getSubEntity(2)->getMaterialName() << "\n"
<< "\t" << ent->getSubEntity(3)->getMaterialName() << "\n"
<< "\t" << ent->getSubEntity(4)->getMaterialName() << "\n"
<< "\t" << ent->getSubEntity(5)->getMaterialName() << "\n";
// Write pivot info
output << "\t" << e->isPivot << "\n";
if (e->isPivot)
{
// pivot indexes
output << "\t" << e->pivotArrays[0] << " " << e->pivotArrayIndexes[0] << "\n"
<< "\t" << e->pivotArrays[1] << " " << e->pivotArrayIndexes[1] << "\n";
}
// flush
output << std::endl;
}
output.close();
}
}
示例7: doConnect
bool NetworkManager::doConnect( Ogre::String serverIP, Ogre::ushort serverPort )
{
mConnectAtemp = true;
switch(mRakPeer->Connect(serverIP.c_str(), serverPort, 0, 0, 0))
{
case RakNet::CONNECTION_ATTEMPT_STARTED:
{
Ogre::LogManager::getSingletonPtr()
->logMessage(RealToys::logMessagePrefix + "CONNECTION_ATTEMPT_STARTED");
return true;
break;
}
case RakNet::INVALID_PARAMETER:
{
Ogre::LogManager::getSingletonPtr()
->logMessage(RealToys::logMessagePrefix + "INVALID_PARAMETER");
break;
}
case RakNet::CANNOT_RESOLVE_DOMAIN_NAME:
{
Ogre::LogManager::getSingletonPtr()
->logMessage(RealToys::logMessagePrefix + "CANNOT_RESOLVE_DOMAIN_NAME");
break;
}
case RakNet::ALREADY_CONNECTED_TO_ENDPOINT:
{
Ogre::LogManager::getSingletonPtr()
->logMessage(RealToys::logMessagePrefix + "ALREADY_CONNECTED_TO_ENDPOINT");
break;
}
case RakNet::CONNECTION_ATTEMPT_ALREADY_IN_PROGRESS:
{
Ogre::LogManager::getSingletonPtr()
->logMessage(RealToys::logMessagePrefix + "CONNECTION_ATTEMPT_ALREADY_IN_PROGRESS");
break;
}
case RakNet::SECURITY_INITIALIZATION_FAILED:
{
Ogre::LogManager::getSingletonPtr()
->logMessage(RealToys::logMessagePrefix + "SECURITY_INITIALIZATION_FAILED");
break;
}
}
return false;
}
示例8: fnmatch
bool fnmatch (Ogre::String pattern, Ogre::String name, int dummy)
{
if (pattern == "*")
{
return true;
}
if (pattern.substr(0,2) == "*.")
{
Ogre::StringUtil::toLowerCase(pattern);
Ogre::StringUtil::toLowerCase(name);
Ogre::String extToFind = pattern.substr(2, pattern.size() - 2);
if ((name.size() > extToFind.size()) &&(extToFind == name.substr(name.size() - extToFind.size(), extToFind.size())))
{
return 0; // match
}
else
{
return 1; // don't match
}
}
return false;
}
示例9: mpCam
MovableTextOverlayAttributes::MovableTextOverlayAttributes(const Ogre::String & name, const Ogre::Camera *cam,
const Ogre::String & fontName, int charHeight, const Ogre::ColourValue & color, const Ogre::String & materialName)
: mpCam(cam)
, mpFont(NULL)
, mName(name)
, mFontName("")
, mMaterialName("")
, mCharHeight(charHeight)
, mColor(ColourValue::ZERO)
{
if (fontName.length() == 0)
Ogre::Exception(Ogre::Exception::ERR_INVALIDPARAMS, "Invalid font name", "MovableTextOverlayAttributes::MovableTextOverlayAttributes");
setFontName(fontName);
setMaterialName(materialName);
setColor(color);
}
示例10: writeXMLFile
//-----------------------------------------------------------------------
void XercesWriter::writeXMLFile(const XMLNode* root, const Ogre::String& filename)
{
XERCES_CPP_NAMESPACE_USE;
DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(L"Core");
DOMDocumentType* docType = NULL;
DOMDocument* doc = impl->createDocument(NULL, transcode(root->getName()).c_str(), docType);
populateDOMElement(root, doc->getDocumentElement());
LocalFileFormatTarget destination(filename.c_str());
DOMWriter* writer = impl->createDOMWriter();
writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
writer->writeNode(&destination, *doc);
writer->release();
doc->release();
}
示例11: 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;
}
示例12: HasAttribute
bool LuaScriptUtilities::HasAttribute(
lua_State* const luaVM,
const int tableIndex,
const Ogre::String& attributeName)
{
if (!lua_istable(luaVM, tableIndex))
return false;
lua_pushstring(luaVM, attributeName.c_str());
lua_gettable(luaVM, tableIndex);
const bool result = lua_isnil(luaVM, -1);
lua_pop(luaVM, 1);
return !result;
}
示例13: exportCollision
void CollisionSerializer::exportCollision(const CollisionPtr& collision, const Ogre::String& filename)
{
if( !collision )
OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Argument collision is NULL","CollisionSerializer::exportCollision");
mpfFile=fopen(filename.c_str(),"wb");
if (!mpfFile)
{
OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Unable to open file " + filename + " for writing","CollisionSerializer::exportCollision");
}
NewtonCollisionSerialize(collision->getWorld()->getNewtonWorld(), collision->m_col, &CollisionSerializer::_newtonSerializeCallback, this);
fclose(mpfFile);
}
示例14: GetRealAttribute
Ogre::Real LuaScriptUtilities::GetRealAttribute(
lua_State* const luaVM,
const Ogre::String attributeName,
const int tableIndex)
{
if (!lua_istable(luaVM, tableIndex))
return Ogre::Real();
lua_pushstring(luaVM, attributeName.c_str());
lua_gettable(luaVM, tableIndex);
Ogre::Real value = lua_tonumber(luaVM, -1);
lua_pop(luaVM, 1);
return value;
}
示例15: lock
void
AudioManager::Player::Play( const Ogre::String &file )
{
boost::recursive_mutex::scoped_lock lock( *m_UpdateMutex );
// open vorbis file
if( ov_fopen( const_cast< char* >( file.c_str() ), &m_VorbisFile ) )
{
LOG_ERROR( "Can't play file \"" + file + "\"." );
return;
}
// get file info
m_VorbisInfo = ov_info( &m_VorbisFile, -1.0f );
// create sound source
alGenSources( 1, &m_Source );
// create buffers
ALuint buffers[ m_ChannelBufferNumber ];
alGenBuffers( m_ChannelBufferNumber, buffers );
// set source parameters
alSourcei( m_Source, AL_LOOPING, AL_FALSE );
// fill buffers
for( int i = 0; i < m_ChannelBufferNumber; ++i )
{
ALsizei buffer_size = FillBuffer();
if( buffer_size )
{
alBufferData( buffers[ i ], m_VorbisInfo->channels == 1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16, ( const ALvoid* )AudioManager::getSingleton().m_Buffer, ( ALsizei )buffer_size, ( ALsizei )m_VorbisInfo->rate );
alSourceQueueBuffers( m_Source, 1, &buffers[ i ] );
}
else
{
m_StreamFinished = true;
alDeleteBuffers( 1, &buffers[ i ] );
}
}
// start playback
alSourcePlay( m_Source );
}