[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4070] tags/2_65a_release/py/scripts/ addons/io_scene_obj: merge fixes 4034 4053
Campbell Barton
ideasman42 at gmail.com
Wed Dec 19 11:38:04 CET 2012
Revision: 4070
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4070
Author: campbellbarton
Date: 2012-12-19 10:38:02 +0000 (Wed, 19 Dec 2012)
Log Message:
-----------
merge fixes 4034 4053
Modified Paths:
--------------
tags/2_65a_release/py/scripts/addons/io_scene_obj/export_obj.py
tags/2_65a_release/py/scripts/addons/io_scene_obj/import_obj.py
Modified: tags/2_65a_release/py/scripts/addons/io_scene_obj/export_obj.py
===================================================================
--- tags/2_65a_release/py/scripts/addons/io_scene_obj/export_obj.py 2012-12-19 10:22:26 UTC (rev 4069)
+++ tags/2_65a_release/py/scripts/addons/io_scene_obj/export_obj.py 2012-12-19 10:38:02 UTC (rev 4070)
@@ -79,7 +79,7 @@
fw('Ni %.6f\n' % mat.ior) # Refraction index
else:
fw('Ni %.6f\n' % 1.0)
- fw('d %.6f\n' % (1.0 - mat.alpha)) # Alpha (obj uses 'd' for dissolve)
+ fw('d %.6f\n' % mat.alpha) # Alpha (obj uses 'd' for dissolve)
# 0 to disable lighting, 1 for ambient & diffuse only (specular color set to black), 2 for full lighting.
if mat.use_shadeless:
Modified: tags/2_65a_release/py/scripts/addons/io_scene_obj/import_obj.py
===================================================================
--- tags/2_65a_release/py/scripts/addons/io_scene_obj/import_obj.py 2012-12-19 10:22:26 UTC (rev 4069)
+++ tags/2_65a_release/py/scripts/addons/io_scene_obj/import_obj.py 2012-12-19 10:38:02 UTC (rev 4070)
@@ -74,6 +74,7 @@
assign colors and images to the materials from all referenced material libs
"""
DIR = os.path.dirname(filepath)
+ context_material_vars = set()
#==================================================================================#
# This function sets textures defined in .mtl file #
@@ -109,7 +110,8 @@
texture.use_interpolation = True
texture.use_alpha = True
blender_material.use_transparency = True
- blender_material.alpha = 0.0
+ if "alpha" not in context_material_vars:
+ blender_material.alpha = 0.0
blender_material.game_settings.alpha_blend = 'ALPHA'
else:
@@ -155,7 +157,8 @@
mtex.use_map_alpha = True
blender_material.use_transparency = True
blender_material.transparency_method = 'Z_TRANSPARENCY'
- blender_material.alpha = 0.0
+ if "alpha" not in context_material_vars:
+ blender_material.alpha = 0.0
# Todo, unset deffuse material alpha if it has an alpha channel
elif type == 'refl':
@@ -200,6 +203,7 @@
elif line.startswith(b'newmtl'):
context_material_name = line_value(line.split())
context_material = unique_materials.get(context_material_name)
+ context_material_vars.clear()
elif context_material:
# we need to make a material to assign properties to it.
@@ -215,10 +219,12 @@
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_func(line_split[1]), 3)) # between 1 and 3
+ context_material_vars.add("ior")
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
context_material.translucency = float_func(line_split[1])
elif line_lower.startswith(b'tf'):
@@ -305,10 +311,12 @@
if do_transparency:
context_material.use_transparency = True
context_material.transparency_method = 'RAYTRACE' if do_raytrace else 'Z_TRANSPARENCY'
- context_material.alpha = 0.0
+ if "alpha" not in context_material_vars:
+ context_material.alpha = 0.0
if do_glass:
- context_material.raytrace_transparency.ior = 1.5
+ if "ior" not in context_material_vars:
+ context_material.raytrace_transparency.ior = 1.5
if do_fresnel:
context_material.raytrace_mirror.fresnel = 1.0 # could be any value for 'ON'
@@ -1163,15 +1171,3 @@
print("finished importing: %r in %.4f sec." % (filepath, (time_new - time_main)))
return {'FINISHED'}
-
-
-# NOTES (all line numbers refer to 2.4x import_obj.py, not this file)
-# check later: line 489
-# can convert now: edge flags, edges: lines 508-528
-# ngon (uses python module BPyMesh): 384-414
-# NEXT clamp size: get bound box with RNA
-# get back to l 140 (here)
-# search image in bpy.config.textureDir - load_image
-# replaced BPyImage.comprehensiveImageLoad with a simplified version that only checks additional directory specified, but doesn't search dirs recursively (obj_image_load)
-# bitmask won't work? - 132
-# uses bpy.sys.time()
More information about the Bf-extensions-cvs
mailing list