gpvigano / AsImpL

Asynchronous Importer and run-time Loader for Unity
MIT License
212 stars 37 forks source link

IndexOutOfRangeException in the Solve Function #2

Closed trevortknguyen closed 7 years ago

trevortknguyen commented 7 years ago

I'm currently trying to load OBJ files. This error is consistently happening on complex models.

IndexOutOfRangeException: Array index is out of range.
AsImpL.ObjectBuilder.Solve (UnityEngine.Mesh origMesh) (at Assets/AsImpL/Scripts/Dataset/ObjectBuilder.cs:152)
AsImpL.ObjectBuilder.ImportSubObject (UnityEngine.GameObject parentObj, AsImpL.ObjectData objData, System.Collections.Generic.Dictionary`2 mats) (at Assets/AsImpL/Scripts/Dataset/ObjectBuilder.cs:409)
AsImpL.ObjectBuilder.BuildNextObject (UnityEngine.GameObject parentObj, System.Collections.Generic.Dictionary`2 mats) (at Assets/AsImpL/Scripts/Dataset/ObjectBuilder.cs:304)
AsImpL.ObjectBuilder.BuildObjectAsync (AsImpL.ProgressInfo& info) (at Assets/AsImpL/Scripts/Dataset/ObjectBuilder.cs:114)
AsImpL.Loader+<Build>c__Iterator1.MoveNext () (at Assets/AsImpL/Scripts/Loaders/Loader.cs:380)
UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)
gpvigano commented 7 years ago

I think the problem is related to texture coordinates, probably your model has not texture coordinates and the Solve() method assumes they are defined. This is a bug, it should be fixed by my last commit. Please let me know if this work for you.

trevortknguyen commented 7 years ago

I am sorry for my late reply. It appears as though it still does not work.

I get this error when I run the 001_Import_SimpleTest with the path to a custom .obj file. I don't know where I could post the file, but it is 2,625 KB in space to give a comparison for size.

IndexOutOfRangeException: Array index is out of range.
AsImpL.ObjectBuilder.Solve (UnityEngine.Mesh origMesh) (at Assets/AsImpL/Scripts/Dataset/ObjectBuilder.cs:157)
AsImpL.ObjectBuilder.ImportSubObject (UnityEngine.GameObject parentObj, AsImpL.ObjectData objData, System.Collections.Generic.Dictionary`2 mats) (at Assets/AsImpL/Scripts/Dataset/ObjectBuilder.cs:414)
AsImpL.ObjectBuilder.BuildNextObject (UnityEngine.GameObject parentObj, System.Collections.Generic.Dictionary`2 mats) (at Assets/AsImpL/Scripts/Dataset/ObjectBuilder.cs:309)
AsImpL.ObjectBuilder.BuildObjectAsync (AsImpL.ProgressInfo& info) (at Assets/AsImpL/Scripts/Dataset/ObjectBuilder.cs:114)
AsImpL.Loader+<Build>c__Iterator1.MoveNext () (at Assets/AsImpL/Scripts/Loaders/Loader.cs:380)
UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)
gpvigano commented 7 years ago

In my last commit I added more checks in Solve() method to prevent exceptions: if some data is missing the method prints a warning and returns without any further calculation. I hope this will allow to load your models, please let me know if it works for you.

gpvigano commented 7 years ago

@trevortknguyen : is it still possible for you to check if the latest version works with your models? After your answer I will be able to close this issue. Thanks in advance.