Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <mail@jlucke.com>2018-10-02 18:33:55 +0300
committerJacques Lucke <mail@jlucke.com>2018-10-02 18:33:55 +0300
commit7bc4655e7b000bfe49336257edcb3a934d01650a (patch)
tree341dec4385bb5bd4c3024dcc47f0cb51ce45ea71 /io_anim_bvh
parent043b5bc972d9faadd3027b2c88656260860bc119 (diff)
port BVH format addon to Blender 2.8
Reviewers: brecht Differential Revision: https://developer.blender.org/D3757
Diffstat (limited to 'io_anim_bvh')
-rw-r--r--io_anim_bvh/__init__.py43
-rw-r--r--io_anim_bvh/export_bvh.py8
-rw-r--r--io_anim_bvh/import_bvh.py24
3 files changed, 41 insertions, 34 deletions
diff --git a/io_anim_bvh/__init__.py b/io_anim_bvh/__init__.py
index c9b5dfdf..01484af9 100644
--- a/io_anim_bvh/__init__.py
+++ b/io_anim_bvh/__init__.py
@@ -22,7 +22,7 @@ bl_info = {
"name": "BioVision Motion Capture (BVH) format",
"author": "Campbell Barton",
"version": (1, 0, 0),
- "blender": (2, 74, 0),
+ "blender": (2, 80, 0),
"location": "File > Import-Export",
"description": "Import-Export BVH from armature objects",
"warning": "",
@@ -62,9 +62,9 @@ class ImportBVH(bpy.types.Operator, ImportHelper):
bl_options = {'REGISTER', 'UNDO'}
filename_ext = ".bvh"
- filter_glob = StringProperty(default="*.bvh", options={'HIDDEN'})
+ filter_glob: StringProperty(default="*.bvh", options={'HIDDEN'})
- target = EnumProperty(items=(
+ target: EnumProperty(items=(
('ARMATURE', "Armature", ""),
('OBJECT', "Object", ""),
),
@@ -72,41 +72,41 @@ class ImportBVH(bpy.types.Operator, ImportHelper):
description="Import target type",
default='ARMATURE')
- global_scale = FloatProperty(
+ global_scale: FloatProperty(
name="Scale",
description="Scale the BVH by this value",
min=0.0001, max=1000000.0,
soft_min=0.001, soft_max=100.0,
default=1.0,
)
- frame_start = IntProperty(
+ frame_start: IntProperty(
name="Start Frame",
description="Starting frame for the animation",
default=1,
)
- use_fps_scale = BoolProperty(
+ use_fps_scale: BoolProperty(
name="Scale FPS",
description=("Scale the framerate from the BVH to the current scenes, "
"otherwise each BVH frame maps directly to a Blender frame"),
default=False,
)
- update_scene_fps = BoolProperty(
+ update_scene_fps: BoolProperty(
name="Update Scene FPS",
description="Set the scene framerate to that of the BVH file (note that this "
"nullifies the 'Scale FPS' option, as the scale will be 1:1)",
default=False
)
- update_scene_duration = BoolProperty(
+ update_scene_duration: BoolProperty(
name="Update Scene Duration",
description="Extend the scene's duration to the BVH duration (never shortens the scene)",
default=False,
)
- use_cyclic = BoolProperty(
+ use_cyclic: BoolProperty(
name="Loop",
description="Loop the animation playback",
default=False,
)
- rotate_mode = EnumProperty(
+ rotate_mode: EnumProperty(
name="Rotation",
description="Rotation conversion",
items=(('QUATERNION', "Quaternion",
@@ -145,29 +145,29 @@ class ExportBVH(bpy.types.Operator, ExportHelper):
bl_label = "Export BVH"
filename_ext = ".bvh"
- filter_glob = StringProperty(
+ filter_glob: StringProperty(
default="*.bvh",
options={'HIDDEN'},
)
- global_scale = FloatProperty(
+ global_scale: FloatProperty(
name="Scale",
description="Scale the BVH by this value",
min=0.0001, max=1000000.0,
soft_min=0.001, soft_max=100.0,
default=1.0,
)
- frame_start = IntProperty(
+ frame_start: IntProperty(
name="Start Frame",
description="Starting frame to export",
default=0,
)
- frame_end = IntProperty(
+ frame_end: IntProperty(
name="End Frame",
description="End frame to export",
default=0,
)
- rotate_mode = EnumProperty(
+ rotate_mode: EnumProperty(
name="Rotation",
description="Rotation conversion",
items=(('NATIVE', "Euler (Native)",
@@ -181,7 +181,7 @@ class ExportBVH(bpy.types.Operator, ExportHelper):
),
default='NATIVE',
)
- root_transform_only = BoolProperty(
+ root_transform_only: BoolProperty(
name="Root Translation Only",
description="Only write out translation channels for the root bone",
default=False,
@@ -217,15 +217,22 @@ def menu_func_export(self, context):
self.layout.operator(ExportBVH.bl_idname, text="Motion Capture (.bvh)")
+classes = [
+ ImportBVH,
+ ExportBVH
+]
+
def register():
- bpy.utils.register_module(__name__)
+ for cls in classes:
+ bpy.utils.register_class(cls)
bpy.types.TOPBAR_MT_file_import.append(menu_func_import)
bpy.types.TOPBAR_MT_file_export.append(menu_func_export)
def unregister():
- bpy.utils.unregister_module(__name__)
+ for cls in classes:
+ bpy.utils.unregister_class(cls)
bpy.types.TOPBAR_MT_file_import.remove(menu_func_import)
bpy.types.TOPBAR_MT_file_export.remove(menu_func_export)
diff --git a/io_anim_bvh/export_bvh.py b/io_anim_bvh/export_bvh.py
index ed80ed59..503ffa68 100644
--- a/io_anim_bvh/export_bvh.py
+++ b/io_anim_bvh/export_bvh.py
@@ -245,12 +245,12 @@ def write_armature(context,
itrans = Matrix.Translation(-dbone.rest_bone.head_local)
if dbone.parent:
- mat_final = dbone.parent.rest_arm_mat * dbone.parent.pose_imat * dbone.pose_mat * dbone.rest_arm_imat
- mat_final = itrans * mat_final * trans
+ mat_final = dbone.parent.rest_arm_mat @ dbone.parent.pose_imat @ dbone.pose_mat @ dbone.rest_arm_imat
+ mat_final = itrans @ mat_final @ trans
loc = mat_final.to_translation() + (dbone.rest_bone.head_local - dbone.parent.rest_bone.head_local)
else:
- mat_final = dbone.pose_mat * dbone.rest_arm_imat
- mat_final = itrans * mat_final * trans
+ mat_final = dbone.pose_mat @ dbone.rest_arm_imat
+ mat_final = itrans @ mat_final @ trans
loc = mat_final.to_translation() + dbone.rest_bone.head
# keep eulers compatible, no jumping on interpolation.
diff --git a/io_anim_bvh/import_bvh.py b/io_anim_bvh/import_bvh.py
index e7cbd779..2eca71da 100644
--- a/io_anim_bvh/import_bvh.py
+++ b/io_anim_bvh/import_bvh.py
@@ -308,15 +308,15 @@ def bvh_node_dict2objects(context, bvh_name, bvh_nodes, rotate_mode='NATIVE', fr
scene = context.scene
for obj in scene.objects:
- obj.select = False
+ obj.select_set("DESELECT")
objects = []
def add_ob(name):
obj = bpy.data.objects.new(name, None)
- scene.objects.link(obj)
+ context.collection.objects.link(obj)
objects.append(obj)
- obj.select = True
+ obj.select_set("SELECT")
# nicer drawing.
obj.empty_display_type = 'CUBE'
@@ -381,15 +381,15 @@ def bvh_node_dict2armature(context,
# Add the new armature,
scene = context.scene
for obj in scene.objects:
- obj.select = False
+ obj.select_set("DESELECT")
arm_data = bpy.data.armatures.new(bvh_name)
arm_ob = bpy.data.objects.new(bvh_name, arm_data)
- scene.objects.link(arm_ob)
+ context.collection.objects.link(arm_ob)
- arm_ob.select = True
- scene.objects.active = arm_ob
+ arm_ob.select_set("SELECT")
+ context.view_layer.objects.active = arm_ob
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
bpy.ops.object.mode_set(mode='EDIT', toggle=False)
@@ -538,14 +538,14 @@ def bvh_node_dict2armature(context,
bone_translate_matrix = Matrix.Translation(
Vector(bvh_loc) - bvh_node.rest_head_local)
- location[frame_i] = (bone_rest_matrix_inv *
+ location[frame_i] = (bone_rest_matrix_inv @
bone_translate_matrix).to_translation()
# For each location x, y, z.
for axis_i in range(3):
curve = action.fcurves.new(data_path=data_path, index=axis_i)
keyframe_points = curve.keyframe_points
- keyframe_points.add(num_frame)
+ keyframe_points.add(count=num_frame)
for frame_i in range(num_frame):
keyframe_points[frame_i].co = \
@@ -572,8 +572,8 @@ def bvh_node_dict2armature(context,
# note that the rot_order_str is reversed.
euler = Euler(bvh_rot, bvh_node.rot_order_str[::-1])
bone_rotation_matrix = euler.to_matrix().to_4x4()
- bone_rotation_matrix = (bone_rest_matrix_inv *
- bone_rotation_matrix *
+ bone_rotation_matrix = (bone_rest_matrix_inv @
+ bone_rotation_matrix @
bone_rest_matrix)
if 4 == len(rotate[frame_i]):
@@ -587,7 +587,7 @@ def bvh_node_dict2armature(context,
for axis_i in range(len(rotate[0])):
curve = action.fcurves.new(data_path=data_path, index=axis_i)
keyframe_points = curve.keyframe_points
- curve.keyframe_points.add(num_frame)
+ curve.keyframe_points.add(count=num_frame)
for frame_i in range(0, num_frame):
keyframe_points[frame_i].co = \