-
Notifications
You must be signed in to change notification settings - Fork 1
/
makehuman.py
executable file
·132 lines (106 loc) · 4.04 KB
/
makehuman.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/usr/bin/python3
import argparse, textwrap
import os
import sys
from time import sleep
from PySide6.QtWidgets import QApplication
from PySide6.QtCore import QEventLoop
from core.globenv import programInfo, globalObjects
from gui.mainwindow import MHMainWindow
from gui.infowindow import MHInfoWindow
from gui.application import MHApplication
from core.baseobj import baseClass
def main():
"""
main simply
* parses arguments
* calls environment
* sets theme
* starts application itself
"""
parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter)
# optional arguments
parser.add_argument("model", type=str, nargs='?', help="name of an mhm model file (use with base mesh")
parser.add_argument('-V', '--version', action='store_true', help="Show version and License")
parser.add_argument("--nomultisampling", action="store_true", help=textwrap.dedent('''\
disable multisampling (used to display multi transparent layers)
without multisampling normal blend function is used'''))
parser.add_argument("-l", action="store_true", help="force to write to log file")
parser.add_argument("-b", "--base", type=str, help="preselect base mesh use 'none' for no preselection")
parser.add_argument("-A", '--admin', action="store_true", help="Support administrative tasks ('Admin'). Command will write into program folder, where makehuman is installed.")
parser.add_argument("-v", "--verbose", type=int, default = 1, help= textwrap.dedent('''\
bitwise verbose option (add values)
1 low log level (standard)
2 mid log level
4 memory management
8 file access
16 enable numpy runtime error messages
32 JSON for e.g glTF'''))
args = parser.parse_args()
frozen = getattr(sys, 'frozen', False) # frozen means, no source download
if frozen:
syspath = os.path.dirname(sys.executable)
else:
syspath = os.path.dirname(os.path.realpath(__file__))
# get programInfo as environment (only for strings to be printed in JSON)
# and globalObjects for non-printable objects
env = programInfo(frozen, syspath, args)
if not env.environment():
print (env.last_error)
exit (20)
if args.version:
env.showVersion()
exit(0)
glob = globalObjects(env)
if not glob.readShaderInitJSON():
print (env.last_error)
exit (21)
if args.verbose & 2:
print (env)
theme = env.existDataFile("themes", env.config["theme"])
app = MHApplication(glob, sys.argv)
glob.setApplication(app)
if app.setStyles(theme) is False:
env.logLine(1, env.last_error)
if args.base:
if args.base == "none":
env.basename = None
else:
env.basename = args.base
if env.basename is not None:
dirname = env.existDataDir("base", env.basename)
if dirname is None:
print("Base mesh " + env.basename + " does not exist")
exit(22)
modelfile = None
if args.model is not None:
if env.basename is None:
print("Cannot load a model with undefined base mesh")
exit(23)
if not args.model.endswith(".mhm"):
args.model += ".mhm"
modelpath = env.stdUserPath("models")
modelfile = env.existDataFile("models", env.basename, args.model)
if modelfile is None:
print("File '" + args.model + "' does not exist in: " + str(modelpath))
exit(24)
# splash screen
#
loading = MHInfoWindow(glob)
loading.show()
sleep(0.5)
app.processEvents(QEventLoop.AllEvents)
if env.basename is not None:
base = baseClass(glob, env.basename, dirname)
base.prepareClass(modelfile)
mainwin = MHMainWindow(glob)
mainwin.show()
mainwin.move(app.topLeftCentered(mainwin))
loading.close()
#
# all we need from openGL is now existent (get initial values)
#
mainwin.initParams()
app.exec()
if __name__ == '__main__':
main()