[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3954] trunk/py/scripts/addons/ io_scene_obj/export_obj.py: patch [#32914] wavefront (.obj) export
Campbell Barton
ideasman42 at gmail.com
Mon Nov 12 03:03:36 CET 2012
Revision: 3954
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3954
Author: campbellbarton
Date: 2012-11-12 02:03:34 +0000 (Mon, 12 Nov 2012)
Log Message:
-----------
patch [#32914] wavefront (.obj) export
from dan grauer (kromar)
With change use_map_color_emission (which is for volumetrics only) to use_map_emit.
also ignore generated face-images (which have no file path).
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 2012-11-12 01:34:18 UTC (rev 3953)
+++ trunk/py/scripts/addons/io_scene_obj/export_obj.py 2012-11-12 02:03:34 UTC (rev 3954)
@@ -61,7 +61,7 @@
# Get the Blender data for the material and the image.
# Having an image named None will make a bug, dont do it :)
- fw('newmtl %s\n' % mtl_mat_name) # Define a new material: matname_imgname
+ fw('\nnewmtl %s\n' % mtl_mat_name) # Define a new material: matname_imgname
if mat:
# convert from blenders spec to 0 - 1000 range.
@@ -100,9 +100,16 @@
# Write images!
if face_img: # We have an image on the face!
- # write relative image path
- rel = bpy_extras.io_utils.path_reference(face_img.filepath, source_dir, dest_dir, path_mode, "", copy_set, face_img.library)
- fw('map_Kd %s\n' % rel) # Diffuse mapping image
+ filepath = face_img.filepath
+ if filepath: # may be '' for generated images
+ # write relative image path
+ filepath = bpy_extras.io_utils.path_reference(filepath, source_dir, dest_dir,
+ path_mode, "", copy_set, face_img.library)
+ fw('map_Kd %s\n' % filepath) # Diffuse mapping image
+ del filepath
+ else:
+ # so we write the materials image.
+ face_img = None
if mat: # No face image. if we havea material search for MTex image.
image_map = {}
@@ -112,27 +119,40 @@
image = mtex.texture.image
if image:
# texface overrides others
- if mtex.use_map_color_diffuse and face_img is None:
+ if (mtex.use_map_color_diffuse and
+ (face_img is None) and
+ (mtex.use_map_warp is False) and
+ (mtex.texture_coords != 'REFLECTION')):
image_map["map_Kd"] = image
if mtex.use_map_ambient:
image_map["map_Ka"] = image
+ # this is the Spec intensity channel but Ks stands for specular Color
+ '''
if mtex.use_map_specular:
image_map["map_Ks"] = image
+ '''
+ if mtex.use_map_color_spec: # specular color
+ image_map["map_Ks"] = image
+ if mtex.use_map_hardness: # specular hardness/glossiness
+ image_map["map_Ns"] = 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:
+ if mtex.use_map_normal and (texture.use_normal_map is True):
image_map["map_Bump"] = image
- if mtex.use_map_hardness:
- image_map["map_Ns"] = image
+ if mtex.use_map_normal and (texture.use_normal_map is False):
+ image_map["map_Disp"] = image
+ if mtex.use_map_color_diffuse and (mtex.texture_coords == 'REFLECTION'):
+ image_map["map_refl"] = image
+ if mtex.use_map_emit:
+ image_map["map_Ke"] = image
for key, image in image_map.items():
- filepath = bpy_extras.io_utils.path_reference(image.filepath, source_dir, dest_dir, path_mode, "", copy_set, image.library)
+ filepath = bpy_extras.io_utils.path_reference(image.filepath, source_dir, dest_dir,
+ path_mode, "", copy_set, image.library)
fw('%s %s\n' % (key, repr(filepath)[1:-1]))
- fw('\n\n')
-
file.close()
More information about the Bf-extensions-cvs
mailing list