[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4060] contrib/py/scripts/addons/ io_scene_ms3d: added exporter options to apply transform and apply modifiers on export

Alexander Nussbaumer alpha-beta-release at gmx.net
Mon Dec 17 11:33:40 CET 2012


Revision: 4060
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4060
Author:   beta-tester
Date:     2012-12-17 10:33:39 +0000 (Mon, 17 Dec 2012)
Log Message:
-----------
added exporter options to apply transform and apply modifiers on export

Modified Paths:
--------------
    contrib/py/scripts/addons/io_scene_ms3d/__init__.py
    contrib/py/scripts/addons/io_scene_ms3d/ms3d_export.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-12-17 00:25:18 UTC (rev 4059)
+++ contrib/py/scripts/addons/io_scene_ms3d/__init__.py	2012-12-17 10:33:39 UTC (rev 4060)
@@ -23,7 +23,7 @@
         'description': "Import / Export MilkShape3D MS3D files"\
                 " (conform with v1.8.4)",
         'author': "Alexander Nussbaumer",
-        'version': (0, 6, 0, 4),
+        'version': (0, 7, 0, 0),
         'blender': (2, 6, 3, 0),
         'location': "File > Import & File > Export",
         #'warning': "",

Modified: contrib/py/scripts/addons/io_scene_ms3d/ms3d_export.py
===================================================================
--- contrib/py/scripts/addons/io_scene_ms3d/ms3d_export.py	2012-12-17 00:25:18 UTC (rev 4059)
+++ contrib/py/scripts/addons/io_scene_ms3d/ms3d_export.py	2012-12-17 10:33:39 UTC (rev 4060)
@@ -239,11 +239,31 @@
             blender_scene.objects.active = blender_mesh_object_temp
             blender_mesh_temp.validate(self.options.verbose)
 
+            if self.options.apply_transform:
+                matrix_transform = blender_mesh_object_temp.matrix_local
+            else:
+                matrix_transform = Matrix()
+
+            # apply modifiers
+            enable_edit_mode(False)
+            if self.options.apply_modifiers:
+                for modifier in blender_mesh_object_temp.modifiers:
+                    if (self.options.apply_modifiers_mode == Ms3dUi.PROP_ITEM_APPLY_MODIFIERS_MODE_VIEW \
+                            and modifier.show_viewport) \
+                            or (self.options.apply_modifiers_mode == Ms3dUi.PROP_ITEM_APPLY_MODIFIERS_MODE_RENDER \
+                            and modifier.show_render):
+                        if not modifier.type in {'ARMATURE',
+                                'CLOTH', 'COLLISION', 'DYNAMIC_PAINT', 'EXPLODE', 'FLUID_SIMULATION', 'OCEAN',
+                                'PARTICLE_INSTANCE', 'PARTICLE_SYSTEM', 'SMOKE', 'SOFT_BODY', 'SURFACE', }:
+                            if ops.object.modifier_apply.poll():
+                                ops.object.modifier_apply(apply_as='DATA', modifier=modifier.name)
+
             # convert to tris
             enable_edit_mode(True)
             select_all(True)
             if ops.mesh.quads_convert_to_tris.poll():
                 ops.mesh.quads_convert_to_tris()
+
             enable_edit_mode(False)
 
             enable_edit_mode(True)
@@ -291,8 +311,7 @@
                     ms3d_vertex = Ms3dVertex()
                     ms3d_vertex.__index = index
 
-                    loc = (bmv.co + blender_mesh_object_temp.location)
-                    ms3d_vertex._vertex = self.geometry_correction(loc)
+                    ms3d_vertex._vertex = self.geometry_correction(matrix_transform * bmv.co)
 
                     if layer_deform:
                         blender_vertex_group_ids = bmv[layer_deform]
@@ -449,7 +468,6 @@
                 blender_context.blend_data.meshes.remove(blender_mesh_temp)
 
 
-
     ###########################################################################
     def create_animation(self, blender_context, ms3d_model, blender_mesh_objects, blender_to_ms3d_bones):
         ##########################

Modified: contrib/py/scripts/addons/io_scene_ms3d/ms3d_strings.py
===================================================================
--- contrib/py/scripts/addons/io_scene_ms3d/ms3d_strings.py	2012-12-17 00:25:18 UTC (rev 4059)
+++ contrib/py/scripts/addons/io_scene_ms3d/ms3d_strings.py	2012-12-17 10:33:39 UTC (rev 4060)
@@ -117,6 +117,7 @@
         'LABEL_NAME_OBJECT': "World Processing:",
         'LABEL_NAME_OPTIONS': "Advanced Options:",
         'LABEL_NAME_PROCESSING': "Object Processing:",
+        'LABEL_NAME_MODIFIER': "Modifier Processing:",
         'LABEL_PANEL_BUTTON_NONE': "None",
         'LABEL_PANEL_GROUPS': "MS3D - Groups",
         'LABEL_PANEL_JOINTS': "MS3D - Joint",
@@ -223,6 +224,17 @@
         'ENUM_TO_BLENDER_2' : "copies and puts all available values to blender",
         'PROP_NAME_EXTENDED_NORMAL_HANDLING': "Extended Normal Handling",
         'PROP_DESC_EXTENDED_NORMAL_HANDLING': "adds extra vertices if normals are different",
