#Using glTF models as meshes?
9 messages · Page 1 of 1 (latest)
ah I think I need to go into the imported resource and save the mesh
can we automate this? (without it becoming its own topic)
Depends what your workflow is; I import the blend file directly into godot and instantiate it as a scene within my game
So I'd say it is about as automated as I can imagine right now
I believe the flow works the same way for a gltf file (it can be used directly as a subscene; that's how the raw .blend file import is actually implemented)
During import you can also set animation paths and mesh paths and material paths
Which if set will save the resources in the place; that's another way of automatically extracting the thing (but you do have to interact with the import dialog to tell it you want this)
Yeah this is what I was referring to, but this is quite tedious if I have to do it for many glTF files
So I think what I'm looking for is a postimport script that can do this for me
This is what I'm working on currently and I'm currently figuring out how Godot deals with file paths (I know they're strings)
@tool # Needed so it runs in editor.
extends EditorScenePostImport
# This sample changes all node names.
# Called right after the scene is imported and gets the root node.
func _post_import(scene):
# Change all node names to "modified_[oldnodename]"
iterate(scene)
return scene # Remember to return the imported scene
func iterate(node: Node):
if node != null:
for child in node.get_children():
if child.get_class() != "MeshInstance3D":
#var mesh_instance: MeshInstance3D = child
#mesh_instance.mesh
continue
ResourceSaver.save(child.mesh, node.scene_file_path)
print(child.get_class())
I have exported glTF files from Blender and want to use them in my MeshInstance3D node and also feed them into a mesh array variable of a script but they're of course imported as scenes. How do I go about doing this conversion or am I thinking about it wrong?