[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3861] trunk/py/scripts/addons/ io_scene_obj/import_obj.py: OBJ now reads MTL using the float_func(), so materials can use commas in floating point values too.
Campbell Barton
ideasman42 at gmail.com
Mon Oct 15 22:21:48 CEST 2012
Revision: 3861
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3861
Author: campbellbarton
Date: 2012-10-15 20:21:41 +0000 (Mon, 15 Oct 2012)
Log Message:
-----------
OBJ now reads MTL using the float_func(), so materials can use commas in floating point values too.
Modified Paths:
--------------
trunk/py/scripts/addons/io_scene_obj/import_obj.py
Modified: trunk/py/scripts/addons/io_scene_obj/import_obj.py
===================================================================
--- trunk/py/scripts/addons/io_scene_obj/import_obj.py 2012-10-15 18:04:03 UTC (rev 3860)
+++ trunk/py/scripts/addons/io_scene_obj/import_obj.py 2012-10-15 20:21:41 UTC (rev 3861)
@@ -68,7 +68,7 @@
return load_image(imagepath, DIR, recursive=recursive, place_holder=True)
-def create_materials(filepath, material_libs, unique_materials, unique_material_images, use_image_search):
+def create_materials(filepath, material_libs, unique_materials, unique_material_images, use_image_search, float_func):
"""
Create all the used materials in this obj,
assign colors and images to the materials from all referenced material libs
@@ -203,17 +203,17 @@
line_split = line.split()
line_lower = line.lower().lstrip()
if line_lower.startswith(b'ka'):
- context_material.mirror_color = float(line_split[1]), float(line_split[2]), float(line_split[3])
+ 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'):
- context_material.diffuse_color = float(line_split[1]), float(line_split[2]), float(line_split[3])
+ 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'):
- context_material.specular_color = float(line_split[1]), float(line_split[2]), float(line_split[3])
+ 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'):
- context_material.specular_hardness = int((float(line_split[1]) * 0.51))
+ context_material.specular_hardness = int((float_func(line_split[1]) * 0.51))
elif line_lower.startswith(b'ni'): # Refraction index
- context_material.raytrace_transparency.ior = max(1, min(float(line_split[1]), 3)) # between 1 and 3
+ context_material.raytrace_transparency.ior = max(1, min(float_func(line_split[1]), 3)) # between 1 and 3
elif line_lower.startswith((b'd', b'tr')):
- context_material.alpha = float(line_split[1])
+ context_material.alpha = float_func(line_split[1])
context_material.use_transparency = True
context_material.transparency_method = 'Z_TRANSPARENCY'
elif line_lower.startswith(b'tf'):
@@ -1080,7 +1080,7 @@
time_sub = time_new
print('\tloading materials and images...')
- create_materials(filepath, material_libs, unique_materials, unique_material_images, use_image_search)
+ create_materials(filepath, material_libs, unique_materials, unique_material_images, use_image_search, float_func)
time_new = time.time()
print("%.4f sec" % (time_new - time_sub))
More information about the Bf-extensions-cvs
mailing list