gpvigano / AsImpL

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

Load fails but still loads #37

Closed KuraiAndras closed 5 years ago

KuraiAndras commented 5 years ago

I'm trying to load a .obj file from: C:\Users\MyUser\AppData\LocalLow\My Company\MyProduct\OBJ\Temp.obj

The model, and the related .mtl are loaded nicely, everything works, but I get an error:

HTTP/1.1 404 Not Found AsImpL.d__16:MoveNext() (at Assets/Plugins/AsImpL/Scripts/Loaders/LoaderObj.cs:631)

It looks like AsImpL wants to download it from URL but the string i pass is definitely not a URL.

Could you look into this?

gpvigano commented 5 years ago

I just tested the 001_Import_SimpleTest example with a full path like the one you wrote with no error (Path Settings|Root Path changed to Current Path in the inspector), using both Unity 2018.1 and Unity 2019.2.6 (just installed for this test). What version of Unity are you using?

KuraiAndras commented 5 years ago

2019.2.5, but this existed since around 2019.2.3

KuraiAndras commented 5 years ago

Ok, this is weird, now I put it in C:\asd\Temp.obj, Temp.mtl, and it does the same thing

KuraiAndras commented 5 years ago

Contents of the obj file: https://pastebin.com/YG5AnRK1 mtl: https://pastebin.com/xEcR3yus

gpvigano commented 5 years ago

Could you try this version of LoaderObj.cs in this branch and tell me if it works for you? Thanks.

gpvigano commented 5 years ago

I loaded your model without errors, but I had to put the mtl file in a /OBJ subfolder, because it is referenced as mtllib OBJ\Temp.mtl in the obj file. What about those changes?

KuraiAndras commented 5 years ago

No it does not, also, git diff shows that the changes to my current version is only in comments, no code is affected.

Also, it seems that i found the problem.

The obj file is created with IfcConvert http://ifcopenshell.org/ifcconvert.html, and the file begins with: mtllib OBJ\Temp.mtl Then this program outputs the mtl and obj files into the destination folder (OBJ) but references it like its one folder higher.

If I create a subfolder and put the .mtl in there Destination/OBJ(here is the .obj file)/OBJ/Temp.mtl then AsImpL finds it with not problem.

I think a solution for it would be to when LoaderObj looks for the mtl library, first look for the reference, then if it can't find it look in the same folder, and if it can't find it even there then throw a FileNotFound exception

KuraiAndras commented 5 years ago

I loaded your model without errors, but I had to put the mtl file in a /OBJ subfolder, because it is referenced as mtllib OBJ\Temp.mtl in the obj file. What about those changes?

Yes, i think it would work, but now because of the exception thrown nothing is loaded

gpvigano commented 5 years ago

Sorry, I forgot to push my changes on the repository, now it is updated, but I guess this does not fit with your problem. About your suggestion: that it is exacltly what should happen, even with your version: if the material library is not found (probably here you see the error) AsImpL looks in the same folder as the OBJ, look here. ...OK, I got you, maybe it's a better idea to avoid the trial/error approach.

KuraiAndras commented 5 years ago

I think the expected behabiour would be is to only throw an exception if AsImpL can not find a way to load, otherwise just log a warning that some files were not where it expected them

gpvigano commented 5 years ago

Are you sure that an exception is thrown? I just got the error printed by AsImpL... In my last commit (on master) I removed that error in case the mtl is found with the obj. What about it?

KuraiAndras commented 5 years ago

Now it works perfectly, thanks. Could you push this to master?

gpvigano commented 5 years ago

It was already there... Do you think we can close this issue?

KuraiAndras commented 5 years ago

Yes, thank you

gpvigano commented 5 years ago

You're welcome, happy to help you.