|
import bpy
import bmesh
from time import ctime
def bm_cor (mworld,bm):
x, y, z = 0.0, 0.0, 0.0
for v in bm.verts:
v_x, v_y, v_z = mworld @ v.co
x += v_x
y += v_y
z += v_z
num = len(bm.verts)
x /= num
y /= num
z /= num
return x, y, z
print("Start body_loc_wr at ",ctime())
context = bpy.context
tR_ob = bpy.data.objects['toe.R.G']
tR_mworld = tR_ob.matrix_world
tL_ob = bpy.data.objects['toe.L.G']
tL_mworld = tL_ob.matrix_world
for frame in range(int(footN),int(footE)+1):
print("KK10:",frame,tstate)
bpy.data.scenes['Scene'].frame_set(frame)
context.view_layer.update()
depsgraph = context.evaluated_depsgraph_get()
tR_bm = bmesh.new()
tR_bm.from_object(tR_ob, depsgraph)
x, y, z = 0.0, 0.0, 0.0
for v in tR_bm.verts:
v_x, v_y, v_z = tR_mworld @ v.co
x += v_x
y += v_y
z += v_z
num_verts = len(tR_bm.verts)
x /= num_verts
y /= num_verts
z /= num_verts
x1,y1,z1=bm_cor(tR_mworld,tR_bm)
tR_bm.free()
xR6,yR6,zR6=x,y,z
tL_bm = bmesh.new()
tL_bm.from_object(tL_ob, depsgraph)
x, y, z = 0.0, 0.0, 0.0
for v in tL_bm.verts:
v_x, v_y, v_z = tL_mworld @ v.co
x += v_x
y += v_y
z += v_z
num_verts = len(tL_bm.verts)
x /= num_verts
y /= num_verts
z /= num_verts
x1,y1,z1=bm_cor(tL_mworld,tL_bm)
tL_bm.free()
|
|