[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4759] trunk/py/scripts/addons/ io_scene_ms3d: added: exporter takes armature parent in account of animation handling.

Alexander N. alpha-beta-release at gmx.net
Mon Sep 16 15:50:20 CEST 2013


Revision: 4759
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4759
Author:   beta-tester
Date:     2013-09-16 13:50:20 +0000 (Mon, 16 Sep 2013)
Log Message:
-----------
added: exporter takes armature parent in account of animation handling.

only one armature source will can be taken at the moment, and will taken in the following "priority" order:
1. armature parent will be taken if exist.
2. first available armature modifier will be taken if exist.

open question: what is best practice, in case of existence of multiple armature sources?
(armature parent and one or more armature modifier)
can that case happen (very often) in real world mesh modeling?

Modified Paths:
--------------
    trunk/py/scripts/addons/io_scene_ms3d/__init__.py
    trunk/py/scripts/addons/io_scene_ms3d/ms3d_export.py

Modified: trunk/py/scripts/addons/io_scene_ms3d/__init__.py
===================================================================
--- trunk/py/scripts/addons/io_scene_ms3d/__init__.py	2013-09-16 08:52:33 UTC (rev 4758)
+++ trunk/py/scripts/addons/io_scene_ms3d/__init__.py	2013-09-16 13:50:20 UTC (rev 4759)
@@ -23,7 +23,7 @@
     'description': "Import / Export MilkShape3D MS3D files"\
             " (conform with MilkShape3D v1.8.4)",
     'author': "Alexander Nussbaumer",
-    'version': (0, 99, 2),
+    'version': (0, 99, 3),
     'blender': (2, 66, 0),
     'location': "File > Import & File > Export",
     'warning': "",

Modified: trunk/py/scripts/addons/io_scene_ms3d/ms3d_export.py
===================================================================
--- trunk/py/scripts/addons/io_scene_ms3d/ms3d_export.py	2013-09-16 08:52:33 UTC (rev 4758)
+++ trunk/py/scripts/addons/io_scene_ms3d/ms3d_export.py	2013-09-16 13:50:20 UTC (rev 4759)
@@ -574,25 +574,56 @@
             blender_bones = None
             blender_action = None
             blender_nla_tracks = None
-            for blender_modifier in blender_mesh_object.modifiers:
-                if blender_modifier.type == 'ARMATURE' \
-                        and blender_modifier.object.pose:
-                    blender_bones = blender_modifier.object.data.bones
-                    blender_pose_bones = blender_modifier.object.pose.bones
-                    if blender_modifier.object.animation_data:
-                        blender_action = \
-                                blender_modifier.object.animation_data.action
-                        blender_nla_tracks = \
-                                blender_modifier.object.animation_data.nla_tracks
 
-                    # apply transform
-                    if self.options_apply_transform:
-                        matrix_transform = blender_modifier.object.matrix_basis
-                    else:
-                        matrix_transform = 1
+            # note: only one armature modifier/parent will be handled.
+            #   if the parent is an armature, it will be handled irrespective
+            #   of existence of any armature modifier
 
-                    break
+            # question: maybe it is better to handle
+            #   all existing armature sources (parent / modifier)
+            #   as a merged animation...
+            #   what is best practice in case of multiple animation sources?
 
+            # take parent to account if it is an armature
+            if blender_mesh_object.parent and \
+                    blender_mesh_object.parent_type == 'ARMATURE' and \
+                    blender_mesh_object.parent.pose:
+                blender_bones = blender_mesh_object.parent.data.bones
+                blender_pose_bones = blender_mesh_object.parent.pose.bones
+                if blender_mesh_object.parent.animation_data:
+                    blender_action = \
+                            blender_mesh_object.parent.animation_data.action
+                    blender_nla_tracks = \
+                            blender_mesh_object.parent.animation_data.nla_tracks
+
+                # apply transform
+                if self.options_apply_transform:
+                    matrix_transform = blender_mesh_object.parent.matrix_basis
+                else:
+                    matrix_transform = 1
+
+            # search for animation modifier
+            else:
+                for blender_modifier in blender_mesh_object.modifiers:
+                    if blender_modifier.type == 'ARMATURE' \
+                            and blender_modifier.object.pose:
+                        blender_bones = blender_modifier.object.data.bones
+                        blender_pose_bones = blender_modifier.object.pose.bones
+                        if blender_modifier.object.animation_data:
+                            blender_action = \
+                                    blender_modifier.object.animation_data.action
+                            blender_nla_tracks = \
+                                    blender_modifier.object.animation_data.nla_tracks
+
+                        # apply transform
+                        if self.options_apply_transform:
+                            matrix_transform = blender_modifier.object.matrix_basis
+                        else:
+                            matrix_transform = 1
+
+                        break
+
+            # skip animation/bone handling, if no animation data is available
             if blender_bones is None \
                     and (blender_action is None and blender_nla_tracks is None):
                 continue



More information about the Bf-extensions-cvs mailing list