[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3593] contrib/py/scripts/addons/ io_scene_ms3d: smoothing group panel now shows all assigned and selected smoothing groups ('.'==assigned, ':'==selected)

Alexander Nussbaumer alpha-beta-release at gmx.net
Sat Jul 7 23:31:50 CEST 2012


Revision: 3593
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3593
Author:   beta-tester
Date:     2012-07-07 21:31:48 +0000 (Sat, 07 Jul 2012)
Log Message:
-----------
smoothing group panel now shows all assigned and selected smoothing groups ('.'==assigned, ':'==selected)

and other cosmetically code changes

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_spec.py
    contrib/py/scripts/addons/io_scene_ms3d/ms3d_strings.py
    contrib/py/scripts/addons/io_scene_ms3d/ms3d_ui.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	2012-07-07 16:04:04 UTC (rev 3592)
+++ contrib/py/scripts/addons/io_scene_ms3d/__README__.txt	2012-07-07 21:31:48 UTC (rev 3593)
@@ -50,11 +50,13 @@
                     \xA7 Blender maintenance
 
 ms3d_export.py      : entry point for exporter
-                      functions to bring Blender content in a correct way to MilkShape
+                      functions to bring Blender content in a correct way to
+                      MilkShape
                     \xA7 Blender -> MilkShape3D maintenance
 
 ms3d_import.py      : entry point for importer
-                      functions to bring MilkShape content in a correct way to Blender
+                      functions to bring MilkShape content in a correct way to
+                      Blender
                     \xA7 MilkShape3D -> Blender maintenance
 
 ms3d_spec.py        : objects and structures that specified a MilkShape3D file
@@ -65,7 +67,8 @@
                       give user access to MilkShape specific properties
                     \xA7 Blender maintenance
 
-ms3d_strings.py     : most of the strings used in the addon to have a central point for optional internationalization
+ms3d_strings.py     : most of the strings used in the addon to have a
+                      central point for optional internationalization
 
 
 known issues:
@@ -73,16 +76,18 @@
     - does not import keyframes
 
   exporter issues:
-    - does only export the first existing material, if more than one material is used per mesh
-    - does only export the first existing UV texture coordinates, if more than one UV texture is used per mesh
+    - does only export the first existing material, if more than one material
+            is used per mesh
+    - does only export the first existing UV texture coordinates,
+            if more than one UV texture is used per mesh
     - does not export bones
     - does not export joints
     - does not export keyframes
