2023年4月6日木曜日

完成 31個の 線路レールからの移動

 

import bpy
import math


zion_collection_name = "stop300Sphere"

# コレクションを作成する
col = bpy.data.collections.new(zion_collection_name)
bpy.context.scene.collection.children.link(col)




import bpy
import math


zion_collection_name = "stop600Sphere"

# コレクションを作成する
col = bpy.data.collections.new(zion_collection_name)
bpy.context.scene.collection.children.link(col)






import bpy

from mathutils import Vector


# 球体の中心位置リストを作成する

centers = []

for i in range(31):

    x = -30 + i*2

    centers.append(Vector((x, 0, 0)))


# 目標位置を指定する

target_location = Vector((0, -30, 0))


# フレーム数を指定する

last_frame = 300


# 移動する距離を指定する

distance_per_frame = 0.1


# スフィアの作成

for center in centers:

    bpy.ops.mesh.primitive_uv_sphere_add(radius=1, enter_editmode=False, location=center)


# アニメーションの作成

for frame in range(last_frame+1):

    for index, obj in enumerate(bpy.data.objects):

        if obj.name.startswith("Sphere"):

            distance = (target_location - obj.location).length

            if distance > 0.01:  # 目標位置にまだ到達していない場合

                direction = (target_location - obj.location).normalized()

                obj.location += direction * min(distance_per_frame, distance)

                obj.keyframe_insert(data_path="location", frame=frame)






import bpy

from mathutils import Vector


# 球体の中心位置リストを作成する

centers = []

for i in range(31):

    x = -30 + i*2

    centers.append(Vector((x, 0, 0)))


# 目標位置を指定する

target_location = Vector((0, -30, 0))


# フレーム数を指定する

last_frame = 600


# 移動する距離を指定する

distance_per_frame = 0.1


# スフィアの作成

for center in centers:

    bpy.ops.mesh.primitive_uv_sphere_add(radius=1, enter_editmode=False, location=center)


# アニメーションの作成

for frame in range(last_frame+1):

    for index, obj in enumerate(bpy.data.objects):

        if obj.name.startswith("Sphere"):

            distance = (target_location - obj.location).length

            if distance > 0.01:  # 目標位置にまだ到達していない場合

                direction = (target_location - obj.location).normalized()

                obj.location += direction * min(distance_per_frame, distance)

                obj.keyframe_insert(data_path="location", frame=frame)













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

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