加入顶点注释和面注释
This commit is contained in:
+3
-1
@@ -26,6 +26,7 @@ def create_triangular_obj_from_json(vertices_file, indices_file, output_file):
|
||||
|
||||
# 写入顶点信息 (v x y z)
|
||||
for i, vertex in enumerate(vertices):
|
||||
f.write(f"# 顶点 {i}\n")
|
||||
f.write(f"v {vertex[0]:.6f} {vertex[1]:.6f} {vertex[2]:.6f}\n")
|
||||
|
||||
f.write("\n")
|
||||
@@ -33,6 +34,7 @@ def create_triangular_obj_from_json(vertices_file, indices_file, output_file):
|
||||
# 写入面信息 (f v1 v2 v3)
|
||||
for triangle in triangles:
|
||||
# OBJ文件索引从1开始,所以需要+1
|
||||
f.write(f"# 面 {triangle[0]} {triangle[1]} {triangle[2]}\n")
|
||||
f.write(f"f {triangle[0]+1} {triangle[1]+1} {triangle[2]+1}\n")
|
||||
|
||||
def edges_to_triangles(edges):
|
||||
@@ -72,7 +74,7 @@ if __name__ == "__main__":
|
||||
indices_file = "point_connection.json" # 线索引数据文件
|
||||
|
||||
# 输出文件
|
||||
output_file = "D:/temp/vulkantest/Assets/face.obj" # 生成的OBJ文件
|
||||
output_file = "D:/Vulkan-Samples/python/face.obj" # 生成的OBJ文件
|
||||
|
||||
# 生成OBJ文件
|
||||
create_triangular_obj_from_json(vertices_file, indices_file, output_file)
|
||||
|
||||
Reference in New Issue
Block a user