球と平面

 

 

 

 

blender python

 

半径1の球を 旧中心 0,0,0

名前 基準球体

 

基準球体 表面の1点に

1辺2の正方形を 接点で接触させる

 

基準球体と この正方形を貫く垂線が直角

この接点位置を y=1に作って

 

この接点位置を指定できるように 冒頭定義

 

 

 

 

import bpy
import math

# このスクリプトでは、start_position、pass_through_position_1、pass_through_position_2、およびspeedに基づいて、
# 球体の移動アニメーションとフレーム数が自動的に調整されます。
# speedの値を大きくすると、球体の移動速度が増加し、結果としてフレーム数も自動的に調整されます。

# 球体の移動速度(blender unit per second)
speed = 1.0  # blender unit per second (increasing this value will increase the speed of the sphere)

# 球体の半径
radius = 0.15

# スタート位置 (x, y, z)
start_position = (0, 1, 0)

# 通過位置1 (x, y, z)
pass_through_position_1 = (1, 1, 0)

# 通過位置2 (x, y, z)
pass_through_position_2 = (0, 1, 0)

# 移動距離と時間を計算する関数
def calculate_distance_and_duration(start_pos, end_pos):
    distance = math.sqrt*1

    total_distance2, total_duration2 = calculate_distance_and_duration(pass_through_position_1, pass_through_position_2)
    set_animation(obj, pass_through_position_1, pass_through_position_2, int*2

    total_distance3, total_duration3 = calculate_distance_and_duration(pass_through_position_2, start_position)
    set_animation(obj, pass_through_position_2, start_position, int*3

    # アニメーションの終了時に現在のフレームをリセットしてループ再生する
    total_frames = int((total_duration + total_duration2 + total_duration3 + 2) * bpy.context.scene.render.fps)
    
    bpy.context.scene.frame_start = 1
    bpy.context.scene.frame_end = total_frames
    bpy.context.scene.frame_current = 1

# 球体のアニメーションを設定
animate_sphere(start_position, pass_through_position_1, pass_through_position_2)

 

 

*1:end_pos[0] - start_pos[0])**2 + (end_pos[1] - start_pos[1])**2 + (end_pos[2] - start_pos[2])**2)
    duration = distance / speed
    return distance, duration

# 移動アニメーションを設定する関数
def set_animation(obj, start_pos, end_pos, start_frame, end_frame):
    distance, duration = calculate_distance_and_duration(start_pos, end_pos)

    # 移動アニメーションの設定
    obj.location = start_pos
    obj.keyframe_insert(data_path="location", frame=start_frame)
    obj.location = end_pos
    obj.keyframe_insert(data_path="location", frame=end_frame)

