Files
ShortVideoGenerator/tools/blender/smoke_fixture.py
T

50 lines
1.9 KiB
Python

"""실행 검사 전용 3D 구와 두 카메라를 만든다. 제작 내용과 무관하다."""
import sys
import bpy
from mathutils import Vector
bpy.ops.object.select_all(action="SELECT")
bpy.ops.object.delete(use_global=False)
scene = bpy.context.scene
scene.name = "SceneA"
scene.frame_start, scene.frame_end = 1, 21
scene.world.color = (0.1, 0.1, 0.1)
bpy.ops.mesh.primitive_uv_sphere_add(segments=24, ring_count=16, radius=0.65, location=(-1, 0, 0))
ball = bpy.context.object
ball.name = "Ball"
ball.keyframe_insert("location", frame=1)
ball.location.x = 1
ball.keyframe_insert("location", frame=11)
material = bpy.data.materials.new("Blue")
material.diffuse_color = (0.03, 0.3, 0.8, 1)
ball.data.materials.append(material)
bpy.ops.object.light_add(type="AREA", location=(-3, -4, 6))
light = bpy.context.object
light.data.energy = 900
light.data.shape = "DISK"
light.data.size = 5
light.rotation_euler = (Vector((0, 0, 0)) - light.location).to_track_quat("-Z", "Y").to_euler()
bpy.ops.object.camera_add(location=(0, -7, 4))
camera = bpy.context.object
camera.rotation_euler = (-camera.location).to_track_quat("-Z", "Y").to_euler()
camera.data.type = "ORTHO"
camera.data.ortho_scale = 5
scene.camera = camera
second = bpy.data.scenes.new("SceneB")
second.frame_start, second.frame_end = 1, 21
second.world = scene.world
second.collection.objects.link(ball)
second.collection.objects.link(light)
other = camera.copy()
other.data = camera.data.copy()
other.location = (5, -7, 1)
other.rotation_euler = (-other.location).to_track_quat("-Z", "Y").to_euler()
second.collection.objects.link(other)
second.camera = other
if "--external-image" in sys.argv:
bpy.data.images.load(sys.argv[sys.argv.index("--external-image") + 1]).use_fake_user = True
if "--short-scene" in sys.argv:
scene.frame_end = second.frame_end = 1
bpy.ops.wm.save_as_mainfile(filepath=sys.argv[sys.argv.index("--") + 1])