def appendQt(self):
        import qtui

        self.open()
        self.write("PYQT.VERSION: %s", qtui.getQtVersionString())
        self.write("PYQT.JPG_SUPPORT: %s", "supported" if qtui.supportsJPG() else "not supported")
        self.write("PYQT.SVG_SUPPORT: %s", "supported" if qtui.supportsSVG() else "not supported")
        py_plugin_path = os.path.pathsep.join(
            [getpath.pathToUnicode(str(p)) for p in qtui.QtCore.QCoreApplication.libraryPaths()]
        )
        self.write("QT.PLUGIN_PATH: %s" % py_plugin_path)
        qt_plugin_path_env = os.environ["QT_PLUGIN_PATH"] if "QT_PLUGIN_PATH" in os.environ else ""
        self.write("QT.PLUGIN_PATH_ENV: %s" % qt_plugin_path_env)
        qt_conf_present = os.path.isfile(getpath.getSysPath("qt.conf"))
        if qt_conf_present:
            from codecs import open

            f = open(getpath.getSysPath("qt.conf"), "r", encoding="utf-8", errors="replace")
            qt_conf_content = f.read()
            qt_conf_content = qt_conf_content.replace("\n", "\n" + (" " * len("QT.CONF: "))).strip()
            f.close()
            self.write("QT.CONF: %s" % qt_conf_content)
        else:
            self.write("QT.CONF: NOT PRESENT")
        self.close()
Exemple #2
0
    def __init__(self, app, size):
        self.app = app
        super(Frame, self).__init__()

        self.setWindowTitle(self.title)
        if supportsSVG():
            # SVG icons allow better resolution when resized
            self.setWindowIcon(
                QtGui.QIcon(getpath.getSysPath("icons/makehuman_bg.svg")))
        else:
            # Older Qt libraries do not support svg icons
            self.setWindowIcon(
                QtGui.QIcon(getpath.getSysPath("icons/makehuman.png")))

        self.setAttribute(QtCore.Qt.WA_KeyCompression, False)
        self.setAcceptDrops(True)
        self.resize(*size)

        # work-around for mac QT toolbar bug described in: https://bugreports.qt-project.org/browse/QTBUG-18567
        if sys.platform.startswith("darwin"):
            self.toolbar = self.addToolBar("Toolbar")
            self.toolbar.hide()

        self.statusBar = qtgui.StatusBar()
        self.setStatusBar(self.statusBar)
        self.central = QtWidgets.QWidget()
        self.setCentralWidget(self.central)
        self.create()
Exemple #3
0
    def __init__(self, app, size):
        self.app = app
        super(Frame, self).__init__()

        self.setWindowTitle(self.title)
        if supportsSVG():
            # Explicitly include Qt SVG lib to force pyinstaller to pack it
            #from PyQt4 import QtSvg
            self.setWindowIcon(QtGui.QIcon(getpath.getSysPath("icons/makehuman_bg.svg")))
        else:
            # Older Qt libraries do not support svg icons
            self.setWindowIcon(QtGui.QIcon(getpath.getSysPath("icons/makehuman.png")))

        self.setAttribute(QtCore.Qt.WA_KeyCompression, False)
        self.resize(*size)
        
        # work-around for mac QT toolbar bug described in: https://bugreports.qt-project.org/browse/QTBUG-18567
        if sys.platform.startswith("darwin"):
            self.toolbar = self.addToolBar("Toolbar")
            self.toolbar.hide()

        self.statusBar = qtgui.StatusBar()
        self.setStatusBar(self.statusBar)
        self.central = QtGui.QWidget()
        self.setCentralWidget(self.central)
        self.create()
    def __init__(self, app, size):
        self.app = app
        super(Frame, self).__init__()

        self.setWindowTitle(self.title)
        if supportsSVG():
            # SVG icons allow better resolution when resized
            self.setWindowIcon(QtGui.QIcon(getpath.getSysPath("icons/makehuman_bg.svg")))
        else:
            # Older Qt libraries do not support svg icons
            self.setWindowIcon(QtGui.QIcon(getpath.getSysPath("icons/makehuman.png")))

        self.setAttribute(QtCore.Qt.WA_KeyCompression, False)
        self.setAcceptDrops(True)
        self.resize(*size)
        
        # work-around for mac QT toolbar bug described in: https://bugreports.qt-project.org/browse/QTBUG-18567
        if sys.platform.startswith("darwin"):
            self.toolbar = self.addToolBar("Toolbar")
            self.toolbar.hide()

        self.statusBar = qtgui.StatusBar()
        self.setStatusBar(self.statusBar)
        self.central = QtGui.QWidget()
        self.setCentralWidget(self.central)
        self.create()
