I built a human model in Blender first and then loaded a bvh file into ths model. Now I have 200 frames which show a running scene in Blender. I can iterate every frame. I want to get all the vertex coordinates from the 200 frames. I did it with the following code segment, but, want is to get the vertex coordinates of the original human model.
Can someone help me?
for frame in range(scene.frame_start, scene.frame_end):
scene.frame_set(frame)
scene.update()
bpy.ops.object.mode_set(mode='OBJECT',toggle = True)
obj = bpy.context.active_object
loops = len(obj.data.loops)
verts = len(obj.data.vertices)
mat = bpy.context.active_object.matrix_world
vertex = [mat * verts.co for verts in obj.data.vertices]
the_file = "pointCloud_f" + str('{:03d}'.format(scene.frame_current)) + ".ply"
print("loading "+the_path + the_file+'\n')
with open(the_path + the_file, 'w') as wFile:
wFile.write(headerOfPLY)
count = 0
for vcol in obj.data.vertex_colors:
colors={}
for i in range(loops):
v=obj.data.loops[i].vertex_index
c = vcol.data[i].color
colors[v]=c
for j in range(len(vertex)):
wFile.write('%f %f %f %d %d %d \n' %(vertex[j].x,vertex[j].y,vertex[j].z,int(colors[j].r*255),int(colors[j].g*255),int(colors[j].b*255)))
print("writing completed!")
wFile.close()
return {'FINISHED'}