本文整理汇总了C++中ogre::String::size方法的典型用法代码示例。如果您正苦于以下问题:C++ String::size方法的具体用法?C++ String::size怎么用?C++ String::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::String
的用法示例。
在下文中一共展示了String::size方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveToMemory
/**
* \brief This function is used by android to store the gamestate when minimizing
* \param pointer Output for the memory location
* \param size Output for the memory size
*/
void saveToMemory(void* &pointer, size_t &size) const {
size = sizeof(CGameState::EGameStates);
tinyxml2::XMLPrinter xmlprinter;
m_XMLDoc.Accept(&xmlprinter);
Ogre::String xmltext = xmlprinter.CStr();
size += xmltext.size();
pointer = malloc(size);
memcpy(pointer, &m_eCurrentGameState, sizeof(CGameState::EGameStates));
memcpy(static_cast<CGameState::EGameStates*>(pointer) + 1, xmltext.c_str(), xmltext.size());
}
示例2:
float
ParseKeyFrameTime( const float length, const Ogre::String& string )
{
float res = 0;
if( string.at( string.size() - 1 ) == '%' )
{
res = length * Ogre::StringConverter::parseReal( string.substr( 0, string.size() - 1 ) ) / 100;
}
else
{
res = Ogre::StringConverter::parseReal( string );
}
return res;
}
示例3: 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;
}
示例4: setupAnimations
//-------------------------------------------------------------------------------------
void EntitySimple::setupAnimations()
{
if(modelName_ == "ogrehead.mesh")
return;
Ogre::AnimationStateSet* aniStetes = mBodyEnt->getAllAnimationStates();
if(aniStetes != NULL)
{
// populate our animation list
for (int i = 0; i < SIMPLE_NUM_ANIMS; i++)
{
if(aniStetes->hasAnimationState(animNames[i]))
{
mAnims[i] = mBodyEnt->getAnimationState(animNames[i]);
mAnims[i]->setLoop(true);
}
else
{
char c = animNames[i].c_str()[animNames[i].size() - 1];
if(c > '1' && c <= '9')
{
Ogre::String name = animNames[i];
name.erase(name.size() - 1, 1);
name += "1";
mAnims[i] = mBodyEnt->getAnimationState(name);
mAnims[i]->setLoop(true);
}
else
mAnims[i] = NULL;
}
}
}
else
{
for (int i = 0; i < SIMPLE_NUM_ANIMS; i++)
{
mAnims[i] = NULL;
}
}
if(mState != 1)
playAnimation("Idle");
else
playAnimation("Die");
}
示例5: stripNonASCII
// same as: return preg_replace("/[^A-Za-z0-9-_.]/", "_", $s);
Ogre::String stripNonASCII(Ogre::String s)
{
char filename[9046] = "";
sprintf(filename, "%s", s.c_str());
for(size_t i=0;i<s.size(); i++)
{
bool replace = true;
if (filename[i] >= 48 && filename[i] <= 57) replace = false; // 0-9
else if(filename[i] >= 65 && filename[i] <= 90) replace = false; // A-Z
else if(filename[i] >= 97 && filename[i] <= 122) replace = false; // a-z
else if(filename[i] == 45 || filename[i] == 95 || filename[i] == 46) replace = false; // -_.
if(replace)
filename[i]='_';
}
return Ogre::String(filename);
}
示例6: createScene
//-------------------------------------------------------------------------------------
void SpaceLogin::createScene(void)
{
g_accountName = kbe_getLastAccountName();
if(g_accountName.size() == 0)
g_accountName = KBEngine::StringConv::val2str(KBEngine::genUUID64());
mTrayMgr->createButton(OgreBites::TL_CENTER, "login", "fast login", 120);
Ogre::StringVector values;
values.push_back(g_accountName);
mTrayMgr->createParamsPanel(OgreBites::TL_CENTER, "accountName", 300, values);
mTrayMgr->showCursor();
mTrayMgr->hideFrameStats();
mTrayMgr->hideLogo();
mTrayMgr->hideBackdrop();
mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC);
// Create the camera
mActiveCamera = mSceneMgr->createCamera("PlayerCam");
// Position it at 500 in Z direction
mActiveCamera->setPosition(Ogre::Vector3(0,0,80));
// Look back along -Z
mActiveCamera->lookAt(Ogre::Vector3(0,0,-300));
mActiveCamera->setNearClipDistance(5);
mCameraMan = new OgreBites::SdkCameraMan(mActiveCamera); // create a default camera controller
mCameraMan->setTopSpeed(7.0f);
OgreApplication::getSingleton().setCurrCameraMan(mCameraMan);
// Create one viewport, entire window
Ogre::Viewport* vp = mWindow->addViewport(mActiveCamera);
vp->setBackgroundColour(Ogre::ColourValue(0,0,0));
// Alter the camera aspect ratio to match the viewport
mActiveCamera->setAspectRatio(
Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));
}
示例7: setToken
void ScriptLexer::setToken(const Ogre::String &lexeme, Ogre::uint32 line, const String &source, Ogre::ScriptTokenList *tokens)
{
#if OGRE_WCHAR_T_STRINGS
const wchar_t openBracket = L'{', closeBracket = L'}', colon = L':',
quote = L'\"', var = L'$';
#else
const char openBracket = '{', closeBracket = '}', colon = ':',
quote = '\"', var = '$';
#endif
ScriptTokenPtr token(OGRE_NEW_T(ScriptToken, MEMCATEGORY_GENERAL)(), SPFM_DELETE_T);
token->lexeme = lexeme;
token->line = line;
token->file = source;
bool ignore = false;
// Check the user token map first
if(lexeme.size() == 1 && isNewline(lexeme[0]))
{
token->type = TID_NEWLINE;
if(!tokens->empty() && tokens->back()->type == TID_NEWLINE)
ignore = true;
}
else if(lexeme.size() == 1 && lexeme[0] == openBracket)
token->type = TID_LBRACKET;
else if(lexeme.size() == 1 && lexeme[0] == closeBracket)
token->type = TID_RBRACKET;
else if(lexeme.size() == 1 && lexeme[0] == colon)
token->type = TID_COLON;
else if(lexeme[0] == var)
token->type = TID_VARIABLE;
else
{
// This is either a non-zero length phrase or quoted phrase
if(lexeme.size() >= 2 && lexeme[0] == quote && lexeme[lexeme.size() - 1] == quote)
{
token->type = TID_QUOTE;
}
else
{
token->type = TID_WORD;
}
}
if(!ignore)
tokens->push_back(token);
}
示例8: toTag
Tag TagManager::toTag(const Ogre::String &tag)
{
if(0 == tag.size())
return INVALID_TAG;
auto it = mTagsMap.find(tag);
Tag returnedValue = INVALID_TAG;
if(mTagsMap.end() == it)
{
mTagsMap[tag] = returnedValue = mNextTag;
mInverseTagsMap[mNextTag] = tag;
++mNextTag;
SignalManager::instance().emit(newTagCreatedSignal());
}
else
{
returnedValue = it->second;
}
return returnedValue;
}
示例9: setupDirectories
void TestContext::setupDirectories(Ogre::String batchName)
{
// ensure there's a root directory for visual tests
mOutputDir = mFSLayer->getWritablePath("VisualTests/");
static_cast<Ogre::FileSystemLayer*>(mFSLayer)->createDirectory(mOutputDir);
// make sure there's a directory for the test set
mOutputDir += mTestSetName + "/";
static_cast<Ogre::FileSystemLayer*>(mFSLayer)->createDirectory(mOutputDir);
// add a directory for the render system
Ogre::String rsysName = Ogre::Root::getSingleton().getRenderSystem()->getName();
// strip spaces from render system name
for (unsigned int i = 0;i < rsysName.size(); ++i)
if (rsysName[i] != ' ')
mOutputDir += rsysName[i];
mOutputDir += "/";
static_cast<Ogre::FileSystemLayer*>(mFSLayer)->createDirectory(mOutputDir);
// and finally a directory for the test batch itself
static_cast<Ogre::FileSystemLayer*>(mFSLayer)->createDirectory(mOutputDir
+ batchName + "/");
}
示例10: LoadText
void CLASS::LoadText()
{
m_vehicle_title->setMaxTextLength(33);
m_vehicle_title->setCaptionWithReplacing(currTruck->getTruckName());
Ogre::UTFString txt;
std::vector<authorinfo_t> file_authors = currTruck->getAuthors();
if (!file_authors.empty())
{
Ogre::String authors = "";
for (std::vector<authorinfo_t>::iterator it = file_authors.begin(); it != file_authors.end(); ++it)
{
authors += "* " + (*it).name + " \n";
}
txt = txt + _L("Authors: \n") + authors;
}
else
txt = txt + _L("(no author information available) ");
std::vector<std::string> description = currTruck->getDescription();
for (unsigned int i = 1; i < 3; i++)
{
if (i < description.size())
{
txt = txt + _L("\nDescription: \n");
txt = txt + (ANSI_TO_UTF(description[i])) + "\n";
}
}
txt = txt + _L("\nCommands: \n");
int filledCommands = 0;
for (int i = 1; i < MAX_COMMANDS && filledCommands < COMMANDS_VISIBLE; i += 2)
{
if (currTruck->commandkey[i].beams.empty() || currTruck->commandkey[i].description == "hide") continue;
filledCommands++;
char commandID[256] = {};
Ogre::String keyStr = "";
sprintf(commandID, "COMMANDS_%02d", i);
int eventID = RoR::Application::GetInputEngine()->resolveEventName(Ogre::String(commandID));
Ogre::String keya = RoR::Application::GetInputEngine()->getEventCommand(eventID);
sprintf(commandID, "COMMANDS_%02d", i + 1);
eventID = RoR::Application::GetInputEngine()->resolveEventName(Ogre::String(commandID));
Ogre::String keyb = RoR::Application::GetInputEngine()->getEventCommand(eventID);
// cut off expl
if (keya.size() > 6 && keya.substr(0, 5) == "EXPL+") keya = keya.substr(5);
if (keyb.size() > 6 && keyb.substr(0, 5) == "EXPL+") keyb = keyb.substr(5);
keyStr = keya + "/" + keyb;
if (currTruck->commandkey[i].description.empty())
{
txt = txt + "* " + keyStr + ": " + _L("unknown function");
}
else
{
txt = txt + "* " + keyStr + ": " + currTruck->commandkey[i].description;
}
txt = txt + "\n";
}
m_vehicle_desc->setCaption(Ogre::String(txt));
}
示例11: Export
//-----------------------------------------------------------------------------
int COFSSceneSerializer::Export(bool SaveAs, Ogre::String exportfile)
{
OgitorsRoot *ogRoot = OgitorsRoot::getSingletonPtr();
OgitorsSystem *mSystem = OgitorsSystem::getSingletonPtr();
OFS::OfsPtr& mFile = ogRoot->GetProjectFile();
PROJECTOPTIONS *pOpt = ogRoot->GetProjectOptions();
bool forceSave = false;
Ogre::String fileLocation = ogRoot->GetProjectFile()->getFileSystemName();
Ogre::String fileName = "";
if (!exportfile.empty())
{
// Save location was passed, so use this filename
fileLocation = exportfile;
}
if (SaveAs)
{
// Saving at a different location
UTFStringVector extlist;
if( mFile->getFileSystemType() == OFS::OFS_PACKED )
{
extlist.push_back(OTR("Ogitor File System File"));
extlist.push_back("*.ofs");
}
else
{
extlist.push_back(OTR("Ogitor Scene File"));
extlist.push_back("*" + Globals::OGSCENE_FORMAT_EXTENSION);
}
Ogre::String newfileLocation = mSystem->DisplaySaveDialog(OTR("Save As"), extlist, fileLocation);
if(newfileLocation == "")
return SCF_CANCEL;
mSystem->SetSetting("system", "oldOpenPath", newfileLocation);
if(Ogre::StringUtil::match(newfileLocation, fileLocation, false))
{
SaveAs = false;
}
else
{
forceSave = true;
fileLocation = newfileLocation;
}
}
Ogre::String filePath = OgitorsUtils::ExtractFilePath(fileLocation);
fileName = OgitorsUtils::ExtractFileName(fileLocation);
// Change the project directory to the new path
pOpt->ProjectDir = filePath;
if(fileName.substr(fileName.size() - 4, 4) != ".ofs")
fileLocation = filePath;
int dotpos = fileName.find_last_of(".");
if (dotpos > 0)
{
fileName.erase(dotpos, fileName.length() - dotpos);
}
if (SaveAs && mFile->moveFileSystemTo(fileLocation.c_str()) != OFS::OFS_OK)
{
return SCF_ERRFILE;
}
if (SaveAs)
{
mFile->deleteFile((pOpt->ProjectName + Globals::OGSCENE_FORMAT_EXTENSION).c_str());
pOpt->ProjectName = fileName;
}
if (_writeFile(fileName + Globals::OGSCENE_FORMAT_EXTENSION, forceSave) != SCF_OK)
{
return SCF_ERRFILE;
}
return SCF_OK;
}
示例12: OgreMeshExportOptions_PPGEvent
//.........这里部分代码省略.........
Parameter param = prop.GetParameters().GetItem(L"animationList");
GridData gd(param.GetValue());
populateAnimationsList(gd);
}
}
else if( buttonPressed.GetAsText() == L"addAnimation" )
{
Parameter param = prop.GetParameters().GetItem(L"animationList");
GridData gd(param.GetValue());
gd.PutRowCount(gd.GetRowCount() + 1);
// default export to true and sample rate
gd.PutCell(ANIMATION_LIST_EXPORT_COL, gd.GetRowCount()-1, true);
gd.PutCell(ANIMATION_LIST_IKFREQ_COL, gd.GetRowCount()-1, (LONG)5);
}
else if( buttonPressed.GetAsText() == L"removeAnimation" )
{
Parameter param = prop.GetParameters().GetItem(L"animationList");
GridData gd(param.GetValue());
GridWidget gw = gd.GetGridWidget();
// cell-level selection, so have to search for selection in every cell
long selRow = -1;
for (long row = 0; row < gd.GetRowCount() && selRow == -1; ++row)
{
for (long col = 0; col < gd.GetColumnCount() && selRow == -1; ++col)
{
if (gw.IsCellSelected(col, row))
{
selRow = row;
}
}
}
if (selRow != -1)
{
LONG btn;
CStatus ret = app.GetUIToolkit().MsgBox(
L"Are you sure you want to remove this animation entry?",
siMsgYesNo,
L"Confirm",
btn);
if (btn == 6)
{
// Move all the contents up one
for (long row = selRow; row < gd.GetRowCount(); ++row)
{
for (long col = 0; col < gd.GetColumnCount(); ++col)
{
gd.PutCell(col, row, gd.GetCell(col, row+1));
}
}
// remove last row
gd.PutRowCount(gd.GetRowCount() - 1);
}
}
}
}
// Changed a parameter
else if ( eventID == PPGEventContext::siParameterChange )
{
Parameter changed = ctx.GetSource() ;
CustomProperty prop = changed.GetParent() ;
CString paramName = changed.GetScriptName() ;
// Check paramName against parameter names, perform custom onChanged event
if (paramName == L"targetMeshFileName")
{
// Default skeleton & material name
Ogre::String meshName = XSItoOgre(XSI::CString(changed.GetValue()));
if (hasSkel)
{
Ogre::String skelName = meshName;
if (Ogre::StringUtil::endsWith(skelName, ".mesh"))
{
skelName = skelName.substr(0, skelName.size() - 5) + ".skeleton";
}
CString xsiSkelName = OgretoXSI(skelName);
prop.PutParameterValue(L"targetSkeletonFileName", xsiSkelName);
}
// default material script name
Ogre::String matName = meshName;
if (Ogre::StringUtil::endsWith(matName, ".mesh"))
{
matName = matName.substr(0, matName.size() - 5) + ".material";
}
CString xsiMatName = OgretoXSI(matName);
prop.PutParameterValue(L"targetMaterialFileName", xsiMatName);
}
}
return CStatus::OK;
}
示例13: OnOgreMeshExportMenu
//.........这里部分代码省略.........
float currentInc = distanceInc;
for (int l = 0; l < numlods; ++l)
{
lodData->distances.push_back(currentInc);
currentInc += distanceInc;
}
lodData->quota = (quota == L"p") ?
Ogre::ProgressiveMesh::VRQ_PROPORTIONAL : Ogre::ProgressiveMesh::VRQ_CONSTANT;
if (lodData->quota == Ogre::ProgressiveMesh::VRQ_PROPORTIONAL)
lodData->reductionValue = reduction * 0.01;
else
lodData->reductionValue = reduction;
}
param = prop.GetParameters().GetItem( L"exportSkeleton" );
bool exportSkeleton = param.GetValue();
param = prop.GetParameters().GetItem( L"exportVertexAnimation" );
bool exportVertexAnimation = param.GetValue();
param = prop.GetParameters().GetItem( L"exportMaterials" );
bool exportMaterials = param.GetValue();
param = prop.GetParameters().GetItem( L"copyTextures" );
bool copyTextures = param.GetValue();
// create singletons
Ogre::ResourceGroupManager rgm;
Ogre::MeshManager meshMgr;
Ogre::SkeletonManager skelMgr;
Ogre::MaterialManager matMgr;
Ogre::DefaultHardwareBufferManager hardwareBufMgr;
// determine number of exportsteps
size_t numSteps = 3 + OGRE_XSI_NUM_MESH_STEPS;
if (numlods > 0)
numSteps++;
if (edgeLists)
numSteps++;
if (tangents)
numSteps++;
if (exportSkeleton)
numSteps += 3;
Ogre::ProgressManager progressMgr(numSteps);
// Any material prefix? We need that for mesh linking too
param = prop.GetParameters().GetItem( L"materialPrefix" );
Ogre::String materialPrefix = XSItoOgre(XSI::CString(param.GetValue()));
param = prop.GetParameters().GetItem( L"fps" );
float fps = param.GetValue();
if (fps == 0.0f)
{
OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS,
"You must supply a valid value for 'FPS'",
"OGRE Export");
}
Ogre::AnimationList selAnimList;
if (exportSkeleton || exportVertexAnimation)
{
param = prop.GetParameters().GetItem( L"animationList" );
GridData gd(param.GetValue());
for (int a = 0; a < gd.GetRowCount(); ++a)
{