見出し画像

ChatGPT(GPT-4o)で3Dモデル生成(テキストから)

OpenAIが新しいマルチモーダルAI「GPT-4o(omni)」発表し、音声・視覚・テキストをリアルタイムで処理できるようになりました。

下の動画のように、GPT-4oにテーブルの3Dモデルを作成するよう依頼すると、指定したフォーマットで3Dモデルを作成し、ダウンロードできます。

Code Interpreter(Advanced Data Analysis)機能で以下のようなプログラムコード(Python)を生成・実行し、結果を出力してくれているわけですが、普通の人はプログラムコードが欲しいのではなくて、結果としての3Dモデルが欲しいのですから、ダウンロードまで一貫してできるのは良いですね。


import trimesh
import numpy as np

# Function to create a rectangular table with cylindrical legs
def create_table():
    # Table dimensions
    table_length = 2.0  # meters
    table_width = 1.0  # meters
    table_height = 0.1  # meters (thickness of the tabletop)
    leg_radius = 0.05  # meters
    leg_height = 0.75  # meters
    
    # Create the tabletop
    tabletop_vertices = [
        [0, 0, table_height],
        [table_length, 0, table_height],
        [table_length, table_width, table_height],
        [0, table_width, table_height],
        [0, 0, 0],
        [table_length, 0, 0],
        [table_length, table_width, 0],
        [0, table_width, 0]
    ]
    tabletop_faces = [
        [0, 1, 2, 3],
        [4, 5, 6, 7],
        [0, 1, 5, 4],
        [2, 3, 7, 6],
        [1, 2, 6, 5],
        [0, 3, 7, 4]
    ]
    
    # Create the legs
    def create_leg(x, y):
        theta = np.linspace(0, 2 * np.pi, 20)
        x_circle = leg_radius * np.cos(theta) + x
        y_circle = leg_radius * np.sin(theta) + y
        z_top = np.full_like(theta, table_height)
        z_bottom = np.full_like(theta, -leg_height)
        
        vertices = np.column_stack((x_circle, y_circle, z_top))
        vertices_bottom = np.column_stack((x_circle, y_circle, z_bottom))
        
        return vertices, vertices_bottom
    
    legs = []
    for x in [leg_radius, table_length - leg_radius]:
        for y in [leg_radius, table_width - leg_radius]:
            vertices_top, vertices_bottom = create_leg(x, y)
            legs.append((vertices_top, vertices_bottom))
    
    return tabletop_vertices, tabletop_faces, legs

# Generate the table
tabletop_vertices, tabletop_faces, legs = create_table()

# Convert to trimesh object
tabletop_mesh = trimesh.Trimesh(vertices=tabletop_vertices, faces=tabletop_faces)

# Create leg meshes and add to the table mesh
for vertices_top, vertices_bottom in legs:
    leg_vertices = np.vstack((vertices_top, vertices_bottom))
    leg_faces = []
    for i in range(len(vertices_top) - 1):
        leg_faces.append([i, i+1, i+len(vertices_top)+1])
        leg_faces.append([i, i+len(vertices_top), i+len(vertices_top)+1])
    leg_mesh = trimesh.Trimesh(vertices=leg_vertices, faces=leg_faces)
    tabletop_mesh = trimesh.util.concatenate([tabletop_mesh, leg_mesh])

# Export to STL
tabletop_mesh.export('/mnt/data/table_model.stl')

# Verify by displaying the mesh
tabletop_mesh.show()

また、自然言語処理と統合されているので、結構、雑な指示でも細かい部分はChatGPTが条件を自分で補いつつ、それなりの3Dモデルを生成してくれるのもすごいところです。

また、プログラムによって3D形状を生成しているので、将来的にはBIMのようなパラメトリックなオブジェクトや属性情報も扱えるようにあることが期待できますね。

Autodeskも2D画像やテキスト、ボクセル、点群などから機能的な3D形状を素早く生成できる「Project Bernini」を発表しています。

3D形状を生成するAIは、まだ、簡単なルールや単純な形状なものしか生成できないと思いますが、今後どのように進化していくのか目が離せませんね。


この記事が気に入ったらサポートをしてみませんか?