0 votes

I need to retrieve a list of all of the vertices which are transformed by any given blend shape. To do this, I'm applying the blend shapes and keeping track of which vertices changed. However, it seems like global_transform.xform() just returns a vertex position from the base mesh, without taking blend shapes into account. Here's a simplified version of my code in case I'm doing something wrong:

func _ready():
    var MDT = MeshDataTool.new()
    MDT.create_from_surface(mesh, 0)
    var old_verts = []
    var new_verts = []
    for v in MDT.get_vertex_count():
        old_verts.append(global_transform.xform(MDT.get_vertex(v)))
    set_blend_shape("Blend Shape 1", 1) # this function just sets a blend shape's value
    for v in MDT.get_vertex_count():
        new_verts.append(global_transform.xform(MDT.get_vertex(v)))
    for v in old_verts.size():
        if old_verts[v] != new_verts[v]:
            print("!") # this never happens, so old_verts must be identical to new_verts
Godot version 3.3.stable
in Engine by (12 points)

1 Answer

0 votes

You need to reference the mesh in question. Try mesh.set("blend_shapes/blend_shape_1", 1) instead of set_blend_shape. Also, remove the spaces in the name, that's asking for trouble.

Let me know if it works.

by (795 points)
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 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 webmaster@godotengine.org with your username.