-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
25 lines (18 loc) · 955 Bytes
/
utils.py
File metadata and controls
25 lines (18 loc) · 955 Bytes
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
"""Various utility functions"""
def ccwify_obj_file(filepath: str) -> None:
"""Note: this will create a new file with '_ccw' concatenated to the original filename
More accurately, this function flips all face winding orders, so cw -> ccw and vice-versa
"""
if (filepath[-4:] != ".obj"):
raise FileNotFoundError(f"No obj file found at {filepath}")
with open(filepath, 'r') as file:
raw = file.readlines()
with open(filepath[:-4]+"_ccw.obj", 'w') as newf:
#vertexes = [[float(vertex) for vertex in line.split()[1:]] for line in raw if line[:2] == 'f ']
for line in raw:
if (line[:2] == 'f '):
faces = line.split()[1:]
newf.write("f " + ' '.join(faces[::-1])+'\n')
continue
newf.write(line)
#ccwify_obj_file("./assets/cube/cube.obj")