Exemple #5
0
 def appendQt(self):
     import qtui
     self.open()
     self.write("QT.VERSION: %s", qtui.getQtVersionString())
     self.write("QT.JPG_SUPPORT: %s",
                "supported" if qtui.supportsJPG() else "not supported")
     self.write("QT.SVG_SUPPORT: %s",
                "supported" if qtui.supportsSVG() else "not supported")
     py_plugin_path = os.path.pathsep.join([
         getpath.pathToUnicode(p)
         for p in qtui.QtCore.QCoreApplication.libraryPaths()
     ])
     self.write("QT.PLUGIN_PATH: %s" % py_plugin_path)
     qt_plugin_path_env = os.environ[
         'QT_PLUGIN_PATH'] if 'QT_PLUGIN_PATH' in os.environ else ""
     self.write("QT.PLUGIN_PATH_ENV: %s" %
                getpath.pathToUnicode(qt_plugin_path_env))
     qt_conf_present = os.path.isfile(getpath.getSysPath('qt.conf'))
     if qt_conf_present:
         import io
         f = io.open(getpath.getSysPath('qt.conf'),
                     "r",
                     encoding="utf-8",
                     errors="replace")
         qt_conf_content = f.read()
         qt_conf_content = qt_conf_content.replace(
             '\n', '\n' + (' ' * len('QT.CONF: '))).strip()
         f.close()
         self.write("QT.CONF: %s" % qt_conf_content)
     else:
         self.write("QT.CONF: NOT PRESENT")
     self.close()
Exemple #6
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)
def addRig(human, rigfile):
    if not os.path.isfile(rigfile):
        rigfile = getpath.findFile(rigfile, 
                                   searchPaths = [getpath.getSysDataPath(),
                                                  getpath.getSysPath()])
        if not os.path.isfile(rigfile):
            #log.error("Rig file %s does not exist.", mhclofile)
            #return
            raise RuntimeError('Rig file "%s" does not exist.' % rigfile)

    import skeleton

    if not human.getBaseSkeleton():
        # TODO when starting in GUI mode, base skeleton will be loaded twice
        base_skel = skeleton.load(getpath.getSysDataPath('rigs/default.mhskel'), human.meshData)
        human.setBaseSkeleton(base_skel)

    referenceRig = human.getBaseSkeleton()

    # TODO update skeleton library when in gui mode
    skel = skeleton.load(rigfile, human.meshData)
    skel.autoBuildWeightReferences(referenceRig)
    vertexWeights = skel.getVertexWeights(referenceRig.getVertexWeights())
    skel.addReferencePlanes(referenceRig)  # Not strictly needed for the new way in which we determine bone normals

    human.setSkeleton(skel)
Exemple #8
0
    def loadMeshAndObject(self, human):
        import files3d
        import guicommon
        import getpath
        
        import inspect  # temp code to log calling routines
        log.debug("loadMeshAndObject called by: %s", inspect.stack()[1][3])
        
        name = self.obj_file
        if isinstance(name, bytes):
            name = name.decode('utf-8')
                                  
        name = getpath.getSysPath(name)
        mesh = files3d.loadMesh(name, maxFaces = self.max_pole)
        if not mesh:
            log.error("loadMeshAndObject failed to load %s", name)
            log.error("The meshname is %s", name)

        log.debug("Now the path has been extended to %s", name)
        mesh.priority = self.z_depth           # Set render order
        mesh.setCameraProjection(0)             # Set to model camera

        obj = self.object = guicommon.Object(mesh, human.getPosition())
        obj.proxy = self
        obj.material = self.material
        obj.setRotation(human.getRotation())
        obj.setSolid(human.solid)    # Set to wireframe if human is in wireframe
        # TODO perhaps other properties should be copied from human to object, such as subdivision state. For other hints, and duplicate code, see guicommon Object.setProxy()

        # TODO why return both obj and mesh if you can access the mesh easily through obj.mesh?
        return mesh,obj
