Open Naming-things-is-hard-btw opened 3 months ago
update: it looks like it imports mesh instances as importer mesh instances and it doesn't convert it back into a normal mesh via inportermesh::get_mesh()
update2: i will dig a bit more btw why does this importer use importer mesh instance class while gltf doesn't? edit: okay gltf also uses that.... but somehow converts it to a normal mesh instance hmmmm... maybe looping through the entire tree to convert importer mesh instance to a normal mesh instance might work? im fully open for any better ideas.
update3:
actually this can be as simple as adding in fbxdocument::generate_scene()
meshinst.mesh = importermesh.mesh.get_mesh();
in a recursive loop right???
Please edit your earlier comments instead of commenting several times in a row, it creates a lot of unnecessary notifications
Please edit your earlier comments instead of commenting several times in a row, it creates a lot of unnecessary notifications
thanks i will do that
My application could also load gltf with gdscript at runtime but if I just try the same with FBXDocument/FBXState I get this error:
E 0:00:28:0463 Viewer.gd:265 @ _load_gltf_or_fbx(): No loader found for resource: /home/andreas/Games/Assets/3d/kaykit/KayKit_Adventurers_1.0_SOURCE/Assets/fbx/rogue_texture.png (expected type: Texture2D) <C++-Fehler> Method/function failed. Returning: Ref
() <C++-Quelle> core/io/resource_loader.cpp:291 @ _load() Viewer.gd:265 @ _load_gltf_or_fbx() Viewer.gd:253 @ load_fbx() Viewer.gd:350 @ _on_files_dropped()
But the texture png exist at this path. I assume it's the same problem as it seems to be imported correct (e.g. animations are correctly read in) but the mesh is not available. My application is opensource. So in case the bug authors code isn't enough to analyze the problem I could link my code here.
My application could also load gltf with gdscript at runtime but if I just try the same with FBXDocument/FBXState I get this error:
E 0:00:28:0463 Viewer.gd:265 @ _load_gltf_or_fbx(): No loader found for resource: /home/andreas/Games/Assets/3d/kaykit/KayKit_Adventurers_1.0_SOURCE/Assets/fbx/rogue_texture.png (expected type: Texture2D) <C++-Fehler> Method/function failed. Returning: Ref() <C++-Quelle> core/io/resource_loader.cpp:291 @ _load() Viewer.gd:265 @ _load_gltf_or_fbx() Viewer.gd:253 @ load_fbx() Viewer.gd:350 @ _on_files_dropped()
But the texture png exist at this path. I assume it's the same problem as it seems to be imported correct (e.g. animations are correctly read in) but the mesh is not available. My application is opensource. So in case the bug authors code isn't enough to analyze the problem I could link my code here.
this seems off topic u should create a separate issue for that with a Minimal reproduction project (MRP) ill try to look into that too what version do you use i tried what u've said and gltf importer works flawlessly
edit: sorry i misunderstood ur comment ur issue is relevant to this topic
i was able to fix the issue [finally] but the "fix" is more of a flex tape rather than a real solution i added this at line 2144 in fbx_document.cpp file, almost exactly at the end of the generate_scene function
_convert_meshimporters_recursive(root);
return root;
}
void FBXDocument::_convert_meshimporters_recursive(Node *parent) {
TypedArray<Node> children = parent->get_children();
for (int i = 0; i < children.size(); i++) {
_convert_meshimporters_recursive(cast_to<Node>(children[i]));
ImporterMeshInstance3D *child = cast_to<ImporterMeshInstance3D>(children[i]);
if (child == nullptr) {
continue;
}
Ref<Mesh> imported_mesh = cast_to<ImporterMeshInstance3D>(child)->get_mesh()->get_mesh();
MeshInstance3D *meshinst = memnew(MeshInstance3D);
child->replace_by(meshinst);
meshinst->set_name(child->get_name());
meshinst->set_transform(child->get_transform());
meshinst->set_mesh(imported_mesh);
meshinst->set_skin(child->get_skin());
meshinst->set_skeleton_path(child->get_skeleton_path());
memfree(child);
}
}
and in fbx_document.hpp at line 68 i added
void _convert_meshimporters_recursive(Node *parent);
and now it looks good but i will test it more first i still have to duplicate transforms and other variables too btw i only know gdscript this is the first time i do anything in c++ so please if u can help i will appreciate it and still we need to find the real problem cus this might create more problems than it fixes idk
it works now all meshes are converted (the fix) all animations and transforms and materials imported (so it didn't break... cool) now i have no idea what to do hehe should i wait for review or pull or what exactly
Thanks, I created a new ticket in #96043
Tested versions
4.3
System information
manjaro linux godot 4.3-stable (this doesnt matter since this "bug" is on all platforms)
Issue description
the new ufbx importer for godot 4.3 cant import fbx files at runtime but gltf importer can
O. some notes:
O. after some tests: i found is that it actually (kind of) imports everything correctly but all meshes are importer mesh type with no data so.... maybe importer mesh doesn't work in-game??
im currently looking at the source code to check whats going on with that i have a small experience with c++ and i'd love to help (since this matters alot to me)
Steps to reproduce
just try the MRP i gave run the project and it wont show anything (even tho im trying to load fbx with fbxDocument just like gltfDocument)
Minimal reproduction project (MRP)
MRP.zip