2023年4月10日月曜日

x^2+y^2+z^2 = zion_distance

 


blender python で frame 毎に 進む距離を

x^2+y^2+z^2 = zion_distance 

と定義して Pythonスクリプト



Blender Pythonで、

各フレームでオブジェクトを移動する距離を

zion_distanceで定義し、

その距離だけオブジェクトを移動するスクリプト




import bpy

from mathutils import Vector


# 初期位置を取得

start_pos = bpy.context.active_object.location

# 初期フレームを取得

start_frame = bpy.context.scene.frame_current


def move_object():

    # 現在のフレームを取得

    current_frame = bpy.context.scene.frame_current

    # オブジェクトを移動する距離を計算

    zion_distance = (current_frame - start_frame)**2

    # 移動ベクトルを作成

    move_vector = Vector((zion_distance, zion_distance, zion_distance))

    # オブジェクトを移動

    bpy.context.active_object.location = start_pos + move_vector


# フレームを進める

for frame in range(start_frame, bpy.context.scene.frame_end+1):

    bpy.context.scene.frame_set(frame)

    move_object()


Blender Pythonでx^2+y^2+z^2 = r^2の球体を、

フレーム0から600で拡大するスクリプト




円錐 トーラス



import bpy


# 初期半径を設定

start_radius = 1

# 最終半径を設定

end_radius = 60

# 初期位置を取得

start_pos = (0, 0, 0)

# 初期フレームを取得

start_frame = bpy.context.scene.frame_current


# トーラスを作成する関数を定義

def create_torus(major_radius, minor_radius):

    bpy.ops.mesh.primitive_torus_add(major_radius=major_radius, minor_radius=minor_radius, location=start_pos)

    return bpy.context.object


# 半径を計算する関数を定義

def calculate_radius():

    current_frame = bpy.context.scene.frame_current

    current_radius = start_radius + (end_radius - start_radius) * current_frame / 600

    return current_radius


# フレームを進めて、トーラスを作成する

torus_objs = []

for frame in range(start_frame, 61):

    bpy.context.scene.frame_set(frame)




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

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