Bugfix for [#23676] Obj Import fails again.
authorThomas Dinges <blender@dingto.org>
Sat, 4 Sep 2010 11:11:37 +0000 (11:11 +0000)
committerThomas Dinges <blender@dingto.org>
Sat, 4 Sep 2010 11:11:37 +0000 (11:11 +0000)
release/scripts/op/io_scene_obj/import_obj.py

index 73b5484ff3a8a6c7223ea1182d82d1ad8dc2ea79..a5605d23cb31b9c064cde69ed8270170a0e0e238 100644 (file)
@@ -298,32 +298,52 @@ def create_materials(filepath, material_libs, unique_materials, unique_material_
                 # Image has alpha
 
                 # XXX bitmask won't work?
-                blender_material.add_texture(texture, 'UV', {'COLOR', 'ALPHA'})
+                mtex = blender_material.texture_slots.add()
+                mtex.texture = texture
+                mtex.texture_coords = 'UV'
+                mtex.use_map_color_diffuse = True
+                mtex.use_map_alpha = True
+
                 texture.mipmap = True
                 texture.interpolation = True
                 texture.use_alpha = True
                 blender_material.use_transparency = True
                 blender_material.alpha = 0.0
             else:
-                blender_material.add_texture(texture, 'UV', 'COLOR')
+                mtex = blender_material.texture_slots.add()
+                mtex.texture = texture
+                mtex.texture_coords = 'UV'
+                mtex.use_map_color_diffuse = True
 
             # adds textures to faces (Textured/Alt-Z mode)
             # Only apply the diffuse texture to the face if the image has not been set with the inline usemat func.
             unique_material_images[context_material_name]= image, has_data # set the texface image
 
         elif type == 'Ka':
-            blender_material.add_texture(texture, 'UV', 'AMBIENT')
+            mtex = blender_material.texture_slots.add()
+            mtex.texture = texture
+            mtex.texture_coords = 'UV'
+            mtex.use_map_ambient = True
 #             blender_material.setTexture(1, texture, Texture.TexCo.UV, Texture.MapTo.CMIR) # TODO- Add AMB to BPY API
 
         elif type == 'Ks':
-            blender_material.add_texture(texture, 'UV', 'SPECULARITY')
-#             blender_material.setTexture(2, texture, Texture.TexCo.UV, Texture.MapTo.SPEC)
+            mtex = blender_material.texture_slots.add()
+            mtex.texture = texture
+            mtex.texture_coords = 'UV'
+            mtex.use_map_specular = True
+#           blender_material.setTexture(2, texture, Texture.TexCo.UV, Texture.MapTo.SPEC)
 
         elif type == 'Bump':
-            blender_material.add_texture(texture, 'UV', 'NORMAL')
+            mtex = blender_material.texture_slots.add()
+            mtex.texture = texture
+            mtex.texture_coords = 'UV'
+            mtex.use_map_normal = True
 #             blender_material.setTexture(3, texture, Texture.TexCo.UV, Texture.MapTo.NOR)
         elif type == 'D':
-            blender_material.add_texture(texture, 'UV', 'ALPHA')
+            mtex = blender_material.texture_slots.add()
+            mtex.texture = texture
+            mtex.texture_coords = 'UV'
+            mtex.use_map_alpha = True
             blender_material.z_transparency = True
             blender_material.alpha = 0.0
 #             blender_material.setTexture(4, texture, Texture.TexCo.UV, Texture.MapTo.ALPHA)
@@ -332,7 +352,10 @@ def create_materials(filepath, material_libs, unique_materials, unique_material_
             # Todo, unset deffuse material alpha if it has an alpha channel
 
         elif type == 'refl':
-            blender_material.add_texture(texture, 'UV', 'REFLECTION')
+            mtex = blender_material.texture_slots.add()
+            mtex.texture = texture
+            mtex.texture_coords = 'UV'
+            mtex.use_map_reflect = True
 #             blender_material.setTexture(5, texture, Texture.TexCo.UV, Texture.MapTo.REF)