static async Task LoadPMX(StorageFile file, StorageFolder folder, ModelPack pack, ProcessingList processingList) { string path = file.Path; BinaryReader reader = new BinaryReader((await file.OpenReadAsync()).AsStreamForRead()); pack.Reload2(reader); pack.fullPath = path; pack.folder = folder; pack.relativePath = file.Name; reader.Dispose(); processingList.AddObject(pack.GetMesh()); pack.Status = GraphicsObjectStatus.loaded; pack.LoadTask = null; }
public static async Task LoadEntityIntoScene(Coocoo3DMain appBody, Scene scene, StorageFile pmxFile, StorageFolder storageFolder) { string pmxPath = pmxFile.Path; string relatePath = pmxFile.Name; ModelPack pack = null; lock (appBody.mainCaches.ModelPackCaches) { pack = appBody.mainCaches.ModelPackCaches.GetOrCreate(pmxPath); if (pack.LoadTask == null && pack.Status != GraphicsObjectStatus.loaded) { pack.LoadTask = Task.Run(async() => { BinaryReader reader = new BinaryReader((await pmxFile.OpenReadAsync()).AsStreamForRead()); pack.lastModifiedTime = (await pmxFile.GetBasicPropertiesAsync()).DateModified; pack.Reload2(reader); pack.folder = storageFolder; pack.relativePath = relatePath; reader.Dispose(); appBody.ProcessingList.AddObject(pack.GetMesh()); pack.Status = GraphicsObjectStatus.loaded; pack.LoadTask = null; }); } } if (pack.Status != GraphicsObjectStatus.loaded && pack.LoadTask != null) { await pack.LoadTask; } MMD3DEntity entity = new MMD3DEntity(); entity.Reload2(appBody.ProcessingList, pack, GetTextureList(appBody, storageFolder, pack.pmx), pmxPath); scene.AddSceneObject(entity); appBody.RequireRender(); appBody.mainCaches.ReloadTextures(appBody.ProcessingList, appBody.RequireRender); }