public void loadMeshAsync(string filename) { if (currentLoadedARObject != null) { unloadARObject(currentLoadedARObject); } Debug.Log("!!! ATTEMPTING TO LOAD MESH"); using (var assetLoader = new AssetLoaderAsync()) { try { var assetLoaderOptions = AssetLoaderOptions.CreateInstance(); // assetLoaderOptions.RotationAngles = new Vector3(90f, 180f, 0f); // assetLoaderOptions.AutoPlayAnimations = true; assetLoaderOptions.Use32BitsIndexFormat = true; string filetoload = Application.persistentDataPath + "/" + filename; assetLoader.LoadFromFile(filetoload, assetLoaderOptions, null, delegate(GameObject loadedGameObject) { //recalculateNormals(loadedGameObject); loadedGameObject.transform.position = Vector3.zero; loadedGameObject.transform.rotation = Quaternion.identity; currentLoadedARObject = loadedGameObject; Debug.Log("!!!!!!!!!**** game object loaded"); }); } catch (Exception e) { Debug.LogError(e.ToString()); } } }
void testasync() { using (var assetLoaderAsync = new AssetLoaderAsync()) { var assetLoaderOptions = AssetLoaderOptions.CreateInstance(); //Creates the AssetLoaderOptions instance. //AssetLoaderOptions let you specify options to load your model. //(Optional) You can skip this object creation and it's parameter or pass null. //You can modify assetLoaderOptions before passing it to LoadFromFile method. You can check the AssetLoaderOptions API reference at: //https://ricardoreis.net/trilib/manual/html/class_tri_lib_1_1_asset_loader_options.html var wrapperGameObject = gameObject; //Sets the game object where your model will be loaded into. //(Optional) You can skip this object creation and it's parameter or pass null. var thread = assetLoaderAsync.LoadFromFile("PATH TO MY FILE.FBX", assetLoaderOptions, wrapperGameObject, delegate(GameObject myGameObject) { //Here you can get the reference to the loaded model using myGameObject. }); //Loads the model asynchronously and returns the reference to the created Task/Thread. } }
//Generates the progress bar textures and starts to load the asset private void Start() { //Generates progress bar textures GenerateProgressBarTextures(); //Creates our AssetLoaderAsync instance using (var assetLoaderAsync = new AssetLoaderAsync()) { try { //Loads the given asset and set the loading progress and loading completed callback assetLoaderAsync.LoadFromFile(Application.dataPath + "/TriLib/TriLib/Samples/Models/BigModel.obj", null, gameObject, OnAssetLoaded, null, OnAssetLoadingProgress); } catch (Exception e) { //Stores the error message to show on GUI _error = e.ToString(); } } }
//Generates the progress bar textures and starts to load the asset private void Start() { //Generates progress bar textures GenerateProgressBarTextures(); //Creates our AssetLoaderAsync instance using (var assetLoaderAsync = new AssetLoaderAsync()) { try { //Loads the given asset and set the loading progress and loading completed callback assetLoaderAsync.LoadFromFile(string.Format("{0}/BigModel.obj", TriLibProjectUtils.FindPathRelativeToProject("Models", "t:Model BigModel")), null, gameObject, OnAssetLoaded, null, OnAssetLoadingProgress); } catch (Exception e) { //Stores the error message to show on GUI _error = e.ToString(); } } }
/// <summary> /// Tries to load "Bouncing.fbx" model /// </summary> protected void Start() { using (var assetLoader = new AssetLoaderAsync()) { try { var assetLoaderOptions = AssetLoaderOptions.CreateInstance(); assetLoaderOptions.RotationAngles = new Vector3(90f, 180f, 0f); assetLoaderOptions.AutoPlayAnimations = true; assetLoader.LoadFromFile(Application.dataPath + "/TriLib/TriLib/Samples/Models/Bouncing.fbx", assetLoaderOptions, null, delegate(GameObject loadedGameObject) { loadedGameObject.transform.position = new Vector3(128f, 0f, 0f); }); } catch (Exception e) { Debug.LogError(e.ToString()); } } }
/// <summary> /// Tries to load "Bouncing.fbx" model /// </summary> protected void Start() { using (var assetLoader = new AssetLoaderAsync()) { try { var assetLoaderOptions = AssetLoaderOptions.CreateInstance(); //assetLoaderOptions.RotationAngles = new Vector3(90f, 180f, 0f); assetLoaderOptions.AutoPlayAnimations = true; //assetLoaderOptions.UseOriginalPositionRotationAndScale = true; assetLoader.LoadFromFile(string.Format("{0}/Bouncing.fbx", TriLibProjectUtils.FindPathRelativeToProject("Models", "t:Model Bouncing")), assetLoaderOptions, null, delegate(GameObject loadedGameObject) { // loadedGameObject.transform.position = new Vector3(128f, 0f, 0f); }); } catch (Exception e) { Debug.LogError(e.ToString()); } } }