kotlin-graphics / assimp

JVM Open Asset Import Library (Assimp)
Other
95 stars 28 forks source link

read from memory relative paths #17

Open Wasabi375 opened 6 years ago

Wasabi375 commented 6 years ago

MD3 sometimes uses relative paths to resolve shaders. It's also possible that other formats reference textures with relative paths. The MemoryIOSystem does not fully support them. It's not possible to use .. to reference the parent directory. There are 3 options to solve this:

  1. A simple workaround by adjusting the name of a buffer when passing it to the ioSystem eg. "somePath/../../../scripts/object.shader" as the name for the buffer. This works for now but I don't think it's a permanent solution.
  2. modify the ioSystem so that it can handle paths with ".." in them.
  3. Move from using String to java.nio.file.Path to qualify the buffers in MemoryIOSystem. This way resolving paths would be trivial but it would require a full implementation of Path, FileSystem and FileSystemProvider. This is a lot of effort and I'm not sure it's worth it.

I think option 2 is the best on. It should work in all cases. Option 3 is overkill as the user should not interact with the ioSystem themself.