export_shaderdoc

alt text

alt text

alt text

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# -*- coding: utf-8 -*-
import csv

# 存储顶点数据
vertices = []
# 存储纹理坐标数据
tex_coords = []
# 存储面数据
faces = []

# 读取CSV文件
with open('kjj.csv', 'r') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
# 解析顶点数据
vertex = [
float(row[' Position.x']),
float(row[' Position.y']),
float(row[' Position.z']),

]
vertices.append(vertex)

# 解析纹理坐标数据
tex_coord = [
float(row[' UV0.x']),
float(row[' UV0.y'])
]
tex_coords.append(tex_coord)

# 每三个顶点组成一个面
for i in range(0, len(vertices), 3):
face = f"f {i+1}/{i+1}/{i+1} {i+2}/{i+2}/{i+2} {i+3}/{i+3}/{i+3}\n"
faces.append(face)

# 写入OBJ文件
with open('kjj.obj', 'w') as obj_file:
# 写入顶点数据
for vertex in vertices:
obj_file.write(f"v {vertex[0]} {vertex[1]} {vertex[2]}\n")

# 写入纹理坐标数据
for tex_coord in tex_coords:
obj_file.write(f"vt {tex_coord[0]} {tex_coord[1]}\n")

# 写入面数据
for face in faces:
obj_file.write(face)

export_shaderdoc
http://tt432.github.io/export-shaderdoc/
作者
秦千久
发布于
2024年11月30日
许可协议