vpenades / SharpGLTF

glTF reader and writer for .NET Standard
MIT License
457 stars 72 forks source link

Relative paths not allowed when loading files? #136

Open deccer opened 2 years ago

deccer commented 2 years ago

Hi,

I have been using relative paths whenever I write something, because it feels very natural and nobody is interfering with any path so far, but SharpGLTF tries to be smart here for no reason. Unless I am wrong.

After finding out how to load an actual file via

var modelRoot = ModelRoot.Load(fileName, readSettings);

It yelled at me that it can't find the file specified. In my example the file is sitting in Models/BarberShopChair_01_1k.gltf relative to my .exe (and i confirmed its there, Assimp also has no trouble finding it)

But passing that as fileName yielded the following exception

Could not find a part of the path 'P:\Private\Code\Games\SpaceConflict\src\SpaceConflict\bin\Debug\Models\Models\BarberShopChair_01_1k.gltf'.

It adds another Models layer into my path.

readSettings also does not reveal any mode or option I can set to whatever make it work as is.

Please advise.

vpenades commented 2 years ago

Indeed, this is a bug.

Full paths are supported, as loading files directly from the current directory, but it seems relative path make the library crash.

Looking at it.

deccer commented 2 years ago

Full paths cause some other trouble mentioned in #137 :)

If you need to test something/or have somebody test stuff, feel free to boop me.

deccer commented 1 year ago

Also apologies for the late reply to this issue.

Indeed relative paths don't work well at all with this library, and for now i simply generate an absolute filepath using Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Relative/Path/Here") which works just fine.

Technically I am not really bothered anymore by this "flaw" but let you decide whether you want to take a look once a gain, or close it for good.