2023年3月17日金曜日

aaa





import bpy
import math

# トーラスの情報を格納するリスト
torus_info_list = [{'tag_name': 'torus_r30&0.2_0_0_0', 'location': (0, 0, 0)}]

for torus_info in torus_info_list:
    tag_name = torus_info['tag_name']
    location = torus_info['location']

    # コレクションを取得する
    collection = bpy.data.collections.get(tag_name)

    # コレクションが存在しない場合は作成する
    if not collection:
        collection = bpy.data.collections.new(tag_name)
        bpy.context.scene.collection.children.link(collection)

    # トーラスの半径と太さ
    major_radius = 30.0
    minor_radius = 0.2

    # トーラスを作成するための頂点と面のリスト
    verts = []
    faces = []

    # トーラスの頂点を作成する
    num_major_segments = 64
    num_minor_segments = 32
    major_angle_step = 2 * math.pi / num_major_segments
    minor_angle_step = 2 * math.pi / num_minor_segments
    for i in range(num_major_segments):
        for j in range(num_minor_segments):
            x = (major_radius + minor_radius * math.cos(minor_angle_step * j)) * math.cos(major_angle_step * i)
            y = (major_radius + minor_radius * math.cos(minor_angle_step * j)) * math.sin(major_angle_step * i)
            z = minor_radius * math.sin(minor_angle_step * j)
            verts.append((x, y, z))

    # トーラスの面を作成する
    for i in range(num_major_segments):
        for j in range(num_minor_segments):
            a = i * num_minor_segments + j
            b = (i + 1) % num_major_segments * num_minor_segments + j
            c = (i + 1) % num_major_segments * num_minor_segments + (j + 1) % num_minor_segments
            d = i * num_minor_segments + (j + 1) % num_minor_segments
            faces.append((a, b, c, d))

    # メッシュオブジェクトを作成する
    mesh = bpy.data.meshes.new(tag_name + '_mesh')
    mesh.from_pydata(verts, [], faces)

    # オブジェクトを作成して、メッシュを割り当てる
    obj = bpy.data.objects.new(tag_name + '_object', mesh)
    obj.location = location
    collection.objects.link(obj)





































bbb

連番 007 未来光円錐 過去光円錐 円周中心からの球体放出

aaa 参考 2023年3月26日日曜日 製作 002b 未来光円錐の方向 線路レールで https://ia2023sha.blogspot.com/2023/03/002b.html import bpy import math zion_co...