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:
authorCampbell Barton <ideasman42@gmail.com>2012-11-12 06:03:34 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-11-12 06:03:34 +0400
commit24cebd7bedd20af91427426f0d2e52606e732014 (patch)
tree886944421828851f66ef9bf80ef2e9247f0e0c7c /io_scene_obj
parent896011aebe86beb164c53a4ad88220e9c33adef9 (diff)
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).
Diffstat (limited to 'io_scene_obj')
-rw-r--r--io_scene_obj/export_obj.py42
1 files changed, 31 insertions, 11 deletions
diff --git a/io_scene_obj/export_obj.py b/io_scene_obj/export_obj.py
index a5b00e8e..55d34069 100644
--- a/io_scene_obj/export_obj.py
+++ b/io_scene_obj/export_obj.py
@@ -61,7 +61,7 @@ def write_mtl(scene, filepath, path_mode, copy_set, mtl_dict):
# 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 @@ def write_mtl(scene, filepath, path_mode, copy_set, mtl_dict):
# 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 @@ def write_mtl(scene, filepath, path_mode, copy_set, mtl_dict):
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()