[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3924] contrib/py/scripts/addons/ io_scene_ms3d: fix: import - keyframe location

Alexander Nussbaumer alpha-beta-release at gmx.net
Sat Nov 3 22:16:48 CET 2012


Revision: 3924
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3924
Author:   beta-tester
Date:     2012-11-03 21:16:46 +0000 (Sat, 03 Nov 2012)
Log Message:
-----------
fix: import - keyframe location

Modified Paths:
--------------
    contrib/py/scripts/addons/io_scene_ms3d/__init__.py
    contrib/py/scripts/addons/io_scene_ms3d/ms3d_import.py

Modified: contrib/py/scripts/addons/io_scene_ms3d/__init__.py
===================================================================
--- contrib/py/scripts/addons/io_scene_ms3d/__init__.py	2012-11-03 19:38:28 UTC (rev 3923)
+++ contrib/py/scripts/addons/io_scene_ms3d/__init__.py	2012-11-03 21:16:46 UTC (rev 3924)
@@ -23,10 +23,10 @@
         'description': "Import / Export MilkShape3D MS3D files"\
                 " (conform with v1.8.4)",
         'author': "Alexander Nussbaumer",
-        'version': (0, 4, 8, 0),
+        'version': (0, 4, 8, 1),
         'blender': (2, 6, 3, 0),
         'location': "File > Import & File > Export",
-        'warning': "[2012-11-03] exporter working, but is incomplete",
+        'warning': "[2012-11-03] exporter is working, but is incomplete",
         'wiki_url': "http://wiki.blender.org/index.php/Extensions:2.6/Py/"\
                 "Scripts/Import-Export/MilkShape3D_MS3D",
         'tracker_url': "http://projects.blender.org/tracker/index.php"\

Modified: contrib/py/scripts/addons/io_scene_ms3d/ms3d_import.py
===================================================================
--- contrib/py/scripts/addons/io_scene_ms3d/ms3d_import.py	2012-11-03 19:38:28 UTC (rev 3923)
+++ contrib/py/scripts/addons/io_scene_ms3d/ms3d_import.py	2012-11-03 21:16:46 UTC (rev 3924)
@@ -755,14 +755,13 @@
         blender_armature_object.animation_data.action = blender_action
 
         ##########################
-        # this part is incomplete ! (some animations are not correct)
+        # transition between keys may be incorrect
         for ms3d_joint_name, ms3d_joint  in ms3d_joint_by_name.items():
             blender_pose_bone = blender_armature_object.pose.bones.get(
                     ms3d_joint.blender_bone_name)
             if blender_pose_bone is None:
+                print("#DEBUG: missing bone: {}".format(ms3d_joint.blender_bone_name))
                 continue
-            ms3d_joint_local_matrix = ms3d_joint.__matrix_local
-            ms3d_joint_global_matrix = ms3d_joint.__matrix_global
 
             data_path = blender_pose_bone.path_from_id('location')
             fcurve_location_x = blender_action.fcurves.new(data_path, index=0)
@@ -773,29 +772,40 @@
                 matrix_local = Matrix.Translation(
                         Vector(translation_key_frames.position))
                 v = (matrix_local) * Vector()
-                fcurve_location_x.keyframe_points.insert(frame, v[0])
+                fcurve_location_x.keyframe_points.insert(frame, -v[0])
                 fcurve_location_y.keyframe_points.insert(frame, v[2])
                 fcurve_location_z.keyframe_points.insert(frame, v[1])
 
-            blender_pose_bone.rotation_mode = 'QUATERNION'
-            data_path = blender_pose_bone.path_from_id("rotation_quaternion")
-            fcurve_rotation_w = blender_action.fcurves.new(data_path, index=0)
-            fcurve_rotation_x = blender_action.fcurves.new(data_path, index=1)
-            fcurve_rotation_y = blender_action.fcurves.new(data_path, index=2)
-            fcurve_rotation_z = blender_action.fcurves.new(data_path, index=3)
-            for rotation_key_frames in ms3d_joint.rotation_key_frames:
-                frame = (rotation_key_frames.time * ms3d_model.animation_fps)
-                matrix_local_rot = (
-                        Matrix.Rotation(rotation_key_frames.rotation[2], 4, 'Y')
-                        * Matrix.Rotation(rotation_key_frames.rotation[1], 4, 'Z')
-                        ) * Matrix.Rotation(-rotation_key_frames.rotation[0], 4, 'X')
+            if True:
+                blender_pose_bone.rotation_mode = 'QUATERNION'
+                data_path = blender_pose_bone.path_from_id("rotation_quaternion")
+                fcurve_rotation_w = blender_action.fcurves.new(data_path, index=0)
+                fcurve_rotation_x = blender_action.fcurves.new(data_path, index=1)
+                fcurve_rotation_y = blender_action.fcurves.new(data_path, index=2)
+                fcurve_rotation_z = blender_action.fcurves.new(data_path, index=3)
+                for rotation_key_frames in ms3d_joint.rotation_key_frames:
+                    frame = (rotation_key_frames.time * ms3d_model.animation_fps)
+                    matrix_local_rot = (
+                            Matrix.Rotation(rotation_key_frames.rotation[2], 4, 'Y')
+                            * Matrix.Rotation(rotation_key_frames.rotation[1], 4, 'Z')
+                            ) * Matrix.Rotation(-rotation_key_frames.rotation[0], 4, 'X')
+                    q = (matrix_local_rot).to_quaternion()
+                    fcurve_rotation_w.keyframe_points.insert(frame, q.w)
+                    fcurve_rotation_x.keyframe_points.insert(frame, q.x)
+                    fcurve_rotation_y.keyframe_points.insert(frame, q.y)
+                    fcurve_rotation_z.keyframe_points.insert(frame, q.z)
+            else:
+                blender_pose_bone.rotation_mode = 'XZY'
+                data_path = blender_pose_bone.path_from_id("rotation_euler")
+                fcurve_rotation_x = blender_action.fcurves.new(data_path, index=0)
+                fcurve_rotation_y = blender_action.fcurves.new(data_path, index=1)
+                fcurve_rotation_z = blender_action.fcurves.new(data_path, index=2)
+                for rotation_key_frames in ms3d_joint.rotation_key_frames:
+                    frame = (rotation_key_frames.time * ms3d_model.animation_fps)
+                    fcurve_rotation_x.keyframe_points.insert(frame, -rotation_key_frames.rotation[0])
+                    fcurve_rotation_y.keyframe_points.insert(frame, rotation_key_frames.rotation[2])
+                    fcurve_rotation_z.keyframe_points.insert(frame, rotation_key_frames.rotation[1])
 
-                q = (matrix_local_rot).to_quaternion()
-                fcurve_rotation_w.keyframe_points.insert(frame, q.w)
-                fcurve_rotation_x.keyframe_points.insert(frame, q.x)
-                fcurve_rotation_y.keyframe_points.insert(frame, q.y)
-                fcurve_rotation_z.keyframe_points.insert(frame, q.z)
-
         enable_pose_mode(False)
 
         return blender_armature_object



More information about the Bf-extensions-cvs mailing list