I am trying to make a program to merge fbx models. Each model have multiple nodes. Some of the nodes have a specific name meaning that those are functioning as connection points for other models.
I already solved pretty much everything regarding the merge, except for the problem of textures. Mesh and material indexes has been updated, but when it come to textures, which are referenced by materials as file paths, I encountered a strange problem. To solve the problem of merging models with different full paths, textures cause a problem, since they are referenced with relative paths to the model file.
When loaded with the basic code below:
// Initialize the Assimp context
AssimpContext importer = new AssimpContext();
// Load the model with desired post-processing flags
Scene model = importer.ImportFile(filePath, PostProcessPreset.TargetRealTimeMaximumQuality |
PostProcessSteps.Triangulate |
PostProcessSteps.FlipUVs |
PostProcessSteps.EmbedTextures |
PostProcessSteps.GlobalScale |
PostProcessSteps.ValidateDataStructure);
The paths stored by the material looks very strange. For example a relative path of the file "Normal.jpg" in the same folder as the fbx file itself gets stored as "*1\0mal.jpg", another one in a .fbm subfolder named "GPV-2.fbm\BaseColor.jpg" as "*0\0-2 BG.fbm\BaseColor.jpg". To me it looks like the first 3 character gets overwritten at some point during import.
I use the Assimp.NET 5.0.0-beta1 package.
Has someone seen anything like this before? What is the reason the paths look like this and how can I solve it?
Since Assimp.NET has no problem loading the textures I guess the paths are good during the import. Perhaps I could somehow get the fullpath out of assimp?
Path.Combine Does not work. I tried to manually cut the pieces, but the missing characters still cause a problem, and I would try file search if nothing else would work.
I tried to look into Assimp code, but couldn't find exactly how it imports.
I also tried to discuss it with ChatGPT, but couldn't solve it either, neither could it give me pointers where to look.