[Bf-extensions-cvs] [0d585a73] master: io_coat3D: Big update: Better REFERENCE MESH and VOXEL MESH support.
Kalle-Samuli Riihikoski
noreply at git.blender.org
Sat Sep 21 12:07:12 CEST 2019
Commit: 0d585a73ef03ce8ba0757525a1d85e8cd563a35a
Author: Kalle-Samuli Riihikoski
Date: Sat Sep 21 13:07:15 2019 +0300
Branches: master
https://developer.blender.org/rBA0d585a73ef03ce8ba0757525a1d85e8cd563a35a
io_coat3D: Big update: Better REFERENCE MESH and VOXEL MESH support.
===================================================================
M io_coat3D/__init__.py
M io_coat3D/tex.py
===================================================================
diff --git a/io_coat3D/__init__.py b/io_coat3D/__init__.py
index eff4c385..0938b9f1 100644
--- a/io_coat3D/__init__.py
+++ b/io_coat3D/__init__.py
@@ -208,7 +208,6 @@ def make_texture_list(texturefolder):
'''
def updatemesh(objekti, proxy, texturelist):
-
# Vertex colors
if(len(proxy.data.vertex_colors) > 0):
bring_vertex_map = True
@@ -241,8 +240,9 @@ def updatemesh(objekti, proxy, texturelist):
# UV -Sets
udim_textures = False
- if(texturelist[0][0].startswith('100')):
- udim_textures =True
+ if(texturelist != []):
+ if(texturelist[0][0].startswith('100')):
+ udim_textures =True
proxy.select_set(True)
objekti.select_set(True)
@@ -265,9 +265,11 @@ def updatemesh(objekti, proxy, texturelist):
index = index + 1
# Mesh Copy
-
- for ind, v in enumerate(objekti.data.vertices):
- v.co = proxy.data.vertices[ind].co
+ if(proxy.name.startswith('RetopoGroup')):
+ objekti.data = proxy.data
+ else:
+ for ind, v in enumerate(objekti.data.vertices):
+ v.co = proxy.data.vertices[ind].co
class SCENE_OT_folder(bpy.types.Operator):
bl_idname = "update_exchange_folder.pilgway_3d_coat"
@@ -277,9 +279,9 @@ class SCENE_OT_folder(bpy.types.Operator):
def invoke(self, context, event):
coat3D = bpy.context.scene.coat3D
-
if(os.path.isdir(coat3D.exchangedir)):
coat3D.exchange_found = True
+ bpy.coat3D['status'] = 1
else:
coat3D.exchange_found = False
@@ -577,39 +579,13 @@ class SCENE_OT_export(bpy.types.Operator):
matindex = 0
for objekti in bpy.context.selected_objects:
+ objekti.name = '__' + objekti.name
if(objekti.material_slots.keys() == []):
newmat = bpy.data.materials.new('Material')
newmat.use_nodes = True
objekti.data.materials.append(newmat)
matindex += 1
- new_name = objekti.data.name
- name_boxs = new_name.split('.')
- if(len(name_boxs)>1):
- objekti.name = name_boxs[0] + name_boxs[1]
- nimiNum = int(name_boxs[1])
- looking = False
- lyytyi = False
- while(looking == False):
- for all_ob in bpy.data.meshes:
- numero = ("%.3d"%(nimiNum))
- nimi2 = name_boxs[0] + numero
- if(all_ob.name == nimi2):
- lyytyi = True
- break
- else:
- lyytyi = False
-
- if(lyytyi == True):
- nimiNum += 1
- else:
- looking = True
- objekti.data.name = nimi2
- objekti.name = nimi2
-
- else:
- objekti.name = name_boxs[0]
- objekti.data.name = name_boxs[0]
- objekti.coat3D.applink_name = objekti.data.name
+ objekti.coat3D.applink_name = objekti.name
mod_mat_list = {}
@@ -624,6 +600,7 @@ class SCENE_OT_export(bpy.types.Operator):
for objekti in bpy.context.selected_objects:
mod_mat_list[objekti.name] = []
objekti.coat3D.applink_scale = objekti.scale
+ objekti.coat3D.retopo = False
''' Checks what materials are linked into UV '''
@@ -750,7 +727,7 @@ class SCENE_OT_export(bpy.types.Operator):
file.close()
for idx, objekti in enumerate(bpy.context.selected_objects):
-
+ objekti.name = objekti.name[2:]
if(len(bpy.context.selected_objects) == 1):
objekti.coat3D.applink_onlyone = True
objekti.coat3D.type = coat3D.type
@@ -856,7 +833,10 @@ class SCENE_OT_import(bpy.types.Operator):
Blender_export += ('%sexport.txt'%(os.sep))
new_applink_address = 'False'
new_object = False
+ new_ref_object = False
+ exportfile3 = coat3D.exchangedir
+ exportfile3 += ('%sexport.txt' % (os.sep))
if(os.path.isfile(Blender_export)):
obj_pathh = open(Blender_export)
new_object = True
@@ -870,359 +850,453 @@ class SCENE_OT_import(bpy.types.Operator):
if(scene_objects.coat3D.applink_address == new_applink_address):
new_object = False
+
+ elif(os.path.isfile(exportfile3)):
+ obj_pathh = open(exportfile3)
+
+ for line in obj_pathh:
+ new_applink_address = line
+ break
+ obj_pathh.close()
+
+ for scene_objects in bpy.context.collection.all_objects:
+ if(scene_objects.type == 'MESH'):
+ if(scene_objects.coat3D.applink_address == new_applink_address and scene_objects.coat3D.type == 'ref'):
+ scene_objects.coat3D.type == ''
+ new_ref_object = True
+ nimi = scene_objects.name
+
+
+
exportfile = coat3D.exchangedir
exportfile += ('%sBlender' % (os.sep))
exportfile += ('%sexport.txt' % (os.sep))
if (os.path.isfile(exportfile)):
os.remove(exportfile)
+
+ if(new_ref_object):
- if(new_object == False):
+ create_collection = True
+ for collection in bpy.data.collections:
+ if collection.name == 'Applink_Objects':
+ create_collection = False
- '''
- #Blender -> 3DC -> Blender workflow
- #First check if objects needs to be imported, if imported it will then delete extra mat and objs.
- '''
+ if create_collection:
+ bpy.data.collections.new('Applink_Objects')
- old_materials = bpy.data.materials.keys()
- old_objects = bpy.data.objects.keys()
- cache_base = bpy.data.objects.keys()
+ coll_items = bpy.context.scene.collection.children.items()
+ add_applink_collection = True
+ for coll in coll_items:
+ if coll[0] == 'Applink_Objects':
+ add_applink_collection = False
+
+ if add_applink_collection:
+ bpy.context.scene.collection.children.link(bpy.data.collections['Applink_Objects'])
+
+ bpy.context.view_layer.active_layer_collection = bpy.context.view_layer.layer_collection.children['Applink_Objects']
+
+ old_objects = bpy.data.objects.keys()
object_list = []
- import_list = []
- import_type = []
-
- for objekti in bpy.data.objects:
- if objekti.type == 'MESH':
- obj_coat = objekti.coat3D
- if(obj_coat.applink_mesh == True):
- object_list.append(objekti.name)
-
- if(os.path.isfile(obj_coat.applink_address)):
- if (obj_coat.objecttime != str(os.path.getmtime(obj_coat.applink_address))):
- obj_coat.dime = objekti.dimensions
- obj_coat.import_mesh = True
- obj_coat.objecttime = str(os.path.getmtime(obj_coat.applink_address))
- if(obj_coat.applink_address not in import_list):
- import_list.append(obj_coat.applink_address)
- import_type.append(coat3D.type)
-
- if(import_list or coat3D.importmesh):
- for idx, list in enumerate(import_list):
- bpy.ops.import_scene.fbx(filepath=list, global_scale = 0.01,axis_forward='X',use_custom_normals=False)
- cache_objects = bpy.data.objects.keys()
- cache_objects = [i for i in cache_objects if i not in cache_base]
- for cache_object in cache_objects:
- bpy.data.objects[cache_object].coat3D.type = import_type[idx]
- bpy.data.objects[cache_object].coat3D.applink_address = list
- cache_base.append(cache_object)
+
+ bpy.ops.import_scene.fbx(filepath=new_applink_address, global_scale = 0.01,axis_forward='X', axis_up='Y',use_custom_normals=False)
+ new_objects = bpy.data.objects.keys()
+ diff_objects = [i for i in new_objects if i not in old_objects]
+ texturelist = []
+
+ for diff_object in diff_objects:
+
+ refmesh = bpy.data.objects[nimi]
+ copymesh = bpy.data.objects[nimi].copy()
+
+ copymesh.data = bpy.data.objects[diff_object].data
+ copymesh.coat3D.applink_name = bpy.data.objects[diff_object].data.name
+ copymesh.coat3D.applink_address = refmesh.coat3D.applink_address
+ ne_name = bpy.data.objects[diff_object].data.name
+
+ copymesh.coat3D.type = 'ppp'
+ copymesh.coat3D.retopo = True
+
+ bpy.data.collections['Applink_Objects'].objects.link(copymesh)
+
+ bpy.data.objects.remove(bpy.data.objects[diff_object])
bpy.ops.object.select_all(action='DESELECT')
- new_materials = bpy.data.materials.keys()
- new_objects = bpy.data.objects.keys()
+ copymesh.select_set(True)
+ copymesh.delta_rotation_euler[0] = 1.5708
+ copymesh.name = ne_name
+ normal_node = copymesh.material_slots[0].material.node_tree.nodes['Normal Map']
+ copymesh.material_slots[0].material.node_tree.nodes.remove(normal_node)
+ copymesh.material_slots[0].material.node_tree.nodes['Principled BSDF'].inputs['Metallic'].default_value = 0
+ copymesh.material_slots[0].material.node_tree.nodes['Principled BSDF'].inputs['Specular'].default_value = 0.5
- diff_mat = [i for i in new_materia
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list