Skip to content
Snippets Groups Projects
Commit df3640b0 authored by Bastien Montagne's avatar Bastien Montagne
Browse files

Fix T43116: Obj/mtl displace texture import error.

startswith('d') is too generic, matches 'disp' lines too...
So added space after expected keyword in all case.
parent 468a9845
No related branches found
No related tags found
No related merge requests found
......@@ -214,28 +214,28 @@ def create_materials(filepath, relpath,
# we need to make a material to assign properties to it.
line_split = line.split()
line_lower = line.lower().lstrip()
if line_lower.startswith(b'ka'):
if line_lower.startswith(b'ka '):
context_material.mirror_color = float_func(line_split[1]), float_func(line_split[2]), float_func(line_split[3])
elif line_lower.startswith(b'kd'):
elif line_lower.startswith(b'kd '):
context_material.diffuse_color = float_func(line_split[1]), float_func(line_split[2]), float_func(line_split[3])
elif line_lower.startswith(b'ks'):
elif line_lower.startswith(b'ks '):
context_material.specular_color = float_func(line_split[1]), float_func(line_split[2]), float_func(line_split[3])
elif line_lower.startswith(b'ns'):
elif line_lower.startswith(b'ns '):
context_material.specular_hardness = int((float_func(line_split[1]) * 0.51))
elif line_lower.startswith(b'ni'): # Refraction index
elif line_lower.startswith(b'ni '): # Refraction index
context_material.raytrace_transparency.ior = max(1, min(float_func(line_split[1]), 3)) # between 1 and 3
context_material_vars.add("ior")
elif line_lower.startswith(b'd'): # dissolve (trancparency)
elif line_lower.startswith(b'd '): # dissolve (trancparency)
context_material.alpha = float_func(line_split[1])
context_material.use_transparency = True
context_material.transparency_method = 'Z_TRANSPARENCY'
context_material_vars.add("alpha")
elif line_lower.startswith(b'tr'): # trancelucency
elif line_lower.startswith(b'tr '): # trancelucency
context_material.translucency = float_func(line_split[1])
elif line_lower.startswith(b'tf'):
elif line_lower.startswith(b'tf '):
# rgb, filter color, blender has no support for this.
pass
elif line_lower.startswith(b'illum'):
elif line_lower.startswith(b'illum '):
illum = int(line_split[1])
do_ambient = True
......@@ -336,33 +336,33 @@ def create_materials(filepath, relpath,
# written when raytracing wasnt default, annoying to disable for blender users.
context_material.use_raytrace = True
elif line_lower.startswith(b'map_ka'):
elif line_lower.startswith(b'map_ka '):
img_filepath = line_value(line.split())
if img_filepath:
load_material_image(context_material, context_material_name, img_filepath, 'Ka')
elif line_lower.startswith(b'map_ks'):
elif line_lower.startswith(b'map_ks '):
img_filepath = line_value(line.split())
if img_filepath:
load_material_image(context_material, context_material_name, img_filepath, 'Ks')
elif line_lower.startswith(b'map_kd'):
elif line_lower.startswith(b'map_kd '):
img_filepath = line_value(line.split())
if img_filepath:
load_material_image(context_material, context_material_name, img_filepath, 'Kd')
elif line_lower.startswith((b'map_bump', b'bump')): # 'bump' is incorrect but some files use it.
elif line_lower.startswith((b'map_bump ', b'bump ')): # 'bump' is incorrect but some files use it.
img_filepath = line_value(line.split())
if img_filepath:
load_material_image(context_material, context_material_name, img_filepath, 'Bump')
elif line_lower.startswith((b'map_d', b'map_tr')): # Alpha map - Dissolve
elif line_lower.startswith((b'map_d ', b'map_tr ')): # Alpha map - Dissolve
img_filepath = line_value(line.split())
if img_filepath:
load_material_image(context_material, context_material_name, img_filepath, 'D')
elif line_lower.startswith((b'map_disp', b'disp')): # reflectionmap
elif line_lower.startswith((b'map_disp ', b'disp ')): # displacementmap
img_filepath = line_value(line.split())
if img_filepath:
load_material_image(context_material, context_material_name, img_filepath, 'disp')
elif line_lower.startswith((b'map_refl', b'refl')): # reflectionmap
elif line_lower.startswith((b'map_refl ', b'refl ')): # reflectionmap
img_filepath = line_value(line.split())
if img_filepath:
load_material_image(context_material, context_material_name, img_filepath, 'refl')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment