[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3682] contrib/py/scripts/addons/ io_directx_bel: 25/01/12 0.18

Jerome Neo jerome.le.chat at free.fr
Mon Aug 20 18:58:11 CEST 2012


Revision: 3682
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3682
Author:   littleneo
Date:     2012-08-20 16:58:11 +0000 (Mon, 20 Aug 2012)
Log Message:
-----------
25/01/12 0.18
  . code rewrite according to api bmesh changes (me.polygon and uv layers essentially)
  . implemented foreachset() call for uv import (faster)

Modified Paths:
--------------
    contrib/py/scripts/addons/io_directx_bel/README
    contrib/py/scripts/addons/io_directx_bel/__init__.py
    contrib/py/scripts/addons/io_directx_bel/bel/__init__.py
    contrib/py/scripts/addons/io_directx_bel/bel/fs.py
    contrib/py/scripts/addons/io_directx_bel/bel/image.py
    contrib/py/scripts/addons/io_directx_bel/bel/material.py
    contrib/py/scripts/addons/io_directx_bel/bel/mesh.py
    contrib/py/scripts/addons/io_directx_bel/bel/ob.py
    contrib/py/scripts/addons/io_directx_bel/bel/uv.py
    contrib/py/scripts/addons/io_directx_bel/import_x.py

Modified: contrib/py/scripts/addons/io_directx_bel/README
===================================================================
--- contrib/py/scripts/addons/io_directx_bel/README	2012-08-17 03:40:24 UTC (rev 3681)
+++ contrib/py/scripts/addons/io_directx_bel/README	2012-08-20 16:58:11 UTC (rev 3682)
@@ -24,7 +24,11 @@
   . start blender
   . enable then addon in  user prefs > addons
   . run the script with file > import > directX
-
+ 
+25/01/12 0.18
+  . code rewrite according to api bmesh changes (me.polygon and uv layers essentially)
+  . implemented foreachset() call for uv import (faster)
+  
 25/01/12 0.17
   . faster, 60% faster in some case : various loops improvements, infile templates parsing disabled by default
     saw another bottleneck about data chunks as string but will wait for binary support for better point of view.

Modified: contrib/py/scripts/addons/io_directx_bel/__init__.py
===================================================================
--- contrib/py/scripts/addons/io_directx_bel/__init__.py	2012-08-17 03:40:24 UTC (rev 3681)
+++ contrib/py/scripts/addons/io_directx_bel/__init__.py	2012-08-20 16:58:11 UTC (rev 3682)
@@ -3,8 +3,9 @@
     "name": "DirectX Importer",
     "description": "Import directX Model Format (.x)",
     "author": "Littleneo (Jerome Mahieux)",
-    "version": (0, 17),
-    "blender": (2, 6, 1),
+    "version": (0, 18),
+    "blender": (2, 6, 3),
+    "api": 42615,
     "location": "File > Import > DirectX (.x)",
     "warning": "",
     "wiki_url": "https://github.com/littleneo/directX_blender/wiki",
@@ -32,24 +33,11 @@
                                  path_reference_mode,
                                  axis_conversion,
                                  )
-
-'''
-class DisplayTree(bpy.types.Operator) :
-    bl_idname = 'city.selector'
-    bl_label = 'preview'
-
-    def execute(self,context) :
-'''
-
-def hide_templates(self,context) :
-    if self.use_templates == False : self.show_templates = False
-
-def not_parented(self,context) :
-    self.parented = False
-    self.use_templates = False
-
+try : import bel
+except : import io_directx_bel.bel
+    
 class ImportX(bpy.types.Operator, ImportHelper):
-    """Load a Direct x File"""
+    '''Load a Direct x File'''
     bl_idname = "import_scene.x"
     bl_label = "Import X"
     bl_options = {'PRESET', 'UNDO'}
