2023年4月8日土曜日

ニュートン ball 速度規定を 基準にする distance_per_frame = 0.1

 



# 斜め上 スタート


import bpy

from math import sin, cos, pi


zion_object_name = "幻想 斜め 速度"


# 設定可能な変数

start_pos = (0, 0, 30)  # 開始位置

end_pos = (-30, 0, 0)  # 終了位置

radius = 2.0  # 半径

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


sokudo_chousei =1.41

distance_per_frame = 0.1 * sokudo_chousei  # 1フレームあたりに進む距離


# 球体を作成する

bpy.ops.mesh.primitive_uv_sphere_add(radius=radius, enter_editmode=False, align='WORLD', location=start_pos)

sphere = bpy.context.object

sphere.name = zion_object_name  # オブジェクトの名前を変更


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

def animate_sphere(scene):

    global sphere, distance_per_frame


    # 現在のフレームにおける球体の位置を計算する

    frame = scene.frame_current

    pos_x = start_pos[0] - ((start_pos[0] - end_pos[0]) / animation_frames) * frame

    pos_y = start_pos[1] - ((start_pos[1] - end_pos[1]) / animation_frames) * frame

    pos_z = start_pos[2] - ((start_pos[2] - end_pos[2]) / animation_frames) * frame

    sphere.location = (pos_x, pos_y, pos_z)


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

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


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

bpy.context.scene.frame_end = animation_frames


# スクリプトを実行する前にフレームを初期化する

bpy.context.scene.frame_set(0)






 # 水平地面


import bpy

from math import sin, cos, pi


zion_object_name = "リアル水平 速度"


# 設定可能な変数

start_pos = (0, 0, 0)  # 開始位置

end_pos = (-30, 0, 0)  # 終了位置

radius = 2.0  # 半径

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


sokudo_chousei =1.0

distance_per_frame = 0.1 * sokudo_chousei  # 1フレームあたりに進む距離


# 球体を作成する

bpy.ops.mesh.primitive_uv_sphere_add(radius=radius, enter_editmode=False, align='WORLD', location=start_pos)

sphere = bpy.context.object

sphere.name = zion_object_name  # オブジェクトの名前を変更


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

def animate_sphere(scene):

    global sphere, distance_per_frame


    # 現在のフレームにおける球体の位置を計算する

    frame = scene.frame_current

    pos_x = start_pos[0] - ((start_pos[0] - end_pos[0]) / animation_frames) * frame

    pos_y = start_pos[1] - ((start_pos[1] - end_pos[1]) / animation_frames) * frame

    pos_z = start_pos[2] - ((start_pos[2] - end_pos[2]) / animation_frames) * frame

    sphere.location = (pos_x, pos_y, pos_z)


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

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


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

bpy.context.scene.frame_end = animation_frames


# スクリプトを実行する前にフレームを初期化する

bpy.context.scene.frame_set(0)






#  リアル斜め 速度 


import bpy

from math import sin, cos, pi


zion_object_name = "リアル斜め 速度 "


# 設定可能な変数

start_pos = (0, 0, 30)  # 開始位置

end_pos = (-30, 0, 0)  # 終了位置

radius = 2.0  # 半径

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


sokudo_chousei =1.0

distance_per_frame = 0.1 * sokudo_chousei  # 1フレームあたりに進む距離


# 球体を作成する

bpy.ops.mesh.primitive_uv_sphere_add(radius=radius, enter_editmode=False, align='WORLD', location=start_pos)

sphere = bpy.context.object

sphere.name = zion_object_name  # オブジェクトの名前を変更


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

def animate_sphere(scene):

    global sphere, distance_per_frame


    # 現在のフレームにおける球体の位置を計算する

    frame = scene.frame_current

    pos_x = start_pos[0] - ((start_pos[0] - end_pos[0]) / animation_frames) * frame

    pos_y = start_pos[1] - ((start_pos[1] - end_pos[1]) / animation_frames) * frame

    pos_z = start_pos[2] - ((start_pos[2] - end_pos[2]) / animation_frames) * frame

    sphere.location = (pos_x, pos_y, pos_z)


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

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


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

bpy.context.scene.frame_end = animation_frames


# スクリプトを実行する前にフレームを初期化する

bpy.context.scene.frame_set(0)






 









ニュートン bball 色付き 幻想ボールから

 

最初に定義されたzion_object_name変数は、球体オブジェクトの名前として使用されているため、変更するとエラーが発生する可能性があります。その場合は、sphere = bpy.data.objects["幻想 ball 上昇"]のように、直接オブジェクト名を使用して球体オブジェクトを取得することができます。




import bpy

from math import sin, cos, pi


zion_object_name = "幻想 斜め下降"


# 設定可能な変数

start_pos = (0, 0, 30)  # 開始位置

end_pos = (-30, 0, 0)  # 終了位置

radius = 2.0  # 半径

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


# 球体を作成する

bpy.ops.mesh.primitive_uv_sphere_add(radius=radius, enter_editmode=False, align='WORLD', location=start_pos)

sphere = bpy.context.object

sphere.name = zion_object_name  # オブジェクトの名前を変更


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

def animate_sphere(scene):

    global sphere

    

    # 現在のフレームにおける球体の位置を計算する

    frame = scene.frame_current

    pos_x = start_pos[0] - ((start_pos[0] - end_pos[0]) / animation_frames) * frame

    pos_y = start_pos[1] - ((start_pos[1] - end_pos[1]) / animation_frames) * frame

    pos_z = start_pos[2] - ((start_pos[2] - end_pos[2]) / animation_frames) * frame

    sphere.location = (pos_x, pos_y, pos_z)


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

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


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

