If modifiers are used...
If the plane is only transformed, ie the object is only translated rotated or scaled then the object world times vertex coord will give the global location of the vertex.
ob.matrix_world * v.co for v in ob.data.vertices
If however a modifier is used, then this is a different kettle of fish, as these modifications will not show from the base mesh vertex locations.
I propose using a method similar to https://blender.stackexchange.com/a/57038/15543 Parent an empty in global space to each vertex, loop thru frames and export the empty locations. Remove the empties to clean up.
Here is an example method, prints the vertex locations of context object mesh for each 0.1 seconds elapsed from from animation start frame to end frame. (change the print to write to CSV file to suit. The print shows the time in seconds, frame (as a float), vertex index and coordinate)
Note the use of bpy.utils.time_from_frame
and time_to_frame
and scene.frame_set(f, subframe=f % 1)
to set the frame to match time, using just the frame or the time (it worries about all the nuances of fps for us.
import bpy
from bpy.utils import time_to_frame, time_from_frame
def export_vert_locs(context):
scene = context.scene
obj = context.object
me = obj.data
empties = []
# add empties to verts
for v in me.vertices:
empty = bpy.data.objects.new("Empty", None)
empty.parent = obj
empty.parent_type = 'VERTEX'
empty.parent_vertices = [v.index] * 3
scene.objects.link(empty)
empty.matrix_parent_inverse.identity()
empties.append((v.index, empty))
t = time_from_frame(scene.frame_start).total_seconds()
end = time_from_frame(scene.frame_end).total_seconds()
while t < end:
f = time_to_frame(t)
scene.frame_set(int(f), subframe=f % 1)
for index, empty in empties:
print("frame %3.1f" % f, "%4.2f secs" % t, "Vert %d location: " % index, empty.matrix_world.to_translation())
t += 0.1
# remove the empties
for i, empty in empties:
scene.objects.unlink(empty)
bpy.data.objects.remove(empty)
# test call
export_vert_locs(bpy.context)
Sample output, frame rate 24 fps, start frame 1. every 0.1 seconds is 2.4 frames.
frame 1.0 0.04 secs Vert 0 location: <Vector (-1.0000, -1.0000, 0.0000)>
frame 1.0 0.04 secs Vert 1 location: <Vector (1.0000, -1.0000, 0.0000)>
frame 1.0 0.04 secs Vert 2 location: <Vector (-1.0000, 1.0000, 0.0000)>
frame 1.0 0.04 secs Vert 3 location: <Vector (1.0000, 1.0000, 0.0000)>
frame 3.4 0.14 secs Vert 0 location: <Vector (-0.9997, -0.9998, 5.9995)>
frame 3.4 0.14 secs Vert 1 location: <Vector (1.0003, -0.9998, 5.9995)>
frame 3.4 0.14 secs Vert 2 location: <Vector (-0.9997, 1.0002, 5.9995)>
frame 3.4 0.14 secs Vert 3 location: <Vector (1.0003, 1.0002, 5.9995)>
frame 5.8 0.24 secs Vert 0 location: <Vector (-0.9868, -0.9893, 5.9774)>
frame 5.8 0.24 secs Vert 1 location: <Vector (1.0132, -0.9893, 5.9774)>
Alternatives to getting modified vert locations would require using ob_to_mesh()
each frame or bmesh.from_object(...)
to get the deformed locations.