import subprocess import os import sys import tempfile import argparse import json…
- User
import subprocess import os import sys import tempfile import argparse import json import textwrap # Added to handle indentation in the multi-line string
def load_config(config_path): """Load the configuration from the JSON file.""" with open(config_path, 'r') as f: config = json.load(f) return config
def create_blender_script(blender_executable, logo_path, output_dir, duration, fps, rotation_deg, resolution, render_engine, render_device): """ Creates a Blender Python script to animate the logo. Returns the path to the temporary Blender script. """ blender_script = f''' import bpy import sys import os
Parameters
LOGO_PATH = r"{logo_path}" OUTPUT_DIR = r"{output_dir}" DURATION = {duration} FPS = {fps} ROTATION_SPEED = {rotation_deg} RESOLUTION = {resolution}
def clear_scene(): """Remove all objects from the current Blender scene.""" bpy.ops.wm.read_factory_settings(use_empty=True)
def import_logo(logopath): """Import the logo image as a plane with transparency.""" # Enable the Import Images as Planes addon bpy.ops.wm.addon_enable(module="io_import_images_as_planes")
code# Import the image as a plane bpy.ops.import_image.to_plane(files=[{{"name": os.path.basename(logopath)}}], directory=os.path.dirname(logopath)) # Get a reference to the imported plane logo = bpy.context.selected_objects[0] # Scale the logo to fit the scene logo.scale = (1, 1, 1) # Adjust as necessary return logodef setup_material(logo_obj): """Set up the material of the logo for better visual effects.""" mat = bpy.data.materials.new(name="LogoMaterial") mat.use_nodes = True nodes = mat.node_tree.nodes links = mat.node_tree.links
code - Assistant