[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2777] contrib/py/scripts/addons/ io_scene_ms3d: mod: exporter use an other logic to reduces the total number of smooth groups

Alexander Nussbaumer alpha-beta-release at gmx.net
Tue Dec 13 19:12:24 CET 2011


Revision: 2777
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2777
Author:   beta-tester
Date:     2011-12-13 18:12:13 +0000 (Tue, 13 Dec 2011)
Log Message:
-----------
mod: exporter use an other logic to reduces the total number of smooth groups

Modified Paths:
--------------
    contrib/py/scripts/addons/io_scene_ms3d/__README__.txt
    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_import.py
    contrib/py/scripts/addons/io_scene_ms3d/ms3d_utils.py

Modified: contrib/py/scripts/addons/io_scene_ms3d/__README__.txt
===================================================================
--- contrib/py/scripts/addons/io_scene_ms3d/__README__.txt	2011-12-13 17:47:27 UTC (rev 2776)
+++ contrib/py/scripts/addons/io_scene_ms3d/__README__.txt	2011-12-13 18:12:13 UTC (rev 2777)
@@ -89,7 +89,9 @@
 
 
 changelog:
-changed: (0, 3, 5, "beta (2011-12-13 00:00)"),
+changed: (0, 3, 6, "beta (2011-12-13 00:00)"),
+mod: exporter use an other logic to reduces the total number of smooth groups
+mod: correct "version" and "blender" in __init__.py
 fix: division by zero in importer
 mod: import armature bones (head-tail to tail-head + additional post process to connect for better auto IK handling)
 add: import bones and joints with armature modifier

Modified: contrib/py/scripts/addons/io_scene_ms3d/__init__.py
===================================================================
--- contrib/py/scripts/addons/io_scene_ms3d/__init__.py	2011-12-13 17:47:27 UTC (rev 2776)
+++ contrib/py/scripts/addons/io_scene_ms3d/__init__.py	2011-12-13 18:12:13 UTC (rev 2777)
@@ -56,8 +56,8 @@
         "description":  "Import / Export MilkShape3D MS3D files"
                 " (conform with v1.8.4)",
         "author": "Alexander Nussbaumer",
-        "version": (0, 3, 5, "beta (2011-12-12 00:00)"),
-        "blender": (2, 6, 0),
+        "version": (0, 3, 6),
+        "blender": (2, 60, 0),
         "api": 41226,
         "location": "File > Import-Export",
         "warning": "imports and exports only geometry and material of ms3d"\
@@ -75,14 +75,14 @@
 def menu_func_import(self, context):
     self.layout.operator(
             ms3d_import.ImportMS3D.bl_idname,
-            text = ms3d_utils.TEXT_OPERATOR
+            text=ms3d_utils.TEXT_OPERATOR
             )
 
 
 def menu_func_export(self, context):
     self.layout.operator(
             ms3d_export.ExportMS3D.bl_idname,
-            text = ms3d_utils.TEXT_OPERATOR
+            text=ms3d_utils.TEXT_OPERATOR
             )
 
 

Modified: contrib/py/scripts/addons/io_scene_ms3d/ms3d_export.py
===================================================================
--- contrib/py/scripts/addons/io_scene_ms3d/ms3d_export.py	2011-12-13 17:47:27 UTC (rev 2776)
+++ contrib/py/scripts/addons/io_scene_ms3d/ms3d_export.py	2011-12-13 18:12:13 UTC (rev 2777)
@@ -67,9 +67,7 @@
         bpy.types.Operator,
         bpy_extras.io_utils.ExportHelper
         ):
-    """
-    Save a MilkShape3D MS3D File
-    """
+    """Save a MilkShape3D MS3D File"""
 
     bl_idname = "io_scene_ms3d.ms3d_export"
     bl_label = "Export MS3D"
