Replies: 2 comments 3 replies
-
The documentation is here but it can certainly be improved. @kbayes can you address the questions and perhaps improve the documentation if required? |
Beta Was this translation helpful? Give feedback.
-
The first minor issue is a quick fix, so I'll just go ahead and do that. VFS was created for some Google-internal reasons where the OS filesystem might not be accessible. However, you can see another use case here where we load assets from a Python dictionary. Let me get back to you on the exact intended behavior of the VFS related to your question. I'll also flush out the docs more while I'm at it. Going forward, I created resource providers, which is a replacement for VFS (in fact VFS is retrofitted to use resource providers). You can try writing a custom provider if that fits your needs. |
Beta Was this translation helpful? Give feedback.
-
I previously have been using VFS to load models at runtime that were supplied as strings (similar as in this discussion #24 (comment)). Since these strings have no path they reside in, every resource within these model strings was supplied with absolute paths and loading did work without errors.
Now I experimented on using VFS with actual model (xml) files and I encountered some issues:
the first issue was that
mj_addFileVFS
expects the directory to be supplied with a trailing filesystem separator, while, for instanceboost::filesystem::path::parent_path()
, removes trailing slashes on linux. I think this requirement should either be stated somewhere in the documentation or the function should be able to handle paths where it is missing.But that is not my main concern, I also found that storing a model that contains an
include
tag and/or meshes defined with relative paths does not throw an error. However, when you try to load such a model, these relative resources cannot be found.As an example you can try running the following code with any menagerie model:
In case of the panda model you'll get the following error message:
So for this to work (without manually adding all required resources) the
mj_addFileVFS
function should parse all included resources and either add them or replace relative paths with absolute ones.But the latter option imho somehow defeats the purpose of using VFS in the first place.
The former option begs the question if and how filestructures should be realized within the VFS.
Resource names such as "link0.stl" seem way too generic. A way to avoid filename clashes if more than one model is cached in the VFS would be to prepend the root filename and replace filesystem separators with e.g. underscores to get something like "panda.xml_assets_link0.stl".
At least that was my train of thought until I noticed that from the brief description in the documentation it is not apparent if VFS is even meant to be used in this way. That's why I'm suggesting to clarify what VFS should and shouldn't be used for and maybe come up with some ideas on how to handle this above mentioned case.
tl;dr:
This basically boils down to these questions:
Beta Was this translation helpful? Give feedback.
All reactions