[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3928] contrib/py/scripts/addons/ io_scene_ms3d: add: importer - euler rotation mode (as default)

Alexander Nussbaumer alpha-beta-release at gmx.net
Sun Nov 4 08:55:29 CET 2012


Revision: 3928
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3928
Author:   beta-tester
Date:     2012-11-04 07:55:25 +0000 (Sun, 04 Nov 2012)
Log Message:
-----------
add: importer - euler rotation mode (as default)

..., to be able to fix possible gimbal-lock problems in animations between keyframes by hand: 'Graph Editor -> Key -> Discontinuity (Euler) Filter'

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

Modified: contrib/py/scripts/addons/io_scene_ms3d/__init__.py
===================================================================
--- contrib/py/scripts/addons/io_scene_ms3d/__init__.py	2012-11-04 03:04:17 UTC (rev 3927)
+++ contrib/py/scripts/addons/io_scene_ms3d/__init__.py	2012-11-04 07:55:25 UTC (rev 3928)
@@ -23,10 +23,10 @@
         'description': "Import / Export MilkShape3D MS3D files"\
                 " (conform with v1.8.4)",
         'author': "Alexander Nussbaumer",
-        'version': (0, 4, 8, 1),
+        'version': (0, 4, 8, 2),
         'blender': (2, 6, 3, 0),
         'location': "File > Import & File > Export",
-        'warning': "[2012-11-03] exporter is working, but is incomplete",
+        'warning': "[2012-11-04] 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-04 03:04:17 UTC (rev 3927)
+++ contrib/py/scripts/addons/io_scene_ms3d/ms3d_import.py	2012-11-04 07:55:25 UTC (rev 3928)
@@ -756,11 +756,19 @@
 
         ##########################
         # transition between keys may be incorrect
+        # because of the gimbal-lock problem!
+        # http://www.youtube.com/watch?v=zc8b2Jo7mno
+        # http://www.youtube.com/watch?v=rrUCBOlJdt4
+        # you can fix it manually by selecting the affected keyframes
+        # and allpy the following option to it:
+        # "Graph Editor -> Key -> Discontinuity (Euler) Filter"
+        # ==> "bpy.ops.graph.euler_filter()"
+        # but this option is only available for Euler rotation f-curves!
+        #
         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
 
             data_path = blender_pose_bone.path_from_id('location')
@@ -776,7 +784,7 @@
                 fcurve_location_y.keyframe_points.insert(frame, v[2])
                 fcurve_location_z.keyframe_points.insert(frame, v[1])
 
-            if True:
+            if self.options.is_rotation_mode_quaternion:
                 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)

Modified: contrib/py/scripts/addons/io_scene_ms3d/ms3d_strings.py
===================================================================
--- contrib/py/scripts/addons/io_scene_ms3d/ms3d_strings.py	2012-11-04 03:04:17 UTC (rev 3927)
+++ contrib/py/scripts/addons/io_scene_ms3d/ms3d_strings.py	2012-11-04 07:55:25 UTC (rev 3928)
@@ -224,9 +224,20 @@
         'PROP_NAME_APPLY_MODIFIER_MODE': "Mode",
         'PROP_DESC_APPLY_MODIFIER_MODE': "apply mode, if applicable",
         'PROP_ITEM_APPLY_MODIFIER_MODE_PREVIEW_1': "Preview",
-        'PROP_ITEM_APPLY_MODIFIER_MODE_PREVIEW_2': "takes the 'preview' settings of modifier, if applicable",
+        'PROP_ITEM_APPLY_MODIFIER_MODE_PREVIEW_2': "takes the 'preview' settings"\
+                " of modifier, if applicable",
         'PROP_ITEM_APPLY_MODIFIER_MODE_RENDER_1': "Render",
-        'PROP_ITEM_APPLY_MODIFIER_MODE_RENDER_2': "takes the 'render' settings of modifier, if applicable",
+        'PROP_ITEM_APPLY_MODIFIER_MODE_RENDER_2': "takes the 'render' settings"\
+                " of modifier, if applicable",
+        'PROP_NAME_ROTATION_MODE' : "Bone rotation mode",
+        'PROP_DESC_ROTATION_MODE' : "set the preferred rotation mode of bones",
+        'PROP_ITEM_ROTATION_MODE_EULER_1' : "Euler",
+        'PROP_ITEM_ROTATION_MODE_EULER_2' : "use euler bone rotation"\
+                " (gimbal-lock can be fixed by using "\
+                "'Graph Editor -> Key -> Discontinuity (Euler) Filter')",
+        'PROP_ITEM_ROTATION_MODE_QUATERNION_1' : "Quaternion",
+        'PROP_ITEM_ROTATION_MODE_QUATERNION_2' : "use quaternion bone rotation"\
+                " (no gimbal-lock filter available!)",
 
         'PROP_NAME_': "Name",
         'PROP_DESC_': "Description",

