How can I create a mesh from a .obj file? Not a MeshInstance, but a Mesh? I can do it in the editor GUI, but how could it be done in code? Mesh doesnt seem to have a load() function like MeshInstance...
How to create a Mesh in code?
I guess then by "create" you mean load right? You basically want to swap meshes?
Well the editor needs to load the mesh. I don't believe you can load assets like OBJ files at run-time with GDScript. But you can load several OBJ files in the editor, which will give you MeshInstances, then access the Mesh with the mesh property on that node. From there you can do whatever you want.
When I wrote code to cut meshes in half I found that MeshInstance has a function get_mesh()
and set_mesh(mesh)
. So if it's loaded somewhere you can update it.
Yes, those are accessor functions. You can also do:
var the_mesh = my_mesh_node.mesh
6 months later
Megalomaniak added the Godot Help tag .