Exemple #9
0
def getCredits(richtext=False):
    import getpath

    def _error(text):
        if richtext:
            return '<span style="color: red;">%s</span>' % text
        else:
            return text

    def _block(text):
        if richtext:
            return '%s<hr style="border: 1px solid #ffa02f;">' % text
        else:
            return text

    license_folder = getpath.getSysPath('licenses')
    cfile = os.path.join(license_folder, "credits.txt")
    if not os.path.isfile(cfile):
        return (_error(
            "Error: Credits file %s is not found, this is an incomplete MakeHuman distribution!"
            % cfile))
    with open(cfile, encoding='utf-8') as f:
        text = f.read()

    text = _wordwrap(text)
    return (_block(text))
Exemple #10
0
def addRig(human, rigfile):
    if not os.path.isfile(rigfile):
        rigfile = getpath.findFile(
            rigfile,
            searchPaths=[getpath.getSysDataPath(),
                         getpath.getSysPath()])
        if not os.path.isfile(rigfile):
            #log.error("Rig file %s does not exist.", mhclofile)
            #return
            raise RuntimeError('Rig file "%s" does not exist.' % rigfile)

    import skeleton

    if not human.getBaseSkeleton():
        # TODO when starting in GUI mode, base skeleton will be loaded twice
        base_skel = skeleton.load(
            getpath.getSysDataPath('rigs/default.mhskel'), human.meshData)
        human.setBaseSkeleton(base_skel)

    referenceRig = human.getBaseSkeleton()

    # TODO update skeleton library when in gui mode
    skel = skeleton.load(rigfile, human.meshData)
    skel.autoBuildWeightReferences(referenceRig)
    vertexWeights = skel.getVertexWeights(referenceRig.getVertexWeights())
    skel.addReferencePlanes(
        referenceRig
    )  # Not strictly needed for the new way in which we determine bone normals

    human.setSkeleton(skel)
Exemple #11
0
def getFilePath(filename, folder=None):
    if not filename:
        return filename

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

    # Search within current folder
    if folder:
        path = os.path.join(folder, filename)
        if os.path.isfile(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)
    # Search in user data folder
    from getpath import getPath, getSysDataPath, getSysPath
    userPath = getPath(filename)
    if os.path.isfile(userPath):
        return os.path.abspath(userPath)
    # Search in system path
    sysPath = getSysPath(filename)
    if os.path.isfile(sysPath):
        return os.path.abspath(sysPath)
    # Search in system data path
    sysPath = getSysDataPath(filename)
    if os.path.isfile(sysPath):
        return os.path.abspath(sysPath)

    # Nothing found
    return os.path.normpath(filename)
Exemple #12
0
def addRig(human, rigfile):
    if not os.path.isfile(rigfile):
        rigfile = getpath.findFile(
            rigfile,
            searchPaths=[getpath.getSysDataPath(),
                         getpath.getSysPath()])
        if not os.path.isfile(rigfile):
            #log.error("Rig file %s does not exist.", mhclofile)
            #return
            raise RuntimeError('Rig file "%s" does not exist.' % mhclofile)

    import skeleton
    from armature.options import ArmatureOptions

    armature_options = ArmatureOptions()

    descr = armature_options.loadPreset(
        rigfile, None)  # TODO update skeleton library when in gui mode
    # Load skeleton definition from options
    human._skeleton, boneWeights = skeleton.loadRig(armature_options,
                                                    human.meshData)
    human._skeleton.options = armature_options

    # TODO this should be resolved in the future
    def skeleton_getter():
        return human._skeleton

    human.getSkeleton = skeleton_getter
