示例#1
0
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Expression mixer')

        self.human = gui3d.app.selectedHuman

        self.base_bvh = None
        self.base_anim = None

        self.sliders = []
        self.modifiers = {}

        savebox = self.addRightWidget(gui.GroupBox("Save"))
        loadbox = self.addRightWidget(gui.GroupBox('Load'))
        resetbox = self.addRightWidget(gui.GroupBox('Reset'))

        self.nameField = savebox.addWidget(TextEdit("Name"))
        self.descrField = savebox.addWidget(TextEdit("Description"))
        self.tagsField = savebox.addWidget(TextEdit("Tags (separate with ;)"))
        self.authorField = savebox.addWidget(TextEdit("Author"))
        self.copyrightField = savebox.addWidget(TextEdit("Copyright"))
        self.licenseField = savebox.addWidget(TextEdit("License"))
        self.websiteField = savebox.addWidget(TextEdit("Website"))

        lic = mh.getAssetLicense()
        self.authorField.setValue(lic.author)
        self.copyrightField.setValue(lic.copyright)
        self.licenseField.setValue(lic.license)
        self.websiteField.setValue(lic.homepage)
        self.descrField.setValue("No description set")
        self.tagsField.setValue("")

        self.saveBtn = savebox.addWidget(
            gui.BrowseButton(mode='save', label="Save pose"))
        self.saveBtn.setFilter("MakeHuman blend pose file (*.mhpose)")
        savepath = getpath.getDataPath('expressions')
        if not os.path.exists(savepath):
            os.makedirs(savepath)
        self.saveBtn.setDirectory(getpath.getDataPath('expressions'))

        self.loadBtn = loadbox.addWidget(
            gui.BrowseButton(mode='open', label='Load pose'))
        self.loadBtn.setFilter('MakeHuman Poses (*.mhpose)')

        self.resetBtn = resetbox.addWidget(gui.Button('Reset'))

        @self.saveBtn.mhEvent
        def onClicked(path):
            if path:
                if not os.path.splitext(path)[1]:
                    path = path + ".mhpose"
                self.saveCurrentPose(path)

        @self.loadBtn.mhEvent
        def onClicked(path):
            if os.path.isfile(path):
                self.loadPose(path)

        @self.resetBtn.mhEvent
        def onClicked(event):
            self.resetExpression()
示例#2
0
文件: facesum.py 项目: gmkarl/facesum
    def __init__(this, path):
        this.path = path + '/makehuman'
        this.syspath = ['.' + x for x in ('/', '/lib', '/apps', '/shared', '/apps/gui', '/core', '/plugins')]

        #cwd = os.getcwd()
        #syspath = sys.path
        os.chdir(this.path)
        sys.path += this.syspath
    
        if verbose:
            sys.stderr.write("Probing makehuman ...\n")
    
        import core
        import headless
        import getpath
        import humanmodifier
        import log
        
        ## uncomment to disable makehuman log
        #log.init()
        
        #core.G.app = headless.ConsoleApp()
        #this.human = core.G.app.selectedHuman
        
        
        modifierGroups = ('head', 'forehead', 'eyebrows', 'neck', 'nose', 'mouth', 'ears', 'chin', 'cheek', 'macrodetails', 'macrodetails-universal', 'macrodetails-proportions')
        proxyTypes = ('hair', 'eyebrows', 'eyelashes')
        
        modifiers = humanmodifier.loadModifiers(getpath.getSysDataPath('modifiers/modeling_modifiers.json'), None)
        modifiers = [x for x in modifiers if x.groupName in modifierGroups and x.fullName != 'macrodetails/Caucasian']
        this.symmetricalModifiers = [x for x in modifiers if x.getSymmetrySide() is None]
        this.rightModifiers = [x for x in modifiers if x.getSymmetrySide() == 'r']
        this.leftModifiers = [x for x in modifiers if x.getSymmetrySide() == 'l']
        if verbose:
            sys.stderr.write("Found %i symmetrical facial features\n" % len(this.symmetricalModifiers))
            sys.stderr.write("Found %i left facial features\n" % len(this.leftModifiers))
            sys.stderr.write("Found %i right facial features\n" % len(this.rightModifiers))
        
        this.proxies = {}
        for proxyType in proxyTypes:
            files = getpath.search([getpath.getDataPath(proxyType),getpath.getSysDataPath(proxyType)], ['.proxy', '.mhclo'], True)
            files = list(files)
            if verbose:
                sys.stderr.write("Found %i %s proxies\n" % (len(files), proxyType))
            this.proxies[proxyType] = files
        
        skins = getpath.search([getpath.getDataPath('skins'),getpath.getSysDataPath('skins')], ['.mhmat'], True)
        this.skins = list(skins)
        if verbose:
            sys.stderr.write("Found %i skins\n" % len(this.skins))
示例#3
0
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Pose')
        filecache.MetadataCacher.__init__(self, ['bvh'], 'pose_filecache.mhc')
        self.cache_format_version = '1c'  # Bump cacher version for updated format of pose metadata

        self.human = G.app.selectedHuman
        self.currentPose = None
        self.bvh_bone_length = None
        self.bvh_root_translation = None

        self.sysDataPath = getpath.getSysDataPath('poses')
        self.userDataPath = getpath.getDataPath('poses')
        if not os.path.exists(self.userDataPath):
            os.makedirs(self.userDataPath)
        self.paths = [self.userDataPath, self.sysDataPath]

        self.filechooser = self.addRightWidget(fc.IconListFileChooser(self.paths, ['bvh'], 'thumb', mh.getSysDataPath('poses/notfound.thumb'), name='Pose', noneItem=True))
        self.filechooser.setIconSize(50,50)
        self.filechooser.enableAutoRefresh(False)

        @self.filechooser.mhEvent
        def onFileSelected(filename):
            gui3d.app.do(PoseAction("Change pose", self, self.currentPose, filename))

        self.filechooser.setFileLoadHandler(fc.TaggedFileLoader(self))
        self.addLeftWidget(self.filechooser.createTagFilter())

        self.skelObj = None
示例#4
0
def _getFilePath(filename, folder = None):
    if not filename or not isinstance(filename, basestring):
        return filename

    # Ensure unix style path
    filename.replace('\\', '/')

    searchPaths = []

    # Search within current folder
    if folder:
        searchPaths.append(folder)

    from getpath import findFile, getPath, getSysDataPath, getSysPath, getDataPath
    searchPaths.extend([getDataPath(), getSysDataPath(), getPath(), getSysPath()])

    # Search in user / sys data, and user / sys root folders
    path = findFile(filename, searchPaths, strict=True)
    if path:
        return os.path.abspath(path)

    # Treat as absolute path or search relative to application path
    if os.path.isfile(filename):
        return os.path.abspath(filename)

    # Nothing found
    return os.path.normpath(filename)