+        'PROP_NAME_APPLY_TRANSFORM': "Apply Transform",
+        'PROP_DESC_APPLY_TRANSFORM': "applies location, rotation, scale transform on export",
+        'PROP_NAME_APPLY_MODIFIERS': "Apply Modifiers",
+        'PROP_DESC_APPLY_MODIFIERS': "applies modifiers on export that are enabled(except of Armature and Physic modifiers)",
+        'PROP_NAME_APPLY_MODIFIERS_MODE': "Apply Mode",
+        'PROP_DESC_APPLY_MODIFIERS_MODE': "apply if modifiers enabled in this mode",
+        'PROP_ITEM_APPLY_MODIFIERS_MODE_VIEW_1': "View",
+        'PROP_ITEM_APPLY_MODIFIERS_MODE_VIEW_2': "apply modifiers that are enabled in viewport",
+        'PROP_ITEM_APPLY_MODIFIERS_MODE_RENDER_1': "Render",
+        'PROP_ITEM_APPLY_MODIFIERS_MODE_RENDER_2': "apply modifiers that are enabled in renderer",
+
         'PROP_NAME_': "Name",
         'PROP_DESC_': "Description",
         # ms3d_str['']

Modified: contrib/py/scripts/addons/io_scene_ms3d/ms3d_ui.py
===================================================================
--- contrib/py/scripts/addons/io_scene_ms3d/ms3d_ui.py	2012-12-17 00:25:18 UTC (rev 4059)
+++ contrib/py/scripts/addons/io_scene_ms3d/ms3d_ui.py	2012-12-17 10:33:39 UTC (rev 4060)
@@ -200,6 +200,7 @@
     ICON_OPTIONS = 'LAMP'
     ICON_OBJECT = 'WORLD'
     ICON_PROCESSING = 'OBJECT_DATAMODE'
+    ICON_MODIFIER = 'MODIFIER'
     ICON_ANIMATION = 'RENDER_ANIMATION'
     ICON_ROTATION_MODE = 'BONE_DATA'
     ICON_ERROR = 'ERROR'
@@ -224,8 +225,15 @@
     PROP_DEFAULT_USE_BLENDER_NAMES = True
     PROP_DEFAULT_USE_BLENDER_MATERIALS = False
     PROP_DEFAULT_EXTENDED_NORMAL_HANDLING = False
+    PROP_DEFAULT_APPLY_TRANSFORM = True
+    PROP_DEFAULT_APPLY_MODIFIERS = True
 
     ###########################################################################
+    PROP_ITEM_APPLY_MODIFIERS_MODE_VIEW = 'VIEW'
+    PROP_ITEM_APPLY_MODIFIERS_MODE_RENDER = 'RENDER'
+    PROP_DEFAULT_APPLY_MODIFIERS_MODE = PROP_ITEM_APPLY_MODIFIERS_MODE_VIEW
+
+    ###########################################################################
     PROP_ITEM_ROTATION_MODE_EULER = 'EULER'
     PROP_ITEM_ROTATION_MODE_QUATERNION = 'QUATERNION'
     PROP_DEFAULT_ANIMATION_ROTATION = PROP_ITEM_ROTATION_MODE_EULER
@@ -407,6 +415,31 @@
             default=Ms3dUi.PROP_DEFAULT_USE_BLENDER_MATERIALS,
             )
 
+    apply_transform = BoolProperty(
+            name=ms3d_str['PROP_NAME_APPLY_TRANSFORM'],
+            description=ms3d_str['PROP_DESC_APPLY_TRANSFORM'],
+            default=Ms3dUi.PROP_DEFAULT_APPLY_TRANSFORM,
+            )
+
+    apply_modifiers = BoolProperty(
+            name=ms3d_str['PROP_NAME_APPLY_MODIFIERS'],
+            description=ms3d_str['PROP_DESC_APPLY_MODIFIERS'],
+            default=Ms3dUi.PROP_DEFAULT_APPLY_MODIFIERS,
+            )
+
+    apply_modifiers_mode =  EnumProperty(
+            name=ms3d_str['PROP_NAME_APPLY_MODIFIERS_MODE'],
+            description=ms3d_str['PROP_DESC_APPLY_MODIFIERS_MODE'],
+            items=( (Ms3dUi.PROP_ITEM_APPLY_MODIFIERS_MODE_VIEW,
+                            ms3d_str['PROP_ITEM_APPLY_MODIFIERS_MODE_VIEW_1'],
+                            ms3d_str['PROP_ITEM_APPLY_MODIFIERS_MODE_VIEW_2']),
+                    (Ms3dUi.PROP_ITEM_APPLY_MODIFIERS_MODE_RENDER,
+                            ms3d_str['PROP_ITEM_APPLY_MODIFIERS_MODE_RENDER_1'],
+                            ms3d_str['PROP_ITEM_APPLY_MODIFIERS_MODE_RENDER_2']),
+                    ),
+            default=Ms3dUi.PROP_DEFAULT_APPLY_MODIFIERS_MODE,
+            )
+
     normalize_weights = BoolProperty(
             name=ms3d_str['PROP_NAME_NORMALIZE_WEIGHTS'],
             description=ms3d_str['PROP_DESC_NORMALIZE_WEIGHTS'],
@@ -456,6 +489,16 @@
         box.prop(self, 'use_blender_materials')
 
         box = layout.box()
+        box.label(ms3d_str['LABEL_NAME_MODIFIER'],
+                icon=Ms3dUi.ICON_MODIFIER)
+        box.prop(self, 'apply_transform')
+        row = box.row()
+        row.prop(self, 'apply_modifiers')
+        sub = row.row()
+        sub.active = self.apply_modifiers
+        sub.prop(self, 'apply_modifiers_mode', text="")
+
+        box = layout.box()
         box.label(ms3d_str['LABEL_NAME_ANIMATION'],
                 icon=Ms3dUi.ICON_ANIMATION)
         box.prop(self, 'normalize_weights')



More information about the Bf-extensions-cvs mailing list