From 44604c923b2f40bca4efc32e6d2fb483808e5613 Mon Sep 17 00:00:00 2001 From: Kalle-Samuli Riihikoski Date: Wed, 6 Mar 2019 20:38:27 +0200 Subject: users has now control what textures are linked to material. --- io_coat3D/__init__.py | 127 ++++++++++++++++++++++++++++++++++++++++++++++---- io_coat3D/tex.py | 56 +++++++++++++++------- 2 files changed, 159 insertions(+), 24 deletions(-) diff --git a/io_coat3D/__init__.py b/io_coat3D/__init__.py index 78a94f09..17be77da 100644 --- a/io_coat3D/__init__.py +++ b/io_coat3D/__init__.py @@ -1249,6 +1249,46 @@ class SCENE_PT_Settings(ObjectButtonsPanel,bpy.types.Panel): def draw(self, context): pass +class MaterialButtonsPanel(): + bl_space_type = 'PROPERTIES' + bl_region_type = 'WINDOW' + bl_context = "material" + +class SCENE_PT_Material(MaterialButtonsPanel,bpy.types.Panel): + bl_label = "3D-Coat Applink" + bl_space_type = "PROPERTIES" + bl_region_type = "WINDOW" + bl_context = "material" + + def draw(self, context): + pass + +class SCENE_PT_Material_Import(MaterialButtonsPanel, bpy.types.Panel): + bl_label = "Import Textures:" + bl_parent_id = "SCENE_PT_Material" + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'} + + def draw(self, context): + layout = self.layout + layout.use_property_split = False + coat3D = bpy.context.active_object.active_material + + layout.active = True + + flow = layout.grid_flow(row_major=True, columns=0, even_columns=False, even_rows=False, align=True) + + col = flow.column() + col.prop(coat3D, "coat3D_diffuse", text="Diffuse") + col.prop(coat3D, "coat3D_metalness", text="Metalness") + col.prop(coat3D, "coat3D_roughness", text="Roughness") + col.prop(coat3D, "coat3D_ao", text="AO") + col = flow.column() + col.prop(coat3D, "coat3D_normal", text="NormalMap") + col.prop(coat3D, "coat3D_displacement", text="Displacement") + col.prop(coat3D, "coat3D_emissive", text="Emissive") + + + class SCENE_PT_Settings_Update(ObjectButtonsPanel, bpy.types.Panel): bl_label = "Update" bl_parent_id = "SCENE_PT_Settings" @@ -1471,10 +1511,6 @@ class ObjectCoat3D(PropertyGroup): name="Scale", description="Scale" ) -class MaterialCoat3D(PropertyGroup): - Nodegroup: StringProperty( - name="NodeGroup", - ) class SceneCoat3D(PropertyGroup): defaultfolder: StringProperty( @@ -1656,26 +1692,58 @@ class SceneCoat3D(PropertyGroup): default=False ) - class MeshCoat3D(PropertyGroup): applink_address: StringProperty( name="ApplinkAddress", subtype="APPLINK_ADDRESS", ) + class MaterialCoat3D(PropertyGroup): - name: StringProperty( + name: BoolProperty( name="ApplinkAddress", subtype="APPLINK_ADDRESS", + default=True + ) + bring_diffuse: BoolProperty( + name="Import diffuse texture", + description="Import diffuse texture", + default=True + ) + bring_metalness: BoolProperty( + name="Import diffuse texture", + description="Import diffuse texture", + default=True + ) + bring_roughness: BoolProperty( + name="Import diffuse texture", + description="Import diffuse texture", + default=True + ) + bring_normal: BoolProperty( + name="Import diffuse texture", + description="Import diffuse texture", + default=True + ) + bring_displacement: BoolProperty( + name="Import diffuse texture", + description="Import diffuse texture", + default=True + ) + bring_emissive: BoolProperty( + name="Import diffuse texture", + description="Import diffuse texture", + default=True ) classes = ( - #ObjectButtonsPanel, SCENE_PT_Main, SCENE_PT_Settings, + SCENE_PT_Material, SCENE_PT_Settings_Update, SCENE_PT_Bake_Settings, SCENE_PT_Settings_Folders, SCENE_PT_Settings_DeleteNodes, + SCENE_PT_Material_Import, SCENE_OT_folder, SCENE_OT_opencoat, SCENE_OT_export, @@ -1697,6 +1765,43 @@ def register(): bpy.coat3D['status'] = 1 bpy.coat3D['kuva'] = 1 + bpy.types.Material.coat3D_diffuse = BoolProperty( + name="Import diffuse texture", + description="Import diffuse texture", + default=True + ) + bpy.types.Material.coat3D_roughness = BoolProperty( + name="Import diffuse texture", + description="Import diffuse texture", + default=True + ) + bpy.types.Material.coat3D_metalness = BoolProperty( + name="Import diffuse texture", + description="Import diffuse texture", + default=True + ) + bpy.types.Material.coat3D_normal = BoolProperty( + name="Import diffuse texture", + description="Import diffuse texture", + default=True + ) + bpy.types.Material.coat3D_displacement = BoolProperty( + name="Import diffuse texture", + description="Import diffuse texture", + default=True + ) + bpy.types.Material.coat3D_emissive = BoolProperty( + name="Import diffuse texture", + description="Import diffuse texture", + default=True + ) + bpy.types.Material.coat3D_ao = BoolProperty( + name="Import diffuse texture", + description="Import diffuse texture", + default=True + ) + + from bpy.utils import register_class for cls in classes: register_class(cls) @@ -1720,7 +1825,13 @@ def unregister(): del bpy.types.Object.coat3D del bpy.types.Scene.coat3D - del bpy.types.Mesh.coat3D + del bpy.types.Material.coat3D + bpy.types.Material.coat3D_diffuse + bpy.types.Material.coat3D_metalness + bpy.types.Material.coat3D_roughness + bpy.types.Material.coat3D_normal + bpy.types.Material.coat3D_displacement + bpy.types.Material.coat3D_emissive del bpy.coat3D kc = bpy.context.window_manager.keyconfigs.addon diff --git a/io_coat3D/tex.py b/io_coat3D/tex.py index edb03d36..5b70c0b4 100644 --- a/io_coat3D/tex.py +++ b/io_coat3D/tex.py @@ -160,29 +160,53 @@ def readtexturefolder(objekti, mat_list, texturelist, is_new, udim_textures): #r if texture_info[0] == index_mat.name: if texture_info[2] == 'color' or texture_info[2] == 'diffuse': - texcoat['color'].append(texture_info[3]) - create_nodes = True + 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': - texcoat['metalness'].append(texture_info[3]) - create_nodes = True + 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': - texcoat['rough'].append(texture_info[3]) - create_nodes = True + 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': - texcoat['nmap'].append(texture_info[3]) - create_nodes = True + 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': - texcoat['emissive'].append(texture_info[3]) - create_nodes = True + 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': - texcoat['emissive_power'].append(texture_info[3]) - create_nodes = True + 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': - texcoat['ao'].append(texture_info[3]) - create_nodes = True + 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'): - texcoat['displacement'].append(texture_info[3]) - create_nodes = True + if (index_mat.material.coat3D_displacement): + texcoat['displacement'].append(texture_info[3]) + create_nodes = True + else: + os.remove(texture_info[3]) create_group_node = True else: for texture_info in texturelist: -- cgit v1.2.3