示例#5
0
    def __init__(self, category, appFacsAnim):
        gui3d.TaskView.__init__(self, category, 'FACSvatar')
        self.facs_human = appFacsAnim.selectedHuman
        self.app = appFacsAnim
        ##########################################################################
        # .json Au's list loading
        ##########################################################################

        self.facs_code_names_path = getpath.getDataPath('FACSHuman')
        self.facs_code_names_file = self.facs_code_names_path + '/au.json'
        self.facs_code_names = json.loads(
            open(self.facs_code_names_file).read())

        box_facsvatar = self.addLeftWidget(gui.GroupBox('FACSvatar listener'))
        #Box Midi
        self.facsvatar_start_stop = box_facsvatar.addWidget(
            gui.CheckBox('Start FACSvatar'))
        self.facsvatar_label = box_facsvatar.addWidget(
            gui.TextView('Listening STOPPED'))
        #self.facsvatar_render = box_facsvatar.addWidget(gui.CheckBox('Render video'))

        self.facs_modifiers = []
        self.facs_modifiers = G.app.selectedHuman.getModifiersByGroup(
            'Upper Face AUs')
        self.facs_modifiers.extend(
            G.app.selectedHuman.getModifiersByGroup('Lower Face AUs'))
        self.facs_modifiers.extend(
            G.app.selectedHuman.getModifiersByGroup('Head Positions'))
        self.facs_modifiers.extend(
            G.app.selectedHuman.getModifiersByGroup('Eye Positions'))
        self.facs_modifiers.extend(
            G.app.selectedHuman.getModifiersByGroup(
                'Lip Parting and Jaw Opening'))
        self.facs_modifiers.extend(
            G.app.selectedHuman.getModifiersByGroup('Miscellaneous AUs'))
        self.facs_modifiers.extend(
            G.app.selectedHuman.getModifiersByGroup('Emotions Blender'))

        self.modifiers_sliders = {}

        for mod in self.facs_modifiers:
            self.modifiers_sliders[mod.name] = modifierslider.ModifierSlider(
                modifier=mod, label=mod.name)
            #self.aus_list_items.addItem(self.facs_code_names[str(mod.name)], 'black', mod.name,  False)

# Midi Thread creation
        self.facsvatar_listener = FacsvatarThread(self.modifiers_sliders,
                                                  self.renderFacsPicture)

        @self.facsvatar_start_stop.mhEvent
        def onClicked(event):
            if self.facsvatar_start_stop.selected:
                self.facsvatar_label.setText('START')
                #self.facsvatar_listener.slider_assign(self.animation_test)
                #self.facsvatar_listener.text_box_assign(self.midi_msg_received)
                self.facsvatar_listener.start()
            else:
                self.facsvatar_label.setText('STOP')
                self.facsvatar_listener.stopListening()
    def getAvailableUserSkins(self):

        path = getpath.getDataPath("skins")
        matches = []
        for root, dirnames, filenames in os.walk(path):
            for filename in fnmatch.filter(filenames, '*.mhmat'):
                matches.append(os.path.join(root, filename))

        return matches
    def _listDataFiles(foldername, extensions, onlySysData=False, recursive=True):
        import getpath
        if onlySysData:
            paths = [getpath.getSysDataPath(foldername)]
        else:
            paths = [getpath.getDataPath(foldername), 
                     getpath.getSysDataPath(foldername)]

        return getpath.search(paths, extensions, recursive)
示例#8
0
def addProxy(human, mhclofile, type):
    # TODO if eyes proxy is loaded, the one loaded by default should be removed

    if not os.path.isfile(mhclofile):
        mhclofile = getpath.findFile(mhclofile,
                                     searchPaths=[
                                         getpath.getDataPath(),
                                         getpath.getSysDataPath(),
                                         getpath.getPath(),
                                         getpath.getSysPath()
                                     ])
        if not os.path.isfile(mhclofile):
            #log.error("Proxy file %s does not exist (%s).", mhclofile, type)
            #return
            raise RuntimeError('Proxy file "%s" does not exist (%s).' %
                               (mhclofile, type))

    import proxy
    pxy = proxy.loadProxy(human, mhclofile, type=type.capitalize())
    mesh, obj = pxy.loadMeshAndObject(human)

    if type == "proxymeshes":
        human.setProxy(pxy)
        return

    mesh, obj = pxy.loadMeshAndObject(human)

    if not mesh:
        raise RuntimeError('Failed to load proxy mesh "%s"', pxy.obj_file)

    def _adaptProxyToHuman(pxy, obj):
        mesh = obj.getSeedMesh()
        pxy.update(mesh)
        mesh.update()
        # Update subdivided mesh if smoothing is enabled
        if obj.isSubdivided():
            obj.getSubdivisionMesh()

    _adaptProxyToHuman(pxy, obj)
    obj.setSubdivided(human.isSubdivided())

    if type == "hair":
        human.hairProxy = pxy
    elif type == "eyes":
        human.eyesProxy = pxy
    elif type == "eyebrows":
        human.eyebrowsProxy = pxy
    elif type == "eyelashes":
        human.eyelashesProxy = pxy
    elif type == "teeth":
        human.teethProxy = pxy
    elif type == "tongue":
        human.tongueProxy = pxy
    elif type == "clothes":
        human.addClothesProxy(pxy)
    else:
        raise RuntimeError("Unknown proxy type: %s" % type)
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Expression mixer')

        self.human = gui3d.app.selectedHuman

        self.base_bvh = None
        self.base_anim = None

        self.sliders = []
        self.modifiers = {}

        savebox = self.addRightWidget(gui.GroupBox("Save"))

        self.nameField = savebox.addWidget(TextEdit("Name"))
        self.descrField = savebox.addWidget(TextEdit("Description"))
        self.tagsField = savebox.addWidget(TextEdit("Tags (separate with ;)"))
        self.authorField = savebox.addWidget(TextEdit("Author"))
        self.copyrightField = savebox.addWidget(TextEdit("Copyright"))
        self.licenseField = savebox.addWidget(TextEdit("License"))
        self.websiteField = savebox.addWidget(TextEdit("Website"))

        lic = mh.getAssetLicense()
        self.authorField.setValue(lic.author)
        self.copyrightField.setValue(lic.copyright)
        self.licenseField.setValue(lic.license)
        self.websiteField.setValue(lic.homepage)
        self.descrField.setValue("No description set")
        self.tagsField.setValue("no tag;expression")

        self.saveBtn = savebox.addWidget(gui.BrowseButton('save', "Save pose"))
        self.saveBtn.setFilter("MakeHuman blend pose file (*.mhpose)")
        savepath = getpath.getDataPath('expressions')
        if not os.path.exists(savepath):
            os.makedirs(savepath)
        self.saveBtn.setDirectory(getpath.getDataPath('expressions'))

        @self.saveBtn.mhEvent
        def onClicked(path):
            if path:
                if not os.path.splitext(path)[1]:
                    path = path + ".mhpose"
                self.saveCurrentPose(path)
示例#10
0
def getLanguages():
    """
    The languages available on this MH installation, by listing all .json
    files in the languages folder in user and system data path.
    """
    langDirFiles = os.listdir(getSysDataPath('languages'))
    try:
        langDirFiles = langDirFiles + os.listdir(getDataPath('languages'))
    except:
        pass
    return ['english'] + [os.path.basename(filename).replace('.json', '') for filename in langDirFiles if filename.split(os.extsep)[-1] == "json"]
