-
Notifications
You must be signed in to change notification settings - Fork 2
/
convex_decomposition.py
33 lines (26 loc) · 1018 Bytes
/
convex_decomposition.py
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
import pybullet as p
import argparse
import os
""" This file generates a folder called vhacd_meshes/ under the same parent folder as the input_dir """
def get_args():
parser = argparse.ArgumentParser()
parser.add_argument('--input_dir', type=str, required=True)
args = parser.parse_args()
return args
if __name__ == "__main__":
args = get_args()
parent_dir = os.path.dirname(args.input_dir)
meshes = os.listdir(args.input_dir)
meshes.sort()
output_dir = os.path.join(parent_dir, 'vhacd_meshes')
if not os.path.exists(output_dir):
os.makedirs(output_dir)
for i, m in enumerate(meshes):
input_mesh_path = os.path.join(args.input_dir, m)
output_mesh_path = os.path.join(output_dir, m)
log_file_path = os.path.join(output_dir, f'{i}.txt')
p.vhacd(fileNameIn=input_mesh_path,
fileNameOut=output_mesh_path,
fileNameLogging=log_file_path,
resolution=16000000,
depth=32)