本文整理汇总了C++中ogre::String::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ String::c_str方法的具体用法?C++ String::c_str怎么用?C++ String::c_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::String
的用法示例。
在下文中一共展示了String::c_str方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wxFlexGridSizer
void
MaterialPreviewDialog::InitPreviewGrids(void)
{
wxFlexGridSizer *item0 = new wxFlexGridSizer( 6, 0, 0 );
typedef std::list<Ogre::String> MaterialFileNameList;
MaterialFileNameList materialFileNameList;
Ogre::FileInfoListPtr fileInfoList =
Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
"*.material");
for (Ogre::FileInfoList::const_iterator it = fileInfoList->begin(); it != fileInfoList->end(); ++it)
{
if ( it->archive->getName() == EFFECT_PATH)
{
materialFileNameList.push_back(it->filename);
}
}
wxComboBox *matCombo = mParentDialog->mMaterialComboBox;
assert (matCombo);
for ( int i=0; i<matCombo->GetCount(); ++i )
{
Ogre::String matName = matCombo->GetString(i);
Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().getByName(matName);
if (mat.isNull())
{
}
else
{
size_t numOfTex = mat->getTechnique(0)->getPass(0)->getNumTextureUnitStates();
if (numOfTex > 0)
{
Ogre::String texName = mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->getTextureName();
if (texName.empty() == false)
{
wxBoxSizer *item1 = new wxBoxSizer( wxVERTICAL );
wxStaticBitmap *item2 = new wxStaticBitmap( this, ID_STATICBITMAP, TexturePreview( 0 ), wxDefaultPosition, wxSize(64,64) );
item1->Add( item2, 0, wxALIGN_CENTER|wxALL, 5 );
wxStaticText *item3 = new wxStaticText( this, ID_TEXT_MATERIAL_NAME, _("text"), wxDefaultPosition, wxDefaultSize, 0 );
item1->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );
wxButton *item4 = new wxButton( this, ID_BUTTON_USE, _("Use"), wxDefaultPosition, wxDefaultSize, 0 );
item1->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );
item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
buildPreviewBitmap( texName );
item2->SetBitmap(mCurrentPreviewImage);
item3->SetLabel(texName.c_str());
item4->SetLabel(matName.c_str());
}
}
}
}
this->SetSizer( item0 );
item0->SetSizeHints( this );
}
示例2: createDirectory
//---------------------------------------------------------------------
bool FileSystemLayer::createDirectory(const Ogre::String& path)
{
return !_mkdir(path.c_str()) || errno == EEXIST; // Use CRT API rather than CreateDirectoryA to pass Windows Store validation
}
示例3: renameFile
//---------------------------------------------------------------------
bool FileSystemLayer::renameFile(const Ogre::String& oldname, const Ogre::String& newname)
{
if(fileExists(oldname) && fileExists(newname))
removeFile(newname);
return !rename(oldname.c_str(), newname.c_str()); // Use CRT API to pass Windows Store validation
}
示例4: start
bool NetworkManager::start(bool isServer, Ogre::ushort serverPort, Ogre::String serverIP)
{
mServer = isServer;
RakNet::Time waitTime = 10000;
RakNet::Time prevTime = 0;
if(isServer)
{
Ogre::LogManager::getSingletonPtr()
->logMessage(RealToys::logMessagePrefix + "Starting network as "
+ "server on port " + Ogre::StringConverter::toString(serverPort) );
}
else
{
Ogre::LogManager::getSingletonPtr()
->logMessage(RealToys::logMessagePrefix + "Starting network as "
+ "client to server " + serverIP + " on port " +
Ogre::StringConverter::toString(serverPort) );
}
mAirplaneManager = AirplaneManager::getSingletonPtr();
upAndRunning = false;
mConnectAtemp = false;
mWaitForPong = false;
RakNet::SocketDescriptor sd;
mRakPeer = RakNet::RakPeerInterface::GetInstance();
if(isServer)
{
sd.port = serverPort;
mReplicaManager = RT_ReplicaManager(mSceneMgr, mWorld);
}
else
{
sd.port = 0;
mReplicaManager = RT_ReplicaManager(mSceneMgr);
}
mReplicaManager.SetDefaultPacketReliability(UNRELIABLE_SEQUENCED);
mReplicaManager.SetDefaultPacketPriority(HIGH_PRIORITY);
// The network ID authority is the system that creates the common numerical identifier used to lookup pointers (the server here).
//mNetworkIdManager.SetIsNetworkIDAuthority(isServer);
// ObjectMemberRPC, AutoRPC for objects, and ReplicaManager3 require that you call SetNetworkIDManager()
mReplicaManager.SetNetworkIDManager(&mNetworkIdManager);
// Setup RPC3 system and classes
//mRPCIdManager.SetIsNetworkIDAuthority(true);
mRPC3Inst.SetNetworkIDManager(&mRPCIdManager);
this->SetNetworkIDManager(&mRPCIdManager);
RakNet::NetworkID id0 = 0;
this->SetNetworkID(id0);
RPC3_REGISTER_FUNCTION(&mRPC3Inst, &NetworkManager::createAirplane);
RPC3_REGISTER_FUNCTION(&mRPC3Inst, &NetworkManager::processAirplaneInput);
// Start RakNet, up to 32 connections if the server
if(!doStartup(isServer, sd))
{
return false;
}
mRakPeer->AttachPlugin(&mReplicaManager);
mRakPeer->AttachPlugin(&mRPC3Inst);
mNetworkID = mRakPeer->GetGuidFromSystemAddress(RakNet::UNASSIGNED_SYSTEM_ADDRESS);
// The server should allow systems to connect. Clients do not need to unless we want to transmit messages directly between systems or to use RakVoice
if (isServer)
{
// mRakPeer->SetMaximumIncomingConnections(RealToys::maxClients-1);
mRakPeer->SetMaximumIncomingConnections(0); //will not accept connections until setCurrentMap is called
//mNetworkID = RealToys::serverPlayerID;
}
else
{
if(serverIP == "255.255.255.255")
{
if(mRakPeer->Ping( serverIP.c_str(), serverPort, true, 0 ) )
{
Ogre::LogManager::getSingletonPtr()
->logMessage(RealToys::logMessagePrefix + "Client will try to search for servers on LAN");
mWaitForPong = true;
}
else
{
Ogre::LogManager::getSingletonPtr()
->logMessage(RealToys::logMessagePrefix + "Client PING failed");
return false;
}
}
else
{
if(!doConnect(serverIP, serverPort))
{
return false;
}
//.........这里部分代码省略.........
示例5: callLuaScriptFunction
void GameScriptParser::callLuaScriptFunction(const Ogre::String &func) {
lua_getglobal(lua_state, func.c_str()); // function to be called, without parameters and without return value!
lua_call(lua_state,0, 0);
}
示例6: if
wxPGConstants * WXEffectEditDialog::PopulateConstants(const Ogre::String& type)
{
size_t id = reinterpret_cast<size_t>(&type);
wxPGConstants* constants = wxPropertyGrid::GetConstantsArray(id);
if (constants)
{
for (std::list<wxPGConstants*>::iterator it = mConstantList.begin(); it != mConstantList.end(); ++it)
{
if (constants == *it)
{
if (constants->UnRef())
delete constants;
mConstantList.erase(it);
break;
}
}
}
// if (!constants)
// {
constants = wxPropertyGrid::CreateConstantsArray(id);
if ( type == "Material" )
{
typedef std::list<Ogre::String> MaterialFileNameList;
MaterialFileNameList materialFileNameList;
Ogre::FileInfoListPtr fileInfoList =
Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
"*.material");
for (Ogre::FileInfoList::const_iterator it = fileInfoList->begin(); it != fileInfoList->end(); ++it)
{
if ( it->archive->getName() == EFFECT_PATH)
{
materialFileNameList.push_back(it->filename);
}
}
// 第一个为空,表示设置这个元素的材质是用原mesh的材质
constants->Add("none");
Ogre::ResourceManager::ResourceMapIterator resourceMapIterator = Ogre::MaterialManager::getSingleton().getResourceIterator();
while ( resourceMapIterator.hasMoreElements() )
{
Ogre::String matName = resourceMapIterator.peekNextValue()->getName();
for ( MaterialFileNameList::iterator i = materialFileNameList.begin();
i != materialFileNameList.end(); ++i )
{
if ( *i == resourceMapIterator.peekNextValue()->getOrigin() )
{
constants->Add(matName.c_str());
break;
}
}
resourceMapIterator.moveNext();
}
}
else if ( type == "MeshName" )
{
constants->Add("none");
Ogre::FileInfoListPtr fileInfoList =
Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
"*.mesh");
for (Ogre::FileInfoList::const_iterator it = fileInfoList->begin(); it != fileInfoList->end(); ++it)
{
if ( it->archive->getName() == EFFECT_PATH)
{
const Fairy::String& name = it->filename;
constants->Add(name.c_str());
}
}
}
else if ( type == "ParticleSystem" )
{
Ogre::ParticleSystemManager::ParticleSystemTemplateIterator iterator = Ogre::ParticleSystemManager::getSingleton().getTemplateIterator();
while ( iterator.hasMoreElements() )
{
// 获取到粒子系统的名称
Ogre::String parName = iterator.peekNextKey();
constants->Add(parName.c_str());
// 使iterator往后移
iterator.moveNext();
}
}
registerConstants(constants);
// }
return constants;
}
示例7: 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;
}
示例8: FileExists
bool FileExists(Ogre::String const & path)
{
return FileExists(path.c_str());
}
示例9: FolderExists
bool FolderExists(Ogre::String const & path)
{
return FolderExists(path.c_str());
}
示例10: doExportAnimations
void MilkshapePlugin::doExportAnimations(msModel* pModel, Ogre::SkeletonPtr& ogreskel)
{
Ogre::LogManager& logMgr = Ogre::LogManager::getSingleton();
std::vector<SplitAnimationStruct> splitInfo;
Ogre::String msg;
int numFrames = msModel_GetTotalFrames(pModel);
msg = "Number of frames: " + Ogre::StringConverter::toString(numFrames);
logMgr.logMessage(msg);
if (splitAnimations)
{
// Explain
msg = "You have chosen to create multiple discrete animations by splitting up the frames in "
"the animation sequence. In order to do this, you must supply a simple text file "
"describing the separate animations, which has a single line per animation in the format: \n\n"
"startFrame,endFrame,animationName\n\nFor example: \n\n"
"1,20,Walk\n21,35,Run\n36,40,Shoot\n\n"
"..creates 3 separate animations (the frame numbers are inclusive)."
"You must browse to this file in the next dialog.";
MessageBox(0,msg.c_str(), "Splitting Animations",MB_ICONINFORMATION | MB_OK);
// Prompt for a file which contains animation splitting info
OPENFILENAME ofn;
memset (&ofn, 0, sizeof (OPENFILENAME));
char szFile[MS_MAX_PATH];
char szFileTitle[MS_MAX_PATH];
char szDefExt[32] = "skeleton";
char szFilter[128] = "All Files (*.*)\0*.*\0\0";
szFile[0] = '\0';
szFileTitle[0] = '\0';
ofn.lStructSize = sizeof (OPENFILENAME);
ofn.lpstrDefExt = szDefExt;
ofn.lpstrFilter = szFilter;
ofn.lpstrFile = szFile;
ofn.nMaxFile = MS_MAX_PATH;
ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = MS_MAX_PATH;
ofn.Flags = OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
ofn.lpstrTitle = "Open animation split configuration file";
if (!::GetOpenFileName (&ofn))
{
msg = "Splitting aborted, generating a single animation called 'Default'";
MessageBox(0, msg.c_str(), "Info", MB_OK | MB_ICONWARNING);
SplitAnimationStruct split;
split.start = 1;
split.end = numFrames;
split.name = "Default";
splitInfo.push_back(split);
}
else
{
// Read file
Ogre::String sline;
char line[256];
SplitAnimationStruct newSplit;
std::ifstream istr;
istr.open(szFile);
while (!istr.eof())
{
istr.getline(line, 256);
sline = line;
// Ignore blanks & comments
if (sline == "" || sline.substr(0,2) == "//")
continue;
// Split on ','
std::vector<Ogre::String> svec = Ogre::StringUtil::split(line, ",\n");
// Basic validation on number of elements
if (svec.size() != 3)
{
MessageBox(0, "Warning: corrupt animation details in file. You should look into this. ",
"Corrupt animations file", MB_ICONWARNING | MB_OK);
continue;
}
// Remove any embedded spaces
Ogre::StringUtil::trim(svec[0]);
Ogre::StringUtil::trim(svec[1]);
Ogre::StringUtil::trim(svec[2]);
// Create split info
newSplit.start = atoi(svec[0].c_str());
newSplit.end = atoi(svec[1].c_str());
newSplit.name = svec[2];
splitInfo.push_back(newSplit);
}
}
}
else
{
//.........这里部分代码省略.........
示例11: setMessageText
void DebugWindow::setMessageText(const Ogre::String& text)
{
CeGuiString o(text.c_str());
mMessageText->setText(o);
}
示例12: createDirectory
//---------------------------------------------------------------------
bool FileSystemLayerImpl::createDirectory(const Ogre::String& path)
{
return CreateDirectory(path.c_str(), NULL) != 0 ||
GetLastError() == ERROR_ALREADY_EXISTS;
}
示例13: OnSaveSkillObject
void SkillObjectEditor::OnSaveSkillObject(wxCommandEvent &e)
{
if (NULL == mSkill)
{
wxMessageBox("您还没有创建技能,请创建后重试!","提示");
return;
}
if(mSaveFileName == "")
{
SaveSkillDialog *dlg = new SaveSkillDialog(this, wxID_ANY,
_("保存技能"), mSkill);
bool ok = (dlg->ShowModal() == wxID_OK);
if(ok)
{
mSaveFileName = dlg->mComboBox->GetValue().c_str();
//判断文件名
Ogre::StringVector strings = Ogre::StringUtil::split( mSaveFileName, "." );
if (strings.size() != 2 || strings[1] != "skill")
{
mSaveFileName.append(".skill");
}
dlg->Destroy();
}
else
{
dlg->Destroy();
return;
}
}
//if(mbRecoverSave)
//{
// char buf[256];
// sprintf(buf,"是否覆盖文件%s中的%s效果数据!",mSaveFileName.c_str(),mSkillTemplateName.c_str());
// RecoverSaveDialog* dlg = new RecoverSaveDialog(m_Frame,wxID_ANY,wxT("覆盖文件"));
// dlg->SetText(wxString(buf));
// if(wxID_OK == dlg->ShowModal())
// {
// mbRecoverSave = false;
// dlg->Destroy();
// }
// else
// {
// dlg->Destroy();
// return;
// }
//}
Ogre::StringVector templates;
const Ogre::String fileName = mSaveFileName;
Fairy::EffectManager::getSingleton().getSkillTemplatesFromScriptFile(fileName, templates);
std::ofstream outFile;
Ogre::String pathFileName = EFFECT_PATH+fileName;
outFile.open ( pathFileName.c_str(), std::ios::out | std::ios::trunc ); // append to file
if (!outFile.is_open())
{
return;
}
bool newTemplate = true;
// 把所有的模板都写入该文件中
for ( size_t i=0; i<templates.size(); ++i )
{
// if (templates[i] != mEffect->getTemplateName())
///{
Fairy::Skill *skill = Fairy::EffectManager::getSingleton().getSkill(templates[i]);
assert (skill);
if (skill->getSkillName() == mSkillTemplateName)
{
saveSkill(mSkill, mSkillTemplateName, outFile );
*skill = *mSkill;
newTemplate = false;
}
else
saveSkill(skill, skill->getSkillName(), outFile);
}
if (newTemplate)
{
saveSkill(mSkill, mSkillTemplateName, outFile );
mSkill->setSkillName(mSkillTemplateName);
//.........这里部分代码省略.........
示例14: OnSaveAsSkillObject
void SkillObjectEditor::OnSaveAsSkillObject(wxCommandEvent &e)
{
if (NULL == mSkill)
{
wxMessageBox("您还没有创建技能,请创建后重试!","提示");
return;
}
SaveAsSkillDialog *dlg = new SaveAsSkillDialog(this, wxID_ANY,
_("另存技能"), mSkill);
bool ok = (dlg->ShowModal() == wxID_OK);
if(ok)
{
Ogre::StringVector templates;
Ogre::String fileName = dlg->mComboBox->GetValue().c_str();
Ogre::String templateName = dlg->mTextCtrl->GetValue().c_str();
if(templateName.length() == 0)
{
dlg->Destroy();
return;
}
//判断文件名
Ogre::StringVector strings = Ogre::StringUtil::split( fileName, "." );
if (strings.size() != 2 || strings[1] != "skill")
{
fileName.append(".skill");
}
Fairy::EffectManager::getSingleton().getSkillTemplatesFromScriptFile(fileName, templates);
std::ofstream outFile;
Ogre::String pathFileName = EFFECT_PATH+fileName;
outFile.open ( pathFileName.c_str(), std::ios::out | std::ios::trunc ); // append to file
if (!outFile.is_open())
{
dlg->Destroy();
return;
}
bool newTemplate = true;
// 把所有的模板都写入该文件中
for ( size_t i=0; i<templates.size(); ++i )
{
// if (templates[i] != mEffect->getTemplateName())
///{
Fairy::Skill *skill = Fairy::EffectManager::getSingleton().getSkill(templates[i]);
assert (skill);
if (skill->getSkillName() == dlg->mTextCtrl->GetValue().c_str())
{
saveSkill(mSkill, dlg->mTextCtrl->GetValue().c_str(), outFile );
newTemplate = false;
}
else
saveSkill(skill, skill->getSkillName(), outFile);
}
if (newTemplate)
{
// 刷新EffectManager中的模板内容
Fairy::Skill *skill = Fairy::EffectManager::getSingleton().getSkill(templateName);
if (NULL == skill)
{
skill = Fairy::EffectManager::getSingleton().createSkillTemplate(templateName);
}
*skill = *mSkill;
saveSkill(skill, templateName, outFile );
Fairy::EffectManager::getSingleton().addToSkillTemplateScriptFileMap(templateName, fileName);
InitSkillEditor(skill, templateName);
}
outFile.close();
}
wxBusyInfo* busyInfo = new wxBusyInfo(wxT("更新技能数据 ..."), this);
m_Frame->GetSkillSelector()->Reload();
delete busyInfo;
dlg->Destroy();
}
示例15: processTextEvent
void MenuSystem::processTextEvent(const OIS::KeyEvent& ke)
{
switch(ke.key)
{
case OIS::KC_BACK:
{
if(currentText.size() > 0)
{
currentText.pop_back();
}
}
break;
case OIS::KC_RETURN:
{
// Send the current text over the network to either lobby or master
// depending on which we are in.
switch(currentMenu)
{
case LISTLOBBYMENU:
{
// Send the chat to the master
Ogre::String builder = Ogre::String(name + ": " + currentText.c_str());
clientPtr->SendMasterChat(builder.c_str());
currentText.clear();
}
break;
case LOBBYMENU:
{
// Send the chat the lobby
Ogre::String builder = Ogre::String(name + ": " + currentText.c_str());
clientPtr->SendLobbyChat(builder.c_str());
currentText.clear();
}
break;
case MATCHMENU:
{
// Send the chat to the match
clientPtr->SendMatchChat(currentText.c_str());
}
break;
}
}
break;
default:
{
if(ke.text >= ' ' && ke.text <= 'z')
{
currentText.push_back(ke.text);
}
}
}
// Depending on which tray is active send the text to different text boxes
switch(currentMenu)
{
case STARTMENU:
{
ip->setText(currentText);
}
break;
case LISTLOBBYMENU:
{
}
break;
case CREATELOBBYMENU:
{
lobbyName->setText(currentText);
}
break;
case LOBBYMENU:
{
lobbyChatTextField->setText(currentText);
}
break;
case MATCHMENU:
{
}
break;
case RESULTMENU:
{
}
break;
}
}