0 votes
func _on_add_weight_pressed():
    #below 2 lines will be int values
    var weight_dimension = weight_value.text
    var input_dimension = input_value.text

    var surface_tool = SurfaceTool.new()
#add vertices, thus creating a line
    # this creates the mesh with all of the above vertex's and other attributes
    var mesh = Mesh.new()
    # this actually creates an object instance of the above mesh
    var mesh_inst = MeshInstance.new()
    mesh_inst.mesh = mesh


This code will successfully give me a line. If I try and use MeshDataTool to get those vertices in the same function with the below code.

var tool = MeshDataTool.new()
tool.create_from_surface(mesh_inst, 0)

the two lines that should print out the vertex count and what the vertices give me output:

(0, 0, 0)

I am not sure what I'm doing wrong. Is there a way to get the vertices that have been instantiated in the mesh_inst object? I'm ultimately trying to change those vertices given some input.

in Engine by (32 points)

1 Answer

0 votes

How about:
tool.create_from_surface(mesh_inst.mesh, 0)

You tried to create to create from the meshinstance but create_from_surface expects an ArrayMesh therefore use its attribute mesh.

by (3,352 points)

I still get the same output

No error messages in the output window?

What is the value of mesh_inst.get_surface_material_count ()

What is the value of mesh_inst.mesh.surface_get_array_len (0)

I am surprised that you get no error when you print get_vertex(0) because that should be out of range when the vertext count is 0.

Do you get an error when you try to print tool.get_vertex(1) ?

There is no error message in output window.

mesh_inst.get_surface_material_count() = 1

mesh_inst.mesh.surface_get_array_len(0) = 2

tool.get_vertex(1) does not give me an error. it gives me the same output as before, which is (0, 0, 0)

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.