@@ -66,7 +54,7 @@
             )
     show_templates = BoolProperty(
             name="Show x templates",
-            description="display any token structure definition found in the .x file",
+            description="display templates defined in the .x file",
             default=False,
             )
     show_geninfo = BoolProperty(
@@ -79,7 +67,6 @@
             name="Quick mode",
             description="only retrieve mesh basics",
             default=False,
-            update=not_parented
             )
     
     parented = BoolProperty(
@@ -87,13 +74,6 @@
             description="import armatures, empties, rebuild parent-childs relations",
             default=True,
             )
-
-    use_templates = BoolProperty(
-            name="Use infile x templates",
-            description="parse any token structure definition found in the .x file, use it prior to standard ones",
-            default=False,
-            update=hide_templates
-            )
     
     bone_maxlength = FloatProperty(
             name="Bone length",
@@ -106,8 +86,6 @@
     chunksize = EnumProperty(
             name="Chunksize",
             items=(('0', "all", ""),
-                   ('16384', "16KB", ""),
-                   ('8192', "8KB", ""),
                    ('4096', "4KB", ""),
                    ('2048', "2KB", ""),
                    ('1024', "1KB", ""),
@@ -127,7 +105,7 @@
             )
     use_ngons = BoolProperty(
             name="NGons",
-            description="Import faces with more then 4 verts as ngons",
+            description="Import faces with more then 4 verts as fgons",
             default=True,
             )
     use_edges = BoolProperty(
@@ -160,7 +138,7 @@
 
     use_image_search = BoolProperty(
             name="Image Search",
-            description="Search subdirs for any associated images " \
+            description="Search subdirs for any assosiated images " \
                         "(Warning, may be slow)",
             default=True,
             )
@@ -205,7 +183,6 @@
             )
 
     def execute(self, context):
-        from . import bel
         from . import import_x
         if self.split_mode == 'OFF':
             self.use_split_objects = False
@@ -227,7 +204,7 @@
         keywords["global_matrix"] = global_matrix
 
     
-        bel.fs.saveOptions('import_scene.x', self.as_keywords(ignore=(
+        bel.fs.saveOptions(self,'import_scene.x', self.as_keywords(ignore=(
                                             "filter_glob",
                                             "filepath",
                                             )))
@@ -241,15 +218,16 @@
         col = box.column(align=True)
         col.label('Import Options :')  
         col.prop(self, "chunksize")
-        col.prop(self, "use_smooth_groups")      
-        col.prop(self, "quickmode")
+        col.prop(self, "use_smooth_groups")
+        actif = not(self.quickmode)
         row = col.row()
-        row.enabled = not(self.quickmode)
+        row.enabled = actif
         row.prop(self, "parented")
-        #if self.parented :
-        row = col.row()
-        row.enabled = self.parented
-        row.prop(self, "bone_maxlength")
+        if self.parented :
+            row = col.row()
+            row.enabled = actif
+            row.prop(self, "bone_maxlength")      
+        col.prop(self, "quickmode")
         
         # source orientation box
         box = layout.box()
@@ -269,11 +247,8 @@
         col = box.column(align=True)
         col.label('Info / Debug :')
         col.prop(self, "show_tree")
+        col.prop(self, "show_templates")
         col.prop(self, "show_geninfo")
-        col.prop(self, "use_templates")
-        row = col.row()
-        row.enabled = self.use_templates
-        row.prop(self, "show_templates")  
         
         #row = layout.row(align=True)
         #row.prop(self, "use_ngons")
@@ -318,4 +293,4 @@
     #bpy.types.INFO_MT_file_export.remove(menu_func_export)
 
 if __name__ == "__main__":
-    register()
+    register()
\ No newline at end of file

Modified: contrib/py/scripts/addons/io_directx_bel/bel/__init__.py
===================================================================
--- contrib/py/scripts/addons/io_directx_bel/bel/__init__.py	2012-08-17 03:40:24 UTC (rev 3681)
+++ contrib/py/scripts/addons/io_directx_bel/bel/__init__.py	2012-08-20 16:58:11 UTC (rev 3682)
@@ -1,7 +1,7 @@
 # set a given name to a unique
 # blender data name in its collection
-def bpyname(name,collection,suffix=4) :
-    name = name[:20-suffix]
+def bpyname(name,collection,limit=63,suffix=4) :
+    name = name[:limit-suffix]
     tpl = '%s.%.'+str(suffix)+'d'
     bname = name
     id = 0
@@ -20,4 +20,4 @@
         t = lst[0][0][0]
         return lst, True
     except :
-        return [lst], False
+        return [lst], False
\ No newline at end of file

Modified: contrib/py/scripts/addons/io_directx_bel/bel/fs.py
===================================================================
--- contrib/py/scripts/addons/io_directx_bel/bel/fs.py	2012-08-17 03:40:24 UTC (rev 3681)
+++ contrib/py/scripts/addons/io_directx_bel/bel/fs.py	2012-08-20 16:58:11 UTC (rev 3682)
@@ -48,7 +48,9 @@
             files.extend(scanDir(path + '/' + item))
     return files
 
-def saveOptions(operator_name, tokens, filename='last_run'):
+def saveOptions(op,operator_name, tokens, filename='last_run'):
+    #print(op.as_keywords())
+    #print(dir(op))
     target_path = os_path.join("operator", operator_name)
     target_path = os_path.join("presets", target_path)
     target_path = bpy.utils.user_resource('SCRIPTS',target_path,create=True)

Modified: contrib/py/scripts/addons/io_directx_bel/bel/image.py
===================================================================
--- contrib/py/scripts/addons/io_directx_bel/bel/image.py	2012-08-17 03:40:24 UTC (rev 3681)
+++ contrib/py/scripts/addons/io_directx_bel/bel/image.py	2012-08-20 16:58:11 UTC (rev 3682)
@@ -1,8 +1,9 @@
 import bpy
 import bpy.path
-import io_directx_bel.bel.fs
-from io_directx_bel import bel
 
+from . import __init__ as bel
+from . import fs
+
 debuglevel = 0
 
 def dprint(str,l=2) :
@@ -12,16 +13,16 @@
 # create or retrieve a bdata image
 # given its path 
 def new(path, name=False, relative = True, premul = True) :
-    path = bel.fs.clean(path)
+    path = fs.clean(path)
     # check file
-    if bel.fs.isfile(path) == False :
+    if fs.isfile(path) == False :
         dprint('Texture image not found')
         return False
 
     if relative :
         try :
             path = bpy.path.relpath(path)
-            path = bel.fs.clean(path)
+            path = fs.clean(path)
         except : 
             print('cant turn path into relative one (.blend and img path drive letters ?) ')
         
@@ -29,7 +30,7 @@
     # returns img if paths match
     for img in bpy.data.images :
         if img.filepath != '' :
-            if bpy.path.abspath(path) == bpy.path.abspath(bel.fs.clean(img.filepath)) :
+            if bpy.path.abspath(path) == bpy.path.abspath(fs.clean(img.filepath)) :
                 return img
 
     # create a unique name in image slot
@@ -261,4 +262,4 @@
         texslot.use_map_alpha = alpha
         texslot.alpha_factor = 1.0
 
-    return mat
+    return mat
\ No newline at end of file

Modified: contrib/py/scripts/addons/io_directx_bel/bel/material.py
===================================================================
--- contrib/py/scripts/addons/io_directx_bel/bel/material.py	2012-08-17 03:40:24 UTC (rev 3681)
+++ contrib/py/scripts/addons/io_directx_bel/bel/material.py	2012-08-20 16:58:11 UTC (rev 3682)
@@ -1,13 +1,13 @@
 import bpy
 
-"""
+'''
 given name < 21
 if material name exists :
 naming_method = 0   blender default (increment name)
 naming_method = 1   do nothing, abort creation and use existing
 naming_method = 2   create new, rename existing, 
 naming_method = 3   create new, replace existing
-"""
+'''
 
 def new(name, naming_method=0) :
     if name not in bpy.data.materials or naming_method == 0:

Modified: contrib/py/scripts/addons/io_directx_bel/bel/mesh.py

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list