def addProxy(human, mhclofile, type):
    # TODO if eyes proxy is loaded, the one loaded by default should be removed

    if not os.path.isfile(mhclofile):
        mhclofile = getpath.findFile(mhclofile, 
                                     searchPaths = [getpath.getDataPath(), 
                                                    getpath.getSysDataPath(),
                                                    getpath.getPath(),
                                                    getpath.getSysPath()])
        if not os.path.isfile(mhclofile):
            #log.error("Proxy file %s does not exist (%s).", mhclofile, type)
            #return
            raise RuntimeError('Proxy file "%s" does not exist (%s).' % (mhclofile, type))

    import proxy
    pxy = proxy.loadProxy(human, mhclofile, type=type.capitalize())
    mesh,obj = pxy.loadMeshAndObject(human)

    if type == "proxymeshes":
        human.setProxy(pxy)
        return

    mesh,obj = pxy.loadMeshAndObject(human)

    if not mesh:
        raise RuntimeError('Failed to load proxy mesh "%s"', pxy.obj_file)

    def _adaptProxyToHuman(pxy, obj):
        mesh = obj.getSeedMesh()
        pxy.update(mesh)
        mesh.update()
        # Update subdivided mesh if smoothing is enabled
        if obj.isSubdivided():
            obj.getSubdivisionMesh()

    _adaptProxyToHuman(pxy, obj)
    obj.setSubdivided(human.isSubdivided())

    if type == "hair":
        human.hairProxy = pxy
    elif type == "eyes":
        human.eyesProxy = pxy
    elif type == "eyebrows":
        human.eyebrowsProxy = pxy
    elif type == "eyelashes":
        human.eyelashesProxy = pxy
    elif type == "teeth":
        human.teethProxy = pxy
    elif type == "tongue":
        human.tongueProxy = pxy
    elif type == "clothes":
        human.addClothesProxy(pxy)
    else:
        raise RuntimeError("Unknown proxy type: %s" % type)
def _listDataFiles(foldername,
                   extensions,
                   onlySysData=False,
                   recursive=True):
    with mhpath:  # sadly makehuman seems hardcoded
        if onlySysData:
            paths = [getpath.getSysDataPath(foldername)]
        else:
            paths = [getpath.getDataPath(foldername),
                     getpath.getSysDataPath(foldername)]
    return list(getpath.search(paths, extensions, recursive))
示例#13
0
def getLanguages():
    """
    The languages available on this MH installation, by listing all .json
    files in the languages folder in user and system data path.
    """
    langDirFiles = os.listdir(getSysDataPath('languages'))
    try:
        langDirFiles = langDirFiles + os.listdir(getDataPath('languages'))
    except:
        pass
    return ['english'] + [os.path.basename(filename).replace('.json', '') for filename in langDirFiles if filename.split(os.extsep)[-1] == "json"]
def applyMaterial(matFile, obj):
    if not os.path.isfile(matFile):
        matFile = getpath.findFile(matFile, 
                                   searchPaths = [getpath.getDataPath(), 
                                                  getpath.getSysDataPath(),
                                                  getpath.getPath(),
                                                  getpath.getSysPath()])
    if not os.path.isfile(matFile):
        raise RuntimeError('Material file "%s" does not exist.', matFile)
    else:
        import material
        obj.material = material.fromFile( matFile )
示例#15
0
    def __init__(self):
        super(MixPoseAdapter, self).__init__()
        self.human = G.app.selectedHuman
        self.selectedFile = None
        self.selectedPose = None

        self._setting_pose = False

        self.sysDataPath = getpath.getSysDataPath('special_poses/mix/')
        self.userPath = getpath.getDataPath('special_poses/mix/')
        self.paths = [self.userPath, self.sysDataPath]
        if not os.path.exists(self.userPath):
            os.makedirs(self.userPath)
示例#16
0
def applyMaterial(matFile, obj):
    if not os.path.isfile(matFile):
        matFile = getpath.findFile(matFile,
                                   searchPaths=[
                                       getpath.getDataPath(),
                                       getpath.getSysDataPath(),
                                       getpath.getPath(),
                                       getpath.getSysPath()
                                   ])
    if not os.path.isfile(matFile):
        raise RuntimeError('Material file "%s" does not exist.', matFile)
    else:
        import material
        obj.material = material.fromFile(matFile)
示例#17
0
    def _listDataFiles(foldername,
                       extensions,
                       onlySysData=False,
                       recursive=True):
        import getpath
        if onlySysData:
            paths = [getpath.getSysDataPath(foldername)]
        else:
            paths = [
                getpath.getDataPath(foldername),
                getpath.getSysDataPath(foldername)
            ]

        return getpath.search(paths, extensions, recursive)
示例#18
0
    def __init__(self, category):

        super(SaveTargetsTaskView, self).__init__(category, 'Save Targets')

        self.fileName = 'full_target.target'
        self.dirName = gp.getDataPath('custom')

        self.saveBox = gui.GroupBox('Save Model as Target')
        self.addLeftWidget(self.saveBox)

        label = self.saveBox.addWidget(gui.TextView('Filename:'))

        self.nameEdit = gui.TextEdit(self.fileName)
        self.nameEdit.textChanged.connect(self.onChange)
        self.saveBox.addWidget(self.nameEdit)

        space = self.saveBox.addWidget(gui.TextView(''))

        self.saveButton = gui.Button('Save')
        self.saveBox.addWidget(self.saveButton)

        self.saveAsButton = gui.BrowseButton(label='Save As ...', mode='save')
        self.saveAsButton.path = os.path.join(self.dirName, self.fileName)
        self.saveAsButton.setFilter('MakeHuman Target ( *.target )')
        self.saveBox.addWidget(self.saveAsButton)

        self.createShortCut()

        @self.saveButton.mhEvent
        def onClicked(event):
            self.quickSave()

        @self.saveAsButton.mhEvent
        def onClicked(path):
            if path:
                if not path.lower().endswith('.target'):
                    error_msg = 'Cannot save target to file: {0:s}\n Expected a path to a .target file'.format(
                        path)
                    dialog = gui.Dialog()
                    dialog.prompt(title='Error',
                                  text=error_msg,
                                  button1Label='OK')
                    return
                else:
                    self.saveTargets(path)
                    self.nameEdit.setText(self.fileName)
                    self.saveAsButton.path = path
                    G.app.statusPersist('Saving Directory: ' + self.dirName)
    def __init__(self):
        super(FootPoseAdapter, self).__init__()
        self.human = G.app.selectedHuman
        self.selectedFile = None
        self.selectedPose = None

        self._setting_pose = False

        self.sysDataPath = getpath.getSysDataPath('special_poses/foot')
        self.userPath = getpath.getDataPath('special_poses/foot')
        self.paths = [self.userPath, self.sysDataPath]
        if not os.path.exists(self.userPath):
            os.makedirs(self.userPath)

        skel = self.human.getBaseSkeleton()
        self.affected_bone_idxs = [skel.getBone(bone_name).index for bone_name in FOOT_BONES]
    def getMaterialPaths(self, objType, proxy=None):
        if objType == 'skin':
            objType = 'skins'
        elif objType not in [t.lower() for t in SimpleProxyTypes]:
            objType = 'clothes'
        objType = objType.lower()

        if proxy and objType != 'skins':
            subPath = None
        else:
            subPath = objType

        # General paths
        if subPath:
            paths = [
                mh.getPath(os.path.join('data', subPath)),
                mh.getSysDataPath(subPath)
            ]
            for p in paths:
                if getpath.isSubPath(p,
                                     mh.getPath()) and not os.path.exists(p):
                    os.makedirs(p)
        else:
            paths = []

        # Global material paths
        for p in [
                mh.getPath(os.path.join('data', objType, 'materials')),
                mh.getSysDataPath(os.path.join(objType, 'materials'))
        ]:
            if os.path.isdir(p):
                paths.append(p)

        # Path where proxy file is located
        if proxy:
            dirname = os.path.abspath(os.path.dirname(proxy.file))
            parent = os.path.abspath(os.path.join(dirname, '..'))
            asset_basename = os.path.basename(dirname)
            asset_parentbase = os.path.basename(parent)
            user_parent_base = getpath.getDataPath(asset_parentbase)
            user_asset_final = os.path.abspath(
                os.path.join(user_parent_base, asset_basename))
            paths = [dirname, user_asset_final] + paths

        return paths
