本文整理汇总了C++中ogre::String::find方法的典型用法代码示例。如果您正苦于以下问题:C++ String::find方法的具体用法?C++ String::find怎么用?C++ String::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::String
的用法示例。
在下文中一共展示了String::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkNormalMap
bool GBufferSchemeHandler::checkNormalMap(
TextureUnitState* tus, GBufferSchemeHandler::PassProperties& props)
{
bool isNormal = false;
Ogre::String lowerCaseAlias = tus->getTextureNameAlias();
Ogre::StringUtil::toLowerCase(lowerCaseAlias);
if (lowerCaseAlias.find(NORMAL_MAP_PATTERN) != Ogre::String::npos)
{
isNormal = true;
}
else
{
Ogre::String lowerCaseName = tus->getTextureName();
Ogre::StringUtil::toLowerCase(lowerCaseName);
if (lowerCaseName.find(NORMAL_MAP_PATTERN) != Ogre::String::npos)
{
isNormal = true;
}
}
if (isNormal)
{
if (props.normalMap == 0)
{
props.normalMap = tus;
}
else
{
OGRE_EXCEPT(Exception::ERR_DUPLICATE_ITEM,
"Multiple normal map patterns matches",
"GBufferSchemeHandler::inspectPass");
}
}
return isNormal;
}
示例2: ValidAttr
//-----------------------------------------------------------------------------
void Ogitors::COFSSceneSerializer::_upgradeOgsceneFileFrom2To3(TiXmlNode* ogsceneRootNode)
{
TiXmlElement* element = ogsceneRootNode->FirstChildElement();
unsigned int obj_count = 0;
Ogre::String objecttype;
OgitorsPropertyValueMap params;
OgitorsPropertyValue tmpPropVal;
Ogre::String objAttValue;
size_t offset = 0;
do
{
objAttValue = ValidAttr(element->Attribute("typename"), "");
if(objAttValue != "")
{
if((offset = objAttValue.find(" Object")) != Ogre::String::npos)
{
objAttValue = objAttValue.substr(0, offset);
element->SetAttribute("typename", objAttValue.c_str());
}
}
else
continue;
} while(element = element->NextSiblingElement());
}
示例3: 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;
}
示例4: setFirstTextureGeneration
//.........这里部分代码省略.........
if (texture.isNull())
return;
Ogre::uint8 maxMipMaps = mNumMipMaps + 1; // Increase with one, because there is always one image to blit
maxMipMaps = maxMipMaps > PAINT_MAX_MIP_MAPS ? PAINT_MAX_MIP_MAPS : maxMipMaps; // Just paint a few mipmaps (not all)
Ogre::Image textureOnWhichIsPaintedScaled = mTextureOnWhichIsPainted; // Temporary image must be used, otherwise painting doesn't work
size_t w = mTextureOnWhichIsPaintedWidth;
size_t h = mTextureOnWhichIsPaintedHeight;
Ogre::v1::HardwarePixelBuffer* buffer;
for (Ogre::uint8 i = 0; i < maxMipMaps; ++i)
{
buffer = texture->getBuffer(0, i).getPointer();
buffer->blitFromMemory(textureOnWhichIsPaintedScaled.getPixelBox(0, 0), Ogre::Box(0, 0, 0, w, h, 1));
w*=0.5f; // Mipmaps always are half of the previous one
h*=0.5f;
if (w < 1.0f || h < 1.0f)
break; // Stop when the mipmaps are too small
textureOnWhichIsPaintedScaled.resize(w, h);
}
textureOnWhichIsPaintedScaled.freeMemory();
}
//****************************************************************************/
void TextureLayer::setFirstTextureGeneration (void)
{
// Don't check on existence mTextureFileName, because it does exist
loadTextureGeneration(mTextureFileName);
}
//****************************************************************************/
void TextureLayer::setLastTextureGeneration (void)
{
Ogre::String textureFileNameGeneration = getTextureFileNameGeneration (mMaxSequence); // returns full qualified filename
if (textureFileExists(textureFileNameGeneration))
loadTextureGeneration(textureFileNameGeneration);
}
//****************************************************************************/
void TextureLayer::loadTextureGeneration (Ogre::ushort sequence)
{
Ogre::String textureFileNameGeneration = getTextureFileNameGeneration (sequence); // returns full qualified filename
if (sequence == 0)
loadTextureGeneration(textureFileNameGeneration); // Don't check the filename if sequence is 0, because it is without path
else if (textureFileExists(textureFileNameGeneration))
loadTextureGeneration(textureFileNameGeneration);
}
//****************************************************************************/
void TextureLayer::loadTextureGeneration (const Ogre::String& filename)
{
// Assume the filename exists
mTextureOnWhichIsPainted.load(filename, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
mPixelboxTextureOnWhichIsPainted = mTextureOnWhichIsPainted.getPixelBox(0, 0);
mTextureOnWhichIsPaintedHasAlpha = mTextureOnWhichIsPainted.getHasAlpha();
mTextureOnWhichIsPaintedWidth = mPixelboxTextureOnWhichIsPainted.getWidth();
mTextureOnWhichIsPaintedHeight = mPixelboxTextureOnWhichIsPainted.getHeight();
// In theory, createCarbonCopyTexture() of all related paintlayers should be called,
// but the texture size doesn't change in practice.
blitTexture();
}
//****************************************************************************/
void TextureLayer::saveTextureGeneration (void)
{
// Increase the sequence
++mMaxSequence;
Ogre::String textureFileNameGeneration = getTextureFileNameGeneration (mMaxSequence); // returns full qualified filename
// Saving the Image must be done in the background, otherwise the painting stutters
QThread* thread = new QThread;
TextureSaveWorker* textureSaveWorker = new TextureSaveWorker (mTextureOnWhichIsPainted, textureFileNameGeneration);
textureSaveWorker->moveToThread(thread);
connect(thread, SIGNAL(started()), textureSaveWorker, SLOT(saveImage()));
connect(textureSaveWorker, SIGNAL(finished()), thread, SLOT(quit()));
connect(textureSaveWorker, SIGNAL(finished()), textureSaveWorker, SLOT(deleteLater()));
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
thread->start();
}
//****************************************************************************/
const Ogre::String& TextureLayer::saveTextureWithTimeStampToImportDir (void)
{
Ogre::String strippedTextureFileName = mTextureFileName;
Ogre::String extension = mTextureFileName;
strippedTextureFileName.erase(strippedTextureFileName.find_last_of("."), Ogre::String::npos); // Remove extension
if (strippedTextureFileName.find("_hlms") != Ogre::String::npos)
strippedTextureFileName.erase(strippedTextureFileName.find("_hlms"), Ogre::String::npos); // Remove earlier hlms editor additions
extension.erase(0, extension.find_last_of("."));
mHelperString = strippedTextureFileName +
"_hlms" +
Ogre::StringConverter::toString((size_t)time(0)) +
extension;
mTextureOnWhichIsPainted.save(DEFAULT_IMPORT_PATH.toStdString() + mHelperString); // Saving to the import dir doesn't have to be in the background
return mHelperString; // Return the basename
}
示例5: createProperties
//-----------------------------------------------------------------------------------------
void CEntityEditor::createProperties(OgitorsPropertyValueMap ¶ms)
{
PROPERTY_PTR(mMeshFile , "meshfile" , Ogre::String,"" ,0, SETTER(Ogre::String, CEntityEditor, _setMeshFile));
PROPERTY_PTR(mCastShadows , "castshadows" , bool ,false,0, SETTER(bool, CEntityEditor, _setCastShadows));
PROPERTY_PTR(mSubEntityCount, "subentitycount", int , -1 ,0, 0);
PROPERTY_PTR(mRenderingDistance, "renderingdistance",Ogre::Real ,5000,0, SETTER(Ogre::Real, CEntityEditor, _setRenderingDistance));
int count = 0;
OgitorsPropertyValueMap::const_iterator it = params.find("subentitycount");
if(it != params.end())
count = Ogre::any_cast<int>(it->second.val);
OgitorsPropertyDef *definition;
for(int ix = 0; ix < count; ix++)
{
Ogre::String sCount1 = "SubEntities::SubEntity" + Ogre::StringConverter::toString(ix);
Ogre::String sCount2 = "subentity" + Ogre::StringConverter::toString(ix);
definition = mFactory->AddPropertyDefinition(sCount2 + "::material", sCount1 + "::Material", "Sub Entity's Material Name", PROP_STRING, true, true);
definition->setOptions(OgitorsRoot::GetMaterialNames());
mFactory->AddPropertyDefinition(sCount2 + "::visible", sCount1 + "::Visible", "Sub Entity's Visibility", PROP_BOOL, true, true);
PROPERTY(sCount2 + "::material", Ogre::String, "", ix, SETTER(Ogre::String, CEntityEditor, _setSubMaterial));
PROPERTY(sCount2 + "::visible", bool, true, ix, SETTER(bool, CEntityEditor, _setSubVisible));
}
mProperties.initValueMap(params);
Ogre::String addstr = mMeshFile->get();
int ret = addstr.find(".mesh");
if(ret != -1)
{
addstr.erase(ret, 5);
mMeshFile->init(addstr);
}
}
示例6: _stripNameFromSoftPrefix
//-----------------------------------------------------------------------
void ParticleRenderer::_stripNameFromSoftPrefix(Ogre::String& name)
{
if (name.find(SOFT_PREFIX) != Ogre::String::npos)
{
// Remove the prefix
name.erase(0, SOFT_PREFIX.length());
}
}
示例7: LiquidCreator
void
LiquidCreatorDialog::OnInitDialog(wxInitDialogEvent &e)
{
wxDialog::OnInitDialog(e);
wxSizer* sizer = LiquidCreator(this, true, true);
/// 获取各控件的引用
mComboBox = wxDynamicCast(this->FindWindow(ID_MATERIALCOMBO),wxComboBox);
assert (mComboBox);
Ogre::ResourceManager::ResourceMapIterator resourceMapIterator = Ogre::MaterialManager::getSingleton().getResourceIterator();
while ( resourceMapIterator.hasMoreElements() )
{
if ( resourceMapIterator.peekNextValue()->getGroup() == Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME )
{
Ogre::String matName = resourceMapIterator.peekNextValue()->getName();
// 只有材质名称中包含“水”才加入到combobox中
if (matName.find("water") != Ogre::String::npos ||
matName.find("Water") != Ogre::String::npos ||
matName.find("水01") != Ogre::String::npos)
mComboBox->AppendString( matName.c_str() );
}
resourceMapIterator.moveNext();
}
resourceMapIterator = Ogre::MaterialManager::getSingleton().getResourceIterator();
mComboBox->SetValue( resourceMapIterator.peekNextValue()->getName().c_str() );
mSubDivideTextCtrl = wxDynamicCast(this->FindWindow(ID_SUBDIVISIONTEXTCTRL),wxTextCtrl);
assert (mSubDivideTextCtrl);
mTexScaleTextCtrl = wxDynamicCast(this->FindWindow(ID_TEXCOORDSCALETEXTCTRL),wxTextCtrl);
assert (mTexScaleTextCtrl);
mDiffuseTextCtrl = wxDynamicCast(this->FindWindow(ID_DIFFUSETEXTCTRL),wxTextCtrl);
assert (mDiffuseTextCtrl);
mDepthTextCtrl = wxDynamicCast(this->FindWindow(ID_DEPTHTEXTCTRL),wxTextCtrl);
assert (mDepthTextCtrl);
}
示例8: _destroyAll
//-----------------------------------------------------------------------
void EntityRenderer::_destroyAll(void)
{
if (!mParentTechnique)
return;
// Delete the visual data
vector<EntityRendererVisualData*>::const_iterator it;
vector<EntityRendererVisualData*>::const_iterator itEnd = mAllVisualData.end();
for (it = mAllVisualData.begin(); it != itEnd; ++it)
{
PU_DELETE_T(*it, EntityRendererVisualData, MEMCATEGORY_SCENE_OBJECTS);
}
mAllVisualData.clear();
mVisualData.clear();
// V1.5: Destroy the created ChildSceneNodes (which leads to detaching the Entities)
if (mParentTechnique->getParentSystem())
{
Ogre::SceneNode* parentNode = mParentTechnique->getParentSystem()->getParentSceneNode();
if (parentNode)
{
String sceneNodeName;
std::stringstream ss;
unsigned short numChilds = parentNode->numChildren();
for (unsigned short i = 0; i < numChilds; ++i)
{
Ogre::Node* node = parentNode->getChild(i);
if (node)
{
Ogre::String name = node->getName();
if (name.find("ParticleUniverse") != Ogre::String::npos)
{
parentNode->removeAndDestroyChild(i);
}
}
}
}
} // V1.5
// Destroy the Entities. Do it like this, because it must be assured that the entity still exists
// and has not already been destroyed.
Ogre::SceneManager* sceneManager = mParentTechnique->getParentSystem()->getSceneManager();
for (size_t i = 0; i < mQuota; i++)
{
if (sceneManager->hasEntity(mEntityName + StringConverter::toString(i)))
{
sceneManager->destroyEntity(mEntityName + StringConverter::toString(i));
}
}
mEntities.clear();
// Reset the visual data in the pool
mParentTechnique->initVisualDataInPool();
}
示例9: AddOgreResourcePath
void Main::AddOgreResourcePath(Ogre::String dir, Ogre::String resourceGroup)
{
if (dir.find("svn") != Ogre::String::npos) return;
boost::filesystem::path path(dir.c_str());
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(dir, "FileSystem", resourceGroup);
for (boost::filesystem::directory_iterator i(path); i != boost::filesystem::directory_iterator(); i++)
{
if (boost::filesystem::is_directory((*i))) AddOgreResourcePath((*i).path().directory_string().c_str(), resourceGroup);
}
}
示例10: importFullTerrainFromHeightMap
//-----------------------------------------------------------------------------------------
void CTerrainGroupEditor::importFullTerrainFromHeightMap()
{
UTFStringVector extlist;
extlist.push_back(OTR("PNG Grayscale"));
extlist.push_back("*.png");
extlist.push_back(OTR("Raw 32bit Float File"));
extlist.push_back("*.raw;*.ohm;*.f32;*.r32");
Ogre::UTFString defaultPath = mSystem->GetSetting("system", "ExportTerrainPath", "");
Ogre::String filename = mSystem->DisplayOpenDialog(OTR("Import Heightmap"), extlist, defaultPath);
if(filename == "")
return;
mSystem->SetSetting("system", "ExportTerrainPath", OgitorsUtils::ExtractFilePath(filename));
Ogre::NameValuePairList params;
if(!mSystem->DisplayImportHeightMapDialog(params))
return;
Ogre::Real fScale = Ogre::StringConverter::parseReal(params["scale"]);
Ogre::Real fBias = Ogre::StringConverter::parseReal(params["bias"]);
Ogre::String normal = params["normal"];
Ogre::String diffuse = params["diffuse"];
bool flipV = Ogre::StringConverter::parseBool(params["inverted"]);
float *data = 0;
float *flipBV = 0;
Ogre::String namePart = OgitorsUtils::ExtractFileName(filename);
namePart.erase(0, namePart.find("."));
int imgW = 0;
int imgH = 0;
if(namePart == ".png")
{
std::fstream fstr(filename.c_str(), std::ios::in|std::ios::binary);
Ogre::DataStreamPtr stream = Ogre::DataStreamPtr(OGRE_NEW Ogre::FileStreamDataStream(&fstr, false));
Ogre::Image img;
img.load(stream);
data = OGRE_ALLOC_T(float, img.getWidth() * img.getHeight(), Ogre::MEMCATEGORY_GEOMETRY);
Ogre::PixelBox pb(img.getWidth(), img.getHeight(), 1, Ogre::PF_FLOAT32_R, data);
Ogre::PixelUtil::bulkPixelConversion(img.getPixelBox(), pb);
imgW = img.getWidth();
imgH = img.getHeight();
img.freeMemory();
stream.setNull();
}
示例11: Widget_Caption
void WidgetFactory::Widget_Caption(WidgetPtr _widget, const Ogre::String &_key, const Ogre::String &_value)
{
// change '\n' on char 10
size_t pos = _value.find("\\n");
if (pos == std::string::npos) _widget->setCaption(_value);
else {
std::string value(_value);
while (pos != std::string::npos) {
value[pos++] = '\n';
value.erase(pos, 1);
pos = value.find("\\n");
}
_widget->setCaption(value);
}
}
示例12: renderSystemName
void
dmz::RenderModuleCoreOgreBasic::_init_render_system (Config &local) {
if (_root) {
String renderSystemName (
config_to_string ("renderSystem.name", local, "OpenGL"));
Ogre::RenderSystem *renderSystem (0);
Ogre::RenderSystemList *renderSystemList = _root->getAvailableRenderers ();
if (renderSystemList) {
Ogre::RenderSystemList::iterator it = renderSystemList->begin ();
while (it != renderSystemList->end () && !renderSystem) {
if (renderSystemList->size () == 1) {
renderSystem = *it;
}
else {
Ogre::String curName ((*it)->getName ());
if (curName.find (renderSystemName.get_buffer ()) >= 0) {
renderSystem = *it;
}
}
it++;
}
}
if (renderSystem) {
_root->setRenderSystem (renderSystem);
_root->initialise (false); // don't autocreate a window
}
else {
_log.error
<< "Specified render system (" << renderSystemName << ") not found" << endl;
}
}
}
示例13: parseWindowGeometry
void OgreSetup::parseWindowGeometry(Ogre::ConfigOptionMap& config, unsigned int& width, unsigned int& height, bool& fullscreen) {
auto opt = config.find("Video Mode");
if (opt != config.end()) {
Ogre::String val = opt->second.currentValue;
Ogre::String::size_type pos = val.find('x');
if (pos != Ogre::String::npos) {
width = Ogre::StringConverter::parseUnsignedInt(val.substr(0, pos));
height = Ogre::StringConverter::parseUnsignedInt(val.substr(pos + 1));
}
}
//now on to whether we should use fullscreen
opt = config.find("Full Screen");
if (opt != config.end()) {
fullscreen = (opt->second.currentValue == "Yes");
}
}
示例14: OnToolbarEvent
void wxObjectFolderTree::OnToolbarEvent(int toolID, Ogre::String toolname)
{
if (toolname == "NewResource")
{
wxEdit::Instance().GetWorldExplorer()->GetResourceTree()->ClearObjectPreview();
Ogre::String insertpath = wxEdit::Instance().GetWorldExplorer()->GetResourceTree()->GetInsertPath();
Ogre::String file = wxEdit::Instance().GetWorldExplorer()->GetResourceTree()->DoCreateFileDialog();
if (file == "") return;
if (file.find(".ocs") == Ogre::String::npos) file = file + ".ocs";
Ogre::String fullPath = wxEdit::Instance().GetWorldExplorer()->GetResourceTree()->mRootPath + PATH_SEPERATOR + insertpath + file;
wxEditGOResource *page = ((wxEditGOResource*)(wxEdit::Instance().GetpropertyWindow()->SetPage("EditGOCRes")));
page->NewResource(fullPath);
page->OnApply();
page->SetResource(fullPath);
wxTreeItemId id = wxEdit::Instance().GetWorldExplorer()->GetResourceTree()->ExpandToPath(wxFileName(insertpath + file));
}
}
示例15: 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);
}
}
}