added texture material for cycles render engine
authorAlexander N <alpha-beta-release@gmx.net>
Fri, 23 Aug 2013 23:07:00 +0000 (23:07 +0000)
committerAlexander N <alpha-beta-release@gmx.net>
Fri, 23 Aug 2013 23:07:00 +0000 (23:07 +0000)
io_scene_fpx/__init__.py
io_scene_fpx/fpx_import.py

index 1d007592c82bf4d4106fbad1d7b4a79c695a13e1..4fa4a4e4f0449c9c0b4d4b3b6fa786a596fe3b24 100644 (file)
@@ -34,7 +34,7 @@ bl_info = {
     'name': "Future Pinball FPx format (.fpm/.fpl/.fpt)",
     'description': "Import Future Pinball Model, Library and Table files",
     'author': "Alexander Nussbaumer",
     'name': "Future Pinball FPx format (.fpm/.fpl/.fpt)",
     'description': "Import Future Pinball Model, Library and Table files",
     'author': "Alexander Nussbaumer",
-    'version': (0, 0, 0, '2013-08-23'),
+    'version': (0, 0, 0, '2013-08-24'),
     'blender': (2, 68, 0),
     'location': "File > Import",
     'warning': "",
     'blender': (2, 68, 0),
     'location': "File > Import",
     'warning': "",
index 161778238f23b70721310ed6c2d4669e95af6895..f78b23dcda180db4b6e437c7d537c853799dcc4d 100644 (file)
@@ -933,8 +933,9 @@ class FptImporter():
                     blender_material.use_transparent_shadows = True
                     blender_material.alpha = 0.0
                     render_engine = self.__context.scene.render.engine
                     blender_material.use_transparent_shadows = True
                     blender_material.alpha = 0.0
                     render_engine = self.__context.scene.render.engine
+
                     #blender internal
                     #blender internal
-                    #self.__context.scene.render.engine = 'BLENDER_RENDER'
+                    self.__context.scene.render.engine = 'BLENDER_RENDER'
                     if uv_layer:
                         bt_name = "uv_{}".format(FORMAT_TEXTURE.format(fpx_image_name))
                     else:
                     if uv_layer:
                         bt_name = "uv_{}".format(FORMAT_TEXTURE.format(fpx_image_name))
                     else:
@@ -952,31 +953,49 @@ class FptImporter():
                         tex_slot.uv_layer = uv_layer
                     #blender_material.use_shadeless = True #DEBUG
 
                         tex_slot.uv_layer = uv_layer
                     #blender_material.use_shadeless = True #DEBUG
 
-                    """
                     # blender cycles
                     self.__context.scene.render.engine = 'CYCLES'
                     blender_material.use_nodes = True
                     # blender cycles
                     self.__context.scene.render.engine = 'CYCLES'
                     blender_material.use_nodes = True
-                    blender_material = self.__blend_data.materials.get(blender_material.name)
-                    node_0 = blender_material.node_tree.nodes.new('OUTPUT_MATERIAL')
-                    node_1 = blender_material.node_tree.nodes.new('BSDF_GLOSSY')
-                    node_1.inputs['Roughness'].default_value = 0.25
-                    link1_0 = blender_material.node_tree.links.new(node_1.outputs['BSDF'], node_0.inputs['Surface'])
-                    node_2 = blender_material.node_tree.nodes.new('TEX_IMAGE')
-                    node_2.image = blender_image
-                    link2_1 = blender_material.node_tree.links.new(node_2.outputs['Color'], node_1.inputs['Color'])
-                    node_3 = blender_material.node_tree.nodes.new('TEX_COORD')
+                    nodes = blender_material.node_tree.nodes
+                    links = blender_material.node_tree.links
+                    gap = 50.0
+                    nodes.clear()
+                    node0 = nodes.new('ShaderNodeOutputMaterial')
+                    node1 = nodes.new('ShaderNodeMixShader')
+                    node2 = nodes.new('ShaderNodeBsdfTranslucent')
+                    node2.inputs['Color'].default_value = (1.0, 1.0, 1.0, 1.0)
+                    node3 = nodes.new('ShaderNodeBsdfGlossy')
+                    node3.inputs['Roughness'].default_value = 0.25
+                    node4 = nodes.new('ShaderNodeTexImage')
+                    node4.image = blender_image
+                    node5 = nodes.new('ShaderNodeTexCoord')
+
+                    node5.location = (0.0, 0.0)
+                    node4.location = (node5.location.x + node5.width + gap, 0.0)
+                    node3.location = (node4.location.x + node4.width + gap, 0.0)
+                    node2.location = (node3.location.x + node3.width + gap, 0.0)
+                    node1.location = (node2.location.x + node2.width + gap, 0.0)
+                    node0.location = (node1.location.x + node1.width + gap, 0.0)
+
+                    link1_0 = links.new(node1.outputs['Shader'], node0.inputs['Surface'])
+                    link4_1a = links.new(node4.outputs['Alpha'], node1.inputs[0]) # Fac
+                    link2_1b = links.new(node2.outputs['BSDF'], node1.inputs[1]) # 2'nd Shader
+                    link3_1c = links.new(node3.outputs['BSDF'], node1.inputs[2]) # 1'st Shader
+                    link4_3 = links.new(node4.outputs['Color'], node3.inputs['Color'])
                     if uv_layer:
                     if uv_layer:
-                        out3 = node_3.outputs['UV']
+                        link5_4 = links.new(node5.outputs['UV'], node4.inputs['Vector'])
                     else:
                     else:
-                        out3 = node_3.outputs['Generated']
-                    link3_2 = blender_material.node_tree.links.new(out3, node_2.inputs['Vector'])
+                        link5_4 = links.new(node5.outputs['Generated'], node4.inputs['Vector'])
+                    if render_engine != 'CYCLES':
+                        blender_material.use_nodes = False
 
 
+                    """
                     # blender game
                     self.__context.scene.render.engine = 'BLENDER_GAME'
                     #TODO
                     # blender game
                     self.__context.scene.render.engine = 'BLENDER_GAME'
                     #TODO
+                    """
 
                     self.__context.scene.render.engine = render_engine
 
                     self.__context.scene.render.engine = render_engine
-                    """
 
                 blender_object.data.materials.append(blender_material)
 
 
                 blender_object.data.materials.append(blender_material)