Godot Version
v4.4.1
Question
I’d like to work with the vertices and faces of an existing BoxMesh
, so I’m using MeshDataTool
. I read in the mesh with MeshDataTool.create_from_mesh
, but after doing so, the MDT says it does not have any vertices. I’ve read through the tutorial and related documentation as much as I can, but I can’t see where I’m going wrong.
Example
Here’s a reproducible example. Create a new scene with Node3D
as the root, add a MeshInstance3D
, and to that mesh instance add a BoxMesh
. Attach the following script to the root node:
extends Node3D
@onready var mesh_in = $MeshInstance3D
func _ready() -> void:
var mesh: Mesh = mesh_in.mesh
print(mesh.get_surface_count()) # prints 1
print(len(mesh.get_faces())) # prints 36
var mdt = MeshDataTool.new()
mdt.create_from_surface(mesh, 0)
print(mdt.get_vertex_count()) # prints 0
Here’s a screenshot of the setup (with terminal output) and the script.
Am I missing something obvious? Or something not obvious? The faces of BoxMesh
are tris, right? Thanks in advance.