| 5 | |
| 6 | |
| 7 | def bake_frames(context, framewise=True, frames=None, glyphwise=False, shapewise=False, wordwise=False, linewise=False, layerwise=False, progress_fn=None, object=None): |
| 8 | from ST2.importer import cb |
| 9 | |
| 10 | if not object: |
| 11 | for o in context.selected_objects: |
| 12 | bake_frames(context, framewise, frames, glyphwise, shapewise, wordwise, linewise, layerwise, progress_fn, o) |
| 13 | return |
| 14 | |
| 15 | if object: |
| 16 | obj = object |
| 17 | else: |
| 18 | obj = context.active_object |
| 19 | |
| 20 | print("BAKING...", obj) |
| 21 | |
| 22 | data = obj.st2 |
| 23 | data.frozen = True |
| 24 | |
| 25 | sc = context.scene |
| 26 | current = sc.frame_current |
| 27 | |
| 28 | if not frames: |
| 29 | frames = range(sc.frame_start, sc.frame_end+1) |
| 30 | |
| 31 | duration = len(frames) |
| 32 | |
| 33 | if data.export_style == "TOP": |
| 34 | parent, coll = None, None |
| 35 | elif data.export_style == "PARENT": |
| 36 | parent, coll = True, None |
| 37 | elif data.export_style == "COLLECTION": |
| 38 | parent, coll = None, True |
| 39 | |
| 40 | if parent: |
| 41 | anchor = cb.BpyObj.Empty(f"{obj.name}_BakedFrames_Anchor", collection="Global") |
| 42 | |
| 43 | data.copy_to(anchor.obj.st2) |
| 44 | |
| 45 | anchor.obj.st2.baked = True |
| 46 | anchor.obj.st2.baked_from = obj.name |
| 47 | anchor.obj.st2.bake_frame = -1 |
| 48 | anchor.obj.st2.updatable = True |
| 49 | parent = anchor |
| 50 | |
| 51 | if coll: |
| 52 | coll = f"ST2:Export_{obj.name}" |
| 53 | else: |
| 54 | coll = "Global" |
| 55 | |
| 56 | results = [] |
| 57 | |
| 58 | print("baking...") |
| 59 | |
| 60 | for frame in frames: |
| 61 | if progress_fn: |
| 62 | progress_fn(frame/duration) |
| 63 | |
| 64 | if frame%data.export_every_x_frame != 0: |