def getThirdPartyLicenses(richtext=False):
    import getpath
    from codecs import open
    from collections import OrderedDict
    def _title(name, url, license):
        if richtext:
            return '<a id="%s"><h3>%s</h3></a>%s<br>Licensed under %s license.<br>' % (name, name, url, license)
        else:
            return "%s (%s) licensed under %s license." % (name, url, license)

    def _error(text):
        if richtext:
            return '<span style="color: red;">%s</span>' % text
        else:
            return text

    def _block(text):
        if richtext:
            return '%s<hr style="border: 1px solid #ffa02f;">' % text
            #return '%s<div style="border: none; background-color #ffa02f; height: 1px; width: 100%%">a</div>' % text
        else:
            return text

    if richtext:
        result = '<h2>Third-party licenses</h2>'
    else:
        result = ""
    result += """MakeHuman includes a number of third part software components, which have 
their own respective licenses. We express our gratitude to the developers of
those libraries, without which MakeHuman would not have been made possible.
Here follows a list of the third-party open source libraries that MakeHuman
makes use of.\n"""
    license_folder = getpath.getSysPath('licenses')
    if not os.path.isdir(license_folder):
        return result + _error("Error: external licenses folder is not found, this is an incomplete MakeHuman distribution!")
    external_licenses = [ ("PyQt4", ("pyQt4-license.txt", "http://www.riverbankcomputing.co.uk", "GPLv3")),
                          ("Qt4", ("qt4-license.txt", "http://www.qt-project.org", "LGPLv2.1")),
                          ("Numpy", ("numpy-license.txt", "http://www.numpy.org", "BSD (3-clause)")),
                          ("PyOpenGL", ("pyOpenGL-license.txt", "http://pyopengl.sourceforge.net", "BSD (3-clause)")),
                          ("Transformations", ("transformations-license.txt", "http://www.lfd.uci.edu/~gohlke/", "BSD (3-clause)")),
                          ("pyFBX", ("pyFbx-license.txt", "http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Import-Export/Autodesk_FBX", "GPLv2")),
                          ("Python hglib", ("hglib-license.txt", "http://mercurial.selenic.com/wiki/PythonHglib", "MIT"))
                        ]
    external_licenses = OrderedDict(external_licenses)

    for name, (lic_file, url, lic_type) in external_licenses.items():
        result += _title(name, url, lic_type)

        lfile = os.path.join(license_folder, lic_file)
        if not os.path.isfile(lfile):
            result += "\n%s\n" % _error("Error: License file %s is not found, this is an incomplete MakeHuman distribution!" % lfile)
            continue
        f = open(lfile, encoding='utf-8')
        text = f.read()
        f.close()
        text = _wordwrap(text)
        result += "\n%s\n" % _block(text)

    return result
Exemple #14
0
def getThirdPartyLicenses(richtext=False):
    import getpath
    from io import open
    from collections import OrderedDict
    def _title(name, url, license):
        if richtext:
            return '<a id="%s"><h3>%s</h3></a>%s<br>Licensed under %s license.<br>' % (name, name, url, license)
        else:
            return "%s (%s) licensed under %s license." % (name, url, license)

    def _error(text):
        if richtext:
            return '<span style="color: red;">%s</span>' % text
        else:
            return text

    def _block(text):
        if richtext:
            return '%s<hr style="border: 1px solid #ffa02f;">' % text
            #return '%s<div style="border: none; background-color #ffa02f; height: 1px; width: 100%%">a</div>' % text
        else:
            return text

    if richtext:
        result = '<h2>Third-party licenses</h2>'
    else:
        result = ""
    result += """MakeHuman includes a number of third part software components, which have 
their own respective licenses. We express our gratitude to the developers of
those libraries, without which MakeHuman would not have been made possible.
Here follows a list of the third-party open source libraries that MakeHuman
makes use of.\n"""
    license_folder = getpath.getSysPath('licenses')
    if not os.path.isdir(license_folder):
        return result + _error("Error: external licenses folder is not found, this is an incomplete MakeHuman distribution!")
    external_licenses = [ ("PyQt4", ("pyQt4-license.txt", "http://www.riverbankcomputing.co.uk", "GPLv3")),
                          ("Qt4", ("qt4-license.txt", "http://www.qt-project.org", "LGPLv2.1")),
                          ("Numpy", ("numpy-license.txt", "http://www.numpy.org", "BSD (3-clause)")),
                          ("PyOpenGL", ("pyOpenGL-license.txt", "http://pyopengl.sourceforge.net", "BSD (3-clause)")),
                          ("Transformations", ("transformations-license.txt", "http://www.lfd.uci.edu/~gohlke/", "BSD (3-clause)")),
                          ("pyFBX", ("pyFbx-license.txt", "http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Import-Export/Autodesk_FBX", "GPLv2")),
                          ("Python hglib", ("hglib-license.txt", "http://mercurial.selenic.com/wiki/PythonHglib", "MIT"))
                        ]
    external_licenses = OrderedDict(external_licenses)

    for name, (lic_file, url, lic_type) in list(external_licenses.items()):
        result += _title(name, url, lic_type)

        lfile = os.path.join(license_folder, lic_file)
        if not os.path.isfile(lfile):
            result += "\n%s\n" % _error("Error: License file %s is not found, this is an incomplete MakeHuman distribution!" % lfile)
            continue
        f = io.open(lfile, encoding='utf-8')
        text = f.read()
        f.close()
        text = _wordwrap(text)
        result += "\n%s\n" % _block(text)

    return result
