[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4801] contrib/py/scripts/addons/ io_scene_fpx: fix: missing alpha link at material node.

Alexander N. alpha-beta-release at gmx.net
Tue Oct 15 12:12:17 CEST 2013


Revision: 4801
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4801
Author:   beta-tester
Date:     2013-10-15 10:12:17 +0000 (Tue, 15 Oct 2013)
Log Message:
-----------
fix: missing alpha link at material node.

fix: renaming issue
add: preparation for hole cut (mask)

Modified Paths:
--------------
    contrib/py/scripts/addons/io_scene_fpx/__init__.py
    contrib/py/scripts/addons/io_scene_fpx/fpx_import.py
    contrib/py/scripts/addons/io_scene_fpx/fpx_resource.blend
    contrib/py/scripts/addons/io_scene_fpx/fpx_ui.py

Modified: contrib/py/scripts/addons/io_scene_fpx/__init__.py
===================================================================
--- contrib/py/scripts/addons/io_scene_fpx/__init__.py	2013-10-14 20:53:28 UTC (rev 4800)
+++ contrib/py/scripts/addons/io_scene_fpx/__init__.py	2013-10-15 10:12:17 UTC (rev 4801)
@@ -34,7 +34,7 @@
     'name': "Future Pinball FPx format (.fpm/.fpl/.fpt)",
     'description': "Import Future Pinball Model, Library and Table files",
     'author': "Alexander Nussbaumer",
-    'version': (0, 0, 201310141),
+    'version': (0, 0, 201310151),
     'blender': (2, 68, 0),
     'location': "File > Import",
     'warning': "",
@@ -47,11 +47,9 @@
 
 # KNOWN ISSUES & TODOs & MAYBEs (in a random order):
 #
-# - issue: curve bevel sometimes not assigned.
-#       close blender and open again, may change the behavior.
 # - issue: material assignment is not consistent.
 #       models got multiple materials assigned.
-#       models got christal material assigned instead texture.
+#       models got crystal material assigned instead texture.
 # - issue: some images could not be loaded to blender.
 #       #DEBUG fpl images.load C:\Users\user\AppData\Local\Temp\__grab__fpl__\bulb_trigger_star_v2\Bulb-Trigger-Star-v2.bmp
 #       IMB_ibImageFromMemory: unknown fileformat (C:\Users\user\AppData\Local\Temp\__grab__fpl__\bulb_trigger_star_v2\Bulb-Trigger-Star-v2.bmp)
@@ -63,7 +61,7 @@
 # - todo: create better light settings.
 #       should give nice results for "Blender Render" and "Cycles Render" render engine.
 # - todo: create better material settings.
-#       handling texture, color, transparent, christal, light, chrome.
+#       handling texture, color, transparent, crystal, light, chrome.
 # - todo: create camera + setup
 #       to see the whole table, playfield, backglass.
 # - todo: make all materials and material textures as separate.

Modified: contrib/py/scripts/addons/io_scene_fpx/fpx_import.py
===================================================================
--- contrib/py/scripts/addons/io_scene_fpx/fpx_import.py	2013-10-14 20:53:28 UTC (rev 4800)
+++ contrib/py/scripts/addons/io_scene_fpx/fpx_import.py	2013-10-15 10:12:17 UTC (rev 4801)
@@ -30,6 +30,9 @@
 # ##### END COPYRIGHT BLOCK #####
 
 
