public static void LoadAsync(string modelName, TextureDictionary[] txds, System.Action <GeometryParts> onFinish) { modelName = modelName.ToLower(); if (!s_asyncLoader.TryLoadObject(modelName, onFinish)) { // callback is either called or registered return; } GeometryParts loadedGeoms = null; LoadingThread.RegisterJob(new LoadingThread.Job <Clump> () { action = () => { // read archive file in background thread var clump = ArchiveManager.ReadFile <Clump>(modelName + ".dff"); return(clump); }, callbackSuccess = (Clump clump) => { if (clump.GeometryList == null) { throw new Exception("Invalid mesh"); } // create geometry parts in main thread loadedGeoms = new GeometryParts(modelName, clump, txds); }, callbackFinish = (result) => { s_asyncLoader.OnObjectFinishedLoading(modelName, loadedGeoms, loadedGeoms != null); } }); }
public static GeometryParts Load(string modelName, params TextureDictionary[] txds) { modelName = modelName.ToLower(); if (s_asyncLoader.IsObjectLoaded(modelName)) { return(s_asyncLoader.GetLoadedObject(modelName)); } Profiler.BeginSample("ReadClump"); var clump = ArchiveManager.ReadFile <Clump>(modelName + ".dff"); Profiler.EndSample(); if (clump.GeometryList == null) { throw new Exception("Invalid mesh"); } Profiler.BeginSample("Create GeometryParts"); var loaded = new GeometryParts(modelName, clump, txds); Profiler.EndSample(); s_asyncLoader.AddToLoadedObjects(modelName, loaded); return(loaded); }
public static GeometryParts Load(string modelName, params TextureDictionary[] txds) { modelName = modelName.ToLower(); if (_sLoaded.ContainsKey(modelName)) { return(_sLoaded[modelName]); } var clump = ArchiveManager.ReadFile <Clump>(modelName + ".dff"); if (clump.GeometryList == null) { throw new Exception("Invalid mesh"); } var loaded = new GeometryParts(modelName, clump, txds); _sLoaded.Add(modelName, loaded); return(loaded); }
public static GeometryParts Load(string modelName, params TextureDictionary[] txds) { modelName = modelName.ToLower(); if (_sLoaded.ContainsKey(modelName)) { return _sLoaded[modelName]; } var clump = ArchiveManager.ReadFile<Clump>(modelName + ".dff"); if (clump.GeometryList == null) { throw new Exception("Invalid mesh"); } var loaded = new GeometryParts(modelName, clump, txds); _sLoaded.Add(modelName, loaded); return loaded; }