2023年4月4日火曜日

 


最初の 一個は 捨て





import bpy

from mathutils import Vector



zion_x =-10

zion_y = -50




distance_per_frame = 1.0  # 1フレームごとの移動距離(ブレンダー単位)

run_simultaneously = False  # True なら同時移動、False なら順次移動


for a in range(11):

    # 新しい球体を作成

    bpy.ops.mesh.primitive_uv_sphere_add(radius=1)

    sphere = bpy.context.object


    # 初期位置のキーフレームを設定

    sphere.location = Vector((zion_x +a * 10 + 10, zion_y, 0))

    sphere.keyframe_insert(data_path='location', frame=a * 10)


    # 終了位置のキーフレームを設定

    sphere.location = Vector((zion_x +a * 10 + 10, 50, 0))

    sphere.keyframe_insert(data_path='location', frame=100)


    # 位置のキーフレームを設定

    if run_simultaneously:

        for i in range(101):

            sphere.location = Vector((a * 10 + 10, i * distance_per_frame, 0))

            sphere.keyframe_insert(data_path='location', frame=i)

    else:

        current_frame = a * 10

        current_pos = Vector((a * 10 + 10, zion_y, 0))

        while current_frame <= 500:

            current_pos += Vector((0, distance_per_frame, 0))

            sphere.location = current_pos

            sphere.keyframe_insert(data_path='location', frame=current_frame)

            current_frame += 1


# アニメーションを再生

bpy.context.scene.frame_end = 100

bpy.ops.screen.animation_play()











import bpy

from mathutils import Vector



zion_x =-10

zion_y = -50




distance_per_frame = 1.0  # 1フレームごとの移動距離(ブレンダー単位)

run_simultaneously = True  # True なら同時移動、False なら順次移動


for a in range(11):

    # 新しい球体を作成

    bpy.ops.mesh.primitive_uv_sphere_add(radius=1)

    sphere = bpy.context.object


    # 初期位置のキーフレームを設定

    sphere.location = Vector((zion_x +a * 10 + 10, zion_y, 0))

    sphere.keyframe_insert(data_path='location', frame=a * 10)


    # 終了位置のキーフレームを設定

    sphere.location = Vector((zion_x +a * 10 + 10, 500, 0))

    sphere.keyframe_insert(data_path='location', frame=500)


    # 位置のキーフレームを設定

    if run_simultaneously:

        for i in range(101):

            sphere.location = Vector((a * 10 + 10, i * distance_per_frame, 0))

            sphere.keyframe_insert(data_path='location', frame=i)

    else:

        current_frame = a * 10

        current_pos = Vector((a * 10 + 10, zion_y, 0))

        while current_frame <= 500:

            current_pos += Vector((0, distance_per_frame, 0))

            sphere.location = current_pos

            sphere.keyframe_insert(data_path='location', frame=current_frame)

            current_frame += 1


# アニメーションを再生

bpy.context.scene.frame_end = 500

bpy.ops.screen.animation_play()






import bpy

from mathutils import Vector



zion_x =-10

zion_y = -50




distance_per_frame = 1.0  # 1フレームごとの移動距離(ブレンダー単位)

run_simultaneously = False  # True なら同時移動、False なら順次移動


for a in range(11):

    # 新しい球体を作成

    bpy.ops.mesh.primitive_uv_sphere_add(radius=1)

    sphere = bpy.context.object


    # 初期位置のキーフレームを設定

    sphere.location = Vector((zion_x +a * 10 + 10, zion_y, 0))

    sphere.keyframe_insert(data_path='location', frame=a * 10)


    # 終了位置のキーフレームを設定

    sphere.location = Vector((zion_x +a * 10 + 10, 30, 0))

    sphere.keyframe_insert(data_path='location', frame=500)


    # 位置のキーフレームを設定

    if run_simultaneously:

        for i in range(101):

            sphere.location = Vector((a * 10 + 10, i * distance_per_frame, 0))

            sphere.keyframe_insert(data_path='location', frame=i)

    else:

        current_frame = a * 10

        current_pos = Vector((a * 10 + 10, zion_y, 0))

        while current_frame <= 500:

            current_pos += Vector((0, distance_per_frame, 0))

            sphere.location = current_pos

            sphere.keyframe_insert(data_path='location', frame=current_frame)

            current_frame += 1


# アニメーションを再生

bpy.context.scene.frame_end = 500

bpy.ops.screen.animation_play()








改良中 y=-30 中心 円周への球体36個

できた y= -30 中心で z=0平面移動  import bpy import math zion_collection_name = "線路レール 観察者" # コレクションを作成する col = bpy.data.collections.new(zio...