Exemple #15
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 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 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 )
Exemple #18
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)
Exemple #19
0
def getSoftwareLicense(richtext=False):
    import getpath
    from io import open
    lfile = getpath.getSysPath('license.txt')
    if not os.path.isfile(lfile):
        if richtext:
            return '\n<span style="color: red;">Error: License file %s is not found, this is an incomplete MakeHuman distribution!</span>\n' % lfile
        else:
            return "Error: License file %s is not found, this is an incomplete MakeHuman distribution!" % lfile
    f = open(lfile, encoding='utf-8')
    text = f.read()
    f.close()
    if richtext:
        result = '<h2>MakeHuman software license</h2>'
    else:
        result = ""
    return result + _wordwrap(text)
def getSoftwareLicense(richtext=False):
    import getpath
    from codecs import open
    lfile = getpath.getSysPath('license.txt')
    if not os.path.isfile(lfile):
        if richtext:
            return '\n<span style="color: red;">Error: License file %s is not found, this is an incomplete MakeHuman distribution!</span>\n' % lfile
        else:
            return "Error: License file %s is not found, this is an incomplete MakeHuman distribution!" % lfile
    f = open(lfile, encoding='utf-8')
    text = f.read()
    f.close()
    if richtext:
        result = '<h2>MakeHuman software license</h2>'
    else:
        result = ""
    return result + _wordwrap(text)
Exemple #21
0
def findGitDir():

    global _gitcmd
    global _gitdir

    if not _gitdir is None:
        return _gitdir

    main = getpath.getSysPath()

    # If running from source, we're one subdir down from .git

    main = os.path.join(main, '..', '.git')
    main = os.path.abspath(main)

    if os.path.isdir(main):
        _gitdir = main

    return _gitdir
Exemple #22
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)
def addRig(human, rigfile):
    if not os.path.isfile(rigfile):
        rigfile = getpath.findFile(rigfile, 
                                   searchPaths = [getpath.getSysDataPath(),
                                                  getpath.getSysPath()])
        if not os.path.isfile(rigfile):
            #log.error("Rig file %s does not exist.", mhclofile)
            #return
            raise RuntimeError('Rig file "%s" does not exist.' % mhclofile)

    import skeleton
    from armature.options import ArmatureOptions

    armature_options = ArmatureOptions()

    descr = armature_options.loadPreset(rigfile, None)    # TODO update skeleton library when in gui mode
    # Load skeleton definition from options
    human._skeleton, boneWeights = skeleton.loadRig(armature_options, human.meshData)
    human._skeleton.options = armature_options

    # TODO this should be resolved in the future
    def skeleton_getter():
        return human._skeleton
    human.getSkeleton = skeleton_getter
            raise RuntimeError(
                'Invalid argument for "repository", illegal character')
    DONTREMOVE = args.get('nodelete', default_nodelete)

    # Obtain MH version to download assets for
    version = getVersion()

    print('Refreshing assets from repository "%s" (version %s)' %
          (repo, version))

    ftpPath = os.path.join(ftpPath, version.lstrip('/'), repo.lstrip('/'))
    ftpPath = os.path.normpath(ftpPath)
    ## Use simple sync mechanism, maybe in the future we can use rsync over http?
    # Download contents list
    baseName = os.path.basename(ftpPath)
    contentsFile = getSysPath('%s_%s_contents.txt' %
                              (baseName, version.replace('.', '-')))
    if os.path.isfile(contentsFile):
        # Parse previous contents file
        oldContents = parseContentsFile(contentsFile)
        if len(oldContents) > 0 and len(
                str(oldContents[list(oldContents.keys())[0]])) < 5:
            # Ignore old style contents file
            oldContents = {}
    else:
        oldContents = {}

    # Setup FTP connection
    print("Connecting to FTP...")
    ftp = FTP(ftpUrl)
    ftp.login()
    ftp.cwd(ftpPath.replace('\\', '/'))
            raise RuntimeError(
                'Invalid argument for "repository", illegal character')
    DONTREMOVE = args.get('nodelete', default_nodelete)

    # Obtain MH version to download assets for
    version = getVersion()

    print('Refreshing assets from repository "{}" (version {})'.format(
        repo, version))

    ftpPath = os.path.join(ftpPath, version.lstrip('/'), repo.lstrip('/'))
    ftpPath = os.path.normpath(ftpPath)
    ## Use simple sync mechanism, maybe in the future we can use rsync over http?
    # Download contents list
    baseName = os.path.basename(ftpPath)
    contentsFile = getSysPath('{}_{}_contents.txt'.format(
        baseName, version.replace('.', '-')))
    if os.path.isfile(contentsFile):
        # Parse previous contents file
        oldContents = parseContentsFile(contentsFile)
        if len(oldContents) > 0 and len(
                str(oldContents[list(oldContents.keys())[0]])) < 5:
            # Ignore old style contents file
            oldContents = {}
    else:
        oldContents = {}

    # Setup FTP connection
    print("Connecting to FTP...")
    ftp = FTP(ftpUrl)
    ftp.login()
    ftp.cwd(ftpPath.replace('\\', '/'))
