Fixed 3dc->blender workflow and bake tools

This commit is contained in:
Kalle-Samuli Riihikoski 2019-04-25 11:43:28 +03:00
parent 1b3bbeea01
commit 70af85cdc5
2 changed files with 130 additions and 72 deletions

View File

@ -637,13 +637,13 @@ class SCENE_OT_export(bpy.types.Operator):
objekti.coat3D.applink_name = objekti.data.name
mod_mat_list = {}
if (coat3D.bake_textures):
bake_location = folder_objects + os.sep + 'Bake'
if (os.path.isdir(bake_location)):
shutil.rmtree(bake_location)
os.makedirs(bake_location)
else:
os.makedirs(bake_location)
bake_location = folder_objects + os.sep + 'Bake'
if (os.path.isdir(bake_location)):
shutil.rmtree(bake_location)
os.makedirs(bake_location)
else:
os.makedirs(bake_location)
temp_string = ''
for objekti in bpy.context.selected_objects:
@ -680,9 +680,7 @@ class SCENE_OT_export(bpy.types.Operator):
if (coat3D.bake_normal):
bake_list.append(['NORMAL', '$LOADLOPOLYTANG'])
if (coat3D.bake_roughness):
bake_list.append(['SPECULAR', '$LOADROUGHNESS'])
if (coat3D.bake_metalness):
bake_list.append(['REFLECTION', '$LOADMETAL'])
bake_list.append(['ROUGHNESS', '$LOADROUGHNESS'])
if(coat3D.bake_resolution == 'res_64'):
res_size = 64
@ -1136,7 +1134,6 @@ class SCENE_OT_import(bpy.types.Operator):
index = 0
for c_index in diff_objects:
bpy.data.objects[c_index].data.coat3D.name = '3DC'
bpy.data.objects[c_index].material_slots[0].material = bpy.data.materials[diff_mat[laskuri]]
laskuri += 1
bpy.ops.object.select_all(action='DESELECT')
@ -1156,8 +1153,6 @@ class SCENE_OT_import(bpy.types.Operator):
index = index + 1
bpy.context.view_layer.objects.active = new_obj
keep_materials_count = len(new_obj.material_slots) - len(new_obj.data.uv_layers)
delete_materials_from_end(keep_materials_count, new_obj)
new_obj.coat3D.applink_export = True
if(osoite_3b != ''):
@ -1337,7 +1332,7 @@ class SCENE_PT_Bake_Settings(ObjectButtonsPanel, bpy.types.Panel):
col = flow.column()
col.prop(coat3D, "bake_ao", text="AO")
col = flow.column()
col.prop(coat3D, "bake_metalness", text="Metalness")
col.prop(coat3D, "bake_normal", text="Normal")
col = flow.column()
col.prop(coat3D, "bake_roughness", text="Roughness")
@ -1720,7 +1715,7 @@ class MeshCoat3D(PropertyGroup):
)
class MaterialCoat3D(PropertyGroup):
name: BoolProperty(
name: StringProperty(
name="ApplinkAddress",
# subtype="APPLINK_ADDRESS",
default=True
@ -1762,8 +1757,8 @@ classes = (
SCENE_PT_Material,
SCENE_PT_Settings_Update,
SCENE_PT_Bake_Settings,
SCENE_PT_Settings_Folders,
SCENE_PT_Settings_DeleteNodes,
SCENE_PT_Settings_Folders,
SCENE_PT_Material_Import,
SCENE_OT_folder,
SCENE_OT_opencoat,

View File

@ -183,62 +183,123 @@ def readtexturefolder(objekti, mat_list, texturelist, is_new, udim_textures): #r
if(udim_textures == False):
for texture_info in texturelist:
if texture_info[0] == index_mat.name:
if texture_info[2] == 'color' or texture_info[2] == 'diffuse':
if(index_mat.material.coat3D_diffuse):
texcoat['color'].append(texture_info[3])
create_nodes = True
else:
os.remove(texture_info[3])
elif texture_info[2] == 'metalness' or texture_info[2] == 'specular' or texture_info[2] == 'reflection':
if (index_mat.material.coat3D_metalness):
texcoat['metalness'].append(texture_info[3])
create_nodes = True
else:
os.remove(texture_info[3])
elif texture_info[2] == 'rough' or texture_info[2] == 'roughness':
if (index_mat.material.coat3D_roughness):
texcoat['rough'].append(texture_info[3])
create_nodes = True
else:
os.remove(texture_info[3])
elif texture_info[2] == 'nmap' or texture_info[2] == 'normalmap' or texture_info[2] == 'normal_map' or texture_info[2] == 'normal':
if (index_mat.material.coat3D_normal):
texcoat['nmap'].append(texture_info[3])
create_nodes = True
else:
os.remove(texture_info[3])
elif texture_info[2] == 'emissive':
if (index_mat.material.coat3D_emissive):
texcoat['emissive'].append(texture_info[3])
create_nodes = True
else:
os.remove(texture_info[3])
elif texture_info[2] == 'emissive_power':
if (index_mat.material.coat3D_emissive):
texcoat['emissive_power'].append(texture_info[3])
create_nodes = True
else:
os.remove(texture_info[3])
elif texture_info[2] == 'ao':
if (index_mat.material.coat3D_ao):
texcoat['ao'].append(texture_info[3])
create_nodes = True
else:
os.remove(texture_info[3])
elif texture_info[2].startswith('displacement'):
if (index_mat.material.coat3D_displacement):
texcoat['displacement'].append(texture_info[3])
create_nodes = True
else:
os.remove(texture_info[3])
elif texture_info[2] == 'alpha' or texture_info[2] == 'opacity':
if (index_mat.material.coat3D_metalness):
texcoat['alpha'].append(texture_info[3])
create_nodes = True
else:
os.remove(texture_info[3])
create_group_node = True
if is_new == False:
if texture_info[0] == index_mat.name:
if texture_info[2] == 'color' or texture_info[2] == 'diffuse':
if(index_mat.material.coat3D_diffuse):
texcoat['color'].append(texture_info[3])
create_nodes = True
else:
os.remove(texture_info[3])
elif texture_info[2] == 'metalness' or texture_info[2] == 'specular' or texture_info[2] == 'reflection':
if (index_mat.material.coat3D_metalness):
texcoat['metalness'].append(texture_info[3])
create_nodes = True
else:
os.remove(texture_info[3])
elif texture_info[2] == 'rough' or texture_info[2] == 'roughness':
if (index_mat.material.coat3D_roughness):
texcoat['rough'].append(texture_info[3])
create_nodes = True
else:
os.remove(texture_info[3])
elif texture_info[2] == 'nmap' or texture_info[2] == 'normalmap' or texture_info[2] == 'normal_map' or texture_info[2] == 'normal':
if (index_mat.material.coat3D_normal):
texcoat['nmap'].append(texture_info[3])
create_nodes = True
else:
os.remove(texture_info[3])
elif texture_info[2] == 'emissive':
if (index_mat.material.coat3D_emissive):
texcoat['emissive'].append(texture_info[3])
create_nodes = True
else:
os.remove(texture_info[3])
elif texture_info[2] == 'emissive_power':
if (index_mat.material.coat3D_emissive):
texcoat['emissive_power'].append(texture_info[3])
create_nodes = True
else:
os.remove(texture_info[3])
elif texture_info[2] == 'ao':
if (index_mat.material.coat3D_ao):
texcoat['ao'].append(texture_info[3])
create_nodes = True
else:
os.remove(texture_info[3])
elif texture_info[2].startswith('displacement'):
if (index_mat.material.coat3D_displacement):
texcoat['displacement'].append(texture_info[3])
create_nodes = True
else:
os.remove(texture_info[3])
elif texture_info[2] == 'alpha' or texture_info[2] == 'opacity':
if (index_mat.material.coat3D_metalness):
texcoat['alpha'].append(texture_info[3])
create_nodes = True
else:
os.remove(texture_info[3])
create_group_node = True
else:
if index_mat.name.startswith(texture_info[0]):
if texture_info[2] == 'color' or texture_info[2] == 'diffuse':
if (index_mat.material.coat3D_diffuse):
texcoat['color'].append(texture_info[3])
create_nodes = True
else:
os.remove(texture_info[3])
elif texture_info[2] == 'metalness' or texture_info[2] == 'specular' or texture_info[
2] == 'reflection':
if (index_mat.material.coat3D_metalness):
texcoat['metalness'].append(texture_info[3])
create_nodes = True
else:
os.remove(texture_info[3])
elif texture_info[2] == 'rough' or texture_info[2] == 'roughness':
if (index_mat.material.coat3D_roughness):
texcoat['rough'].append(texture_info[3])
create_nodes = True
else:
os.remove(texture_info[3])
elif texture_info[2] == 'nmap' or texture_info[2] == 'normalmap' or texture_info[
2] == 'normal_map' or texture_info[2] == 'normal':
if (index_mat.material.coat3D_normal):
texcoat['nmap'].append(texture_info[3])
create_nodes = True
else:
os.remove(texture_info[3])
elif texture_info[2] == 'emissive':
if (index_mat.material.coat3D_emissive):
texcoat['emissive'].append(texture_info[3])
create_nodes = True
else:
os.remove(texture_info[3])
elif texture_info[2] == 'emissive_power':
if (index_mat.material.coat3D_emissive):
texcoat['emissive_power'].append(texture_info[3])
create_nodes = True
else:
os.remove(texture_info[3])
elif texture_info[2] == 'ao':
if (index_mat.material.coat3D_ao):
texcoat['ao'].append(texture_info[3])
create_nodes = True
else:
os.remove(texture_info[3])
elif texture_info[2].startswith('displacement'):
if (index_mat.material.coat3D_displacement):
texcoat['displacement'].append(texture_info[3])
create_nodes = True
else:
os.remove(texture_info[3])
elif texture_info[2] == 'alpha' or texture_info[2] == 'opacity':
if (index_mat.material.coat3D_metalness):
texcoat['alpha'].append(texture_info[3])
create_nodes = True
else:
os.remove(texture_info[3])
create_group_node = True
else:
for texture_info in texturelist:
@ -771,10 +832,12 @@ def matlab(objekti,mat_list,texturelist,is_new):
''' FBX Materials: remove all nodes and create princibles node'''
if(is_new):
RemoveFbxNodes(objekti)
print('hei hai hoi')
'''Main Loop for Texture Update'''
updatetextures(objekti)
if(texturelist != []):
udim_textures = False
if texturelist[0][0].startswith('100'):