[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1750] trunk/py/scripts/addons/ io_scene_obj/export_obj.py: fix [#26643] [obj export] mp_bump in .mtl file
Campbell Barton
ideasman42 at gmail.com
Tue Mar 29 17:12:44 CEST 2011
Revision: 1750
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=1750
Author: campbellbarton
Date: 2011-03-29 15:12:43 +0000 (Tue, 29 Mar 2011)
Log Message:
-----------
fix [#26643] [obj export] mp_bump in .mtl file
Modified Paths:
--------------
trunk/py/scripts/addons/io_scene_obj/export_obj.py
Modified: trunk/py/scripts/addons/io_scene_obj/export_obj.py
===================================================================
--- trunk/py/scripts/addons/io_scene_obj/export_obj.py 2011-03-29 14:13:04 UTC (rev 1749)
+++ trunk/py/scripts/addons/io_scene_obj/export_obj.py 2011-03-29 15:12:43 UTC (rev 1750)
@@ -111,17 +111,31 @@
# file.write('map_Kd %s\n' % img.filepath.split('\\')[-1].split('/')[-1]) # Diffuse mapping image
elif mat: # No face image. if we havea material search for MTex image.
- for mtex in mat.texture_slots:
+ image_map = {}
+ # backwards so topmost are highest priority
+ for mtex in reversed(mat.texture_slots):
if mtex and mtex.texture.type == 'IMAGE':
- try:
- filepath = copy_image(mtex.texture.image)
-# filepath = mtex.texture.image.filepath.split('\\')[-1].split('/')[-1]
- file.write('map_Kd %s\n' % repr(filepath)[1:-1]) # Diffuse mapping image
- break
- except:
- # Texture has no image though its an image type, best ignore.
- pass
+ image = mtex.texture.image
+ if image:
+ if mtex.use_map_ambient:
+ image_map["map_Ka"] = image
+ if mtex.use_map_color_diffuse:
+ image_map["map_Kd"] = image
+ if mtex.use_map_specular:
+ image_map["map_Ks"] = image
+ if mtex.use_map_alpha:
+ image_map["map_d"] = image
+ if mtex.use_map_translucency:
+ image_map["map_Tr"] = image
+ if mtex.use_map_normal:
+ image_map["map_Bump"] = image
+ if mtex.use_map_hardness:
+ image_map["map_Ns"] = image
+ for key, image in image_map.items():
+ filepath = copy_image(image)
+ file.write('%s %s\n' % (key, repr(filepath)[1:-1]))
+
file.write('\n\n')
file.close()
More information about the Bf-extensions-cvs
mailing list