From 97b83344a739a446f13e6de2c8cddb218095b94b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 23 Nov 2011 21:23:04 +0000 Subject: fix [#29375] Obj Import fails --- io_scene_obj/import_obj.py | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/io_scene_obj/import_obj.py b/io_scene_obj/import_obj.py index ae3b87a2..b5d70de7 100644 --- a/io_scene_obj/import_obj.py +++ b/io_scene_obj/import_obj.py @@ -55,35 +55,17 @@ def line_value(line_split): return b' '.join(line_split[1:]) -def obj_image_load(imagepath, DIR, use_image_search): +def obj_image_load(imagepath, DIR, recursive): + ''' + Mainly uses comprehensiveImageLoad + but tries to replace '_' with ' ' for Max's exporter replaces spaces with underscores. + ''' if b'_' in imagepath: - image = load_image(imagepath.replace(b'_', b' '), DIR) + image = load_image(imagepath.replace(b'_', b' '), DIR, recursive=recursive) if image: return image - image = load_image(imagepath, DIR) - if image: - return image - - print("failed to load %r doesn't exist" % imagepath) - return None - -# def obj_image_load(imagepath, DIR, use_image_search): -# ''' -# Mainly uses comprehensiveImageLoad -# but tries to replace '_' with ' ' for Max's exporter replaces spaces with underscores. -# ''' - -# if '_' in imagepath: -# image= BPyImage.comprehensiveImageLoad(imagepath, DIR, PLACE_HOLDER= False, RECURSIVE= use_image_search) -# if image: return image -# # Did the exporter rename the image? -# image= BPyImage.comprehensiveImageLoad(imagepath.replace('_', ' '), DIR, PLACE_HOLDER= False, RECURSIVE= use_image_search) -# if image: return image - -# # Return an image, placeholder if it dosnt exist -# image= BPyImage.comprehensiveImageLoad(imagepath, DIR, PLACE_HOLDER= True, RECURSIVE= use_image_search) -# return image + return load_image(imagepath, DIR, recursive=recursive, place_holder=True) def create_materials(filepath, material_libs, unique_materials, unique_material_images, use_image_search): @@ -124,6 +106,8 @@ def create_materials(filepath, material_libs, unique_materials, unique_material_ texture.use_alpha = True blender_material.use_transparency = True blender_material.alpha = 0.0 + + blender_material.game_settings.alpha_blend = 'ALPHA' else: mtex = blender_material.texture_slots.add() mtex.texture = texture @@ -619,8 +603,6 @@ def create_mesh(new_objects, image, has_data = unique_material_images[context_material] if image: # Can be none if the material dosnt have an image. blender_tface.image = image - if has_data and image.depth == 32: - blender_tface.alpha_blend = 'ALPHA' # BUG - Evil eekadoodle problem where faces that have vert index 0 location at 3 or 4 are shuffled. if len(face_vert_loc_indices) == 4: -- cgit v1.2.3