2023年3月19日日曜日

aaa
















import bpy

# Create a sphere object
bpy.ops.mesh.primitive_uv_sphere_add(radius=1.0, location=(-10.0, 0.0, 0.0))

# Set start and end frames
start_frame = 1
end_frame = 200

# Define the start, middle, and end positions
start_pos = (-30.0, 0.0, 0.0)
middle_pos = (0.0, 0.0, 0.0)
end_pos = (30.0, 0.0, 0.0)

# Move the sphere to (0, 0, 0) over time
for i in range(start_frame, int(end_frame/2)+1):
    frame_factor = (i-start_frame)/((end_frame/2)-start_frame)
    bpy.context.scene.frame_set(i)
    bpy.context.object.location = tuple(s*(1-frame_factor) + m*frame_factor for s,m in zip(start_pos, middle_pos))
    bpy.context.object.keyframe_insert(data_path="location", index=-1)

# Move the sphere to (0, -10, 0) over time
for i in range(int(end_frame/2)+1, end_frame+1):
    frame_factor = (i-(end_frame/2)-1)/((end_frame/2)-start_frame)
    bpy.context.scene.frame_set(i)
    bpy.context.object.location = tuple(m*(1-frame_factor) + e*frame_factor for m,e in zip(middle_pos, end_pos))
    bpy.context.object.keyframe_insert(data_path="location", index=-1)


# Repeat the animation after 5 seconds
for i in range(end_frame+1, repeat_frame+1):
    bpy.context.scene.frame_set(i)
    bpy.context.object.location = end_pos
    bpy.context.object.keyframe_insert(data_path="location", index=-1)

# Add a camera and set its position
cam_data = bpy.data.cameras.new('Camera')
cam = bpy.data.objects.new('Camera', cam_data)
bpy.context.scene.collection.objects.link(cam)
cam.location = (0.0, -0.0, 30.0)

# Add a track constraint to the camera to follow the sphere
track_constraint = cam.constraints.new(type='TRACK_TO')
track_constraint.target = bpy.context.object
track_constraint.track_axis
























bbb

連番 007 未来光円錐 過去光円錐 円周中心からの球体放出

aaa 参考 2023年3月26日日曜日 製作 002b 未来光円錐の方向 線路レールで https://ia2023sha.blogspot.com/2023/03/002b.html import bpy import math zion_co...