60 lines
2.2 KiB
Python
60 lines
2.2 KiB
Python
"""실행 검사 전용 두 애니메이션 Scene과 초기 Idle Scene을 만든다."""
|
|
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_ball = ball.copy()
|
|
second_ball.data = ball.data.copy()
|
|
second_ball.name = "BallB"
|
|
second.collection.objects.link(second_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
|
|
idle = bpy.data.scenes.new("Idle")
|
|
idle.world = scene.world
|
|
idle_camera = camera.copy()
|
|
idle_camera.data = camera.data.copy()
|
|
idle.collection.objects.link(idle_camera)
|
|
idle.camera = idle_camera
|
|
bpy.context.window.scene = idle
|
|
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])
|