diff options
author | Alexander N <alpha-beta-release@gmx.net> | 2013-09-16 17:50:20 +0400 |
---|---|---|
committer | Alexander N <alpha-beta-release@gmx.net> | 2013-09-16 17:50:20 +0400 |
commit | 3ed552b9b825c63ab6ff3caff101d0f0ad25503b (patch) | |
tree | f547e1ad32600818243e909a63d01d9e40be01a0 /io_scene_ms3d | |
parent | cf6493491297a05e0e4bcfd7b9e6c7b6b7b2ef86 (diff) |
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?
Diffstat (limited to 'io_scene_ms3d')
-rw-r--r-- | io_scene_ms3d/__init__.py | 2 | ||||
-rw-r--r-- | io_scene_ms3d/ms3d_export.py | 65 |
2 files changed, 49 insertions, 18 deletions
diff --git a/io_scene_ms3d/__init__.py b/io_scene_ms3d/__init__.py index fc228245..7173a1aa 100644 --- a/io_scene_ms3d/__init__.py +++ b/io_scene_ms3d/__init__.py @@ -23,7 +23,7 @@ bl_info = { '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': "", diff --git a/io_scene_ms3d/ms3d_export.py b/io_scene_ms3d/ms3d_export.py index 50390f54..127c2496 100644 --- a/io_scene_ms3d/ms3d_export.py +++ b/io_scene_ms3d/ms3d_export.py @@ -574,25 +574,56 @@ class Ms3dExporter(): 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 - break + # 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 + + # 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 |