208
209
context_material.setAlpha(float(line_split[1]))
209
210
elif line_lower.startswith('map_ka'):
210
211
img_filepath= line_value(line.split())
211
load_material_image(context_material, context_material_name, img_filepath, 'Ka')
213
load_material_image(context_material, context_material_name, img_filepath, 'Ka')
212
214
elif line_lower.startswith('map_ks'):
213
215
img_filepath= line_value(line.split())
214
load_material_image(context_material, context_material_name, img_filepath, 'Ks')
217
load_material_image(context_material, context_material_name, img_filepath, 'Ks')
215
218
elif line_lower.startswith('map_kd'):
216
219
img_filepath= line_value(line.split())
217
load_material_image(context_material, context_material_name, img_filepath, 'Kd')
221
load_material_image(context_material, context_material_name, img_filepath, 'Kd')
218
222
elif line_lower.startswith('map_bump'):
219
223
img_filepath= line_value(line.split())
220
load_material_image(context_material, context_material_name, img_filepath, 'Bump')
225
load_material_image(context_material, context_material_name, img_filepath, 'Bump')
221
226
elif line_lower.startswith('map_d') or line_lower.startswith('map_tr'): # Alpha map - Dissolve
222
227
img_filepath= line_value(line.split())
223
load_material_image(context_material, context_material_name, img_filepath, 'D')
229
load_material_image(context_material, context_material_name, img_filepath, 'D')
225
231
elif line_lower.startswith('refl'): # Reflectionmap
226
232
img_filepath= line_value(line.split())
227
load_material_image(context_material, context_material_name, img_filepath, 'refl')
234
load_material_image(context_material, context_material_name, img_filepath, 'refl')
233
def split_mesh(verts_loc, faces, unique_materials, filepath, SPLIT_OBJECTS, SPLIT_MATERIALS):
240
def split_mesh(verts_loc, faces, unique_materials, filepath, SPLIT_OB_OR_GROUP, SPLIT_MATERIALS):
235
242
Takes vert_loc and faces, and seperates into multiple sets of
236
243
(verts_loc, faces, unique_materials, dataname)
313
320
return [(value[0], value[1], value[2], key_to_name(key)) for key, value in face_split_dict.iteritems()]
316
def create_mesh(new_objects, has_ngons, CREATE_FGONS, CREATE_EDGES, verts_loc, verts_tex, faces, unique_materials, unique_material_images, unique_smooth_groups, dataname):
323
def create_mesh(scn, new_objects, has_ngons, CREATE_FGONS, CREATE_EDGES, verts_loc, verts_tex, faces, unique_materials, unique_material_images, unique_smooth_groups, dataname):
318
325
Takes all the data gathered and generates a mesh, adding the new object to new_objects
319
326
deals with fgons, sharp edges and assigning materials
704
Scene.GetCurrent().objects.selected = []
709
scn = bpy.data.scenes.active
710
scn.objects.selected = []
705
711
new_objects= [] # put new objects here
707
713
print '\tbuilding geometry...\n\tverts:%i faces:%i materials: %i smoothgroups:%i ...' % ( len(verts_loc), len(faces), len(unique_materials), len(unique_smooth_groups) ),
708
714
# Split the mesh by objects/materials, may
709
for verts_loc_split, faces_split, unique_materials_split, dataname in split_mesh(verts_loc, faces, unique_materials, filepath, SPLIT_OBJECTS, SPLIT_MATERIALS):
715
if SPLIT_OBJECTS or SPLIT_GROUPS: SPLIT_OB_OR_GROUP = True
716
else: SPLIT_OB_OR_GROUP = False
718
for verts_loc_split, faces_split, unique_materials_split, dataname in split_mesh(verts_loc, faces, unique_materials, filepath, SPLIT_OB_OR_GROUP, SPLIT_MATERIALS):
710
719
# Create meshes from the data
711
create_mesh(new_objects, has_ngons, CREATE_FGONS, CREATE_EDGES, verts_loc_split, verts_tex, faces_split, unique_materials_split, unique_material_images, unique_smooth_groups, dataname)
720
create_mesh(scn, new_objects, has_ngons, CREATE_FGONS, CREATE_EDGES, verts_loc_split, verts_tex, faces_split, unique_materials_split, unique_material_images, unique_smooth_groups, dataname)
713
722
axis_min= [ 1000000000]*3
714
723
axis_max= [-1000000000]*3
762
771
('Smooth Groups', CREATE_SMOOTH_GROUPS, 'Surround smooth groups by sharp edges'),\
763
772
('Create FGons', CREATE_FGONS, 'Import faces with more then 4 verts as fgons.'),\
764
773
('Lines', CREATE_EDGES, 'Import lines and faces with 2 verts as edges'),\
765
'Seperate objects from obj...',\
774
'Separate objects from obj...',\
766
775
('Object', SPLIT_OBJECTS, 'Import OBJ Objects into Blender Objects'),\
767
776
('Group', SPLIT_GROUPS, 'Import OBJ Groups into Blender Objects'),\
768
777
('Material', SPLIT_MATERIALS, 'Import each material into a seperate mesh (Avoids > 16 per mesh error)'),\