示例#21
0
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Expressions')
        self.extension = 'mhpose'
        filecache.MetadataCacher.__init__(self, self.extension,
                                          'expression_filecache.mhc')

        self.human = gui3d.app.selectedHuman
        self.selectedFile = None
        self.selectedPose = None
        self.face_bone_idxs = None

        self.base_bvh = None
        self.base_anim = None

        self._setting_pose = False

        self.sysDataPath = getpath.getSysDataPath('expressions')
        self.userPath = getpath.getDataPath('expressions')
        self.paths = [self.userPath, self.sysDataPath]
        if not os.path.exists(self.userPath):
            os.makedirs(self.userPath)

        self.filechooser = self.addRightWidget(fc.IconListFileChooser( \
                                                    self.paths,
                                                    self.extension,
                                                    'thumb',
                                                    name='Expression',
                                                    notFoundImage = getpath.getSysDataPath('notfound.thumb'),
                                                    noneItem = True,
                                                    doNotRecurse = False,
                                                    stickyTags = gui3d.app.getSetting('makehumanTags')))
        self.filechooser.setIconSize(50, 50)
        self.filechooser.enableAutoRefresh(False)

        @self.filechooser.mhEvent
        def onFileSelected(filename):
            if filename:
                msg = 'Load expression'
            else:
                msg = "Clear expression"
            gui3d.app.do(
                ExpressionAction(msg, self.selectedFile, filename, self))

        self.filechooser.setFileLoadHandler(fc.TaggedFileLoader(self))
        self.addLeftWidget(self.filechooser.createTagFilter())
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Expressions')
        self.extension = 'mhpose'
        filecache.MetadataCacher.__init__(self, self.extension, 'expression_filecache.mhc')

        self.human = gui3d.app.selectedHuman
        self.selectedFile = None
        self.selectedPose = None
        self.face_bone_idxs = None

        self.base_bvh = None
        self.base_anim = None

        self._setting_pose = False

        self.sysDataPath = getpath.getSysDataPath('expressions')
        self.userPath = getpath.getDataPath('expressions')
        self.paths = [self.userPath, self.sysDataPath]
        if not os.path.exists(self.userPath):
            os.makedirs(self.userPath)

        self.filechooser = self.addRightWidget(fc.IconListFileChooser( \
                                                    self.paths,
                                                    self.extension,
                                                    'thumb',
                                                    name='Expression',
                                                    notFoundImage = getpath.getSysDataPath('notfound.thumb'),
                                                    noneItem = True,
                                                    doNotRecurse = True))
        self.filechooser.setIconSize(50,50)
        self.filechooser.enableAutoRefresh(False)

        @self.filechooser.mhEvent
        def onFileSelected(filename):
            if filename:
                msg = 'Load expression'
            else:
                msg = "Clear expression"
            gui3d.app.do(ExpressionAction(msg, self.selectedFile, filename, self))

        self.filechooser.setFileLoadHandler(fc.TaggedFileLoader(self))
        self.addLeftWidget(self.filechooser.createTagFilter())
示例#23
0
def _getFilePath(filename, folder = None, altExtensions=None):
    if altExtensions is not None:
        # Search for existing path with alternative file extension
        for aExt in altExtensions:
            if aExt.startswith('.'):
                aExt = aExt[1:]
            aFile = os.path.splitext(filename)[0]+'.'+aExt
            aPath = _getFilePath(aFile, folder, altExtensions=None)
            if os.path.isfile(aPath):
                # Path found, return result with original extension
                orgExt = os.path.splitext(filename)[1]
                path = os.path.splitext(aPath)[0]+orgExt
                return os.path.normpath(path)

    if not filename or not isinstance(filename, basestring):
        return filename

    # Ensure unix style path
    filename.replace('\\', '/')

    searchPaths = []

    # Search within current folder
    if folder:
        searchPaths.append(folder)

    from getpath import findFile, getPath, getSysDataPath, getSysPath, getDataPath
    searchPaths.extend([getDataPath(), getSysDataPath(), getPath(), getSysPath()])

    # Search in user / sys data, and user / sys root folders
    path = findFile(filename, searchPaths, strict=True)
    if path:
        return os.path.abspath(path)

    # Treat as absolute path or search relative to application path
    if os.path.isfile(filename):
        return os.path.abspath(filename)

    # Nothing found
    return os.path.normpath(filename)
示例#24
0
    def __init__(self):

        self._git_command = gitutils.findPathToGit()

        self._user_dir = getpath.getPath()
        if not os.path.isdir(self._user_dir):
            os.makedirs(self._user_dir)

        self._user_data_dir = getpath.getDataPath()
        if not os.path.isdir(self._user_data_dir):
            os.makedirs(self._user_data_dir)

        self._git_official_clone_location = os.path.abspath(
            os.path.realpath(os.path.join(self._user_dir, 'official_assets')))

        self.readOverridesFromEnvironment()

        if self._git_command is None or not os.path.isfile(self._git_command):
            print("\n\n\nCould not find git command\n\n")
            sys.exit(1)

        if not gitutils.hasGitLFSSupport():
            print(
                "\n\n\nGIT LFS not detected. This routine requires LFS. See https://git-lfs.github.com/\n\n"
            )
            sys.exit(1)

        if os.path.isdir(self._git_official_clone_location):
            gitutils.pullRepo(self._git_official_clone_location,
                              self._git_official_assets_branch)
        else:
            gitutils.cloneRepo(self._git_official_assets_repo,
                               self._git_official_clone_location,
                               self._git_official_assets_branch,
                               extraargs=['--depth=1'])

        self.copyOfficialAssets()
示例#25
0
 def getAvailableUserSkins(self):
     """Get a list with full paths to all user skins (the MHMAT files)"""
     path = getpath.getDataPath("skins")
     return self._findMaterials(path)
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Skeleton')
        filecache.MetadataCacher.__init__(self, 'mhskel', 'skeleton_filecache.mhc')

        self.human = gui3d.app.selectedHuman

        self.referenceRig = None

        self.selectedRig = None

        self.skelMesh = None
        self.skelObj = None

        self.jointsMesh = None
        self.jointsObj = None

        self.selectedJoint = None

        self.oldHumanMat = self.human.material
        self.oldPxyMats = dict()

        self.sysDataPath = getpath.getSysDataPath('rigs')
        self.userDataPath = getpath.getDataPath('rigs')
        if not os.path.exists(self.userDataPath):
            os.makedirs(self.userDataPath)
        self.paths = [self.userDataPath, self.sysDataPath]

        self.filechooser = self.addRightWidget(fc.IconListFileChooser( \
                                                    self.paths,
                                                    'mhskel',
                                                    'thumb',
                                                    name='Rig presets',
                                                    notFoundImage = mh.getSysDataPath('notfound.thumb'), 
                                                    noneItem = True, 
                                                    doNotRecurse = True))
        self.filechooser.setIconSize(50,50)
        self.filechooser.enableAutoRefresh(False)

        @self.filechooser.mhEvent
        def onFileSelected(filename):
            if filename:
                msg = "Change skeleton"
            else:
                msg = "Clear skeleton"
            gui3d.app.do(SkeletonAction(msg, self, self.selectedRig, filename))

        self.filechooser.setFileLoadHandler(fc.TaggedFileLoader(self))
        self.addLeftWidget(self.filechooser.createTagFilter())

        self.infoBox = self.addLeftWidget(gui.GroupBox('Rig info'))
        self.boneCountLbl = self.infoBox.addWidget(gui.TextView('Bones: '))
        self.infoBox.setSizePolicy(gui.QtGui.QSizePolicy.Preferred, gui.QtGui.QSizePolicy.Maximum)

        descBox = self.addLeftWidget(gui.GroupBox('Description'))
        self.descrLbl = descBox.addWidget(gui.TextView(''))
        self.descrLbl.setSizePolicy(gui.QtGui.QSizePolicy.Ignored, gui.QtGui.QSizePolicy.Preferred)
        self.descrLbl.setWordWrap(True)

        self.xray_mat = None

        # the reference skeleton
        self.referenceRig = self.human.getBaseSkeleton()