+DEV_MODE__APPEND_TO_EXISTING = False # do not enable - only for developing purpose (e.g. appending fpx_resource.blend)
+
+
 #import python stuff
 import io
 from mathutils import (
@@ -311,7 +314,13 @@
         model_filepath = dst_sub_path_names.get("primary_model_data")
         if model_filepath:
             if self.use_scene_per_model:
-                blender_scene = blender_context.blend_data.scenes.new(FORMAT_SCENE.format(model_name))
+                if DEV_MODE__APPEND_TO_EXISTING:
+                    blender_scene = blender_context.blend_data.scenes.get(FpxUtilities.toGoodName(FORMAT_SCENE.format(model_name)))
+                    if not blender_scene:
+                        print("#DEBUG missing scene for:", model_name)
+                        return
+                else:
+                    blender_scene = blender_context.blend_data.scenes.new(FpxUtilities.toGoodName(FORMAT_SCENE.format(model_name)))
                 blender_context.screen.scene = blender_scene
             else:
                 blender_scene = blender_context.scene
@@ -321,24 +330,17 @@
             blender_scene.layers = self.LAYERS_PRIMARY_MODEL
             #{'FINISHED'}
             #{'CANCELLED'}
-            if 'FINISHED' in ops.import_scene.ms3d(filepath=model_filepath, use_animation=True):
-                name = blender_context.active_object.name
-                src_ext = "ms3d"
-                index = name.rfind(".{}.".format(src_ext))
-                if index < 0:
-                    index = name.rfind(".")
-                    #if index < 0:
-                    #    return
+            if DEV_MODE__APPEND_TO_EXISTING or 'FINISHED' in ops.import_scene.ms3d(filepath=model_filepath, use_animation=True):
+                if not DEV_MODE__APPEND_TO_EXISTING:
+                    remove_material(blender_context)
 
-                src_name = "{}.{}".format(name[:index], src_ext)
+                    if not self.keep_name:
+                        src_name = get_object_src_name(blender_context)
+                        rename_active_ms3d(blender_context, src_name, model_name)
 
-                remove_material(blender_context)
-                if not self.keep_name:
-                    rename_active_ms3d(blender_context, src_name, model_name)
+                    if self.use_model_adjustment:
+                        adjust_position(blender_context, blender_scene, dst_sub_path_names)
 
-                if self.use_model_adjustment:
-                    adjust_position(blender_context, blender_scene, dst_sub_path_names)
-
                 if FpxUI.USE_MODEL_FILTER_SECONDARY in self.use_model_filter:
                     model_filepath = dst_sub_path_names.get("secondary_model_data")
                     if model_filepath:
@@ -346,6 +348,7 @@
                         if 'FINISHED' in ops.import_scene.ms3d(filepath=model_filepath, use_animation=False):
                             remove_material(blender_context)
                             if not self.keep_name:
+                                src_name = get_object_src_name(blender_context)
                                 rename_active_ms3d(blender_context, src_name, model_name, "secondary")
 
                 if FpxUI.USE_MODEL_FILTER_MASK in self.use_model_filter:
@@ -355,6 +358,7 @@
                         if 'FINISHED' in ops.import_scene.ms3d(filepath=model_filepath, use_animation=False):
                             remove_material(blender_context)
                             if not self.keep_name:
+                                src_name = get_object_src_name(blender_context)
                                 rename_active_ms3d(blender_context, src_name, model_name, "mask")
 
                 if FpxUI.USE_MODEL_FILTER_REFLECTION in self.use_model_filter:
@@ -364,6 +368,7 @@
                         if 'FINISHED' in ops.import_scene.ms3d(filepath=model_filepath, use_animation=False):
                             remove_material(blender_context)
                             if not self.keep_name:
+                                src_name = get_object_src_name(blender_context)
                                 rename_active_ms3d(blender_context, src_name, model_name, "reflection")
 
                 if FpxUI.USE_MODEL_FILTER_COLLISION in self.use_model_filter:
@@ -393,7 +398,6 @@
                     pass
 
 
-
 ###############################################################################
 class FplImporter():
     """ Load a Future Pinball Library FPL File """
@@ -1140,6 +1144,7 @@
                     node_i1 = nodes.new('ShaderNodeMaterial')
                     node_i1.material = blender_material
                     link_i1_0 = links.new(node_i1.outputs['Color'], node_i0.inputs['Color'])
+                    link_i1_0 = links.new(node_i1.outputs['Alpha'], node_i0.inputs['Alpha'])
                     node_i1_height = 410.0 # issue: [#37075] the height of nodes are always 100.0
                     node_i1.location = (0.0, node_i1_height + gap)
                     node_i0.location = (node_i1.location.x + node_i1.width + gap, node_i1_height + gap)
@@ -1230,6 +1235,7 @@
             node_i1 = nodes.new('ShaderNodeMaterial')
             node_i1.material = blender_material
             link_i1_0 = links.new(node_i1.outputs['Color'], node_i0.inputs['Color'])
+            link_i1_0 = links.new(node_i1.outputs['Alpha'], node_i0.inputs['Alpha'])
             node_i1_height = 410.0 # issue: [#37075] the height of nodes are always 100.0
             node_i1.location = (0.0, node_i1_height + gap)
             node_i0.location = (node_i1.location.x + node_i1.width + gap, node_i1_height + gap)
@@ -1255,7 +1261,7 @@
         if not blender_object.data.materials.get(bm_name):
             blender_object.data.materials.append(blender_material)
 
-    def append_christal_material(self, blender_object, color=(0.5, 0.5, 0.5, 1.0)):
+    def append_christal_material(self, blender_object, color=(0.9, 0.9, 0.9, 1.0)):
         if not blender_object:
             return
         if blender_object.type not in {'MESH', 'CURVE', }:
@@ -1298,6 +1304,7 @@
             node_i1 = nodes.new('ShaderNodeMaterial')
             node_i1.material = blender_material
             link_i1_0 = links.new(node_i1.outputs['Color'], node_i0.inputs['Color'])
+            link_i1_0 = links.new(node_i1.outputs['Alpha'], node_i0.inputs['Alpha'])
             node_i1_height = 410.0 # issue: [#37075] the height of nodes are always 100.0
             node_i1.location = (0.0, node_i1_height + gap)
             node_i0.location = (node_i1.location.x + node_i1.width + gap, node_i1_height + gap)
@@ -1357,6 +1364,7 @@
             node_i1 = nodes.new('ShaderNodeMaterial')
             node_i1.material = blender_material
             link_i1_0 = links.new(node_i1.outputs['Color'], node_i0.inputs['Color'])
+            link_i1_0 = links.new(node_i1.outputs['Alpha'], node_i0.inputs['Alpha'])
             node_i1_height = 410.0 # issue: [#37075] the height of nodes are always 100.0
             node_i1.location = (0.0, node_i1_height + gap)
             node_i0.location = (node_i1.location.x + node_i1.width + gap, node_i1_height + gap)
@@ -3161,6 +3169,18 @@
         image.user_clear()
         blender_data.images.remove(image)
 
+def get_object_src_name(blender_context):
+    name = blender_context.active_object.name
+    src_ext = "ms3d"
+    index = name.rfind(".{}.".format(src_ext))
+    if index < 0:
+        index = name.rfind(".")
+        #if index < 0:
+        #    return
+
+    src_name = "{}.{}".format(name[:index], src_ext)
+    return src_name
+
 def rename_active_ms3d(blender_context, src_name, dst_name, dst_type=None):
     #print("#DEBUG rename_active_ms3d >", blender_context.active_object, src_name, dst_name, dst_type)
     if not blender_context.active_object:
@@ -3188,34 +3208,34 @@
     dst_group_name = FpxUtilities.toGoodName(FORMAT_GROUP.format(dst_name))
 
     obj = blender_context.blend_data.objects.get(src_empty_object_name)
-    if obj:
+    if obj and not blender_context.blend_data.objects.get(dst_empty_object_name):
         obj.name = dst_empty_object_name
 

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list