def setAge(self, age): log.message("SCRIPT: setAge(" + str(age) + ")") self.human.setAge(age) humanmodifier.MacroModifier('macrodetails', None, 'Age', 0.0, 1.0).setValue(gui3d.app.selectedHuman, age) self.human.applyAllTargets() mh.redraw()
def setWeight(self, weight): log.message("SCRIPT: setWeight(" + str(weight) + ")") self.human.setWeight(weight) humanmodifier.MacroModifier('macrodetails', 'universal', 'Weight', 0.0, 1.0).setValue(gui3d.app.selectedHuman, weight) self.human.applyAllTargets() mh.redraw()
def __init__(self, template, bodypart, modtype): global theModifierTypes, theBaseCharacterParts string = template.replace('$', '').replace('{', '').replace('}', '') warppath = os.path.join(mh.getPath(""), "warp", string) if not os.path.exists(os.path.dirname(warppath)): os.makedirs(os.path.dirname(warppath)) if not os.path.exists(warppath): fp = open(warppath, "w") fp.close() humanmodifier.SimpleModifier.__init__(self, warppath) self.eventType = 'warp' self.warppath = warppath self.template = template self.isWarp = True self.bodypart = bodypart self.slider = None self.refTargets = {} self.refTargetVerts = {} self.modtype = modtype self.fallback = None for (tlabel, tname, tvar) in theModifierTypes[modtype]: self.fallback = humanmodifier.MacroModifier(tlabel, tname, tvar) break self.bases = {} self.targetSpecs = {} if modtype == "GenderAge": self.setupBaseCharacters("Gender", "Age", "NoEthnic", "NoUniv", "NoUniv") elif modtype == "GenderAgeEthnic": self.setupBaseCharacters("Gender", "Age", "Ethnic", "NoUniv", "NoUniv") elif modtype == "GenderAgeToneWeight": self.setupBaseCharacters("Gender", "Age", "NoEthnic", "Tone", "Weight")
def __init__(self, category): super(ModifierTaskView, self).__init__(category, self._name, label=self._label) self.groupBoxes = [] self.radioButtons = [] self.sliders = [] self.modifiers = {} self.categoryBox = self.addRightWidget(gui.GroupBox('Category')) self.groupBox = self.addLeftWidget(gui.StackedBox()) for name, base, templates in self._features: title = name.capitalize() # Create box box = self.groupBox.addWidget(gui.GroupBox(title)) self.groupBoxes.append(box) # Create radiobutton radio = self.categoryBox.addWidget( GroupBoxRadioButton(self, self.radioButtons, title, box, selected=len(self.radioButtons) == 0)) # Create sliders for index, template in enumerate(templates): macro = len(template) >= 6 if macro: tlabel, tname, tvar, tmin, tmax, tview = template modifier = humanmodifier.MacroModifier( base, tname, tvar, tmin, tmax) self.modifiers[tlabel] = modifier slider = humanmodifier.GenericSlider( tmin, tmax, modifier, tlabel, None, tview) else: paired = len(template) == 5 if paired: tlabel, tname, tleft, tright, tview = template left = '-'.join([base, tname, tleft]) right = '-'.join([base, tname, tright]) else: tlabel, tname, tview = template left = None right = '-'.join([base, tname]) if tlabel is None: tlabel = tname.split('-') if len(tlabel) > 1 and tlabel[0] == base: tlabel = tlabel[1:] tlabel = ' '.join( [word.capitalize() for word in tlabel]) modifier = humanmodifier.UniversalModifier(left, right) tpath = '-'.join(template[1:-1]) modifierName = tpath clashIndex = 0 while modifierName in self.modifiers: log.debug('modifier clash: %s', modifierName) modifierName = '%s%d' % (tpath, clashIndex) clashIndex += 1 self.modifiers[modifierName] = modifier slider = humanmodifier.UniversalSlider( modifier, tlabel, '%s.png' % tpath, tview) box.addWidget(slider) self.sliders.append(slider) self.updateMacro() self.groupBox.showWidget(self.groupBoxes[0])
import os from pandas import read_pickle import makehuman makehuman.set_sys_path() import human import files3d import wavefront import humanmodifier import json from pybetaface import api humanoid = human.Human(files3d.loadMesh(human.getSysDataPath("3dobjs/base.obj"))) genmod = humanmodifier.MacroModifier('macrodetails','Gender') agemod = humanmodifier.MacroModifier('macrodetails','Age') musclemod = humanmodifier.MacroModifier('macrodetails-universal','Muscle') weightmod = humanmodifier.MacroModifier('macrodetails-universal','Weight') heightmod = humanmodifier.MacroModifier('macrodetails-height','Height') body_proportionmod = humanmodifier.MacroModifier('macrodetails-proportions', 'BodyProportions') africanmod = humanmodifier.MacroModifier('macrodetails','African') asianmod = humanmodifier.MacroModifier('macrodetails','Asian') caucasianmod = humanmodifier.MacroModifier('macrodetails','Caucasian') heightmod.setHuman(humanoid) agemod.setHuman(humanoid) genmod.setHuman(humanoid) weightmod.setHuman(humanoid) musclemod.setHuman(humanoid) body_proportionmod.setHuman(humanoid)
def __init__(self, category): super(ModifierTaskView, self).__init__(category, self._name, label=self._label) def resolveOptionsDict(opts, type = 'simple'): # Function to analyze options passed # with a dictionary in the features. if not 'cam' in opts.keys(): opts['cam'] = 'noSetCamera' if not 'min' in opts.keys(): if type == 'paired': opts['min'] = -1.0 else: opts['min'] = 0.0 if not 'max' in opts.keys(): opts['max'] = 1.0 if 'reverse' in opts.keys() and opts['reverse'] == True: temp = opts['max'] opts['max'] = opts['min'] opts['min'] = temp if not 'label' in opts.keys(): opts['label'] = None self.groupBoxes = [] self.radioButtons = [] self.sliders = [] self.modifiers = {} self.categoryBox = self.addRightWidget(gui.GroupBox('Category')) self.groupBox = self.addLeftWidget(gui.StackedBox()) for name, base, templates in self._features: title = name.capitalize() # Create box box = self.groupBox.addWidget(gui.GroupBox(title)) self.groupBoxes.append(box) # Create radiobutton self.categoryBox.addWidget(GroupBoxRadioButton(self, self.radioButtons, title, box, selected = len(self.radioButtons) == 0)) # Create sliders for index, template in enumerate(templates): macro = len(template) == 3 if macro: tname, tvar, opts = template resolveOptionsDict(opts, 'macro') if tname: groupName = base + "-" + tname else: groupName = base modifier = humanmodifier.MacroModifier(groupName, tvar) modifier.setHuman(G.app.selectedHuman) self.modifiers[tvar] = modifier tpath = '-'.join(template[1:-1]) slider = modifierslider.MacroSlider(modifier, opts['label'], ('%s.png' % tpath).lower(), opts['cam'], opts['min'], opts['max']) else: paired = len(template) == 4 if paired: tname, tleft, tright, opts = template resolveOptionsDict(opts, 'paired') left = '-'.join([base, tname, tleft]) right = '-'.join([base, tname, tright]) else: tname, opts = template resolveOptionsDict(opts) tleft = None tright = None if opts['label'] is None: tlabel = tname.split('-') if len(tlabel) > 1 and tlabel[0] == base: tlabel = tlabel[1:] opts['label'] = ' '.join([word.capitalize() for word in tlabel]) groupName = base name = tname modifier = humanmodifier.UniversalModifier(groupName, name, tleft, tright, centerExt=None) modifier.setHuman(G.app.selectedHuman) tpath = '-'.join(template[0:-1]) modifierName = tpath clashIndex = 0 while modifierName in self.modifiers: log.debug('modifier clash: %s', modifierName) modifierName = '%s%d' % (tpath, clashIndex) clashIndex += 1 self.modifiers[modifierName] = modifier slider = modifierslider.UniversalSlider(modifier, opts['label'], '%s.png' % tpath, opts['cam'], opts['min'], opts['max']) box.addWidget(slider) self.sliders.append(slider) self.updateMacro() self.groupBox.showWidget(self.groupBoxes[0])