本文整理汇总了C++中ogre::String::length方法的典型用法代码示例。如果您正苦于以下问题:C++ String::length方法的具体用法?C++ String::length怎么用?C++ String::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::String
的用法示例。
在下文中一共展示了String::length方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addSound
void Zone::addSound(const Ogre::String& sound)
{
if (sound.length() > 0)
{
mSounds.push_back(sound);
}
}
示例2: OnNewMaterial
void MaterialEditor::OnNewMaterial(wxCommandEvent &e)
{
NewMaterialDialog *dlg = new NewMaterialDialog(this, wxID_ANY,
wxT("新建材质"));
bool ok = (dlg->ShowModal() == wxID_OK);
if(ok)
{
const Ogre::String templateName = dlg->mTextCtrl->GetValue().c_str();
if(templateName.length() == 0)
{
dlg->Destroy();
return;
}
Ogre::MaterialPtr pMaterial= Ogre::MaterialManager::getSingleton().getByName(templateName);
//Ogre::MaterialPtr *pMaterial;
if(pMaterial.isNull())
pMaterial = Ogre::MaterialManager::getSingleton().create(templateName,"General");
InitMaterialEditor(pMaterial,templateName);
m_Frame->GetEffectObjectProperty()->InitMaterialEditor(pMaterial,templateName);
}
dlg->Destroy();
}
示例3: loadRawDataContainer
//----------------------------------------------------------------------------//
void OgreResourceProvider::loadRawDataContainer(const String& filename,
RawDataContainer& output,
const String& resourceGroup)
{
String orpGroup;
if (resourceGroup.empty())
orpGroup = d_defaultResourceGroup.empty() ?
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME.c_str() :
d_defaultResourceGroup;
else
orpGroup = resourceGroup;
Ogre::DataStreamPtr input = Ogre::ResourceGroupManager::getSingleton().
openResource(filename.c_str(), orpGroup.c_str());
if (input.isNull())
CEGUI_THROW(InvalidRequestException(
"Unable to open resource file '" + filename +
"' in resource group '" + orpGroup + "'."));
Ogre::String buf = input->getAsString();
const size_t memBuffSize = buf.length();
unsigned char* mem = new unsigned char[memBuffSize];
memcpy(mem, buf.c_str(), memBuffSize);
output.setData(mem);
output.setSize(memBuffSize);
}
示例4: while
Version::Version(const Ogre::String& version)
{
size_t length = version.length();
size_t offset = 0;
size_t foundAt;
Ogre::String component;
int index = 0;
while (index < MAX_COMPONENTS && offset < length)
{
//Extract the current component
foundAt = version.find('.', offset);
component = version.substr(offset);
this->components[index++] = Ogre::StringConverter::parseInt(component);
//Break out if there is no next '.'
if (foundAt == Ogre::String::npos)
break;
//Move past the next '.'
offset = foundAt + 1;
}
for (; index < MAX_COMPONENTS; index++)
this->components[index] = 0;
}
示例5: _stripNameFromSoftPrefix
//-----------------------------------------------------------------------
void ParticleRenderer::_stripNameFromSoftPrefix(Ogre::String& name)
{
if (name.find(SOFT_PREFIX) != Ogre::String::npos)
{
// Remove the prefix
name.erase(0, SOFT_PREFIX.length());
}
}
示例6: log
void Logger::log(const Ogre::String& component, const Logger::LogLevel level,
const char* message, const Ogre::String& ident)
{
if (ident.length() == 0)
log(level, "[" + component + "] " + message);
else
log(level, "[" + component + "] (" + ident + ") " + message);
}
示例7: parseScript
void AudioScriptLoader::parseScript(Ogre::DataStreamPtr& dataStream, const Ogre::String& groupName)
{
Ogre::String line;
bool nextIsOpenBrace = false;
mScriptContext.mSection = ASS_NONE;
mScriptContext.mSection= ASS_NONE;
mScriptContext.mSound.setNull();
mScriptContext.mLineNo = 0;
mScriptContext.mFileName=dataStream->getName();
mScriptContext.mGroupName=groupName;
Logger::getInstance()->log("About to start parsing sound script "+dataStream->getName());
while(!dataStream->eof())
{
line = dataStream->getLine();
mScriptContext.mLineNo++;
// DEBUG LINE
//Logger::getInstance()->log("About to attempt line(#" +
// Ogre::StringConverter::toString(mScriptContext.mLineNo) + "): " + line);
// Ignore comments & blanks
if (!(line.length() == 0 || line.substr(0,2) == "//"))
{
if (nextIsOpenBrace)
{
// NB, parser will have changed context already
if (line != "{")
{
logParseError("Expecting '{' but got " +
line + " instead.", mScriptContext);
}
nextIsOpenBrace = false;
}
else
{
nextIsOpenBrace = parseLine(line);
}
}
}
// Check all braces were closed
if (mScriptContext.mSection != ASS_NONE)
{
logParseError("Unexpected end of file.", mScriptContext);
}
// Make sure we invalidate our context shared pointer (don't wanna hold on)
mScriptContext.mSound.setNull();
}
示例8: print
void OgreConsole::print(const Ogre::String &text)
{
//subdivide it into lines
const char *str=text.c_str();
int len=text.length();
Ogre::String line;
for(int c=0;c<len;c++){
if(str[c]=='\n'||line.length()>=CONSOLE_LINE_LENGTH){
lines.push_back(line);
line="";
}
if(str[c]!='\n')
line+=str[c];
}
if(line.length())
lines.push_back(line);
if(lines.size()>CONSOLE_LINE_COUNT)
mStartline=lines.size()-CONSOLE_LINE_COUNT;
else
mStartline=0;
mUpdateConsole=true;
}
示例9: LoadOgrePlugins
bool OgreSubsystem::LoadOgrePlugins(Ogre::String const & pluginsfile)
{
Ogre::StringVector pluginList;
Ogre::String pluginDir;
Ogre::ConfigFile cfg;
try
{
cfg.load( pluginsfile );
}
catch (Ogre::Exception)
{
Ogre::LogManager::getSingleton().logMessage(pluginsfile + " not found, automatic plugin loading disabled.");
return false;
}
pluginDir = cfg.getSetting("PluginFolder"); // Ignored on Mac OS X, uses Resources/ directory
pluginList = cfg.getMultiSetting("Plugin");
#if OGRE_PLATFORM != OGRE_PLATFORM_APPLE && OGRE_PLATFORM != OGRE_PLATFORM_IPHONE
if (pluginDir.empty())
{
// User didn't specify plugins folder, try current one
pluginDir = ".";
}
#endif
char last_char = pluginDir[pluginDir.length()-1];
if (last_char != '/' && last_char != '\\')
{
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
pluginDir += "\\";
#elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX
pluginDir += "/";
#endif
}
for ( Ogre::StringVector::iterator it = pluginList.begin(); it != pluginList.end(); ++it )
{
Ogre::String pluginFilename = pluginDir + (*it);
try
{
m_ogre_root->loadPlugin(pluginFilename);
}
catch(Ogre::Exception &e)
{
LOG("failed to load plugin: " + pluginFilename + ": " + e.getFullDescription());
}
}
return true;
}
示例10: 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;
}
示例11: saveUser
void Manager::saveUser(const std::string& file)
{
bfs::ofstream fout((bfs::path(file)));
Ogre::ConfigFile::SectionIterator seci = mFile.getSectionIterator();
while (seci.hasMoreElements())
{
Ogre::String sectionName = seci.peekNextKey();
if (sectionName.length() > 0)
fout << '\n' << '[' << seci.peekNextKey() << ']' << '\n';
Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
Ogre::ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); ++i)
{
fout << i->first.c_str() << " = " << i->second.c_str() << '\n';
}
CategorySettingValueMap::iterator it = mNewSettings.begin();
while (it != mNewSettings.end())
{
if (it->first.first == sectionName)
{
fout << it->first.second << " = " << it->second << '\n';
mNewSettings.erase(it++);
}
else
++it;
}
}
std::string category = "";
for (CategorySettingValueMap::iterator it = mNewSettings.begin();
it != mNewSettings.end(); ++it)
{
if (category != it->first.first)
{
category = it->first.first;
fout << '\n' << '[' << category << ']' << '\n';
}
fout << it->first.second << " = " << it->second << '\n';
}
fout.close();
}
示例12: 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);
}
示例13: Exception
CChest::CChest(Ogre::SceneNode *pNode, CObjectManager &objectManager, btCollisionObject *pCollisionObject, EChestType eChestType, const Ogre::String &id)
: CObject(objectManager, CHEST_OBJECT, pCollisionObject, id), m_eChestType(eChestType) {
m_eChestState = CS_CLOSED;
//setInnerObject(&innerObject);
m_pInnerObject = NULL;
m_pLidSceneNode = objectManager.getMap().getRootSceneNode()->createChildSceneNode();
m_pLidSceneNode->setPosition(pNode->getPosition());
m_pLidSceneNode->setOrientation(pNode->getOrientation());
m_pLidSceneNode->setScale(pNode->getScale());
m_vInnerObjectPos = m_pLidSceneNode->getPosition();
btCollisionShape *pColShape(0);
switch (m_eChestType) {
case CT_SMALL:
m_pLidSceneNode->attachObject(pNode->getCreator()->createEntity("Chest.Small.Upper.mesh"));
m_pLidSceneNode->translate(0, 0.37465f, -0.30862f, Ogre::Node::TS_LOCAL);
m_vInnerObjectPos += m_pLidSceneNode->getOrientation() * Ogre::Vector3(0, 0.15f, 0);
pColShape = new btBoxShape(btVector3(0.3f, 0.08f, 0.2f));
m_vPhysicsOffset = Ogre::Vector3(0, 0.15f, 0.25f);
break;
default:
throw Ogre::Exception(0, "Unknown chest type", __FILE__);
break;
}
m_pLidPhysics = new btRigidBody(0, new btDefaultMotionState(), pColShape);
m_pLidPhysics->getWorldTransform().setOrigin(BtOgre::Convert::toBullet(m_pLidSceneNode->getPosition() + m_pLidSceneNode->getOrientation() * m_vPhysicsOffset));
m_pLidPhysics->getWorldTransform().setRotation(BtOgre::Convert::toBullet(m_pLidSceneNode->getOrientation()));
m_ObjectManager.getMap().getPhysicsManager()->getWorld()->addRigidBody(m_pLidPhysics, COL_STATIC, MASK_STATIC_COLLIDES_WITH);
// check for safe state
if (id.length() > 0) {
EItemSaveState iss = CPlayerData::getSingleton().getMapItemState(m_ObjectManager.getMap().getName(), id, ISS_CLOSED);
if (iss == ISS_OPENED) {
// open chest as initial state
m_eChestState = CS_OPENED;
m_pLidSceneNode->pitch(Ogre::Radian(-CHEST_MAX_ANGLE));
m_pLidPhysics->getWorldTransform().setOrigin(BtOgre::Convert::toBullet(m_pLidSceneNode->getPosition() + m_pLidSceneNode->getOrientation() * m_vPhysicsOffset));
m_pLidPhysics->getWorldTransform().setRotation(BtOgre::Convert::toBullet(m_pLidSceneNode->getOrientation()));
}
}
}
示例14: OnSelectItemCallback
void wxObjectFolderTree::OnSelectItemCallback()
{
ClearObjectPreview();
if (mCurrentItem->IsRoot()) return;
mCurrentPath = Ogre::String(GetRelativePath(mCurrentItem->GetId()).GetPath().c_str()) + PATH_SEPERATOR;
if (mCurrentItem->IsFile())
{
Ogre::String Path = "Data/Editor/Objects/" + Ogre::String(GetRelativePath(mCurrentItem->GetId()).GetPath().c_str()) + PATH_SEPERATOR;
Ogre::String File = mCurrentItem->GetName().c_str();
mCurrentPath += File;
Ogre::String extension = File.substr(File.find(".")+1, File.length());
wxEdit::Instance().GetOgrePane()->OnSelectResource();
if (extension == "ocs" && wxEdit::Instance().GetWorldExplorer()->GetSelection() == 1)
{
CreateObjectPreview(Path + File);
((wxEditGOResource*)(wxEdit::Instance().GetpropertyWindow()->SetPage("EditGOCRes")))->SetResource(Path + File);
}
}
}
示例15: parseScript
void SaveGameManager::parseScript(Ogre::DataStreamPtr &stream, const Ogre::String &groupName)
{
Ogre::String name = stream->getName();
name = name.substr(0, name.length()-5); //delete ".save" at the and of the name
int pointpos = name.find_last_of(".");
name = name.substr(0, pointpos);
if(Ogre::StringConverter::isNumber(name))
{
mHighestSaveGameNumber = std::max(mHighestSaveGameNumber, Ogre::StringConverter::parseInt(name));
SaveGameFile* file = new SaveGameFile("", Ogre::StringConverter::parseInt(name));
LOG_MESSAGE(Logger::RULES, "Parsing header of save game: " + name + ".save");
SaveGameFileReader reader;
reader.parseSaveGameFileHeader(stream, groupName, file);
if(file->getProperty(SaveGameFile::PROPERTY_MODULEID) != "") // broken save game
mSaveGames[Ogre::StringConverter::parseInt(name)] = file;
}
}