Exemple #26
0
import glmodule as gl
import events3d
import qtgui
import eventqueue
import time

import makehuman
import getpath

from mhversion import MHVersion

if False and makehuman.isBuild():
    # Set absolute Qt plugin path programatically on frozen deployment to fix
    # crashes when Qt is on DLL PATH in windows.
    # No qt.conf file should be present in the application folder!
    deployment_path = getpath.canonicalPath(getpath.getSysPath())
    QtCore.QCoreApplication.addLibraryPath(
        os.path.join(deployment_path, 'qt4_plugins'))
    # Plugins will be loaded when QCoreApplication object is constructed. Some
    # Qt deployments are known to prepend new library paths at this time, such
    # as /usr/lib/qt4/plugins on some linux platforms, but this is not a likely
    # case on windows platforms.

# Timeout in seconds after which moving the mousewheel will pick a new mouse pos
# TODO make this configureable in settings?
MOUSEWHEEL_PICK_TIMEOUT = 0.5


class Modifiers:
    SHIFT = int(QtCore.Qt.ShiftModifier)
    CTRL = int(QtCore.Qt.ControlModifier)
 def getInstallationPath(self,subpath = ""):
     """Returns the directory which contains the makehuman.py file"""
     self.trace()
     return getpath.getSysPath(subpath)
 def getInstallationPath(self, subpath=""):
     """Returns the unicode-encoded absolut path to the directory which contains the makehuman.py file"""
     self.trace()
     return self.getUnicodeAbsPath(getpath.getSysPath(subpath))
    for c in ['.', '/', '\\']:
        if c in repo:
            raise RuntimeError('Invalid argument for "repository", illegal character')
    DONTREMOVE = args.get('nodelete', default_nodelete)

    # Obtain MH version to download assets for
    version = getVersion()

    print 'Refreshing assets from repository "%s" (version %s)' % (repo, version)

    ftpPath = os.path.join(ftpPath, version.lstrip('/'), repo.lstrip('/'))
    ftpPath = os.path.normpath(ftpPath)
    ## Use simple sync mechanism, maybe in the future we can use rsync over http?
    # Download contents list
    baseName = os.path.basename(ftpPath)
    contentsFile = getSysPath('%s_%s_contents.txt' % (baseName, version.replace('.','-')))
    if os.path.isfile(contentsFile):
        # Parse previous contents file
        oldContents = parseContentsFile(contentsFile)
        if len(oldContents) > 0 and len(str(oldContents[oldContents.keys()[0]])) < 5:
            # Ignore old style contents file
            oldContents = {}
    else:
        oldContents = {}

    # Setup FTP connection
    print "Connecting to FTP..."
    ftp = FTP(ftpUrl)
    ftp.login()
    ftp.cwd(ftpPath.replace('\\', '/'))
    def __init__(self, app):
        camera = app.modelCamera

        #rendering properties
        self.camera = camera
        self.app = app
        #self.lastUndoItem = None
        #self.lastRotation = [0,0,0]
        #self.lastCameraPosition = [self.camera.eyeX, -self.camera.eyeY, self.camera.eyeZ]
        #self.firstTimeRendering = True
        self.renderResult = ""

        #resource paths
        self.renderPath = getPath('render/renderman_output')
        self.ribsPath = os.path.join(self.renderPath, 'ribFiles')
        self.usrShaderPath = os.path.join(self.ribsPath, 'shaders')
        
        #Texture paths
        self.usrTexturePath = os.path.join(self.ribsPath, 'textures')
        self.applicationPath = getSysPath()
        self.appTexturePath = getSysDataPath('textures')
        self.hairTexturePath = getSysDataPath('hairstyles')
        self.skinTexturePath = getPath('data/skins')
        
        #self.appObjectPath = os.path.join(self.applicationPath, 'data', '3dobjs')
        self.worldFileName = os.path.join(self.ribsPath,"world.rib").replace('\\', '/')
        self.lightsFolderPath = os.path.join(getSysDataPath('lights'), 'aqsis')       

        #mainscenefile
        self.sceneFileName = os.path.join(self.ribsPath, "scene.rib")

        #Human in the scene
        self.humanCharacter = RMRHuman(app.selectedHuman, "base.obj", app.selectedHuman.mesh, self.ribsPath)
        self.humanCharacter.materialInit()
        self.humanCharacter.subObjectsInit()
        
        #Rendering options
        #self.calcShadow = False
        #self.calcSSS = False

        ##Shadow path
        #self.shadowFileName = os.path.join(self.ribsPath,"shadow.rib").replace('\\', '/')

        ##SSS path        
        #self.bakeFilename = os.path.join(self.ribsPath,"skinbake.rib").replace('\\', '/')
        #self.lightmapFileName = os.path.join(self.ribsPath,"lightmap.rib").replace('\\', '/')
        #self.bakeTMPTexture = os.path.join(self.usrTexturePath,"bake.bake").replace('\\', '/')
        #self.bakeTexture = os.path.join(self.usrTexturePath,"bake.texture").replace('\\', '/')
        #self.lightmapTMPTexture = os.path.join(self.usrTexturePath,"lightmap.png").replace('\\', '/')
        #self.lightmapTexture = os.path.join(self.usrTexturePath,"lightmap.texture").replace('\\', '/')

        #Lights list
        self.lights = []

        #creating resources folders
        if not os.path.isdir(self.renderPath):
            os.makedirs(self.renderPath)
        if not os.path.isdir(self.ribsPath):
            os.makedirs(self.ribsPath)
        if not os.path.isdir(self.usrTexturePath):
            os.makedirs(self.usrTexturePath)
        if not os.path.isdir(self.usrShaderPath):
            os.makedirs(self.usrShaderPath)
