Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--io_scene_obj/__init__.py2
-rw-r--r--io_scene_obj/import_obj.py21
2 files changed, 15 insertions, 8 deletions
diff --git a/io_scene_obj/__init__.py b/io_scene_obj/__init__.py
index 399a4d29..e121bb66 100644
--- a/io_scene_obj/__init__.py
+++ b/io_scene_obj/__init__.py
@@ -21,7 +21,7 @@
bl_info = {
"name": "Wavefront OBJ format",
"author": "Campbell Barton, Bastien Montagne",
- "version": (3, 7, 0),
+ "version": (3, 8, 0),
"blender": (2, 81, 6),
"location": "File > Import-Export",
"description": "Import-Export OBJ, Import OBJ mesh, UV's, materials and textures",
diff --git a/io_scene_obj/import_obj.py b/io_scene_obj/import_obj.py
index 4d640d44..0c2d6995 100644
--- a/io_scene_obj/import_obj.py
+++ b/io_scene_obj/import_obj.py
@@ -326,23 +326,30 @@ def create_materials(filepath, relpath,
elif context_material:
+ def _get_colors(line_split):
+ # OBJ 'allows' one or two components values, treat single component as greyscale, and two as blue = 0.0.
+ ln = len(line_split)
+ if ln == 2:
+ return [float_func(line_split[1])] * 3
+ elif ln == 3:
+ return [float_func(line_split[1]), float_func(line_split[2]), 0.0]
+ else:
+ return [float_func(line_split[1]), float_func(line_split[2]), float_func(line_split[3])]
+
# we need to make a material to assign properties to it.
if line_id == b'ka':
- refl = (float_func(line_split[1]) + float_func(line_split[2]) + float_func(line_split[3])) / 3.0
+ refl = sum(_get_colors(line_split)) / 3.0
context_mat_wrap.metallic = refl
context_material_vars.add("metallic")
elif line_id == b'kd':
- col = (float_func(line_split[1]), float_func(line_split[2]), float_func(line_split[3]))
- context_mat_wrap.base_color = col
+ context_mat_wrap.base_color = _get_colors(line_split)
elif line_id == b'ks':
- spec_colors[:] = [
- float_func(line_split[1]), float_func(line_split[2]), float_func(line_split[3])]
+ spec_colors[:] = _get_colors(line_split)
context_material_vars.add("specular")
elif line_id == b'ke':
# We cannot set context_material.emit right now, we need final diffuse color as well for this.
# XXX Unsupported currently
- col = (float_func(line_split[1]), float_func(line_split[2]), float_func(line_split[3]))
- context_mat_wrap.emission_color = col
+ context_mat_wrap.emission_color = _get_colors(line_split)
elif line_id == b'ns':
# XXX Totally empirical conversion, trying to adapt it
# (from 0.0 - 900.0 OBJ specular exponent range to 1.0 - 0.0 Principled BSDF range)...