@@ -80,65 +78,65 @@
 
     filename_ext = ms3d_utils.FILE_EXT
     filter_glob = bpy.props.StringProperty(
-            default = ms3d_utils.FILE_FILTER,
-            options = {'HIDDEN'}
+            default=ms3d_utils.FILE_FILTER,
+            options={'HIDDEN'}
             )
 
     filepath = bpy.props.StringProperty(subtype='FILE_PATH')
 
     prop_verbose = bpy.props.BoolProperty(
-            name = ms3d_utils.PROP_NAME_VERBOSE,
-            description = ms3d_utils.PROP_DESC_VERBOSE,
-            default = ms3d_utils.PROP_DEFAULT_VERBOSE,
-            options = ms3d_utils.PROP_OPT_VERBOSE,
+            name=ms3d_utils.PROP_NAME_VERBOSE,
+            description=ms3d_utils.PROP_DESC_VERBOSE,
+            default=ms3d_utils.PROP_DEFAULT_VERBOSE,
+            options=ms3d_utils.PROP_OPT_VERBOSE,
             )
 
     prop_coordinate_system = EnumProperty(
-            name = ms3d_utils.PROP_NAME_COORDINATESYSTEM,
-            description = ms3d_utils.PROP_DESC_COORDINATESYSTEM,
-            items = ms3d_utils.PROP_ITEMS_COORDINATESYSTEM,
-            default = ms3d_utils.PROP_DEFAULT_COORDINATESYSTEM_EXP,
-            options = ms3d_utils.PROP_OPT_COORDINATESYSTEM,
+            name=ms3d_utils.PROP_NAME_COORDINATESYSTEM,
+            description=ms3d_utils.PROP_DESC_COORDINATESYSTEM,
+            items=ms3d_utils.PROP_ITEMS_COORDINATESYSTEM,
+            default=ms3d_utils.PROP_DEFAULT_COORDINATESYSTEM_EXP,
+            options=ms3d_utils.PROP_OPT_COORDINATESYSTEM,
             )
 
     prop_scale = FloatProperty(
-            name = ms3d_utils.PROP_NAME_SCALE,
-            description = ms3d_utils.PROP_DESC_SCALE,
-            default = 1.0 / ms3d_utils.PROP_DEFAULT_SCALE,
-            min = ms3d_utils.PROP_MIN_SCALE,
-            max = ms3d_utils.PROP_MAX_SCALE,
-            soft_min = ms3d_utils.PROP_SMIN_SCALE,
-            soft_max = ms3d_utils.PROP_SMAX_SCALE,
-            options = ms3d_utils.PROP_OPT_SCALE,
+            name=ms3d_utils.PROP_NAME_SCALE,
+            description=ms3d_utils.PROP_DESC_SCALE,
+            default=1.0 / ms3d_utils.PROP_DEFAULT_SCALE,
+            min=ms3d_utils.PROP_MIN_SCALE,
+            max=ms3d_utils.PROP_MAX_SCALE,
+            soft_min=ms3d_utils.PROP_SMIN_SCALE,
+            soft_max=ms3d_utils.PROP_SMAX_SCALE,
+            options=ms3d_utils.PROP_OPT_SCALE,
             )
 
     prop_objects = EnumProperty(
-            name = ms3d_utils.PROP_NAME_OBJECTS_EXP,
-            description = ms3d_utils.PROP_DESC_OBJECTS_EXP,
-            items = ms3d_utils.PROP_ITEMS_OBJECTS_EXP,
-            default = ms3d_utils.PROP_DEFAULT_OBJECTS_EXP,
-            options = ms3d_utils.PROP_OPT_OBJECTS_EXP,
+            name=ms3d_utils.PROP_NAME_OBJECTS_EXP,
+            description=ms3d_utils.PROP_DESC_OBJECTS_EXP,
+            items=ms3d_utils.PROP_ITEMS_OBJECTS_EXP,
+            default=ms3d_utils.PROP_DEFAULT_OBJECTS_EXP,
+            options=ms3d_utils.PROP_OPT_OBJECTS_EXP,
             )
 
     prop_selected = bpy.props.BoolProperty(
-            name = ms3d_utils.PROP_NAME_SELECTED,
-            description = ms3d_utils.PROP_DESC_SELECTED,
-            default = ms3d_utils.PROP_DEFAULT_SELECTED,
-            options = ms3d_utils.PROP_OPT_SELECTED,
+            name=ms3d_utils.PROP_NAME_SELECTED,
+            description=ms3d_utils.PROP_DESC_SELECTED,
+            default=ms3d_utils.PROP_DEFAULT_SELECTED,
+            options=ms3d_utils.PROP_OPT_SELECTED,
             )
 
     prop_animation = bpy.props.BoolProperty(
-            name = ms3d_utils.PROP_NAME_ANIMATION,
-            description = ms3d_utils.PROP_DESC_ANIMATION,
-            default = ms3d_utils.PROP_DEFAULT_ANIMATION,
-            options = ms3d_utils.PROP_OPT_ANIMATION,
+            name=ms3d_utils.PROP_NAME_ANIMATION,
+            description=ms3d_utils.PROP_DESC_ANIMATION,
+            default=ms3d_utils.PROP_DEFAULT_ANIMATION,
+            options=ms3d_utils.PROP_OPT_ANIMATION,
             )
 
     prop_animation_fp = bpy.props.BoolProperty(
-            name = ms3d_utils.PROP_NAME_ANIMATION_FP,
-            description = ms3d_utils.PROP_DESC_ANIMATION_FP,
-            default = ms3d_utils.PROP_DEFAULT_ANIMATION_FP,
-            options = ms3d_utils.PROP_OPT_ANIMATION_FP,
+            name=ms3d_utils.PROP_NAME_ANIMATION_FP,
+            description=ms3d_utils.PROP_DESC_ANIMATION_FP,
+            default=ms3d_utils.PROP_DEFAULT_ANIMATION_FP,
+            options=ms3d_utils.PROP_OPT_ANIMATION_FP,
             )
 
 
@@ -149,9 +147,7 @@
 
     # entrypoint for blender -> MS3D
     def execute(self, blenderContext):
-        """
-        start executing
-        """
+        """start executing"""
         return self.WriteMs3d(blenderContext)
 
     #
@@ -163,9 +159,7 @@
     # fill ms3dTemplate with blender content
     # writer ms3d file
     def WriteMs3d(self, blenderContext):
-        """
-        convert bender content to ms3d content and write it to file
-        """
+        """convert bender content to ms3d content and write it to file"""
 
         t1 = time.time()
         t2 = None
@@ -215,8 +209,7 @@
 
     ###########################################################################
     def Ms3dFromBlender(self, blenderContext, ms3dTemplate):
-        """
-        known limitations:
+        """ known limitations:
             - bones unsupported yet
             - joints unsupported yet
             - very bad performance
@@ -224,8 +217,7 @@
         notes:
             - interpreating a blender-mesh-objects as ms3d-group
             - only one material allowed per group in ms3d,
-              maybe sub-split a mesh in to material groups???
-        """
+              maybe sub-split a mesh in to material groups???"""
 
         blender = blenderContext.blend_data
 
@@ -614,10 +606,8 @@
 
     ###########################################################################
     def CreateVertex(self,  matrixObject, blenderVertex):
-        """
-        known limitations:
-            - boneId not supported
-        """
+        """ known limitations:
+            - boneId not supported """
         ms3dVertex = ms3d_spec.ms3d_vertex_t()
 
         if (blenderVertex.select):
@@ -641,7 +631,6 @@
 
     ###########################################################################
     def GenerateSmoothGroups(self, blenderContext, ms3dTemplate, blenderFaces):
-
         ms3d_utils.EnableEditMode(True)
 
         # enable face-selection-mode
@@ -653,15 +642,17 @@
         # enable object-mode (important for face.select = value)
         ms3d_utils.EnableEditMode(False)
 
-        smoothGroupFaces = {}
-        smoothGroup = 0
+        handledFacesSet = set()
+        smoothGroupVertices = {}
 
+        blenderVertices = blenderContext.active_object.data.vertices
+
         # run throug the faces
         # mark linked faces and set its smoothGroup value
         nFaces = len(blenderFaces)
 
         for iFace in range(nFaces):
-            if (blenderFaces[iFace].select):
+            if (blenderFaces[iFace].select) or (iFace in handledFacesSet):
                 continue
 
             # a new unhandled face found
@@ -674,15 +665,66 @@
 
             ms3d_utils.EnableEditMode(False)
 
+            # build a set of vertices hashes
+            currentFaceSet = set()
+            currentVertexSet = set()
             for iiFace in range(nFaces):
-                if (blenderFaces[iiFace].select):
-                    if (iiFace not in smoothGroupFaces):
-                        smoothGroupFaces[iiFace] = smoothGroup
+                if ((blenderFaces[iiFace].select)
+                        and (iiFace not in handledFacesSet)):
+                    handledFacesSet.add(iiFace)
+                    currentFaceSet.add(iiFace)
 
-            smoothGroup += 1
-            if (smoothGroup > ms3d_spec.MAX_SMOOTH_GROUP):

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list