Skip to content
Snippets Groups Projects
Commit 7af50e62 authored by Danilo Bargen's avatar Danilo Bargen Committed by Bastien Montagne
Browse files

OBJ import/export cleanup.

Reviewers: mont29

Projects: #import_export

Differential Revision: https://developer.blender.org/D1151
parent 4110b333
No related branches found
No related tags found
No related merge requests found
...@@ -99,7 +99,7 @@ def write_mtl(scene, filepath, path_mode, copy_set, mtl_dict): ...@@ -99,7 +99,7 @@ def write_mtl(scene, filepath, path_mode, copy_set, mtl_dict):
fw('illum 2\n') # light normaly fw('illum 2\n') # light normaly
else: else:
#write a dummy material here? # Write a dummy material here?
fw('Ns 0\n') fw('Ns 0\n')
fw('Ka %.6f %.6f %.6f\n' % world_amb[:]) # Ambient, uses mirror color, fw('Ka %.6f %.6f %.6f\n' % world_amb[:]) # Ambient, uses mirror color,
fw('Kd 0.8 0.8 0.8\n') fw('Kd 0.8 0.8 0.8\n')
...@@ -151,7 +151,7 @@ def write_mtl(scene, filepath, path_mode, copy_set, mtl_dict): ...@@ -151,7 +151,7 @@ def write_mtl(scene, filepath, path_mode, copy_set, mtl_dict):
if mtex.use_map_normal: if mtex.use_map_normal:
image_map["map_Bump"] = image image_map["map_Bump"] = image
if mtex.use_map_displacement: if mtex.use_map_displacement:
image_map["disp"] = image image_map["disp"] = image
if mtex.use_map_color_diffuse and (mtex.texture_coords == 'REFLECTION'): if mtex.use_map_color_diffuse and (mtex.texture_coords == 'REFLECTION'):
image_map["refl"] = image image_map["refl"] = image
if mtex.use_map_emit: if mtex.use_map_emit:
...@@ -611,7 +611,6 @@ def write_file(filepath, objects, scene, ...@@ -611,7 +611,6 @@ def write_file(filepath, objects, scene,
fw('s off\n') fw('s off\n')
contextSmooth = f_smooth contextSmooth = f_smooth
#f_v = [(vi, me_verts[v_idx]) for vi, v_idx in enumerate(f.vertices)]
f_v = [(vi, me_verts[v_idx], l_idx) for vi, (v_idx, l_idx) in enumerate(zip(f.vertices, f.loop_indices))] f_v = [(vi, me_verts[v_idx], l_idx) for vi, (v_idx, l_idx) in enumerate(zip(f.vertices, f.loop_indices))]
fw('f') fw('f')
......
...@@ -36,13 +36,13 @@ import os ...@@ -36,13 +36,13 @@ import os
import time import time
import bpy import bpy
import mathutils import mathutils
from bpy_extras.io_utils import unpack_list, unpack_face_list from bpy_extras.io_utils import unpack_list
from bpy_extras.image_utils import load_image from bpy_extras.image_utils import load_image
def line_value(line_split): def line_value(line_split):
""" """
Returns 1 string represneting the value for this line Returns 1 string representing the value for this line
None will be returned if theres only 1 word None will be returned if theres only 1 word
""" """
length = len(line_split) length = len(line_split)
...@@ -79,11 +79,10 @@ def create_materials(filepath, relpath, ...@@ -79,11 +79,10 @@ def create_materials(filepath, relpath,
DIR = os.path.dirname(filepath) DIR = os.path.dirname(filepath)
context_material_vars = set() context_material_vars = set()
#==================================================================================#
# This function sets textures defined in .mtl file #
#==================================================================================#
def load_material_image(blender_material, context_material_name, imagepath, type): def load_material_image(blender_material, context_material_name, imagepath, type):
"""
Set textures defined in .mtl file.
"""
texture = bpy.data.textures.new(name=type, type='IMAGE') texture = bpy.data.textures.new(name=type, type='IMAGE')
# Absolute path - c:\.. etc would work here # Absolute path - c:\.. etc would work here
...@@ -165,7 +164,7 @@ def create_materials(filepath, relpath, ...@@ -165,7 +164,7 @@ def create_materials(filepath, relpath,
material_libs.append(temp_mtl) material_libs.append(temp_mtl)
del temp_mtl del temp_mtl
#Create new materials # Create new materials
for name in unique_materials: # .keys() for name in unique_materials: # .keys()
if name is not None: if name is not None:
unique_materials[name] = bpy.data.materials.new(name.decode('utf-8', "replace")) unique_materials[name] = bpy.data.materials.new(name.decode('utf-8', "replace"))
...@@ -178,7 +177,7 @@ def create_materials(filepath, relpath, ...@@ -178,7 +177,7 @@ def create_materials(filepath, relpath,
# print(libname) # print(libname)
mtlpath = os.path.join(DIR, libname) mtlpath = os.path.join(DIR, libname)
if not os.path.exists(mtlpath): if not os.path.exists(mtlpath):
print ("\tMaterial not found MTL: %r" % mtlpath) print("\tMaterial not found MTL: %r" % mtlpath)
else: else:
#print('\t\tloading mtl: %e' % mtlpath) #print('\t\tloading mtl: %e' % mtlpath)
context_material = None context_material = None
...@@ -1070,7 +1069,6 @@ def load(operator, context, filepath, ...@@ -1070,7 +1069,6 @@ def load(operator, context, filepath,
bpy.ops.object.select_all(action='DESELECT') bpy.ops.object.select_all(action='DESELECT')
scene = context.scene scene = context.scene
# scn.objects.selected = []
new_objects = [] # put new objects here new_objects = [] # put new objects here
print('\tbuilding geometry...\n\tverts:%i faces:%i materials: %i smoothgroups:%i ...' % print('\tbuilding geometry...\n\tverts:%i faces:%i materials: %i smoothgroups:%i ...' %
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment