import bpy
import math
# フィルタータイプの辞書を作成
filter_types = {
1: 'NOTHING', # 穴なし??
2: 'NGON', # 多角形??
3: 'TRIFAN' # 三角形の組み合わせ??
}
# 冒頭で中心座標とフィルタータイプを選択
zionad_circle = (0, 0, 0) # サークルの中心位置座標を指定
selected_type = 2 # 1: NOTHING, 2: NGON, 3: TRIFAN を選択
num_edges = 0 # 分割数を指定しない場合は 0 とします
# サークルを作成して配置する関数を定義
def create_circle(x_coordinate, y_coordinate, z_coordinate, fill_type, color, num_edges):
"""
与えられた座標に円を作成し、指定されたフィルタータイプで分割します。
Parameters:
x_coordinate (float): x 座標
y_coordinate (float): y 座標
z_coordinate (float): z 座標
fill_type (str): フィルタータイプ
color (tuple): マテリアルの色(RGBA)
num_edges (int): 円の分割数
"""
# サークルを作成
if num_edges > 0:
bpy.ops.mesh.primitive_circle_add(radius=1, fill_type=fill_type, vertices=num_edges, location=(x_coordinate, y_coordinate, z_coordinate))
else:
bpy.ops.mesh.primitive_circle_add(radius=1, fill_type=fill_type, location=(x_coordinate, y_coordinate, z_coordinate))
# アクティブなオブジェクトを取得
obj = bpy.context.active_object
# マテリアルを作成
mat = bpy.data.materials.new(name="MyMaterial")
mat.use_nodes = True
nodes = mat.node_tree.nodes
principled_bsdf = nodes.get("Principled BSDF")
output = nodes.get("Material Output")
# マテリアルにノードを追加して色を設定
color_node = nodes.new(type='ShaderNodeRGB')
color_node.outputs[0].default_value = color
obj.data.materials.append(mat)
# マテリアルのノードを接続
links = mat.node_tree.links
links.new(color_node.outputs[0], principled_bsdf.inputs[0])
links.new(principled_bsdf.outputs[0], output.inputs[0])
# 選択されたフィルタータイプに応じてサークルを作成
fill_type = filter_types[selected_type]
color = (0, 0, 1, 1) if fill_type == 'NOTHING' else (0, 1, 0, 1) if fill_type == 'NGON' else (1, 0, 0, 1)
create_circle(zionad_circle[0], zionad_circle[1], zionad_circle[2], fill_type, color, num_edges)
これで正方形を作り
正方形中心 0,0,0
node で
image texture 使い
"C:\aaa_2024all\2024copy\20240502___IMG_0409.PNG"
この画像を貼る
mix color に繋げ それを
procipled BSDF base color に繋げ
それを material out put の surface につなげる
aaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaa