![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Ben Nicholl |
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()
surface_tool.begin(Mesh.PRIMITIVE_LINES)
#add vertices, thus creating a line
surface_tool.add_vertex(Vector3(0,0,0))
surface_tool.add_vertex(Vector3(weight_dimension,0,1))
# this creates the mesh with all of the above vertex's and other attributes
var mesh = Mesh.new()
surface_tool.commit(mesh)
# this actually creates an object instance of the above mesh
var mesh_inst = MeshInstance.new()
mesh_inst.mesh = mesh
add_child(mesh_inst)
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)
print(tool.get_vertex_count())
print(tool.get_vertex(0))
the two lines that should print out the vertex count and what the vertices give me output:
0
(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.