2023年4月8日土曜日

torus 2 300

 



import bpy

from mathutils import Vector


# 設定可能な変数

zion_object_name = "totus 青300上昇"  # トーラスオブジェクトの名前

radius = 60  # トーラスの半径

tube_radius = 2  # トーラスの筒部分の半径

distance_per_frame = 0.1  # トーラスの移動距離

animation_frames = 1000  # アニメーションの再生時間(フレーム数)

wait_frames = 40  # アニメーション再生完了後の待機時間(フレーム数)

zion_stop = 300 * 0.1

zion_saibyouga = 30


# トーラスを作成する

def create_torus():

    bpy.ops.mesh.primitive_torus_add(major_radius=radius, minor_radius=tube_radius)

    torus = bpy.context.object

    torus.name = zion_object_name

    torus.location = Vector((0, 0, -tube_radius))

    torus.active_material = bpy.data.materials.new(name="zion_material")

    torus.active_material.use_nodes = True

    node_tree = torus.active_material.node_tree

    nodes = node_tree.nodes

    links = node_tree.links

    diffuse = nodes["Principled BSDF"]

    diffuse.inputs['Base Color'].default_value = (0.2, 0.6, 0.5, 0.05)

    return torus


torus = create_torus()


# アニメーションを再生するたびに呼び出される関数

def animate_torus(scene):

    global torus

    # 現在のフレーム数からトーラスの位置を計算する

    z = scene.frame_current * distance_per_frame

    if z <= zion_stop:

        torus.location = Vector((0, 0, -tube_radius + z))

    else:

        torus.location = Vector((0, 0, 30))

    # アニメーション再生完了後は一定フレーム数待機する

    if scene.frame_current >= animation_frames:

        if (scene.frame_current - animation_frames) < wait_frames:

            return

        else:

            # 現在のトーラスを削除して、新しいトーラスを作成する

            bpy.data.objects.remove(torus, do_unlink=True)

            torus = create_torus()

            # フレーム数を初期化する

            scene.frame_set(0)

            return


# フレーム更新のコールバック関数を登録する

bpy.app.handlers.frame_change_pre.append(animate_torus)


# アニメーションの再生時間を設定する

bpy.context.scene.frame_end = animation_frames + wait_frames




import bpy



# フレーム数を変更するための関数

def set_frame_range(start_frame, end_frame):

    bpy.context.scene.frame_start = start_frame

    bpy.context.scene.frame_end = end_frame



# 例: フレーム数を100に変更する場合

set_frame_range(1, 1000)

 


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

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