int ExtractAssets( struct android_app* state , const char* packageDir ) { AAssetManager* assetManager = state->activity->assetManager; LOGI( "Checking for assets to extract" ); // First extract the index file which tells us which other files to extract char* extractionIndexfilePath = GetAssetPath( packageDir, "filestoextract.txt" ); int retValue = ExtractAsset( assetManager, "filestoextract.txt", extractionIndexfilePath ); if ( 0 != retValue ) { LOGI( "Found index of assets to extract" ); // Now go trough the list extraction all files listed. // each line in the index file is a file to extract char entryBuffer[ PATH_MAX ]; FILE* listFptr = fopen( extractionIndexfilePath, "r" ); char* bufferPtr = 0; if ( NULL == listFptr ) { // Abort, unable to open the file FLOGE( "Error %i when opening file %s", errno, extractionIndexfilePath ); free( extractionIndexfilePath ); return 0; } do { // Read the entry bufferPtr = ReadString( listFptr, entryBuffer, PATH_MAX ); if ( NULL != bufferPtr ) { // Create destination path and extract the asset char* destPath = GetAssetPath( packageDir, bufferPtr ); retValue = ExtractAsset( assetManager, entryBuffer, destPath ); if ( 0 == retValue ) { // Failed to extract the current entry, abort FLOGE( "Failed to extract asset to %s", destPath ); free( destPath ); fclose( listFptr ); free( extractionIndexfilePath ); return 0; } free( destPath ); } } while ( NULL != bufferPtr ); fclose( listFptr ); } else { LOGI( "No extraction index is available, no assets will be extracted" ); } free( extractionIndexfilePath ); return 1; }
recondite::Model* reProjectAssets::ImportModel(const wxString& path) { import::ModelImporter modelImporter; import::ModelImporterOptions options; ModelData modelData; int error = modelImporter.ImportModel(path.c_str().AsChar(), modelData, options); if (!error) { modelData.CalculateBoundings(); wxFileName modelPath(path); wxString modelName = modelPath.GetName(); WriteModel(modelData, modelName); if (modelData.GetLineMeshCount() == 0) { CreateSelectionWireframeForModel(modelData); } recondite::Model* model = _component->GetEngine()->content->Models()->LoadFromData(modelData, modelName.c_str().AsChar()); wxString modelHandle = GetAssetPath(rAssetType::Model, modelName); _manifest.Add(rAssetType::Model, modelName.c_str().AsChar(), modelHandle.c_str().AsChar()); return model; } return nullptr; }
int IsFirstRun( const char* packageDir ) { // We know the gucefLOADER relies on a text file named firstrun.completed // we will use the same convention here to keep things consistent char* firstrunFile = GetAssetPath( packageDir, "firstrun.completed" ); int existsBool = FileExists( firstrunFile ); free( firstrunFile ); return existsBool; }
void UnSetFirstRunCompleted( const char* packageDir ) { // We know the gucefLOADER relies on a text file named firstrun.completed.txt // we will use the same convention here to keep things consistent char* firstrunFile = GetAssetPath( packageDir, "firstrun.completed" ); remove( firstrunFile ); free( firstrunFile ); LOGI( "Unset first run flag" ); }
bool reProjectAssets::DeleteModel(const wxString& name) { if (_manifest.RemoveByName(rAssetType::Model, name.c_str().AsChar())) { _component->GetEngine()->content->Models()->Delete(name.c_str().AsChar()); wxString assetPath = GetAssetPath(rAssetType::Model, name); wxString modelFile = GetDirectoryPath() + assetPath; wxRemoveFile(modelFile); return true; } return false; }
int InvokeLoadAndRunGucefPlatformApp( const char* appName , const char* rootDir , int platformArgc , char** platformArgv , int appArgc , char** appArgv ) { char* modulePath = GetLibPath( rootDir, "libgucefLOADER.so" ); void* modulePtr = (void*) dlopen( modulePath, RTLD_NOW ); if ( NULL == modulePtr ) { free( modulePath ); LOGF( "Unable to link gucefLOADER module" ); return 0; } FLOGI( "Loading loader module from: %s", modulePath ); free( modulePath ); modulePath = NULL; TGUCEFCORECINTERFACE_LoadAndRunGucefPlatformApp loadAndRunGucefPlatformApp = (TGUCEFCORECINTERFACE_LoadAndRunGucefPlatformApp) dlsym( modulePtr, "LoadAndRunGucefPlatformApp" ); if ( NULL == loadAndRunGucefPlatformApp ) { LOGF( "Unable to link gucefLOADER function: LoadAndRunGucefPlatformApp" ); dlclose( modulePtr ); return 0; } char* libRootDir = GetAssetLibRoot( rootDir ); char* assetRootDir = GetAssetPath( rootDir, "" ); int returnValue = loadAndRunGucefPlatformApp( appName , rootDir , assetRootDir , libRootDir , platformArgc , platformArgv , appArgc , appArgv ); free( libRootDir ); libRootDir = NULL; free( assetRootDir ); assetRootDir = NULL; dlclose( modulePtr ); modulePtr = NULL; FLOGI( "LoadAndRunGucefPlatformApp returned with code %i", returnValue ); return returnValue; }
bool Model::LoadModel( const char* const filename, ComPtr<ID3D11Device> const device, const void* shaderBCode, const size_t bcodeLength) { IndexedModel model; if (!LoadOBJFromFile(GetAssetPath(filename).c_str(), model)) { return false; } initDimensions.depth = model.maxDepth; initDimensions.height = model.maxHeight; initDimensions.width = model.maxWidth; dimensions = initDimensions; return SetBuffers(device, shaderBCode, bcodeLength, model.vertices, model.indices); }
void SetFirstRunCompleted( const char* packageDir ) { // We know the gucefLOADER relies on a text file named firstrun.completed // we will use the same convention here to keep things consistent char* firstrunFile = GetAssetPath( packageDir, "firstrun.completed" ); int existsBool = FileExists( firstrunFile ); if ( 0 == existsBool ) { if ( 0 != MakeFileDir( firstrunFile, 00777 ) ) { FILE* fptr = fopen( firstrunFile, "wb" ); if ( NULL != fptr ) { FLOGI( "Wrote flag to %s", firstrunFile ); fclose( fptr ); free( firstrunFile ); return; } } FLOGE( "Unable to create flag at %s", firstrunFile ); } free( firstrunFile ); }