Exemple #31
0
def loadMesh(path, loadColors=1, maxFaces=None, obj=None):
    """
    This function loads the specified mesh object into internal MakeHuman data 
    structures, and returns it. The loaded file should be in Wavefront OBJ 
    format.
    
    Parameters:
    -----------
   
    path:     
      *String*.  The file system path to the file containing the object to load.

    Note: loadColors is currently unused

    maxFaces:
      *uint* Number of faces per vertex (pole), None for default (min 4)
    """
    if type(path) is bytes:
        path = path.decode('utf-8')
    log.debug("loadMesh in files3d received a raw path of %s", path)
    name = os.path.basename(path)
    if isinstance(name, bytes):
        name.decode('utf-8')
    log.debug("os.path.basename produce a name of: %s", name)
    log.debug("files3d loadMesh basename is %s", name)
    if obj is None:
        obj = module3d.Object3D(os.path.splitext(path)[0])
        log.message("obj name changed from None to %s",
                    module3d.Object3D(name))
    if maxFaces:
        obj.MAX_FACES = maxFaces

    obj.path = path

    try:
        import getpath
        path = getpath.getSysPath(path)
        log.message("Expanded path is found to be %s", path)
        npzpath = os.path.splitext(path)[0] + '.npz'

        log.debug("files3d loadMesh will attempt to load %s", npzpath)

        if not os.path.isfile(npzpath):
            log.message('compiled file missing: %s', npzpath)
            raise RuntimeError('compiled file missing: %s', npzpath)
        if os.path.isfile(
                path) and os.path.getmtime(path) > os.path.getmtime(npzpath):
            log.message('compiled file out of date: %s', npzpath)
            raise RuntimeError('compiled file out of date: %s', npzpath)
        loadBinaryMesh(obj, npzpath)

        log.message("files3d loadMesh attempting to load %s", npzpath)
        loadTextMesh(obj, path)
        if isSubPath(npzpath, getPath('')):
            # Only write compiled binary meshes to user data path
            saveBinaryMesh(obj, npzpath)
            log.debug('files3d just saved compiled mesh: %s', npzpath)
        else:
            log.debug("files3d using getpath('') could not find (%s).",
                      npzpath)
    except:
        log.error('Unable to load obj file: %s', path, exc_info=True)
        return False

    return obj
