2023年3月13日月曜日

20230314 tue ランダム 50個 球体 雨降り 速度調整 

aaa



import bpy
import random

# タグ名
tag_name = "rain_drops50"

# コレクションを取得する
collection = bpy.data.collections.get(tag_name)

# コレクションが存在しない場合は作成する
if not collection:
    collection = bpy.data.collections.new(tag_name)
    bpy.context.scene.collection.children.link(collection)

# 球体の半径を設定
radius = 5.0

for i in range(50):
    # 球体の初期位置と移動先の位置をランダムに設定
    y = random.uniform(-300, 300)
    loc_a_start = (0, y, 300)
    loc_a_end = (0, y, 0)

    # 球体Aを作成し、初期位置を設定する
    bpy.ops.mesh.primitive_uv_sphere_add(radius=radius, location=loc_a_start)
    obj_a = bpy.context.object

    # コレクションにオブジェクトを追加する
    collection.objects.link(obj_a)

    # アニメーションのフレーム設定を行う
    start_frame = 1  # アニメーションの最初のフレーム
    end_frame_a = int(20 * bpy.context.scene.render.fps)  # 球体Aの移動が終わるフレーム
    bpy.context.scene.frame_start = start_frame  # アニメーションの開始フレームを設定
    bpy.context.scene.frame_end = end_frame_a  # アニメーションの終了フレームを設定

    # キーフレームを設定する
    obj_a.location = loc_a_start  # 球体Aの開始位置を設定
    obj_a.keyframe_insert(data_path="location", frame=start_frame)  # 開始フレームでキーフレームを設定
    obj_a.location = loc_a_end  # 球体Aの終了位置を設定
    obj_a.keyframe_insert(data_path="location", frame=end_frame_a)  # 終了フレームでキーフレームを設定

# アニメーション再生
bpy.ops.screen.animation_play()  # アニメーションを再生










# コレクションを作成し、タグ名を設定する
col = bpy.data.collections.new("rain_drops50")
bpy.context.scene.collection.children.link(col)




    # オブジェクトをコレクションに追加する
    collection.objects.link(obj_a)


bbb
togetter.com/t/c2022meetzionad
togetter.com/t/b2022meetzionad




twitter 新着検索 Dürer & 測距儀


aaa









bbb
twitter zionadchat
twitter に追い出されたら 連絡先は Gettr https://gettr.com/user/zionadchat
twitter サブアカウント https://twitter.com/2022zionad

old page いいい
new page いいい

目次 2022の目次 単純トリック hatena zionadchat
いいいいいいいい

伊勢丹 建物広告 球体群 配置 20240323_001

aaa y軸に 球体半径0.1を等間隔に配置して 球体の名前は Sphere_x_y_z で 小数1桁で 座標位置で 名前を作る y=+1から ー1までで 21個の球体で 作る コレクションだけを作って "y軸の球体群" import bpy #...