2023年3月24日金曜日

成功? 平面充填ランダム

aaa











import bpy
import math
from mathutils import Vector
import random

# 速度を指定する
zion_speed = 1.0

# 目標位置を指定する
zion_target = Vector((0, -30, 0))

# 平行移動するかどうかを指定する
parallel = False

# 平行移動量を指定する
parallel_distance = Vector((300, 300, 300))


# 範囲を指定する
start_point = Vector((-10, 0, -10))
end_point = Vector((10, 0, 10))

# 新しいパラメータを指定する
num_spheres = 200  # 球体の数
radius = 1  # 球体の半径

# 球体を作成する関数
def create_sphere(location, radius):
    bpy.ops.mesh.primitive_uv_sphere_add(location=location, radius=radius)

# 範囲内でランダムに位置を生成する
def random_location(start, end):
    x = random.uniform(start.x, end.x)
    y = random.uniform(start.y, end.y)
    z = random.uniform(start.z, end.z)
    return Vector((x, y, z))

# 球体を作成する
spheres = []
for i in range(num_spheres):
    location = random_location(start_point, end_point)
    create_sphere(location, radius)
    obj = bpy.context.active_object
    spheres.append(obj)

# オブジェクトを作成する関数
def create_sphere(location, radius):
    bpy.ops.mesh.primitive_uv_sphere_add(location=location, radius=radius)


# アニメーションを設定する関数
def set_animation(obj, start_frame, end_frame, target_location, speed):
    distance = (target_location - obj.location).length
    duration = distance / speed
    for frame in range(start_frame, end_frame+1):
        t = (frame - start_frame) / duration
        obj.location = obj.location.lerp(target_location, t)
        obj.keyframe_insert(data_path="location", frame=frame)

# アニメーションを設定する
for i, sphere in enumerate(spheres):
    start_frame = 1
    end_frame = 250
    location = sphere.location
    if parallel:
        target_location = location + parallel_distance
    else:
        target_location = zion_target
    distance = (target_location - location).length
    speed = zion_speed / distance
    set_animation(sphere, start_frame, end_frame, target_location, speed)



























bbb

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

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