//----------------------------------------------------------------------- StringVectorPtr ZipArchive::find(const String& pattern, bool recursive) { StringVectorPtr ret = StringVectorPtr(new StringVector()); FileInfoList::iterator i, iend; iend = mFileList.end(); for (i = mFileList.begin(); i != iend; ++i) { if (recursive || i->path.empty()) { // Check basename matches pattern (zip is case insensitive) if (StringUtil::match(i->basename, pattern, false)) { ret->push_back(i->filename); } } else { // Check full name if (StringUtil::match(i->filename, pattern, false)) { ret->push_back(i->filename); } } } return ret; }
MaterialFactory::MaterialFactory() : bNormalMap(1), bEnvMap(1), bShadows(1), bShadowsDepth(1), bShadowsSoft(1), bShadowsFade(0), iTexSize(4096), iNumShadowTex(3), iShadowsFilterSize(4), fShaderQuality(0.5), fShadowsFadeDistance(20.f), bReflect(0), bRefract(0), bSettingsChanged(1), // always have to generate at start mSceneMgr(0), mTerrain(0), mPSSM(0) { QTimer ti; ti.update(); /// time // find all files with *.matdef extension in all resource groups StringVector resourceGroups = ResourceGroupManager::getSingleton().getResourceGroups(); for (StringVector::iterator it = resourceGroups.begin(); it != resourceGroups.end(); ++it) { StringVectorPtr files = ResourceGroupManager::getSingleton().findResourceNames( (*it), "*.matdef"); for (StringVector::iterator fit = files->begin(); fit != files->end(); ++fit) { loadDefsFromFile( (*fit) ); } } // create our generators mGenerator = new MaterialGenerator(); mGenerator->mParent = this; MaterialGenerator* glass = static_cast<MaterialGenerator*>(new GlassMaterialGenerator()); glass->mParent = this; mCustomGenerators.push_back(glass); MaterialGenerator* pipeglass = static_cast<MaterialGenerator*>(new PipeGlassMaterialGenerator()); pipeglass->mParent = this; mCustomGenerators.push_back(pipeglass); MaterialGenerator* arrow = static_cast<MaterialGenerator*>(new ArrowMaterialGenerator()); arrow->mParent = this; mCustomGenerators.push_back(arrow); MaterialGenerator* water = static_cast<MaterialGenerator*>(new WaterMaterialGenerator()); water->mParent = this; mCustomGenerators.push_back(water); MaterialGenerator* impostor = static_cast<MaterialGenerator*>(new ImpostorMaterialGenerator()); impostor->mParent = this; mCustomGenerators.push_back(impostor); MaterialGenerator* particle = static_cast<MaterialGenerator*>(new ParticleMaterialGenerator()); particle->mParent = this; mCustomGenerators.push_back(particle); ti.update(); /// time float dt = ti.dt * 1000.f; LogO(String("::: Time loading material definitions: ") + toStr(dt) + " ms"); }
void loadScriptLibrary() { StringVectorPtr names = ResourceGroupManager::getSingleton().listResourceNames("DefaultLuaScripts"); for(int i = 0; i < names->size(); ++i) { loadScript(names->at(i)); } names.setNull(); }
void ZipArchiveTests::testFindNonRecursive() { ZipArchive arch(testPath, "Zip"); arch.load(); StringVectorPtr vec = arch.find("*.txt", false); CPPUNIT_ASSERT_EQUAL((size_t)2, vec->size()); CPPUNIT_ASSERT_EQUAL(String("rootfile.txt"), vec->at(0)); CPPUNIT_ASSERT_EQUAL(String("rootfile2.txt"), vec->at(1)); }
//----------------------------------------------------------------------- StringVectorPtr Utf8Archive::list(bool _recursive, bool _dirs) { StringVectorPtr ret = mBaseArchive->list(_recursive, _dirs); for(size_t i = 0; i != ret->size(); ++i) { String& elem = (*ret)[i]; StringUtil::ansiToUtf8(elem); } return ret; }
vector<vector<string> > findLadders0(string start, string end, unordered_set<string> &dict) { dict.insert(start); StringVectorQ q; q.push_back( StringVectorPtr(new StringVector(1, start)) ); const int L = end.size(); StringVectorQ result; StringSet visitedS = {start}; while( !q.empty() ) { StringVectorPtr pv = q.front(); q.pop_front(); if( pv->size() > shortest ) continue; string s = pv->back(); for(int i=0; i<L; ++i) { string newStr = s; char ch = s[i]; do { ch++; if( ch > 'z') ch = 'a'; if( ch == s[i]) break; newStr[i] = ch; if( newStr == end ) { // found it StringVectorPtr newV(new StringVector(*pv)); newV->push_back(newStr); result.push_back(newV); if( newV->size() < shortest) shortest = newV->size(); } if( dict.end() != dict.find(newStr) && std::find(pv->begin(), pv->end(), newStr) == pv->end() ) { // continue with next search StringVectorPtr newV(new StringVector(*pv)); newV->push_back(newStr); visitedS.insert(newStr); q.push_back(newV); } }while(true); } } struct Smaller{ int x; Smaller(int a):x(a){} bool operator()(StringVectorPtr& v) { return v->size() < x; } }; StringVectorVector vv; // std::copy_if(result.begin(), result.end(), std::back_inserter(vv), Smaller(shortest)); for(StringVectorQ::iterator it=result.begin(); it!=result.end(); ++it) { if( (**it).size() <= shortest ) vv.push_back(std::move(**it)); } return std::move(vv); }
void ZipArchiveTests::testFindRecursive() { ZipArchive arch(testPath, "Zip"); arch.load(); StringVectorPtr vec = arch.find("*.material", true); CPPUNIT_ASSERT_EQUAL((size_t)4, vec->size()); CPPUNIT_ASSERT_EQUAL(String("level1/materials/scripts/file.material"), vec->at(0)); CPPUNIT_ASSERT_EQUAL(String("level1/materials/scripts/file2.material"), vec->at(1)); CPPUNIT_ASSERT_EQUAL(String("level2/materials/scripts/file3.material"), vec->at(2)); CPPUNIT_ASSERT_EQUAL(String("level2/materials/scripts/file4.material"), vec->at(3)); }
//----------------------------------------------------------------------- StringVectorPtr Utf8Archive::find(const String& _pattern, bool _recursive, bool _dirs) { String pattern2 = _pattern; StringUtil::utf8ToAnsi(pattern2); StringVectorPtr ret = mBaseArchive->find(pattern2, _recursive, _dirs); for(size_t i = 0; i != ret->size(); ++i) { String& elem = (*ret)[i]; StringUtil::ansiToUtf8(elem); } return ret; }
//----------------------------------------------------------------------- void RenderSystemCapabilitiesManager::parseCapabilitiesFromArchive(const String& filename, const String& archiveType, bool recursive) { // get the list of .rendercaps files Archive* arch = ArchiveManager::getSingleton().load(filename, archiveType); StringVectorPtr files = arch->find(mScriptPattern, recursive); // loop through .rendercaps files and load each one for (StringVector::iterator it = files->begin(), end = files->end(); it != end; it++) { DataStreamPtr stream = arch->open(*it); mSerializer->parseScript(stream); stream->close(); } }
//----------------------------------------------------------------------- StringVectorPtr ZipArchive::list(bool recursive, bool dirs) const { OGRE_LOCK_AUTO_MUTEX; StringVectorPtr ret = StringVectorPtr(OGRE_NEW_T(StringVector, MEMCATEGORY_GENERAL)(), SPFM_DELETE_T); FileInfoList::const_iterator i, iend; iend = mFileList.end(); for (i = mFileList.begin(); i != iend; ++i) if ((dirs == (i->compressedSize == size_t (-1))) && (recursive || i->path.empty())) ret->push_back(i->filename); return ret; }
void ContentModule::precreateMeshes() const { StringVectorPtr meshes = ResourceGroupManager::getSingleton() .findResourceNames(getId(), "*.mesh"); for (size_t i = 0; i < meshes->size(); ++i) { ResourcePtr res = MeshManager::getSingleton().getByName((*meshes)[i]); if (res.isNull()) { MeshPtr mesh = MeshManager::getSingleton().create((*meshes)[i], getId()); } } }
//----------------------------------------------------------------------- StringVectorPtr ZipArchive::list(bool recursive) { StringVectorPtr ret = StringVectorPtr(new StringVector()); FileInfoList::iterator i, iend; iend = mFileList.end(); for (i = mFileList.begin(); i != iend; ++i) { if (recursive || i->path.empty()) { ret->push_back(i->filename); } } return ret; }
void FileSystemArchiveTests::testListNonRecursive() { try { FileSystemArchive arch(testPath, "FileSystem"); arch.load(); StringVectorPtr vec = arch.list(false); CPPUNIT_ASSERT_EQUAL((unsigned int)2, (unsigned int)vec->size()); CPPUNIT_ASSERT_EQUAL(String("rootfile.txt"), vec->at(0)); CPPUNIT_ASSERT_EQUAL(String("rootfile2.txt"), vec->at(1)); } catch (Exception& e) { std::cout << e.getFullDescription(); } }
/** * @author JoSch * @date 04-27-2004 */ void SoundManager::addSounds(const Ogre::String& group) { StringList extlist = getExtension(); StringList::const_iterator cit; for(cit = extlist.begin(); cit != extlist.end(); cit++) { StringVectorPtr sl = ResourceGroupManager::getSingleton().findResourceNames( group, *cit ); StringVector::const_iterator it; for(it = sl->begin(); it != sl->end(); it++) { try { create(*it, group); } catch(...) {} } } }
//----------------------------------------------------------------------------------- String RecursiveArchive::getPath(const String& _filename) { String filepath = _filename; if(!getBaseArchive()->exists(_filename)) { StringVectorPtr vecptr = getBaseArchive()->find(_filename, true, false); if(!vecptr->empty()) { filepath = (*vecptr)[0]; if(vecptr->size() != 1) { GOTHOGRE_LOG(Warning, "RecursiveArchive: Found two files" " with the same name '" << _filename << "'" << ": '" << (*vecptr)[0] << "', '" << (*vecptr)[1] << "'." << "One of these files will be unavailable."); } } } return filepath; }
//----------------------------------------------------------------------- StringVectorPtr ZipArchive::find(const String& pattern, bool recursive, bool dirs) const { OGRE_LOCK_AUTO_MUTEX; StringVectorPtr ret = StringVectorPtr(OGRE_NEW_T(StringVector, MEMCATEGORY_GENERAL)(), SPFM_DELETE_T); // If pattern contains a directory name, do a full match bool full_match = (pattern.find ('/') != String::npos) || (pattern.find ('\\') != String::npos); bool wildCard = pattern.find("*") != String::npos; FileInfoList::const_iterator i, iend; iend = mFileList.end(); for (i = mFileList.begin(); i != iend; ++i) if ((dirs == (i->compressedSize == size_t (-1))) && (recursive || full_match || wildCard)) // Check basename matches pattern (zip is case insensitive) if (StringUtil::match(full_match ? i->filename : i->basename, pattern, false)) ret->push_back(i->filename); return ret; }
void ZipArchiveTests::testListRecursive() { ZipArchive arch(testPath, "Zip"); arch.load(); StringVectorPtr vec = arch.list(true); CPPUNIT_ASSERT_EQUAL((size_t)6, vec->size()); CPPUNIT_ASSERT_EQUAL(String("level1/materials/scripts/file.material"), vec->at(0)); CPPUNIT_ASSERT_EQUAL(String("level1/materials/scripts/file2.material"), vec->at(1)); CPPUNIT_ASSERT_EQUAL(String("level2/materials/scripts/file3.material"), vec->at(2)); CPPUNIT_ASSERT_EQUAL(String("level2/materials/scripts/file4.material"), vec->at(3)); CPPUNIT_ASSERT_EQUAL(String("rootfile.txt"), vec->at(4)); CPPUNIT_ASSERT_EQUAL(String("rootfile2.txt"), vec->at(5)); }
void FileSystemArchiveTests::testListRecursive() { FileSystemArchive arch(testPath, "FileSystem"); arch.load(); StringVectorPtr vec = arch.list(true); CPPUNIT_ASSERT_EQUAL((size_t)48, vec->size()); // 48 including CVS folders! CPPUNIT_ASSERT_EQUAL(String("rootfile.txt"), vec->at(0)); CPPUNIT_ASSERT_EQUAL(String("rootfile2.txt"), vec->at(1)); CPPUNIT_ASSERT_EQUAL(String("level1/materials/scripts/file.material"), vec->at(2)); CPPUNIT_ASSERT_EQUAL(String("level1/materials/scripts/file2.material"), vec->at(3)); CPPUNIT_ASSERT_EQUAL(String("level2/materials/scripts/file3.material"), vec->at(22)); CPPUNIT_ASSERT_EQUAL(String("level2/materials/scripts/file4.material"), vec->at(23)); }
void Sample_MeshLod::setupControls( int uimode /*= 0*/ ) { cleanupControls(); SelectMenu* models = mTrayMgr->createLongSelectMenu(TL_TOPLEFT, "cmbModels", "Model:", 150, 8); models->addItem("Sinbad.mesh"); models->addItem("ogrehead.mesh"); models->addItem("knot.mesh"); models->addItem("fish.mesh"); models->addItem("penguin.mesh"); models->addItem("ninja.mesh"); models->addItem("dragon.mesh"); models->addItem("athene.mesh"); models->addItem("sibenik.mesh"); // Add all meshes from popular: StringVectorPtr meshes = ResourceGroupManager::getSingleton().findResourceNames("General", "*.mesh"); StringVector::iterator it, itEnd; it = meshes->begin(); itEnd = meshes->end(); for(; it != itEnd; it++){ models->addItem(*it); } // Basic options: mWireframe = mTrayMgr->createCheckBox(TL_TOPLEFT, "chkShowWireframe", "Show wireframe", 200); mUseVertexNormals = mTrayMgr->createCheckBox(TL_TOPLEFT, "chkUseVertexNormals", "Use vertex normals", 200); mOutsideWeightSlider = mTrayMgr->createThickSlider(TL_TOPLEFT, "sldOutsideWeight", "Weighten outside", 200, 50, 0, 100, 101); mOutsideWalkAngle = mTrayMgr->createThickSlider(TL_TOPLEFT, "sldOutsideWalkAngle", "Outside angle", 200, 50, -1, 1, 201); mManualMeshes = mTrayMgr->createLongSelectMenu(TL_TOPLEFT, "cmbManualMesh", "Manual LOD:", 100, 8); mManualMeshes->copyItemsFrom(models); mManualMeshes->insertItem(0,""); mReductionSlider = mTrayMgr->createThickSlider(TL_TOPLEFT, "sldReductionValue", "Reduced vertices", 200, 50, 0, 100, 101); mTrayMgr->createButton(TL_TOPLEFT, "btnReduceMore","Reduce More"); mTrayMgr->createButton(TL_TOPLEFT, "btnReduceLess","Reduce Less"); // Level options: mDistanceLabel = mTrayMgr->createLabel(TL_TOPRIGHT, "lblDistance", "Distance: ", 250); mLodLevelList = mTrayMgr->createLongSelectMenu(TL_TOPRIGHT, "cmbLodLevels", "Lod level:", 150, 4); mTrayMgr->createButton(TL_TOPRIGHT, "btnAddLodLevel","Add level", 220); mTrayMgr->createButton(TL_TOPRIGHT, "btnRemoveSelectedLodLevel","Remove level", 220); mTrayMgr->createButton(TL_TOPRIGHT, "btnRemoveInitialLodLevel","Remove level #0", 220); // Serializer options: mTrayMgr->createButton(TL_TOPRIGHT, "btnShowAll", "Show all levels", 220); mTrayMgr->createButton(TL_TOPRIGHT, "btnAutoconfigure", "Show autoconfigured LODs", 220); mTrayMgr->createButton(TL_TOPRIGHT, "btnShowMesh", "Show LODs stored in mesh", 220); mTrayMgr->createButton(TL_TOPRIGHT, "btnSaveMesh", "Save mesh", 220); mTrayMgr->createButton(TL_TOPRIGHT, "btnRestoreMesh", "Restore original mesh", 220); // Profile options mProfileList = mTrayMgr->createLongSelectMenu(TL_TOPRIGHT, "cmbProfiledVertices", "Profile:", 180, 4); mTrayMgr->createButton(TL_TOPRIGHT, "btnRemoveFromProfile","Remove from profile", 220.0); mTrayMgr->createButton(TL_TOPRIGHT, "btnAddToProfile","Add to profile", 220.0); //mTrayMgr->createTextBox(TL_TOPRIGHT, "Help","Help", 200, 200) // ->setText("The last reduced vertex is the selected vertex. Use the slider to select the vertex, then decide to keep or remove it. You can export the Lod buffers into the .mesh file after configuration."); mTrayMgr->showCursor(); }
bool operator()(StringVectorPtr& v) { return v->size() < x; }
//----------------------------------------------------------------------- void MaterialService::createStandardMaterial(unsigned int idx, std::string matName, std::string textureName, std::string resourceGroup) { Image tex; bool loaded = false; // indicates we were successful finding the texture StringVectorPtr texnames = ResourceGroupManager::getSingleton().findResourceNames(resourceGroup, textureName + ".*"); if (texnames->size() <= 0) { // no results, try the localised version // prev. path + /language/filename String locresname = mConfigService->getLocalisedResourcePath(textureName); LOG_INFO("Specified resource (%s) was not found, trying localized version: %s", textureName.c_str(), locresname.c_str()); texnames = ResourceGroupManager::getSingleton().findResourceNames(resourceGroup, locresname + ".*"); } String txtfile; // Let's try the extensions from the extensions vector StringVector::iterator it = texnames->begin(); for (; it != texnames->end(); it++) { // Try loading every given try { tex.load((*it), resourceGroup); TextureManager::getSingleton().loadImage(textureName, resourceGroup, tex, TEX_TYPE_2D, 5, 1.0f); txtfile = (*it); loaded = true; break; // we got it! } catch (Ogre::Exception) { // Nothing. We are trying more extensions } } if (!loaded) LOG_ERROR("Image %s was not found, texture will be invalid!", textureName.c_str()); // Construct a material out of this texture. We'll just clone the material upstairs to enable lmap-txture combinations MaterialPtr shadMat = MaterialManager::getSingleton().create(matName, resourceGroup); shadMat->setReceiveShadows(true); Pass *shadPass = shadMat->getTechnique(0)->getPass(0); shadPass->setAmbient(0.5, 0.5, 0.5); shadPass->setDiffuse(1, 1, 1, 1); shadPass->setSpecular(1, 1, 1, 1); TextureUnitState* tus = createAnimatedTextureState(shadPass, txtfile, resourceGroup, 5); // Set replace on all first layer textures for now // tus->setColourOperation(LBO_REPLACE); tus->setTextureAddressingMode(TextureUnitState::TAM_WRAP); tus->setTextureCoordSet(0); tus->setTextureFiltering(TFO_BILINEAR); tus->setTextureUScale(1.0f); tus->setTextureVScale(1.0f); // tus->setTextureFiltering(TFO_NONE); // Set culling mode to none // shadMat->setCullingMode(CULL_ANTICLOCKWISE); // No dynamic lighting shadMat->setLightingEnabled(false); // DYNL: shadMat->load(); // standard size addWorldMaterialTemplate(idx, shadMat); }
void MeshSerializerTests::testMesh_Version_1_2() { // Exporting legacy Mesh not supported! // testMesh(MESH_VERSION_LEGACY); #ifdef I_HAVE_LOT_OF_FREE_TIME // My sandboxing test. Takes a long time to complete! // Runs on all meshes and exports all to every Lod version. char* groups [] = { "Popular", "General", "Tests" }; for (int i = 0; i < 3; i++) { StringVectorPtr meshes = ResourceGroupManager::getSingleton().findResourceNames(groups[i], "*.mesh"); StringVector::iterator it, itEnd; it = meshes->begin(); itEnd = meshes->end(); for (; it != itEnd; it++) { try { mMesh = MeshManager::getSingleton().load(*it, groups[i]); } catch(std::exception e) { // OutputDebugStringA(e.what()); } getResourceFullPath(mMesh, mMeshFullPath); if (!copyFile(mMeshFullPath + ".bak", mMeshFullPath)) { // If there is no backup, create one. copyFile(mMeshFullPath, mMeshFullPath + ".bak"); } mOrigMesh = mMesh->clone(mMesh->getName() + ".orig.mesh", mMesh->getGroup()); testMesh_XML(); testMesh(MESH_VERSION_1_10); testMesh(MESH_VERSION_1_8); testMesh(MESH_VERSION_1_7); testMesh(MESH_VERSION_1_4); testMesh(MESH_VERSION_1_0); } meshes = ResourceGroupManager::getSingleton().findResourceNames(groups[i], "*.skeleton"); it = meshes->begin(); itEnd = meshes->end(); for (; it != itEnd; it++) { mSkeleton = SkeletonManager::getSingleton().load(*it, groups[i]); getResourceFullPath(mSkeleton, mSkeletonFullPath); if (!copyFile(mSkeletonFullPath + ".bak", mSkeletonFullPath)) { // If there is no backup, create one. copyFile(mSkeletonFullPath, mSkeletonFullPath + ".bak"); } SkeletonSerializer skeletonSerializer; skeletonSerializer.exportSkeleton(mSkeleton.get(), mSkeletonFullPath, SKELETON_VERSION_1_8); mSkeleton->reload(); skeletonSerializer.exportSkeleton(mSkeleton.get(), mSkeletonFullPath, SKELETON_VERSION_1_0); mSkeleton->reload(); } } #endif /* ifdef I_HAVE_LOT_OF_FREE_TIME */ }