# 球体のアニメーションを設定する関数
def animate_sphere(start_position, pass_through_position_1, pass_through_position_2):
    # スタート位置に球体を生成
    bpy.ops.mesh.primitive_uv_sphere_add(radius=radius, location=start_position)
    obj = bpy.context.active_object
    obj.name = "Sphere"

    # 球体の移動アニメーションを設定
    total_distance, total_duration = calculate_distance_and_duration(start_position, pass_through_position_1)
    set_animation(obj, start_position, pass_through_position_1, 1, int(total_duration * bpy.context.scene.render.fps

*2:total_duration + 1) * bpy.context.scene.render.fps), 
                  int((total_duration + total_duration2 + 1) * bpy.context.scene.render.fps

*3:total_duration + total_duration2 + 2) * bpy.context.scene.render.fps), 
                  int((total_duration + total_duration2 + total_duration3 + 2) * bpy.context.scene.render.fps

ボールの3点 動き

 

# このスクリプトでは、start_position、end_position_1、end_position_2、およびspeedに基づいて、
# 球体の移動アニメーションとフレーム数が自動的に調整されます。
# speedの値を大きくすると、球体の移動速度が増加し、結果としてフレーム数も自動的に調整されます。

 

 

 

# スタート位置 (x, y, z)
start_position = (0, 0, 0)

# 通過位置1 (x, y, z)
end_position_1 = (5, 0, 5)

# 目的位置2 (x, y, z)
end_position_2 = (-5, 0, 5)

 

平面の横スライド

 

平面の横スライド

 

 

Collectionを作る

https://chat.openai.com/share/6f4dd998-cd9b-411a-abf2-29bd8f662ddf

 

 

 

https://chat.openai.com/share/8e0be270-db1f-4c3b-b3ab-f7176dd920a9

 

 

以下 捨て

 

 

blender python

以下のスクリプトの球体を

10秒かけて 右に2動かし

一定速度で動かす

 

2動いたら 同じ一定速度で反対方向に2動かす

 

これを繰り返す

20240410 試作 太陽からの放射

 

 

 

 

 

球体を半径0.1で作る

次にxyz

000から300に 5秒で動き反転

300から000に戻りループ

 

 

球体を10秒で 0.0から12.0 へ動かす

https://chat.openai.com/share/d682272b-dcf9-41e4-b425-bf902dd9933a

 

 

球体速度 変更可能

https://chat.openai.com/share/6ad6668a-eab4-41bd-bfa0-0401c8071c7a

 

 

 

 

半径12 球体表面へ 

半径12球体中心から

 

10個の 小球体を動かす

https://chat.openai.com/share/b12d4071-ebe2-4508-ab18-010e6f6dbc74

 

 

 

 

 

# グループ1の球体の移動に関するパラメータ
target_time_group1 = 10  # 移動時間(秒)
center_radius_group1 = 10.0  # 中心の球体の半径
small_radius_group1 = 0.1  # 小さな球体の半径
num_spheres_group1 = 50  # グループ1の小さな球体の数

# グループ2の球体の移動に関するパラメータ
target_time_group2 = 10  # 移動時間(秒)
center_radius_group2 = 20.0  # 中心の球体の半径
small_radius_group2 = 0.2  # 小さな球体の半径
num_spheres_group2 = 50  # グループ2の小さな球体の数

 

 

 

xy平面 円周半径か

球体半経か

 

選択

https://chat.openai.com/share/ab05c8f7-359b-4513-a5fa-edf256ca081d

 

 

選択したオブジェクト複数を青色に

https://chat.openai.com/share/9689787e-1d40-4f63-b217-a0fb6e8cc751

 

 

 

2グループ xy yz zx 平面選択可能

 

 

 

数たくさん 成功

https://chat.openai.com/share/3f20b57f-a7bb-4e73-884c-27ac1a68c56b

 

 

 

 

 

 

最後のとこ 色登録の話

https://chat.openai.com/share/2c0786a8-d5d9-4691-8e52-04206c0f912b

 

このスクリプトでは、Blenderのカスタムパネルを使用してカラーコードを選択し、その選択に基づいてマテリアルが自動的に適用されます。スクリプトを実行すると、3Dビューポート内のカスタムツールカテゴリに「Color Picker」というパネルが表示され、ドロップダウンメニューからカラーコードを選択できます。選択されたカラーコードに基づいてマテリアルが作成され、選択されたメッシュオブジェクトに適用されます。

この方法であれば、コンソールへの表示をせずにインタラクティブにカラーコードを選択できるため、Blender内でのスクリプト実行に適した方法です。

 

放棄 コンソール

 

 

 

 

 

平面3つ 正方形 2重登録をdummy collection で

https://chat.openai.com/share/7721f118-5921-47f2-993d-a3201ed228a2

 

 

 

開発中の これから 反転の動き 注文

https://chat.openai.com/share/3f20b57f-a7bb-4e73-884c-27ac1a68c56b

 

 

 

 


アニメーションがループする際に、フレームの遷移がスムーズでないと感じられる場合は、アニメーションのキーフレームを調整することで解決できる場合があります。具体的には、最後のキーフレームと最初のキーフレームを繋げることで、滑らかなループを実現できます。

 

 

駄目な終了

https://chat.openai.com/share/2483517c-bc90-4c1f-8817-8205f642247d