示例#27
0
 def getUserDataPath(self,subpath = ""):
     """Returns the location of the user's "data" directory (as opposed to the installation's data directory)"""
     self.trace()
     return getpath.getDataPath(subpath)
示例#28
0
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Skeleton')
        filecache.MetadataCacher.__init__(self, 'mhskel', 'skeleton_filecache.mhc')
        self.optionsSelector = None

        self.systemRigs = mh.getSysDataPath('rigs')
        self.userRigs = os.path.join(mh.getPath(''), 'data', 'rigs')
        self.rigPaths = [self.userRigs, self.systemRigs]
        if not os.path.exists(self.userRigs):
            os.makedirs(self.userRigs)

        self.human = gui3d.app.selectedHuman

        self.referenceRig = None

        self.selectedRig = None

        self.humanChanged = False   # Used for determining when joints need to be redrawn

        self.skelMesh = None
        self.skelObj = None

        self.jointsMesh = None
        self.jointsObj = None

        self.selectedJoint = None

        self.oldHumanMat = self.human.material
        self.oldPxyMats = dict()

        #
        #   Display box
        #

        '''
        self.displayBox = self.addLeftWidget(gui.GroupBox('Display'))
        self.showHumanTggl = self.displayBox.addWidget(gui.CheckBox("Show human"))
        @self.showHumanTggl.mhEvent
        def onClicked(event):
            if self.showHumanTggl.selected:
                self.human.show()
            else:
                self.human.hide()
        self.showHumanTggl.setSelected(True)

        self.showJointsTggl = self.displayBox.addWidget(gui.CheckBox("Show joints"))
        @self.showJointsTggl.mhEvent
        def onClicked(event):
            if not self.jointsObj:
                return
            if self.showJointsTggl.selected:
                self.jointsObj.show()
            else:
                self.jointsObj.hide()
        self.showJointsTggl.setSelected(True)
        '''

        self.sysDataPath = getpath.getSysDataPath('rigs')
        self.userDataPath = getpath.getDataPath('rigs')
        if not os.path.exists(self.userDataPath):
            os.makedirs(self.userDataPath)
        self.paths = [self.userDataPath, self.sysDataPath]

        #
        #   Preset box
        #

        self.filechooser = self.addRightWidget(fc.IconListFileChooser( \
                                                    self.paths,
                                                    'mhskel',
                                                    'thumb',
                                                    name='Rig presets',
                                                    notFoundImage = mh.getSysDataPath('notfound.thumb'), 
                                                    noneItem = True, 
                                                    doNotRecurse = True))
        self.filechooser.setIconSize(50,50)
        self.filechooser.enableAutoRefresh(False)

        @self.filechooser.mhEvent
        def onFileSelected(filename):
            if filename:
                msg = "Change skeleton"
            else:
                msg = "Clear skeleton"
            gui3d.app.do(SkeletonAction(msg, self, self.selectedRig, filename))

        self.filechooser.setFileLoadHandler(fc.TaggedFileLoader(self))
        self.addLeftWidget(self.filechooser.createTagFilter())

        self.infoBox = self.addLeftWidget(gui.GroupBox('Rig info'))
        self.boneCountLbl = self.infoBox.addWidget(gui.TextView('Bones: '))
        self.infoBox.setSizePolicy(gui.QtGui.QSizePolicy.Preferred, gui.QtGui.QSizePolicy.Maximum)

        descBox = self.addLeftWidget(gui.GroupBox('Description'))
        self.descrLbl = descBox.addWidget(gui.TextView(''))
        self.descrLbl.setSizePolicy(gui.QtGui.QSizePolicy.Ignored, gui.QtGui.QSizePolicy.Preferred)
        self.descrLbl.setWordWrap(True)

        self.xray_mat = None

        # the reference skeleton
        self.referenceRig = self.human.getBaseSkeleton()
示例#29
0
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Skeleton')
        self.optionsSelector = None

        self._skelFileCache = None

        self.systemRigs = mh.getSysDataPath('rigs')
        self.userRigs = os.path.join(mh.getPath(''), 'data', 'rigs')
        self.rigPaths = [self.userRigs, self.systemRigs]
        if not os.path.exists(self.userRigs):
            os.makedirs(self.userRigs)
        self.extension = "rig"

        self.human = gui3d.app.selectedHuman

        self.referenceRig = None

        self.selectedRig = None

        self.humanChanged = False   # Used for determining when joints need to be redrawn

        self.skelMesh = None
        self.skelObj = None

        self.jointsMesh = None
        self.jointsObj = None

        self.selectedJoint = None

        self.oldHumanMat = self.human.material
        self.oldPxyMats = dict()

        #
        #   Display box
        #

        '''
        self.displayBox = self.addLeftWidget(gui.GroupBox('Display'))
        self.showHumanTggl = self.displayBox.addWidget(gui.CheckBox("Show human"))
        @self.showHumanTggl.mhEvent
        def onClicked(event):
            if self.showHumanTggl.selected:
                self.human.show()
            else:
                self.human.hide()
        self.showHumanTggl.setSelected(True)

        self.showJointsTggl = self.displayBox.addWidget(gui.CheckBox("Show joints"))
        @self.showJointsTggl.mhEvent
        def onClicked(event):
            if not self.jointsObj:
                return
            if self.showJointsTggl.selected:
                self.jointsObj.show()
            else:
                self.jointsObj.hide()
        self.showJointsTggl.setSelected(True)
        '''

        self.sysDataPath = getpath.getSysDataPath('rigs')
        self.userDataPath = getpath.getDataPath('rigs')
        if not os.path.exists(self.userDataPath):
            os.makedirs(self.userDataPath)
        self.paths = [self.userDataPath, self.sysDataPath]

        #
        #   Preset box
        #

        self.filechooser = self.addRightWidget(fc.IconListFileChooser( \
                                                    self.paths,
                                                    'json',
                                                    'thumb',
                                                    name='Rig presets',
                                                    notFoundImage = mh.getSysDataPath('notfound.thumb'), 
                                                    noneItem = True, 
                                                    doNotRecurse = True))
        self.filechooser.setIconSize(50,50)

        @self.filechooser.mhEvent
        def onFileSelected(filename):
            if filename:
                msg = "Change skeleton"
            else:
                msg = "Clear skeleton"
            gui3d.app.do(SkeletonAction(msg, self, self.selectedRig, filename))

        self.filechooser.setFileLoadHandler(fc.TaggedFileLoader(self))
        self.addLeftWidget(self.filechooser.createTagFilter())

        self.infoBox = self.addLeftWidget(gui.GroupBox('Rig info'))
        self.boneCountLbl = self.infoBox.addWidget(gui.TextView('Bones: '))
        self.infoBox.setSizePolicy(gui.QtGui.QSizePolicy.Preferred, gui.QtGui.QSizePolicy.Maximum)

        descBox = self.addLeftWidget(gui.GroupBox('Description'))
        self.descrLbl = descBox.addWidget(gui.TextView(''))
        self.descrLbl.setSizePolicy(gui.QtGui.QSizePolicy.Ignored, gui.QtGui.QSizePolicy.Preferred)
        self.descrLbl.setWordWrap(True)

        self.xray_mat = None
