2023年4月8日土曜日

非表示 円錐300

 


import bpy

from mathutils import Vector


# 設定可能な変数

zion_object_name = "00逆さ円錐 300上昇"  # 円錐オブジェクトの名前

radius = 60  # 円錐の半径

height = 60  # 円錐の高さ

distance_per_frame = 0.1  # 円錐の移動距離

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

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

zion_stop = 300 * 0.1

zion_saibyouga = 30


# 円錐を作成する

def create_cone():

    bpy.ops.mesh.primitive_cone_add(radius1=0, radius2=radius, depth=height)

    cone = bpy.context.object

    cone.name = zion_object_name

    cone.location = Vector((0, 0, -height/2))  # 初期位置を設定する

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

    cone.active_material.use_nodes = True

    node_tree = cone.active_material.node_tree

    nodes = node_tree.nodes

    links = node_tree.links

    diffuse = nodes["Principled BSDF"]

    diffuse.inputs['Base Color'].default_value = (0.7, 0.7, 0.5, 0.1)

    return cone


cone = create_cone()


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

def animate_cone(scene):

    global cone

    # 現在のフレーム数から円錐の位置を計算する

    z = scene.frame_current * distance_per_frame

    if z <= zion_stop:

        # 円錐が存在しない場合は作成する

        if cone is None:

            cone = bpy.data.objects.new("Cone", bpy.data.meshes.new("Cone"))

            bpy.context.scene.collection.objects.link(cone)

        cone.location = Vector((0, 0, -height/2 + z))

        # 円錐を表示する

        cone.hide_render = False

        cone.hide_viewport = False

    else:

        if cone is not None:

            # 円錐を非表示にする

            cone.hide_render = True

            cone.hide_viewport = True

            # 円錐を削除して新しい円錐を作成する

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

            cone = create_cone()

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

            scene.frame_set(0)

        else:

            # 円錐が存在しない場合は何もしない

            pass


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

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


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

bpy.context.scene.frame_end = animation_frames + wait_frames


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

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