| 33 | path_cur_script=os.path.dirname(os.path.abspath(__file__)) |
| 34 | |
| 35 | def export_alembic(out_alembic_path, resolution): |
| 36 | print("-------------------------------------------") |
| 37 | |
| 38 | # bpy.ops.outliner.item_activate(deselect_all=True) |
| 39 | bpy.data.objects["hair_01"].select_set(True) |
| 40 | # hair = bpy.context.active_object |
| 41 | hair = bpy.data.objects["hair_01"] |
| 42 | bpy.context.view_layer.objects.active=hair |
| 43 | |
| 44 | |
| 45 | start=time.time() |
| 46 | for modif in hair.modifiers: |
| 47 | print("applying",modif.name) |
| 48 | bpy.context.view_layer.objects.active = hair |
| 49 | bpy.ops.object.modifier_apply(modifier=modif.name) |
| 50 | print("finished applying all geometry nodes") |
| 51 | end=time.time() |
| 52 | print("applying geometry nodes took", end-start) |
| 53 | #shrinkwrap on the scalp (Wrong because it makes weird strands for the long hair) |
| 54 | #default hair with t=8: 20s |
| 55 | #default hair with t=16: 15s |
| 56 | #50% strans with t=16: 6s |
| 57 | |
| 58 | #with shrinkwrap on the whole mesh |
| 59 | #default hair with t=8: 43s |
| 60 | #default hair with t=16: 34s |
| 61 | #50% strans with t=16: 14s |
| 62 | #50% strans, 50%points with t=16: 7s |
| 63 | #50% strans, 25%points with t=16: 5s |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | #conver particle |
| 69 | bpy.ops.curves.convert_to_particle_system() |
| 70 | |
| 71 | # bpy.ops.outliner.item_activate(deselect_all=True) |
| 72 | # bpy.context.space_data.context = 'PARTICLES' |
| 73 | bpy.context.object.show_instancer_for_render = False |
| 74 | bpy.context.object.show_instancer_for_viewport = False |
| 75 | #I have no idea which one actually works to increase resolution so I change all |
| 76 | # bpy.data.particles["ParticleSettings"].display_step = 7 |
| 77 | # bpy.data.particles["ParticleSettings"].hair_step = 7 |
| 78 | # bpy.data.particles["ParticleSettings"].render_step = 7 |
| 79 | bpy.data.particles["ParticleSettings"].display_step = resolution |
| 80 | bpy.data.particles["ParticleSettings"].hair_step = resolution |
| 81 | bpy.data.particles["ParticleSettings"].render_step = resolution |
| 82 | |
| 83 | |
| 84 | #hide everything except scalp |
| 85 | for obj in bpy.data.objects: |
| 86 | print("obj", obj) |
| 87 | if obj.name!="smplx_scalp_blender": |
| 88 | obj.hide_render=True |
| 89 | obj.hide_viewport=True |
| 90 | else: |
| 91 | print("smplx scalp blender doesn't get hidden") |
| 92 | # for obj in bpy.scene.objects: |