Exemple #32
0
    def __init__(self, app):
        camera = app.modelCamera

        #rendering properties
        self.camera = camera
        self.app = app
        #self.lastUndoItem = None
        #self.lastRotation = [0,0,0]
        #self.lastCameraPosition = [self.camera.eyeX, -self.camera.eyeY, self.camera.eyeZ]
        #self.firstTimeRendering = True
        self.renderResult = ""

        #resource paths
        self.renderPath = getPath('render/renderman_output')
        self.ribsPath = os.path.join(self.renderPath, 'ribFiles')
        self.usrShaderPath = os.path.join(self.ribsPath, 'shaders')
        
        #Texture paths
        self.usrTexturePath = os.path.join(self.ribsPath, 'textures')
        self.applicationPath = getSysPath()
        self.appTexturePath = getSysDataPath('textures')
        self.hairTexturePath = getSysDataPath('hairstyles')
        self.skinTexturePath = getPath('data/skins')
        
        #self.appObjectPath = os.path.join(self.applicationPath, 'data', '3dobjs')
        self.worldFileName = os.path.join(self.ribsPath,"world.rib").replace('\\', '/')
        self.lightsFolderPath = os.path.join(getSysDataPath('lights'), 'aqsis')       

        #mainscenefile
        self.sceneFileName = os.path.join(self.ribsPath, "scene.rib")

        #Human in the scene
        self.humanCharacter = RMRHuman(app.selectedHuman, "base.obj", app.selectedHuman.mesh, self.ribsPath)
        self.humanCharacter.materialInit()
        self.humanCharacter.subObjectsInit()
        
        #Rendering options
        #self.calcShadow = False
        #self.calcSSS = False

        ##Shadow path
        #self.shadowFileName = os.path.join(self.ribsPath,"shadow.rib").replace('\\', '/')

        ##SSS path        
        #self.bakeFilename = os.path.join(self.ribsPath,"skinbake.rib").replace('\\', '/')
        #self.lightmapFileName = os.path.join(self.ribsPath,"lightmap.rib").replace('\\', '/')
        #self.bakeTMPTexture = os.path.join(self.usrTexturePath,"bake.bake").replace('\\', '/')
        #self.bakeTexture = os.path.join(self.usrTexturePath,"bake.texture").replace('\\', '/')
        #self.lightmapTMPTexture = os.path.join(self.usrTexturePath,"lightmap.png").replace('\\', '/')
        #self.lightmapTexture = os.path.join(self.usrTexturePath,"lightmap.texture").replace('\\', '/')

        #Lights list
        self.lights = []

        #creating resources folders
        if not os.path.isdir(self.renderPath):
            os.makedirs(self.renderPath)
        if not os.path.isdir(self.ribsPath):
            os.makedirs(self.ribsPath)
        if not os.path.isdir(self.usrTexturePath):
            os.makedirs(self.usrTexturePath)
        if not os.path.isdir(self.usrShaderPath):
            os.makedirs(self.usrShaderPath)
from core import G
import glmodule as gl
import events3d
import qtgui
import queue
import time
import getpath

import makehuman
import getpath
if False and makehuman.isBuild():
    # Set absolute Qt plugin path programatically on frozen deployment to fix
    # crashes when Qt is on DLL PATH in windows.
    # No qt.conf file should be present in the application folder!
    deployment_path = getpath.canonicalPath(getpath.getSysPath())
    QtCore.QCoreApplication.addLibraryPath(os.path.join(deployment_path,'qt4_plugins'))
    # Plugins will be loaded when QCoreApplication object is constructed. Some
    # Qt deployments are known to prepend new library paths at this time, such
    # as /usr/lib/qt4/plugins on some linux platforms, but this is not a likely
    # case on windows platforms.

# Timeout in seconds after which moving the mousewheel will pick a new mouse pos
# TODO make this configureable in settings?
MOUSEWHEEL_PICK_TIMEOUT = 0.5

class Modifiers:
    SHIFT = int(QtCore.Qt.ShiftModifier)
    CTRL  = int(QtCore.Qt.ControlModifier)
    ALT   = int(QtCore.Qt.AltModifier)
    META  = int(QtCore.Qt.MetaModifier)