コード例 #1
0
ファイル: seam_mender.py プロジェクト: kormgar/Mesh-Rigger
    def process_nif(this_file, repair_doubles = False):
#         if findall(r_nif, test_file) and test_file != current_settings['template']:
        print('******NIF******')
        print('Processing', this_file)

        target_nif = load_nif(this_file, template = template_mesh, settings = current_settings)
        if not target_nif.valid:
            print(target_nif,'Could Not Be Processed')
            return
        nif_gender = target_nif.getGender()
        if gender_list:
            if nif_gender not in gender_list:
                print('Incorrect Gender:', this_file )
                print('Closing', this_file )
                return
            mesh_ = template_mesh.get(nif_gender)
            verts_ = template_verts.get(nif_gender)
        elif nif_gender != current_settings['gender']:
            print('Incorrect Gender:', this_file )
            print('Closing', this_file )
            return
                    
        
        targets_found = 0
        for this_mesh in target_nif.meshes:
            if gender_list:
                targets_found += mainSearch(current_settings, mesh_, this_mesh, search_resolution = 1, vertFunction = setSeams, nmv = target_nmv, act_verts = verts_)
            else:   
                targets_found += mainSearch(current_settings, template_mesh, this_mesh, search_resolution = 1, vertFunction = setSeams, nmv = target_nmv, act_verts = template_verts)       
        if repair_doubles:
            for this_mesh in target_nif.meshes:
                if current_settings.get('doubles'):
                    for tup in this_mesh.nmv_doubles:
                        average_normal = kg.math_util.vector3([0,0,0])
                        bad_normal = 0
                        for v in tup:
                            if v.normal:
                                average_normal += v.normal
                            else:
                                bad_normal += 1
                        if bad_normal == len(tup):
                            continue
                        for v in tup:
                            v.setNormal(kg.math_util.normalizeVector(average_normal))
                            targets_found += 1
        save_file(target_nif, this_file, targets_found, current_settings)
コード例 #2
0
ファイル: mesh_rigger.py プロジェクト: kormgar/Mesh-Rigger
    def process_nif(test_file, bone_list):
        print('Processing', test_file)
        target_nif = load_nif(test_file, template = template_mesh, settings = current_settings)
        if not target_nif.valid:
            print(test_file,'Could Not Be Processed')
        
        targets_found = 0
        for this_mesh in target_nif.meshes:
            targets_found += mainSearch(current_settings, template_mesh, this_mesh, search_resolution = 1, vertFunction = setWeightDictionary, side = side)

        save_file(target_nif, test_file, targets_found, current_settings)
コード例 #3
0
ファイル: mesh_compare.py プロジェクト: kormgar/Mesh-Rigger
 def process_nif(this_path, test_file):
     #return
     if findall(r_nif, test_file) and test_file != current_settings['template']:
         print('Processing', test_file)
         target_nif = load_nif(path.join(this_path, test_file), template = template_mesh, settings = current_settings)
         #target_nif = load_nif(path.join(path, test_file))
         
         targets_found = 0
         for this_mesh in target_nif.meshes:
             mainSearch(current_settings, template_mesh, this_mesh, search_resolution = current_settings['res'], vertFunction = compareMatches)
             print('Displaying Results for', this_mesh.block.name)
             if current_settings.get('report'):
                 for v in this_mesh.verts.values():
                     print(v.idx, 'Exact Match: ', v.exact_match)
                     print('Detail View', v.match_results)
             else:
                 for v in this_mesh.verts.values():
                     if not v.exact_match:
                         print(v.idx, 'Exact Match: ', v.exact_match)
                         print('Detail View', v.match_results)
コード例 #4
0
ファイル: seam_mender.py プロジェクト: kormgar/Mesh-Rigger
    def process_tri(this_file):
        if template_verts:
            print('******TRI******')
            
            mesh_ = template_mesh                         
            verts_ = template_verts
            
            if gender_list or current_settings['gender']:
                """
                Determine Gender of Tri File
                """

                root_nif_path = re.sub(r_tri_end, '.nif', this_file)
                tri_gender = getGenderFlag(root_nif_path)
                if tri_gender is 'NONE' and path.exists(root_nif_path):
                    target_nif = load_nif(root_nif_path, template = False, settings = {})
                    if not target_nif.valid:
                        tri_gender = 'NONE'
                    else:
                        tri_gender = target_nif.getGender()
                if gender_list:
                    mesh_ = template_mesh.get(tri_gender)
                    verts_ = template_verts.get(tri_gender)
                    if not mesh_ or not verts_:
                        print('Incorrect Gender:', this_file )
                        print('Closing', this_file )
                        return
                    
                elif tri_gender != current_settings['gender']:
                    print('Incorrect Gender:', this_file )
                    print('Closing', this_file )
                    return
        
            print('Processing', this_file)

            target_tri = load_tri(this_file, template = template_mesh, settings = current_settings)

            tri_mesh = target_tri.mesh
#             for a in zip(sorted([(vert.idx, vert.getLoc(world_loc = True).as_list()) for vert in tri_mesh.getVerts(nmv = True).values()], key = itemgetter(0)),
#             sorted([(vert.idx, vert.getLoc(world_loc = False).as_list()) for vert in template_mesh.getVerts(nmv = True).values()], key = itemgetter(0))):
#                 print (a)
            
            
            targets_found = mainSearch(current_settings, mesh_, tri_mesh, search_resolution = 1, vertFunction = setTriSeams, nmv = target_nmv, act_verts = verts_, tri = True, world_loc = True)

            save_file(target_tri, this_file, targets_found, current_settings)