-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmakehuman.py
More file actions
executable file
·153 lines (125 loc) · 4.85 KB
/
makehuman.py
File metadata and controls
executable file
·153 lines (125 loc) · 4.85 KB
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/usr/bin/python3
"""
License information: data/licenses/makehuman_license.txt
Author: black-punkduck
"""
import argparse, textwrap
import os
import sys
from time import sleep
from PySide6.QtWidgets import QApplication
from PySide6.QtCore import QEventLoop
sys.path.insert(0, ".") # used for windows
from core.globenv import programInfo, globalObjects
from gui.beforestart import FirstStart
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("-r", "--repository", action="store_true", help=textwrap.dedent('''\
create a new database repository. It is needed when repository seems to have
missing entries or when user space was moved to a new location. The manually
entered data (new tags for categorization) is not deleted.'''))
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 (default)
2 mid log level
4 memory management
8 file access
16 high level and numpy runtime error messages
32 JSON (e.g glTF) or to get lines for face or body poses when loading bvh file'''))
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__))
os.chdir(syspath)
# check for first start (no conffile)
#
fstart = FirstStart(syspath)
result, message = fstart.createConffile()
if result > 1:
print (message)
exit (result)
# 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:
dirnames = env.getDataDirs("base", env.basename)
if len(dirnames) == 0:
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)
base.prepareClass(modelfile)
mainwin = MHMainWindow(glob)
glob.setMainWindow(mainwin)
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()