2023年4月4日火曜日

 


#固定  移動開始位置


import bpy

import math

from mathutils import Vector


# 16個の球体を作成する

spheres = []

for i in range(16):

    angle = 2 * i * 3.14159 / 16

    x = 30 * math.cos(angle)

    y = 30 * math.sin(angle)

    z = 0

    location = Vector((x, y, z))

    radius = 1

    bpy.ops.mesh.primitive_uv_sphere_add(location=location, radius=radius)

    obj = bpy.context.active_object

    obj.name = "300Sphere_" + str(i)  # オブジェクトに名前を付ける

    spheres.append(obj)





import bpy

import math

from mathutils import Vector


# 目標位置を指定する

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


# フレーム数を指定する

last_frame = 300


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

# distance_per_frame = 0.2


# 16個の球体を作成する

spheres = []

for i in range(16):

    angle = 2 * i * 3.14159 / 16

    x = 30 * math.cos(angle)

    y = 30 * math.sin(angle)

    z = 0

    location = Vector((x, y, z))

    radius = 1

    bpy.ops.mesh.primitive_uv_sphere_add(location=location, radius=radius)

    obj = bpy.context.active_object

    obj.name = "300Sphere_" + str(i)  # オブジェクトに名前を付ける

    spheres.append(obj)


# アニメーションを設定する

for i, sphere in enumerate(spheres):

    start_location = sphere.location

    direction = (target_location - start_location).normalized()

    for frame in range(1, last_frame + 1):

        sphere.location += distance_per_frame * direction

        sphere.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...