示例#30
0
    def __init__(self, category):

        super(SaveTargetsTaskView, self).__init__(category, 'Save Targets')

        mainPanel = QtWidgets.QWidget()
        layout = QtWidgets.QVBoxLayout()
        mainPanel.setLayout(layout)

        metaFileID = str(uuid4()) + '.target'
        self.metaFilePath = os.path.join(os.path.dirname(__file__),
                                         '__cache__')
        self.metaFile = os.path.join(self.metaFilePath, metaFileID)

        self.fileName = 'full_target.target'
        self.dirName = gp.getDataPath('custom')

        self.diffFileName = 'diff_target.target'
        self.diffDirName = gp.getDataPath('custom')

        self.saveBox = gui.GroupBox('Save Model as Target')
        layout.addWidget(self.saveBox)

        layout.addSpacing(15)

        label = self.saveBox.addWidget(gui.TextView('Filename:'))

        self.nameEdit = gui.TextEdit(self.fileName)
        self.nameEdit.textChanged.connect(self.onChange)
        self.saveBox.addWidget(self.nameEdit)

        self.stripBaseTargets = gui.CheckBox('Strip Base Targets', True)
        self.saveBox.addWidget(self.stripBaseTargets)

        self.saveButton = gui.Button('Save')
        self.saveBox.addWidget(self.saveButton)

        self.saveAsButton = gui.BrowseButton(label='Save As ...', mode='save')
        self.saveAsButton.path = os.path.join(self.dirName, self.fileName)
        self.saveAsButton.setFilter('MakeHuman Target ( *.target )')
        self.saveBox.addWidget(self.saveAsButton)

        self.saveDiffBox = gui.GroupBox('Save Diff Target')
        layout.addWidget(self.saveDiffBox)

        layout.addSpacing(15)

        self.diffNameEdit = gui.TextEdit(self.diffFileName)
        self.diffNameEdit.textChanged.connect(self.onDiffChange)
        self.saveDiffBox.addWidget(self.diffNameEdit)

        self.setBaseButton = gui.Button('Set Base')
        self.saveDiffBox.addWidget(self.setBaseButton)

        self.saveDiffButton = gui.Button('Save')
        self.saveDiffBox.addWidget(self.saveDiffButton)

        self.saveDiffAsButton = gui.BrowseButton(label='Save As ...',
                                                 mode='save')
        self.saveDiffAsButton.path = os.path.join(self.diffDirName,
                                                  self.diffFileName)
        self.saveDiffAsButton.setFilter('MakeHuman Target ( *.target )')
        self.saveDiffBox.addWidget(self.saveDiffAsButton)

        self.clearButton = gui.Button(label='Clear Cache')
        self.saveDiffBox.addWidget((self.clearButton))

        infoBox = gui.GroupBox('Info')
        layout.addWidget(infoBox)
        infoText = gui.TextView(info_message)
        infoText.setWordWrap(True)
        infoBox.setSizePolicy(gui.SizePolicy.Ignored, gui.SizePolicy.Preferred)
        infoBox.addWidget(infoText)

        layout.addStretch()
        self.addLeftWidget(mainPanel)

        self.createShortCut()

        @self.saveAsButton.mhEvent
        def beforeBrowse(event):
            self.saveAsButton.path = os.path.join(self.dirName, self.fileName)

        @self.saveDiffAsButton.mhEvent
        def beforeBrowse(event):
            self.saveDiffAsButton.path = os.path.join(self.dirName,
                                                      self.fileName)

        @self.saveButton.mhEvent
        def onClicked(event):
            self.quickSave()

        @self.saveAsButton.mhEvent
        def onClicked(path):
            if os.path.exists(path):
                if not path.lower().endswith('.target'):
                    error_msg = 'Cannot save target to file: {0:s}\nExpected a path to a .target file'.format(
                        path)
                    dialog = gui.Dialog()
                    dialog.prompt(title='Error',
                                  text=error_msg,
                                  button1Label='OK')
                    log.error('Cannot save targets to %s. Not a .target file.',
                              path)
                    return
                else:
                    self.saveTargets(path, self.stripBaseTargets.selected)
                    self.fileName = os.path.basename(path)
                    self.dirName = os.path.dirname(path)
                    self.nameEdit.setText(self.fileName)
                    self.saveAsButton.path = path
                    G.app.statusPersist('Saving Target Directory: ' +
                                        self.dirName +
                                        '   Saving Diff Targets Directory: ' +
                                        self.diffDirName)

        @self.setBaseButton.mhEvent
        def onClicked(event):
            if not os.path.isdir(self.metaFilePath):
                os.mkdir(self.metaFilePath)
            self.saveTargets(self.metaFile, False)

        @self.saveDiffButton.mhEvent
        def onClicked(event):
            if not os.path.isfile(self.metaFile):
                error_msg = 'No Base Model defined.\nPress "Set Base"'
                dialog = gui.Dialog()
                dialog.prompt(title='Error', text=error_msg, button1Label='OK')
                log.warning(error_msg)
            else:
                path = os.path.join(self.diffDirName, self.diffFileName)
                overwrite = True
                dialog = gui.Dialog()

                if not path.lower().endswith('.target'):
                    error_msg = 'Cannot save target to file: {0:s}\nExpected a path to a .target file'.format(
                        path)
                    dialog.prompt(title='Error',
                                  text=error_msg,
                                  button1Label='OK')
                    log.error('Cannot save targets to %s. Not a .target file.',
                              path)
                    return
                else:
                    if os.path.exists(path):
                        msg = 'File {0:s} already exists. Overwrite?'.format(
                            path)
                        overwrite = dialog.prompt(title='Warning',
                                                  text=msg,
                                                  button1Label='YES',
                                                  button2Label='NO')
                        if overwrite:
                            log.message('Overwriting %s ...', path)
                    if overwrite:
                        human = G.app.selectedHuman
                        target = algos3d.getTarget(human.meshData,
                                                   self.metaFile)
                        target.apply(human.meshData, -1)
                        self.saveTargets(path, False)
                        target.apply(human.meshData, 1)

        @self.saveDiffAsButton.mhEvent
        def onClicked(path):
            if path:
                if not os.path.isfile(self.metaFile):
                    error_msg = 'No Base Model defined.\nPress "Set Base"'
                    dialog = gui.Dialog()
                    dialog.prompt(title='Error',
                                  text=error_msg,
                                  button1Label='OK')
                    log.warning(error_msg)
                else:
                    if not path.lower().endswith('.target'):
                        error_msg = 'Cannot save diff target to file: {0:s}\nExpected a path to a .target file'.format(
                            path)
                        dialog = gui.Dialog()
                        dialog.prompt(title='Error',
                                      text=error_msg,
                                      button1Label='OK')
                        return
                    else:
                        human = G.app.selectedHuman
                        target = algos3d.getTarget(human.meshData,
                                                   self.metaFile)
                        target.apply(human.meshData, -1)
                        self.saveTargets(path, False)
                        target.apply(human.meshData, 1)
                        self.diffFileName = os.path.basename(path)
                        self.diffDirName = os.path.dirname(path)
                        self.diffNameEdit.setText(self.diffFileName)
                        self.saveDiffAsButton.path = path
                        G.app.statusPersist(
                            'Saving Target Directory: ' + self.dirName +
                            '   Saving Diff Targets Directory: ' +
                            self.diffDirName)

        @self.clearButton.mhEvent
        def onClicked(sevent):
            for file in os.listdir(path=self.metaFilePath):
                if file:
                    try:
                        os.remove(os.path.join(self.metaFilePath, file))
                    except os.error as e:
                        pass
