fix: uptade the file convert2bvh.py for the for change of Blender API
This commit is contained in:
parent
b61bf7148d
commit
71f586c62a
@ -44,14 +44,14 @@ def init_scene(scene, params, gender='male', angle=0):
|
|||||||
|
|
||||||
# delete the default cube (which held the material)
|
# delete the default cube (which held the material)
|
||||||
bpy.ops.object.select_all(action='DESELECT')
|
bpy.ops.object.select_all(action='DESELECT')
|
||||||
bpy.data.objects['Cube'].select = True
|
bpy.data.objects['Cube'].select_set(True)
|
||||||
bpy.ops.object.delete(use_global=False)
|
bpy.ops.object.delete(use_global=False)
|
||||||
|
|
||||||
# set camera properties and initial position
|
# set camera properties and initial position
|
||||||
bpy.ops.object.select_all(action='DESELECT')
|
bpy.ops.object.select_all(action='DESELECT')
|
||||||
cam_ob = bpy.data.objects['Camera']
|
cam_ob = bpy.data.objects['Camera']
|
||||||
scn = bpy.context.scene
|
scn = bpy.context.scene
|
||||||
scn.objects.active = cam_ob
|
bpy.context.view_layer.objects.active = cam_ob
|
||||||
|
|
||||||
th = deg2rad(angle)
|
th = deg2rad(angle)
|
||||||
# cam_ob = init_location(cam_ob, th, params['camera_distance'])
|
# cam_ob = init_location(cam_ob, th, params['camera_distance'])
|
||||||
@ -70,11 +70,11 @@ def init_scene(scene, params, gender='male', angle=0):
|
|||||||
# setup an empty object in the center which will be the parent of the Camera
|
# setup an empty object in the center which will be the parent of the Camera
|
||||||
# this allows to easily rotate an object around the origin
|
# this allows to easily rotate an object around the origin
|
||||||
scn.cycles.film_transparent = True
|
scn.cycles.film_transparent = True
|
||||||
scn.render.layers["RenderLayer"].use_pass_vector = True
|
bpy.context.view_layer.use_pass_vector = True
|
||||||
scn.render.layers["RenderLayer"].use_pass_normal = True
|
bpy.context.view_layer.use_pass_normal = True
|
||||||
scene.render.layers['RenderLayer'].use_pass_emit = True
|
bpy.context.view_layer.use_pass_emit = True
|
||||||
scene.render.layers['RenderLayer'].use_pass_emit = True
|
bpy.context.view_layer.use_pass_material_index = True
|
||||||
scene.render.layers['RenderLayer'].use_pass_material_index = True
|
|
||||||
|
|
||||||
# set render size
|
# set render size
|
||||||
# scn.render.resolution_x = params['resy']
|
# scn.render.resolution_x = params['resy']
|
||||||
@ -91,8 +91,8 @@ def init_scene(scene, params, gender='male', angle=0):
|
|||||||
|
|
||||||
def setState0():
|
def setState0():
|
||||||
for ob in bpy.data.objects.values():
|
for ob in bpy.data.objects.values():
|
||||||
ob.select = False
|
ob.select_set(False)
|
||||||
bpy.context.scene.objects.active = None
|
bpy.context.view_layer.objects.active = None
|
||||||
|
|
||||||
def Rodrigues(rotvec):
|
def Rodrigues(rotvec):
|
||||||
theta = np.linalg.norm(rotvec)
|
theta = np.linalg.norm(rotvec)
|
||||||
@ -198,15 +198,15 @@ def main(params):
|
|||||||
|
|
||||||
ob, obname, arm_ob, cam_ob = init_scene(scene, params, params['gender'])
|
ob, obname, arm_ob, cam_ob = init_scene(scene, params, params['gender'])
|
||||||
setState0()
|
setState0()
|
||||||
ob.select = True
|
ob.select_set(True)
|
||||||
bpy.context.scene.objects.active = ob
|
bpy.context.view_layer.objects.active = ob
|
||||||
|
|
||||||
# unblocking both the pose and the blendshape limits
|
# unblocking both the pose and the blendshape limits
|
||||||
for k in ob.data.shape_keys.key_blocks.keys():
|
for k in ob.data.shape_keys.key_blocks.keys():
|
||||||
bpy.data.shape_keys["Key"].key_blocks[k].slider_min = -10
|
bpy.data.shape_keys["Key"].key_blocks[k].slider_min = -10
|
||||||
bpy.data.shape_keys["Key"].key_blocks[k].slider_max = 10
|
bpy.data.shape_keys["Key"].key_blocks[k].slider_max = 10
|
||||||
|
|
||||||
scene.objects.active = arm_ob
|
bpy.context.view_layer.objects.active = arm_ob
|
||||||
|
|
||||||
motions = load_smpl_params(params['path'])
|
motions = load_smpl_params(params['path'])
|
||||||
for pid, data in motions.items():
|
for pid, data in motions.items():
|
||||||
@ -224,7 +224,7 @@ def main(params):
|
|||||||
pose = data['poses'][frame]
|
pose = data['poses'][frame]
|
||||||
apply_trans_pose_shape(Vector(trans), pose, shape, ob,
|
apply_trans_pose_shape(Vector(trans), pose, shape, ob,
|
||||||
arm_ob, obname, scene, cam_ob, frame)
|
arm_ob, obname, scene, cam_ob, frame)
|
||||||
scene.update()
|
bpy.context.view_layer.update()
|
||||||
bpy.ops.export_anim.bvh(filepath=join(params['out'], '{}.bvh'.format(pid)), frame_start=0, frame_end=nFrames-1)
|
bpy.ops.export_anim.bvh(filepath=join(params['out'], '{}.bvh'.format(pid)), frame_start=0, frame_end=nFrames-1)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user