-
Notifications
You must be signed in to change notification settings - Fork 0
/
cryengine_retrieve_draft_models.py
57 lines (43 loc) · 2.05 KB
/
cryengine_retrieve_draft_models.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
55
56
#!/usr/bin/env python3
import os
import shutil
import configuration
def retrieveTestModel(modelPath):
testPath = os.path.join(configuration.cryengineDirectory, "objects", "_warehouse", "_test")
if os.path.exists(os.path.join(testPath, modelPath)):
retrieveDirectory = os.path.join("models", modelPath, "_retrieved")
if os.path.exists(retrieveDirectory):
shutil.rmtree(retrieveDirectory)
shutil.copytree(os.path.join(testPath, modelPath), retrieveDirectory)
os.remove(os.path.join(retrieveDirectory, "mark-ce-draft.txt"))
print("\nRetrieved finished draft model '%s' from Cryengine game directory!" % \
(modelPath))
os.remove(os.path.join("models", modelPath, "mark-ce-draft.txt"))
materialFilename = os.path.join(retrieveDirectory, os.path.basename(modelPath) + ".mtl")
if os.path.exists(materialFilename):
materialFile = open(materialFilename, "r")
materialData = materialFile.read()
materialFile.close()
materialData = materialData.replace("_warehouse/_test/", "_warehouse/")
materialFile = open(materialFilename, "w")
materialFile.write(materialData)
materialFile.close()
print(" -> Fixed material texture links.\n")
else:
print(" -> Could not retrieve material file to fix.\n")
else:
input("\nNo test model at that location!\n")
once = False
if os.path.exists(configuration.cryengineDirectory):
for (dirpath, dirnames, filenames) in os.walk("models"):
if "mark-ce-draft.txt" in filenames:
once = True
retrieveTestModel(os.sep.join(dirpath.split(os.sep)[1:]))
if not once:
input("\nNo marks found. Copy the mark " + \
"'utilities/mark-ce-draft.txt' to any " + \
"model folder you wish to retrieve after testing.\n")
else:
input("\nAll marked models retrieved!\n")
else:
input("\nCryengine directory is wrong! Change it in 'config.txt'.\n")