示例#31
0
    def __init__(self, category):
        gui3d.TaskView.__init__(self, category, 'Skeleton')
        filecache.MetadataCacher.__init__(self, 'mhskel',
                                          'skeleton_filecache.mhc')

        self.human = gui3d.app.selectedHuman

        self.referenceRig = None

        self.selectedRig = None

        self.skelMesh = None
        self.skelObj = None

        self.jointsMesh = None
        self.jointsObj = None

        self.selectedJoint = None

        self.oldHumanMat = self.human.material
        self.oldPxyMats = dict()

        self.sysDataPath = getpath.getSysDataPath('rigs')
        self.userDataPath = getpath.getDataPath('rigs')
        if not os.path.exists(self.userDataPath):
            os.makedirs(self.userDataPath)
        self.paths = [self.userDataPath, self.sysDataPath]

        self.filechooser = self.addRightWidget(fc.IconListFileChooser( \
                                                    self.paths,
                                                    'mhskel',
                                                    'thumb',
                                                    name='Rig presets',
                                                    notFoundImage = mh.getSysDataPath('notfound.thumb'),
                                                    noneItem = True,
                                                    doNotRecurse = True))
        self.filechooser.setIconSize(50, 50)
        self.filechooser.enableAutoRefresh(False)

        @self.filechooser.mhEvent
        def onFileSelected(filename):
            if filename:
                msg = "Change skeleton"
            else:
                msg = "Clear skeleton"
            gui3d.app.do(SkeletonAction(msg, self, self.selectedRig, filename))

        self.filechooser.setFileLoadHandler(fc.TaggedFileLoader(self))
        self.addLeftWidget(self.filechooser.createTagFilter())

        self.infoBox = self.addLeftWidget(gui.GroupBox('Rig info'))
        self.boneCountLbl = self.infoBox.addWidget(gui.TextView('Bones: '))
        self.infoBox.setSizePolicy(gui.QtGui.QSizePolicy.Preferred,
                                   gui.QtGui.QSizePolicy.Maximum)

        descBox = self.addLeftWidget(gui.GroupBox('Description'))
        self.descrLbl = descBox.addWidget(gui.TextView(''))
        self.descrLbl.setSizePolicy(gui.QtGui.QSizePolicy.Ignored,
                                    gui.QtGui.QSizePolicy.Preferred)
        self.descrLbl.setWordWrap(True)

        self.xray_mat = None

        # the reference skeleton
        self.referenceRig = self.human.getBaseSkeleton()
示例#32
0
 def getAvailableUserClothes(self):
     """Get a list with full paths to all user clothes (the MHCLO files)"""
     path = getpath.getDataPath("clothes")
     return self._findProxies(path)
示例#33
0
 def getUserDataPath(self, subpath=""):
     """Returns unicode-encoded absolute path to the location of the user's "data" directory (as opposed to the installation's data directory)"""
     self.trace()
     return self.getUnicodeAbsPath(getpath.getDataPath(subpath))
