import sys import os import bpy # 1. Resolve path to include workspace root so pr3tz can be imported dir_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) if dir_path not in sys.path: sys.path.append(dir_path) import pr3tz # 2. Register pr3tz addon try: if "pr3tz" in sys.modules: import importlib importlib.reload(pr3tz) else: import pr3tz pr3tz.register() print("[Pr3tz] Registered successfully!") except Exception as e: print(f"[Pr3tz] Failed to register: {e}") sys.exit(1) # 3. Configure the scene (camera, lights, timeline, etc.) pr3tz.setup_scene() # 4. Clear existing playlist scene = bpy.context.scene scene.knot_list.clear() # ── Knot 1: Trefoil (Torus Knot) with Lava Preset ── item_a = scene.knot_list.add() item_a.name = "Trefoil Knot" item_a.shape_type = 'TORUS_KNOT' item_a.torus_p = 2 item_a.torus_q = 3 item_a.torus_R = 2.0 item_a.torus_r = 0.8 item_a.geo_bDepth = 0.05 item_a.material_mode = 'PRESET' item_a.shader_id = 'LAVA' item_a.preset_color = (1.0, 0.2, 0.0) item_a.cycle_rate = 1.0 # ── Knot 2: 3D Lissajous with Glass Preset (Morphed using QUAD_IN_OUT) ── # Triggers a transition morph when transitioning from item_a to item_b item_b = scene.knot_list.add() item_b.name = "Lissajous Morph Target" item_b.shape_type = 'LISSAJOUS' item_b.liss_kx = 3 item_b.liss_ky = 2 item_b.liss_kz = 4 item_b.liss_amp = 2.2 item_b.geo_bDepth = 0.08 item_b.material_mode = 'PRESET' item_b.shader_id = 'GLASS' item_b.preset_color = (0.3, 0.8, 1.0) item_b.preset_roughness = 0.0 item_b.cycle_rate = 1.0 item_b.transition_frames = 60 # Morphs over 60 frames item_b.transition_easing = 'QUAD_IN_OUT' # Smooth ease-in, ease-out curve # ── Knot 3: Mobius Loop with Lichen Preset (Morphed using SMOOTHSTEP) ── item_c = scene.knot_list.add() item_c.name = "Mobius Morph Target" item_c.shape_type = 'MOBIUS' item_c.mobius_twists = 1 item_c.mobius_width = 1.6 item_c.torus_R = 2.4 item_c.geo_bDepth = 0.04 item_c.material_mode = 'PRESET' item_c.shader_id = 'COPPER_PATINA' item_c.preset_color = (0.1, 0.7, 0.5) item_c.cycle_rate = 1.0 item_c.transition_frames = 40 # Morphs over 40 frames item_c.transition_easing = 'SMOOTHSTEP' # S-curve ease # 5. Set up playlist blend materials. # MUST call this whenever modifying transitions or colors programmatically, # so the shader node trees are rebuilt. pr3tz.materials.prewarm_materials_and_blends(scene) # 6. Fit timeline scene.knot_globals.frames_per_knot = 120 bpy.ops.knot.fit_timeline() # 7. Force instant geometry generation for current frame pr3tz.knot_frame_handler(scene) print("\n=====================================================================") print("Example 5: Morph Transitions Playlist Loaded!") print("=====================================================================") print("Created 3 distinct shapes with custom transition settings:") print(" - Trefoil Knot (Lava Preset)") print(" - Lissajous (Glass Preset) morphs from Trefoil over 60 frames (Quad In/Out)") print(" - Mobius Loop (Copper Patina) morphs from Lissajous over 40 frames (Smoothstep)") print("=====================================================================") print("Interact with it in Blender:") print(" - Play the animation (Space).") print(" - Watch how the geometries blend smoothly between shapes.") print(" - Observe the material node network transition from Lava to Glass/Copper.") print("=====================================================================\n")