forked from BartMoyaers/BvhToDeepMimic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_script.py
54 lines (38 loc) · 1.51 KB
/
example_script.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Imports
# ===========================================================================
import json
import os
from os import listdir
from os.path import isfile, join
from bvhtomimic import BvhConverter
# Function declarations
# ===========================================================================
def removeAllFilesInDirectory(directory):
onlyfiles = [f for f in listdir(directory) if isfile(join(directory, f))]
for i in range(0, len(onlyfiles)):
os.remove(f"{directory}{onlyfiles[i]}")
# Initialization
# ===========================================================================
mypath = "./inputBvh/"
dirnames = ["./OutputMimic/", mypath]
for dirname in dirnames:
if not os.path.exists(dirname):
os.makedirs(dirname)
removeAllFilesInDirectory(dirnames[0])
# Locks root position and rotation for dev testing
posLocked = False
# sets onlyfiles to a list of files founds in the "mypath" directory
onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]
# Start of main program
# ===========================================================================
# for all files to convert
for j in range(0, len(onlyfiles)):
outputPath = f"./OutputMimic/{onlyfiles[j]}.txt"
# list containing all the frames
frames = []
# open file to convert
inputPath = "./inputBvh/" + onlyfiles[j]
# Convert file
converter = BvhConverter("./Settings/settings.json")
print("Converting:\t\"" + onlyfiles[j] + "\"")
converter.writeDeepMimicFile(inputPath, outputPath)