示例#34
0
 def getAvailableUserHair(self):
     """Get a list with full paths to all user hair (the MHCLO files)"""
     path = getpath.getDataPath("hair")
     return self._findProxies(path)
    def __init__(self, category, appFacs):
        gui3d.TaskView.__init__(self, category, 'Pain Face Generator')
        self.facs_human = appFacs.selectedHuman
        camera = G.app.modelCamera
        self.app = appFacs

        # self.targets_path_emotions_blender = getpath.getPath('data/FACSHuman/00 Emotions')
        self.targets_path_upper_face = getpath.getPath(
            'data/FACSHuman/01 Upper Face AUs')
        self.targets_path_lower_face = getpath.getPath(
            'data/FACSHuman/02 Lower Face AUs')
        self.targets_path_lip_jaw = getpath.getPath(
            'data/FACSHuman/03 Lip Parting and Jaw Opening')
        # self.targets_path_eye = getpath.getPath('data/FACSHuman/04 Eye Positions')
        # self.targets_path_head = getpath.getPath('data/FACSHuman/05 Head Positions')
        # self.targets_path_misc = getpath.getPath('data/FACSHuman/06 Miscellaneous AUs')

        self.last_directory_rendering = ''
        self.images_to_convert = ''
        self.video_destination = ''
        #self.video_background = 'black.jpg'
        self.renderingWidth = '500'
        self.renderingHeight = '500'
        self.images_set_dir_destination = ''

        # box_emotions_blender = self.addLeftWidget(gui.GroupBox('Emotions blender'))
        box_upper = self.addLeftWidget(gui.GroupBox('Upper Face AUs'))
        box_lower = self.addLeftWidget(gui.GroupBox('Lower Face AUs'))
        # box_head = self.addLeftWidget(gui.GroupBox('Head Positions'))
        # box_eye = self.addLeftWidget(gui.GroupBox('Eye Positions'))
        box_lip = self.addLeftWidget(
            gui.GroupBox('Lip Parting and Jaw Opening'))
        # box_misc = self.addLeftWidget(gui.GroupBox('Miscellaneous AUs'))
        box_weight = self.addRightWidget(gui.GroupBox('AU Matrix Weights'))
        box_gen = self.addRightWidget(gui.GroupBox('View and Generate Images'))
        box_tools = self.addRightWidget(gui.GroupBox('Tools'))
        # box_aus_code = self.addRightWidget(gui.GroupBox('Action Units coding'))

        # self.general_intensity = box_aus_code.addWidget(gui.Slider(value=100, min=0, max=100, label=['General Intensity : ','%d%%']), columnSpan = 2)
        # #self.general_intensity_progress_bar = box_tools.addWidget(gui.ProgressBar())
        # #self.general_intensity_progress_bar.setProgress(1)
        # self.txt_file_loaded = box_aus_code.addWidget(gui.TextView('- New facial code -'), columnSpan = 2)
        # self.load_facs_button = box_aus_code.addWidget(gui.BrowseButton('open', "Load FACS Code"), 3, 0)
        # self.save_facs_button = box_aus_code.addWidget(gui.BrowseButton('save', "Save FACS Code"), 3, 1)
        # # self.save_target_button = box_aus_code.addWidget(gui.BrowseButton('save', "Save target"))
        # self.generate_au_coding_button = box_aus_code.addWidget(gui.Button('Get AU\'s Code'), columnSpan = 2)
        # self.txt_coding = box_aus_code.addWidget(gui.TextView('AU\'s code generated :'), columnSpan = 2)
        # self.au_coding = box_aus_code.addWidget(gui.DocumentEdit(text='Neutral'), columnSpan = 2)
        # self.one_shot_button = box_tools.addWidget(gui.Button('Take one shot'), 1, 0)

        self.survey_img_button = box_weight.addWidget(
            gui.Button('Generate Survey Images'), columnSpan=2)
        self.au4_lab = box_weight.addWidget(gui.TextView('AU4 Weight'))
        self.au4_val = box_weight.addWidget(gui.TextEdit(text='0.8865'))
        self.au7_lab = box_weight.addWidget(gui.TextView('AU7 Weight'))
        self.au7_val = box_weight.addWidget(gui.TextEdit(text='0.7758'))
        self.au9_lab = box_weight.addWidget(gui.TextView('AU9 Weight'))
        self.au9_val = box_weight.addWidget(gui.TextEdit(text='2.6129'))
        self.au10_lab = box_weight.addWidget(gui.TextView('AU10 Weight'))
        self.au10_val = box_weight.addWidget(gui.TextEdit(text='3.6517'))

        self.reset_camera_button = box_gen.addWidget(
            gui.Button('Full face camera view'), columnSpan=2)
        self.master_slider = box_gen.addWidget(gui.Slider(
            value=0, min=0, max=100, label=['General Intensity : ', '%d%%']),
                                               columnSpan=2)
        self.one_shot_button = box_gen.addWidget(gui.Button('Take one shot'),
                                                 columnSpan=2)
        self.generate_set_button = box_gen.addWidget(
            gui.Button('generate pain image set'), columnSpan=2)

        self.one_shot_stereo_button = box_tools.addWidget(
            gui.Button('Stereoscopic shot'), columnSpan=2)
        self.au_set_gen_button = box_tools.addWidget(
            gui.BrowseButton('open', "Dir to img"), 2, 0)
        self.material_gen_button = box_tools.addWidget(
            gui.BrowseButton('open', "Images set"), 2, 1)
        self.material_gen_dir_button = box_tools.addWidget(gui.FileEntryView(
            'Browse', mode='dir'),
                                                           columnSpan=2)
        self.camera_slider_x = box_tools.addWidget(gui.Slider(
            value=0, min=-1, max=1, label=['camera x: ', '%2f']),
                                                   columnSpan=2)
        self.camera_slider_y = box_tools.addWidget(gui.Slider(
            value=0, min=-1, max=1, label=['camera y: ', '%2f']),
                                                   columnSpan=2)
        self.camera_slider_zoom = box_tools.addWidget(gui.Slider(
            value=0, min=4, max=9, label=['Zoom: ', '%2f']),
                                                      columnSpan=2)
        self.rotation_slider_z = box_tools.addWidget(gui.Slider(
            value=0, min=-90, max=90, label=['rotation z: ', '%2f']),
                                                     columnSpan=2)
        self.reset_button = box_tools.addWidget(
            gui.Button('Reset Facial Code'), columnSpan=2)
        self.full_set_button = box_tools.addWidget(
            gui.Button('Full set generation'), columnSpan=2)
        self.facsvatar_set_button = box_tools.addWidget(gui.BrowseButton(
            'open', 'FACAvatar rendering'),
                                                        columnSpan=2)

        self.facs_code_names_path = getpath.getDataPath('FACSHuman')
        self.facs_code_names_file = self.facs_code_names_path + '/au.json'
        self.facs_code_names = json.loads(
            open(self.facs_code_names_file).read())

        self.slidersValues = {
        }  #Keep a trace of values in the General intensity sliders function
        self.sliders = {}
        self.sliders_order = []
        self.labelSlider = {}
        #self.modifiers = {}
        self.au_timeline_values = {}  # For the animation functionality
        self.au_facs_loaded_file_values = {}  # For the animation functionality

        self.facs_code_names_path = getpath.getDataPath('FACSHuman')
        self.facs_code_names_file = self.facs_code_names_path + '/au.json'
        self.facs_code_names = json.loads(
            open(self.facs_code_names_file).read())

        # self.searchTargets(self.targets_path_emotions_blender, box_emotions_blender, 'Emotions Blender')
        self.searchTargets(self.targets_path_upper_face, box_upper,
                           'Upper Face AUs')
        self.searchTargets(self.targets_path_lower_face, box_lower,
                           'Lower Face AUs')
        self.searchTargets(self.targets_path_lip_jaw, box_lip,
                           'Lip Parting and Jaw Opening')
        # self.searchTargets(self.targets_path_eye, box_eye, 'Eye Positions')
        # self.searchTargets(self.targets_path_head, box_head, 'Head Positions')
        # self.searchTargets(self.targets_path_misc, box_misc, 'Miscellaneous AUs')

        @self.camera_slider_x.mhEvent
        def onChanging(value):
            pos = self.facs_human.getPosition()
            pos[0] = value
            self.facs_human.setPosition(pos)
            mh.redraw()

        @self.camera_slider_y.mhEvent
        def onChanging(value):
            pos = self.facs_human.getPosition()
            pos[1] = value
            self.facs_human.setPosition(pos)
            mh.redraw()

        @self.camera_slider_zoom.mhEvent
        def onChanging(value):
            camera.setZoomFactor(value)

        @self.rotation_slider_z.mhEvent
        def onChanging(value):
            pos = self.facs_human.getRotation()
            pos[1] = value
            self.facs_human.setRotation(pos)
            mh.redraw()

##########################################################################
# Generate all AUs images
##########################################################################

        @self.facsvatar_set_button.mhEvent
        def onClicked(path):
            self.generateFacsvatarDirSet(path)

##########################################################################
# Generate all AUs images
##########################################################################

        @self.au_set_gen_button.mhEvent
        def onClicked(path):
            self.generateDirSet(path)

##########################################################################
# Generate material images
##########################################################################

        @self.material_gen_button.mhEvent
        def onClicked(path):
            self.generateCompleteImagesSetFromDir(path)
##########################################################################
# Generate material images
##########################################################################

        @self.material_gen_dir_button.mhEvent
        def onFileSelected(event):
            # self.images_set_dir_destination = os.path.dirname(path)
            self.images_set_dir_destination = event.path
            # self.images_set_dir_destination = os.path.dirname(path)
            gui3d.app.statusPersist('Images destination : ' +
                                    str(self.images_set_dir_destination))

##########################################################################
# Reset button for camera's orientation to have full face view
# in order to have constant point of view for experiments
##########################################################################

        @self.reset_camera_button.mhEvent
        def onClicked(event):
            gui3d.app.setTargetCamera(131, 9, False)
            gui3d.app.axisView([0.0, 0.0, 0.0])
            pos = [0, 0.2, 0]
            self.facs_human.setPosition(pos)
            self.camera_slider_x.setValue(0)
            self.camera_slider_y.setValue(0.2)
            self.camera_slider_zoom.setValue(9)
            self.rotation_slider_z.setValue(0)
            self.rotation_slider_z.onChanging(0)
            self.rotation_slider_z.update()
            mh.redraw()
            gui3d.app.statusPersist('Camera updated')

        @self.one_shot_button.mhEvent
        def onClicked(event):
            self.renderFacsPicture()

##########################################################################
# Reset facial code and AUs button
##########################################################################

        @self.reset_button.mhEvent
        def onClicked(event):
            G.app.prompt('Confirmation',
                         'Do you really want to reset your Facial code ?',
                         'Yes', 'Cancel', self.resetFacialCodes)

##########################################################################
# Generate 81 images for the survey website
##########################################################################

        @self.survey_img_button.mhEvent
        def onClicked(event):
            weight = [0, 0.5, 1]
            for i4 in range(3):
                for i7 in range(3):
                    for i9 in range(3):
                        for i10 in range(3):
                            self.survey_img_gen(weight[i4], weight[i7],
                                                weight[i9], weight[i10])
                            time.sleep(0.5)
                            self.renderSurveyImg(i4, i7, i9, i10)

##########################################################################
# Generate and save 101 images for overall intensity = 0% to 100%
##########################################################################

        @self.generate_set_button.mhEvent
        def onClicked(event):
            for val in range(0, 101):
                self.generate_face_set(val)
                time.sleep(0.5)
                self.renderFacsPicture()


##########################################################################
# View pain expression change at various general intensities
##########################################################################

        @self.master_slider.mhEvent
        def onChange(value):
            self.masterslider_render(value, True)