// ------------------------------------------------------------------------- void OgreBulletApplication::setupResources(void) { ExampleApplication::setupResources(); ResourceGroupManager *rsm = ResourceGroupManager::getSingletonPtr(); StringVector groups = rsm->getResourceGroups(); FileInfoListPtr finfo = ResourceGroupManager::getSingleton().findResourceFileInfo ( "Bootstrap", "axes.mesh"); const bool isSDK = (!finfo->empty()) && StringUtil::startsWith (finfo->begin()->archive->getName(), "../../media/packs/ogrecore.zip", true); const String resName ("OgreBullet"); { if (std::find(groups.begin(), groups.end(), resName) == groups.end()) { rsm->createResourceGroup(resName); String baseName; if (isSDK) { baseName = "../../../ogrebullet/"; } else { baseName = "../../../../../ogreaddons/ogrebullet/"; } rsm->addResourceLocation (baseName + "demos/Media","FileSystem", resName); rsm->addResourceLocation (baseName + "demos/Media/textures", "FileSystem", resName); rsm->addResourceLocation (baseName + "demos/Media/overlays", "FileSystem", resName); rsm->addResourceLocation (baseName + "demos/Media/materials", "FileSystem", resName); rsm->addResourceLocation (baseName + "demos/Media/models", "FileSystem", resName); rsm->addResourceLocation (baseName + "demos/Media/gui", "FileSystem", resName); } } }
Ogre::String GUIManager::getRandomWallpaperImage() { using namespace Ogre; FileInfoListPtr files = ResourceGroupManager::getSingleton().findResourceFileInfo("Wallpapers", "*.jpg", false); if (files.isNull() || files->empty()) { files = ResourceGroupManager::getSingleton().findResourceFileInfo("Wallpapers", "*.png", false); if (files.isNull() || files->empty()) return ""; } srand ( time(NULL) ); int num = 0; for (int i = 0; i<Math::RangeRandom(0, 10); i++) num = Math::RangeRandom(0, files->size()); return files->at(num).filename; }
//-------------------------------------------------------------------------- void DirectMusicPlayContext::play(bool _3D, const String& _filename, const String& _resourceGroup) { // Stop if played already stop(); // Find the full path to the file. FileInfoListPtr fileinfos = ResourceGroupManager::getSingleton().findResourceFileInfo(_resourceGroup, _filename); if(fileinfos->empty()) GOTHOGRE_EXCEPT(_filename << " - File not found."); FileInfo& fi = (*fileinfos)[0]; String path = fi.archive->getName() + "/" + fi.path; // Convert the full path and the filename to UTF-16LE. CodepageConverter* utf16Conv = UnicodeUtil::openConverter("UTF-16LE"); CodepageConverter::ByteBuffer bbFileName, bbPath; utf16Conv->unicodeToBuffer(bbFileName, fi.basename); utf16Conv->unicodeToBuffer(bbPath, path); bbPath.push_back(0); bbPath.push_back(0); bbFileName.push_back(0); bbFileName.push_back(0); WCHAR* wszPath = (WCHAR*) bbPath.data(); WCHAR* wszFileName = (WCHAR*) bbFileName.data(); // Set the search path. DXError::check( mLoader->SetSearchDirectory( GUID_DirectMusicAllTypes, // Types of files sought. wszPath, // Where to look. FALSE ) ); // Don't clear object data // Create a segment from the file. DXError::check( mLoader->LoadObjectFromFile( CLSID_DirectMusicSegment, // Class identifier. IID_IDirectMusicSegment8, // ID of desired interface. wszFileName, // Filename. (LPVOID*) &mSegment ) ); // Pointer that receives interface. // Download instrumental data (DLS) to the audiopath. DXError::check( mSegment->Download( mAudioPath ) ); // Begin playback of the segment. DXError::check( mPerformance->PlaySegmentEx( mSegment, // Segment to play. NULL, // Used for songs; not implemented. NULL, // For transitions. 0, // Flags. 0, // Start time; 0 is immediate. &mSegmentState, // Pointer that receives segment state. NULL, // Object to stop. mAudioPath ) ); // Audiopath, if not default. // Write the new segment state to the static list sSSPCM.insert(mSegmentState, this); mPlaying = true; // Get playback length MUSIC_TIME mtLength; DXError::check( mSegment->GetLength(&mtLength) ); DXError::check( mSegment->GetStartPoint(&mStartMusicTime) ); mEndMusicTime = mtLength + mStartMusicTime; }