Modified: contrib/py/scripts/addons/io_scene_ms3d/ms3d_ui.py
===================================================================
--- contrib/py/scripts/addons/io_scene_ms3d/ms3d_ui.py	2012-11-04 03:04:17 UTC (rev 3927)
+++ contrib/py/scripts/addons/io_scene_ms3d/ms3d_ui.py	2012-11-04 07:55:25 UTC (rev 3928)
@@ -214,8 +214,8 @@
     ICON_OBJECT = 'WORLD'
     ICON_PROCESSING = 'OBJECT_DATAMODE'
     ICON_ANIMATION = 'RENDER_ANIMATION'
+    ICON_ROTATION_MODE = 'BONE_DATA'
 
-
     ###########################################################################
     PROP_DEFAULT_VERBOSE = DEFAULT_VERBOSE
 
@@ -251,6 +251,8 @@
     PROP_ITEM_OBJECT_MATERIAL = 'MATERIAL'
     PROP_ITEM_OBJECT_MESH = 'MESH'
     PROP_ITEM_OBJECT_SMOOTHGROUPS = 'SMOOTHGROUPS'
+
+
     ###########################################################################
     PROP_DEFAULT_OBJECTS_IMP = {
             #PROP_ITEM_OBJECT_MESH,
@@ -271,7 +273,14 @@
     ###########################################################################
     PROP_DEFAULT_ANIMATION = True
 
+
     ###########################################################################
+    PROP_ITEM_ROTATION_MODE_EULER = '0'
+    PROP_ITEM_ROTATION_MODE_QUATERNION = '1'
+    PROP_DEFAULT_ANIMATION_ROTATION = PROP_ITEM_ROTATION_MODE_EULER
+
+
+    ###########################################################################
     PROP_DEFAULT_APPLY_MODIFIER = False
     PROP_ITEM_APPLY_MODIFIER_MODE_PREVIEW = 'PREVIEW'
     PROP_ITEM_APPLY_MODIFIER_MODE_RENDER = 'RENDER'
@@ -355,7 +364,20 @@
             default=Ms3dUi.PROP_DEFAULT_ANIMATION,
             )
 
+    prop_rotation_mode = EnumProperty(
+            name=ms3d_str['PROP_NAME_ROTATION_MODE'],
+            description=ms3d_str['PROP_DESC_ROTATION_MODE'],
+            items=( (Ms3dUi.PROP_ITEM_ROTATION_MODE_EULER,
+                            ms3d_str['PROP_ITEM_ROTATION_MODE_EULER_1'],
+                            ms3d_str['PROP_ITEM_ROTATION_MODE_EULER_2']),
+                    (Ms3dUi.PROP_ITEM_ROTATION_MODE_QUATERNION,
+                            ms3d_str['PROP_ITEM_ROTATION_MODE_QUATERNION_1'],
+                            ms3d_str['PROP_ITEM_ROTATION_MODE_QUATERNION_2']),
+                    ),
+            default=Ms3dUi.PROP_DEFAULT_ANIMATION_ROTATION,
+            )
 
+
     @property
     def is_coordinate_system_1by1(self):
         return (Ms3dUi.PROP_ITEM_COORDINATESYSTEM_1BY1 \
@@ -372,6 +394,17 @@
                 in self.prop_coordinate_system)
 
 
+    @property
+    def is_rotation_mode_euler(self):
+        return (Ms3dUi.PROP_ITEM_ROTATION_MODE_EULER \
+                in self.prop_rotation_mode)
+
+    @property
+    def is_rotation_mode_quaternion(self):
+        return (Ms3dUi.PROP_ITEM_ROTATION_MODE_QUATERNION \
+                in self.prop_rotation_mode)
+
+
     # draw the option panel
     def draw(self, context):
         layout = self.layout
@@ -389,8 +422,8 @@
         box = layout.box()
         box.label(ms3d_str['LABEL_NAME_ANIMATION'], icon=Ms3dUi.ICON_ANIMATION)
         box.prop(self, 'prop_animation')
-        #if (self.prop_animation):
-        #    box.label(ms3d_str['REMARKS_1'], icon='ERROR')
+        if (self.prop_animation):
+            box.prop(self, 'prop_rotation_mode', icon=Ms3dUi.ICON_ROTATION_MODE, expand=False)
 
     # entrypoint for MS3D -> blender
     def execute(self, blender_context):
@@ -564,9 +597,6 @@
     def draw(self, context):
         layout = self.layout
 
-        # DEBUG:
-        layout.row().label(ms3d_str['REMARKS_2'], icon='ERROR')
-
         box = layout.box()
         box.label(ms3d_str['LABEL_NAME_OPTIONS'], icon=Ms3dUi.ICON_OPTIONS)
         box.prop(self, 'prop_verbose', icon='SPEAKER')



More information about the Bf-extensions-cvs mailing list