bpy.context.scene.frame_end = animation_frames


# スクリプトを実行する前にフレームを初期化する

bpy.context.scene.frame_set(0)


# 球体を青色で少し白っぽくする処理

mat = bpy.data.materials.new(name="BlueWhite")

mat.use_nodes = True

mat.node_tree.nodes["Principled BSDF"].inputs[0].default_value = (0.15, 0.3, 0.8, 1) # 青色

mat.node_tree.nodes["Principled BSDF"].inputs[7].default_value = 0.2 # 白さを調整

sphere.data.materials.append(mat)





import bpy

from math import sin, cos, pi


zion_object_name = "幻想 水平 移動"


# 設定可能な変数

start_pos = (0, 0, 0)  # 開始位置

end_pos = (-30, 0, 0)  # 終了位置

radius = 2.0  # 半径

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


# 球体を作成する

bpy.ops.mesh.primitive_uv_sphere_add(radius=radius, enter_editmode=False, align='WORLD', location=start_pos)

sphere = bpy.context.object

sphere.name = zion_object_name  # オブジェクトの名前を変更


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

def animate_sphere(scene):

    global sphere

    

    # 現在のフレームにおける球体の位置を計算する

    frame = scene.frame_current

    pos_x = start_pos[0] - ((start_pos[0] - end_pos[0]) / animation_frames) * frame

    pos_y = start_pos[1] - ((start_pos[1] - end_pos[1]) / animation_frames) * frame

    pos_z = start_pos[2] - ((start_pos[2] - end_pos[2]) / animation_frames) * frame

    sphere.location = (pos_x, pos_y, pos_z)


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

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


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

bpy.context.scene.frame_end = animation_frames


# スクリプトを実行する前にフレームを初期化する

bpy.context.scene.frame_set(0)


# 球体を青色で少し白っぽくする処理

mat = bpy.data.materials.new(name="BlueWhite")

mat.use_nodes = True

mat.node_tree.nodes["Principled BSDF"].inputs[0].default_value = (0.15, 0.3, 0.8, 1) # 青色

mat.node_tree.nodes["Principled BSDF"].inputs[7].default_value = 0.2 # 白さを調整

sphere.data.materials.append(mat)









ニュートンの tree ball 原型 色なし

 



import bpy


from math import sin, cos, pi


zion_object_name = "幻想 ball 上昇"


# 設定可能な変数

start_pos = (0,0, 30)  # 開始位置

end_pos = (-30, 0, 0)  # 終了位置

radius = 1.0  # 半径

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


# 球体を作成する

bpy.ops.mesh.primitive_uv_sphere_add(radius=radius, enter_editmode=False, align='WORLD', location=start_pos)

sphere = bpy.context.object

sphere.name = zion_object_name  # Rename the object


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

def animate_sphere(scene):

    global sphere

    

    # 現在のフレームにおける球体の位置を計算する

    frame = scene.frame_current

    pos_x = start_pos[0] - ((start_pos[0] - end_pos[0]) / animation_frames) * frame

    pos_y = start_pos[1] - ((start_pos[1] - end_pos[1]) / animation_frames) * frame

    pos_z = start_pos[2] - ((start_pos[2] - end_pos[2]) / animation_frames) * frame

    sphere.location = (pos_x, pos_y, pos_z)


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

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


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

bpy.context.scene.frame_end = animation_frames


# スクリプトを実行する前にフレームを初期化する

bpy.context.scene.frame_set(0)




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)






#  幻想 地面 高さ


import bpy


from math import sin, cos, pi


zion_object_name = "幻想 地面高さ ball "


# 設定可能な変数

start_pos = (0,0, 0)  # 開始位置

end_pos = (-30, 0, 0)  # 終了位置

radius = 1.0  # 半径

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


# 球体を作成する

bpy.ops.mesh.primitive_uv_sphere_add(radius=radius, enter_editmode=False, align='WORLD', location=start_pos)

sphere = bpy.context.object

sphere.name = zion_object_name  # Rename the object



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

def animate_sphere(scene):

    global sphere

    

    # 現在のフレームにおける球体の位置を計算する

    frame = scene.frame_current

    pos_x = start_pos[0] - ((start_pos[0] - end_pos[0]) / animation_frames) * frame

    pos_y = start_pos[1] - ((start_pos[1] - end_pos[1]) / animation_frames) * frame

    pos_z = start_pos[2] - ((start_pos[2] - end_pos[2]) / animation_frames) * frame

    sphere.location = (pos_x, pos_y, pos_z)


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

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


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

bpy.context.scene.frame_end = animation_frames


# スクリプトを実行する前にフレームを初期化する

bpy.context.scene.frame_set(0)




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)






"ニュートン りんごの tree"

 RGBA値を使用して




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)

 


動かなくなった 300 ao 円錐代わりに2 300 止まり

 




import bpy

from mathutils import Vector


# 設定可能な変数

zion_object_name = "torus 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.1, 0.1, 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

from mathutils import Vector



# 設定可能な変数

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

radius = 60  # トーラスの半径

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

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

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

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

zion_stop = 600 * 0.1

zion_saibyouga = 60



# トーラスを作成する

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.7, 0.1, 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, 60))

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

    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)


円錐の代わりに トーラス 600 止まり 赤紫 1000 frame +40





import bpy

from mathutils import Vector


# 設定可能な変数

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

radius = 60  # トーラスの半径

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

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

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

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

zion_stop = 600 * 0.1

zion_saibyouga = 60


# トーラスを作成する

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.7, 0.1, 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, 60))

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

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