Forum

Retrieve vertex positions within animation

15 June 2018 14:38
Hi,
I have an animation which is baked with "bake vertex animation" then in javascript i would like to calculate triangle area for each triangle in every animation frame. So far i managed to get vertex positions by:

var parray = m_geom.extract_vertex_array(object_A,"Material",'a_position',m_scenes.DATA_ID_ALL);

but it returns same positions even if animation plays.
So my question is how to get position of vertexes for each frame. This information must be stored somewhere.
15 June 2018 21:47
I tried extract_vertex_array() and I could not get updated (frame-by-frame) values with a vertex animation, but it does work with a shape key animation, so I guess this function is meant for shape keys.

However, you can extract the data from a vertex animation directly in Blender, via Python:
import bpy

my_object_name = "Plane"



obj = bpy.data.objects[my_object_name]
scene = bpy.context.scene
obj_data = obj.to_mesh(scene, True, 'PREVIEW')
verts = [v.co for v in obj_data.vertices]
bpy.data.meshes.remove(obj_data)



print (verts)
This will print out the vertex coords of the current frame (set in the Timeline).
 
Please register or log in to leave a reply.