-    - does not export comments (will never be supported - blender doesn't have similar stuff)
+    - does not export comments (will never be supported - blender doesn't
+            have similar stuff)
 
 
 todo:
-- change internal data structure for more performance on searching vertex indices and double vertices
 - add support for bones and joints in exporter
 - add support for keyframes
 
@@ -93,7 +98,7 @@
             .vertices
                 Ms3dVertex
                     .vertex: 100%
-                    .bone_id: 0%
+                    .bone_id: 100%
                     .reference_count: 0% (100% will be calculated on export)
                     .flags: 100% (value only)
                     .vertex_ex
@@ -107,7 +112,9 @@
                     .s: 100%
                     .t: 100%
                     .group_index: 100%
-                    .smoothing_group: 100% (BUG: generation of sharp edges does not work well on isolated faces - faces, that does not share edges with neighbors)
+                    .smoothing_group: 100% (BUG: generation of sharp edges
+                            does not work well on isolated faces
+                            - faces, that does not share edges with neighbors)
                     .flags: 0%
                     .vertex_normals: 0% (not/never for import)
             .groups

Modified: contrib/py/scripts/addons/io_scene_ms3d/__init__.py
===================================================================
--- contrib/py/scripts/addons/io_scene_ms3d/__init__.py	2012-07-07 16:04:04 UTC (rev 3592)
+++ contrib/py/scripts/addons/io_scene_ms3d/__init__.py	2012-07-07 21:31:48 UTC (rev 3593)
@@ -20,12 +20,13 @@
 
 bl_info = {
         'name': "MilkShape3D MS3D format (.ms3d)",
-        'description': "Import / Export MilkShape3D MS3D files (conform with v1.8.4)",
+        'description': "Import / Export MilkShape3D MS3D files"\
+                " (conform with v1.8.4)",
         'author': "Alexander Nussbaumer",
-        'version': (0, 4, 0, 0),
+        'version': (0, 4, 0, 1),
         'blender': (2, 6, 3, 0),
         'location': "File > Import & File > Export",
-        'warning': "[2012-07-04] currently only the importer is implemented",
+        'warning': "[2012-07-07] currently only the importer is implemented",
         '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_export.py
===================================================================
--- contrib/py/scripts/addons/io_scene_ms3d/ms3d_export.py	2012-07-07 16:04:04 UTC (rev 3592)
+++ contrib/py/scripts/addons/io_scene_ms3d/ms3d_export.py	2012-07-07 21:31:48 UTC (rev 3593)
@@ -32,17 +32,32 @@
 
 #import python stuff
 import io
-import math
-import mathutils
-import os
-import sys
-import time
+from math import (
+        radians,
+        )
+from mathutils import (
+        Vector,
+        Euler,
+        Matrix,
+        )
+from os import (
+        path,
+        )
+from sys import (
+        exc_info,
+        float_info,
+        )
+from time import (
+        time,
+        )
 
 
 # To support reload properly, try to access a package var,
 # if it's there, reload everything
 if ('bpy' in locals()):
     import imp
+    if 'io_scene_ms3d.ms3d_strings' in locals():
+        imp.reload(io_scene_ms3d.ms3d_strings)
     if 'io_scene_ms3d.ms3d_spec' in locals():
         imp.reload(io_scene_ms3d.ms3d_spec)
     if 'io_scene_ms3d.ms3d_utils' in locals():
@@ -50,26 +65,31 @@
     if 'io_scene_ms3d.ms3d_ui' in locals():
         imp.reload(io_scene_ms3d.ms3d_ui)
     pass
-
 else:
-    from io_scene_ms3d.ms3d_spec import *
-    from io_scene_ms3d.ms3d_utils import *
-    from io_scene_ms3d.ms3d_ui import *
+    from io_scene_ms3d.ms3d_strings import (
+            ms3d_str,
+            )
+    from io_scene_ms3d.ms3d_spec import (
+            Ms3dSpec,
+            Ms3dModel,
+            )
+    from io_scene_ms3d.ms3d_utils import (
+            select_all,
+            enable_pose_mode,
+            enable_edit_mode,
+            pre_setup_environment,
+            )
+    from io_scene_ms3d.ms3d_ui import (
+            Ms3dUi,
+            )
     pass
 
 
 #import blender stuff
 import bpy
-import bpy_extras.io_utils
+import bmesh
 
-from bpy.props import (
-        BoolProperty,
-        EnumProperty,
-        FloatProperty,
-        StringProperty,
-        )
 
-
 ###############################################################################
 class Ms3dExporter():
     """ Load a MilkShape3D MS3D File """
@@ -78,8 +98,8 @@
         self.options = options
         pass
 
-    # create a empty ms3d ms3d_template
-    # fill ms3d_template with blender content
+    # create a empty ms3d ms3d_model
+    # fill ms3d_model with blender content
     # writer ms3d file
     def write(self, blender_context):
         """convert bender content to ms3d content and write it to file"""
@@ -92,21 +112,24 @@
             pre_setup_environment(self)
 
             # create an empty ms3d template
-            ms3d_template = Ms3dModel()
+            ms3d_model = Ms3dModel()
 
             # inject blender data to ms3d file
-            self.from_blender(blender_context, ms3d_template)
+            self.from_blender(blender_context, ms3d_model)
 
             t2 = time.time()
 
-            # write ms3d file to disk
-            self.file = io.FileIO(self.filepath, "w")
+            self.file = None
+            try:
+                # write ms3d file to disk
+                self.file = io.FileIO(self.filepath, "wb")
 
-            ms3d_template.write(self.file)
+                ms3d_model.write(self.file)
+                self.file.flush()
+            finally:
+                if self.file is not None:
+                    self.file.close()
 
-            self.file.flush()
-            self.file.close()
-
             # finalize/restore environment
             post_setup_environment(self, False)
 
@@ -124,14 +147,14 @@
             pass
 
         t3 = time.time()
-        print("elapsed time: {0:.4}s (converter: ~{1:.4}s, disk io:"
-                " ~{2:.4}s)".format((t3 - t1), (t2 - t1), (t3 - t2)))
+        print(ms3d_str['SUMMARY_IMPORT'].format(
+                (t3 - t1), (t2 - t1), (t3 - t2)))
 
         return {"FINISHED"}
 
 
     ###########################################################################
-    def from_blender(self, blender_context, ms3d_template):
+    def from_blender(self, blender_context, ms3d_model):
         """ known limitations:
             - bones unsupported yet
             - joints unsupported yet
@@ -213,7 +236,7 @@
             """
             # handle smoothing groups
             smoothGroupFaces = self.generate_smoothing_groups(
-                    blender_context, ms3d_template, blender_mesh.faces)
+                    blender_context, ms3d_model, blender_mesh.faces)
 
             # handle blender-faces
             group_index = len(ms3dGroups)
@@ -274,29 +297,29 @@
             ms3dGroups.append(ms3d_group)
 
         # injecting common data
-        ms3d_template._vertices = ms3d_vertices
-        ms3d_template._triangles = ms3dTriangles
-        ms3d_template._groups = ms3dGroups
-        ms3d_template._materials = ms3dMaterials
+        ms3d_model._vertices = ms3d_vertices
+        ms3d_model._triangles = ms3dTriangles
+        ms3d_model._groups = ms3dGroups
+        ms3d_model._materials = ms3dMaterials
 
         # inject currently unsupported data
-        ms3d_template._vertex_ex = []
-        if (ms3d_template.sub_version_vertex_extra == 1):
-            for i in range(ms3d_template.number_vertices):
-                ms3d_template.vertex_ex.append(Ms3dVertexEx1())
-        elif (ms3d_template.sub_version_vertex_extra == 2):
-            for i in range(ms3d_template.number_vertices):
-                ms3d_template.vertex_ex.append(Ms3dVertexEx2())
-        elif (ms3d_template.sub_version_vertex_extra == 3):
-            for i in range(ms3d_template.number_vertices):
-                ms3d_template.vertex_ex.append(Ms3dVertexEx3())
+        ms3d_model._vertex_ex = []
+        if (ms3d_model.sub_version_vertex_extra == 1):
+            for i in range(ms3d_model.number_vertices):

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list