Exemplo n.º 1
0
    def selectProxy(self, mhclofile):
        """
        Called when a new proxy has been selected.
        If this library selects only a single proxy, specifying None as
        mhclofile parameter will deselect the current proxy and set the selection
        to "none".
        If this library allows selecting multiple proxies, specifying None as
        mhclofile will have no effect.
        """
        if not mhclofile:
            if self.multiProxy:
                return
            else:
                self.deselectProxy(None)
                return

        log.message('Selecting proxy file "%s" from %s library.', mhclofile, self.proxyName)
        human = self.human

        pxy = None
        mhcloId = getpath.canonicalPath(mhclofile)
        if mhcloId in self._proxyCache:
            pxy = self._proxyCache[mhcloId]
            if pxy.mtime < os.path.getmtime(mhclofile):
                pxy = None

        if not pxy:
            pxy = proxy.loadProxy(human, mhclofile, type=self.proxyName.capitalize())
            self._proxyCache[mhcloId] = pxy

        if pxy.uuid in [p.uuid for p in self.getSelection() if p is not None]:
            log.debug("Proxy with UUID %s (%s) already loaded in %s library. Skipping.", pxy.uuid, pxy.file, self.proxyName)
            return

        if not self.multiProxy and self.isProxySelected():
            # Deselect previously selected proxy
            self.deselectProxy(None, suppressSignal = True)

        mesh,obj = pxy.loadMeshAndObject(human)
        mesh.setPickable(True)  # Allow mouse picking for proxies attached to human
        
        if not mesh:
            return

        gui3d.app.addObject(obj)

        self.filechooser.selectItem(mhclofile)


        self.adaptProxyToHuman(pxy, obj)
        obj.setSubdivided(human.isSubdivided()) # Copy subdivided state of human

        # Add to selection
        self.selectedProxies.append(pxy)

        self.filechooser.selectItem(mhclofile)

        self.proxySelected(pxy)

        self.signalChange()
Exemplo n.º 2
0
    def selectProxy(self, mhclofile):
        """
        Called when a new proxy has been selected.
        If this library selects only a single proxy, specifying None as
        mhclofile parameter will deselect the current proxy and set the selection
        to "none".
        If this library allows selecting multiple proxies, specifying None as
        mhclofile will have no effect.
        """
        if not mhclofile:
            if self.multiProxy:
                return
            else:
                self.deselectProxy(None)
                return

        log.message('Selecting proxy file "%s" from %s library.', mhclofile,
                    self.proxyName)
        human = self.human

        pxy = proxy.loadProxy(human, mhclofile, type=self.getProxyType())

        if pxy.uuid in [p.uuid for p in self.getSelection() if p is not None]:
            log.debug(
                "Proxy with UUID %s (%s) already loaded in %s library. Skipping.",
                pxy.uuid, pxy.file, self.proxyName)
            return

        if not self.multiProxy and self.isProxySelected():
            # Deselect previously selected proxy
            self.deselectProxy(None, suppressSignal=True)

        mesh, obj = pxy.loadMeshAndObject(human)
        mesh.setPickable(
            True)  # Allow mouse picking for proxies attached to human

        if not mesh:
            return

        gui3d.app.addObject(obj)

        self.filechooser.selectItem(mhclofile)
        self.filechooser.selectItem(self.getAlternativeFile(
            mhclofile))  # In case an ascii or binary file was loaded instead

        self.adaptProxyToHuman(pxy, obj)
        obj.setSubdivided(
            human.isSubdivided())  # Copy subdivided state of human

        # Add to selection
        self.selectedProxies.append(pxy)

        self.filechooser.selectItem(mhclofile)

        if self.descriptionWidget:
            self.descrLbl.setText(pxy.description)

        self.proxySelected(pxy)

        self.signalChange()
Exemplo n.º 3
0
    def selectProxy(self, mhclofile):
        """
        Called when a new proxy has been selected.
        """
        if not mhclofile:
            self.deselectProxy(None, suppressSignal = True)

        if self.isProxySelected():
            # Deselect previously selected proxy
            self.deselectProxy(None, suppressSignal = True)

        self.filechooser.selectItem(mhclofile)

        if not mhclofile:
            self.signalChange()
            return

        pxy = proxy.loadProxy(self.human,
                              mhclofile,
                              type=self.proxyName.capitalize())

        mesh,obj = pxy.loadMeshAndObject(self.human)

        self.human.setProxy(pxy)

        if self.descriptionWidget:
            self.descrLbl.setText(pxy.description)

        # Add to selection
        self.selectedProxies.append(pxy)

        self.filechooser.selectItem(mhclofile)

        self.signalChange()
Exemplo n.º 4
0
    def getProxies(self):
        """
        Get the proxy list from the current state of the set human object.
        Proxy list will contain all proxy items such as proxy mesh and clothes,
        hair, eyes, genitals and cages.
        """
        if not self.human:
            return {}

        proxies = {}
        for pxy in self.human.getProxies():
            if pxy:
                name = self.goodName(pxy.name)
                proxies[name] = pxy

        if self.human.proxy:
            pxy = self.human.proxy
            name = self.goodName(pxy.name)
            proxies[name] = pxy

        # TODO deprecated? is this going to be revived?
        if self.cage:
            import proxy
            human = G.app.selectedHuman
            filepath = getSysDataPath("cages/cage/cage.mhclo")
            pxy = proxy.loadProxy(human, filepath, type="Cage")
            pxy.update(human.meshData)
            proxies[name] = pxy

        return proxies
Exemplo n.º 5
0
    def selectProxy(self, mhclofile):
        """
        Called when a new proxy has been selected.
        """
        if not mhclofile:
            self.deselectProxy(None, suppressSignal=True)

        if self.isProxySelected():
            # Deselect previously selected proxy
            self.deselectProxy(None, suppressSignal=True)

        if not mhclofile:
            self.signalChange()
            return

        pxy = proxy.loadProxy(self.human,
                              mhclofile,
                              type=self.proxyName.capitalize())

        # Override z_depth and mesh priority to the same as human mesh
        pxy.z_depth = self.human.getSeedMesh().priority
        mesh, obj = pxy.loadMeshAndObject(self.human)

        self.human.setProxy(pxy)

        if self.descriptionWidget:
            self.descrLbl.setText(pxy.description)

        self.filechooser.selectItem(mhclofile)

        self.signalChange()
Exemplo n.º 6
0
    def selectProxy(self, mhclofile):
        """
        Called when a new proxy has been selected.
        If this library selects only a single proxy, specifying None as
        mhclofile parameter will deselect the current proxy and set the selection
        to "none".
        If this library allows selecting multiple proxies, specifying None as
        mhclofile will have no effect.
        """
        if not mhclofile:
            if self.multiProxy:
                return
            else:
                self.deselectProxy(None)
                return

        log.message('Selecting proxy file "%s" from %s library.', mhclofile, self.proxyName)
        human = self.human

        pxy = proxy.loadProxy(human, mhclofile, type=self.getProxyType())

        if pxy.uuid in [p.uuid for p in self.getSelection() if p is not None]:
            log.debug(
                "Proxy with UUID %s (%s) already loaded in %s library. Skipping.", pxy.uuid, pxy.file, self.proxyName
            )
            return

        if not self.multiProxy and self.isProxySelected():
            # Deselect previously selected proxy
            self.deselectProxy(None, suppressSignal=True)

        mesh, obj = pxy.loadMeshAndObject(human)
        mesh.setPickable(True)  # Allow mouse picking for proxies attached to human

        if not mesh:
            return

        gui3d.app.addObject(obj)

        self.filechooser.selectItem(mhclofile)
        self.filechooser.selectItem(
            self.getAlternativeFile(mhclofile)
        )  # In case an ascii or binary file was loaded instead

        self.adaptProxyToHuman(pxy, obj)
        obj.setSubdivided(human.isSubdivided())  # Copy subdivided state of human

        # Add to selection
        self.selectedProxies.append(pxy)

        self.filechooser.selectItem(mhclofile)

        if self.descriptionWidget:
            self.descrLbl.setText(pxy.description)

        self.proxySelected(pxy)

        self.signalChange()
Exemplo n.º 7
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)
Exemplo n.º 9
0
        def onClicked(event):
            print "-----crazy-ClothModifier-----------"
            mhmain_MHApplication = G.app
            human = mhmain_MHApplication.selectedHuman
            cloth_modifier = mhmain_MHApplication.modules[
                '3_libraries_clothes_chooser']

            mhclofile = "data/clothes/male_casualsuit02/male_casualsuit02.mhpxy"
            pxy = proxy.loadProxy(human, mhclofile)

            j = 0
            for obj in sorted(G.world, key=(lambda obj: obj.priority)):
                print "---------crazy-drawMeshes-----[", j, "]-----module3d_obj type = ", type(
                    obj)

                print "module3d_obj.fvert = ", obj.fvert.shape
                print "module3d_obj.fnorm = ", obj.fnorm.shape
                print "module3d_obj.fuvs = ", obj.fuvs.shape
                print "module3d_obj.group = ", obj.group.shape
                j += 1
Exemplo n.º 10
0
def addProxyAsset(type, pxyfile):
    """
    :param type: Type of Asset
        Types = 'Clothes' or 'Eyebrows' or 'Hair'
    :param pxyfile: Asset Full Path
    :return:
    """
    global human
    import proxy, events3d
    import numpy as np

    pxy = proxy.loadProxy(human, str(pxyfile), type=type)
    mesh, obj = pxy.loadMeshAndObject(human)
    mesh.setPickable(True)
    mesh2 = obj.getSeedMesh()
    fit_to_posed = False
    pxy.update(mesh2, fit_to_posed)
    mesh2.update()
    obj.setSubdivided(human.isSubdivided())
    if type == "Clothes":
        human.addClothesProxy(pxy)
    elif type == "Eyebrows":
        human.setEyebrowsProxy(pxy)
    elif type == "Hair":
        human.setHairProxy(pxy)
    else:
        raise Exception("Unknown Asset Type")

    vertsMask = np.ones(human.meshData.getVertexCount(), dtype=bool)
    proxyVertMask = proxy.transferVertexMaskToProxy(vertsMask, pxy)
    # Apply accumulated mask from previous clothes layers on this clothing piece
    obj.changeVertexMask(proxyVertMask)
    # Modify accumulated (basemesh) verts mask
    verts = np.argwhere(pxy.deleteVerts)[..., 0]
    vertsMask[verts] = False
    human.changeVertexMask(vertsMask)
    event = events3d.HumanEvent(human, "proxy")
    event.pxy = "clothes"
    human.callEvent("onChanged", event)
    return
Exemplo n.º 11
0
    def selectProxy(self, mhclofile):
        """
        Called when a new proxy has been selected.
        """
        if not mhclofile:
            self.deselectProxy(None, suppressSignal=True)

        if self.isProxySelected():
            # Deselect previously selected proxy
            self.deselectProxy(None, suppressSignal=True)

        self.filechooser.selectItem(mhclofile)

        if not mhclofile:
            self.signalChange()
            return

        if mhclofile not in self._proxyCache:
            pxy = proxy.loadProxy(self.human,
                                  mhclofile,
                                  type=self.proxyName.capitalize())
            self._proxyCache[mhclofile] = pxy
        else:
            pxy = self._proxyCache[mhclofile]

        mesh, obj = pxy.loadMeshAndObject(self.human)

        self.human.setProxy(pxy)
        self.human.updateProxyMesh()

        # Add to selection
        self.selectedProxies.append(pxy)

        self.filechooser.selectItem(mhclofile)

        self.signalChange()
Exemplo n.º 12
0
    def selectProxy(self, mhclofile):
        """
        Called when a new proxy has been selected.
        """
        if not mhclofile:
            self.deselectProxy(None, suppressSignal = True)

        if self.isProxySelected():
            # Deselect previously selected proxy
            self.deselectProxy(None, suppressSignal = True)

        self.filechooser.selectItem(mhclofile)

        if not mhclofile:
            self.signalChange()
            return

        if mhclofile not in self._proxyCache:
            pxy = proxy.loadProxy(self.human,
                                  mhclofile,
                                  type=self.proxyName.capitalize())
            self._proxyCache[mhclofile] = pxy
        else:
            pxy = self._proxyCache[mhclofile]

        mesh,obj = pxy.loadMeshAndObject(self.human)

        self.human.setProxy(pxy)
        self.human.updateProxyMesh()

        # Add to selection
        self.selectedProxies.append(pxy)

        self.filechooser.selectItem(mhclofile)

        self.signalChange()
Exemplo n.º 13
0
    def selectProxy(self, mhclofile):
        """
        Called when a new proxy has been selected.
        If this library selects only a single proxy, specifying None as
        mhclofile parameter will deselect the current proxy and set the selection
        to "none".
        If this library allows selecting multiple proxies, specifying None as
        mhclofile will have no effect.
        """
        if not mhclofile:
            if self.multiProxy:
                return
            else:
                self.deselectProxy(None)
                return

        log.message('Selecting proxy file "%s" from %s library.', mhclofile,
                    self.proxyName)
        human = self.human

        pxy = None
        mhcloId = getpath.canonicalPath(mhclofile)
        if mhcloId in self._proxyCache:
            pxy = self._proxyCache[mhcloId]
            if pxy.mtime < os.path.getmtime(mhclofile):
                pxy = None

        if not pxy:
            pxy = proxy.loadProxy(human,
                                  mhclofile,
                                  type=self.proxyName.capitalize())
            self._proxyCache[mhcloId] = pxy

        if pxy.uuid in [p.uuid for p in self.getSelection() if p is not None]:
            log.debug(
                "Proxy with UUID %s (%s) already loaded in %s library. Skipping.",
                pxy.uuid, pxy.file, self.proxyName)
            return

        if not self.multiProxy and self.isProxySelected():
            # Deselect previously selected proxy
            self.deselectProxy(None, suppressSignal=True)

        mesh, obj = pxy.loadMeshAndObject(human)
        mesh.setPickable(
            True)  # Allow mouse picking for proxies attached to human

        if not mesh:
            return

        gui3d.app.addObject(obj)

        self.filechooser.selectItem(mhclofile)

        self.adaptProxyToHuman(pxy, obj)
        obj.setSubdivided(
            human.isSubdivided())  # Copy subdivided state of human

        # Add to selection
        self.selectedProxies.append(pxy)

        self.filechooser.selectItem(mhclofile)

        self.proxySelected(pxy)

        self.signalChange()
    buddy = human.Human(
        files3d.loadMesh(mh.getSysDataPath("3dobjs/base.obj"), maxFaces=5))
    G.app = appDummy(buddy)
    base_skel = skeleton.load(mh.getSysDataPath('rigs/default.mhskel'),
                              buddy.meshData)
    buddy.setBaseSkeleton(base_skel)

    import humanmodifier
    humanmodifier.loadModifiers("data/modifiers/modeling_modifiers.json",
                                buddy)
    import proxy
    print os.getcwd()
    sys.stdout = stdout
    buddyProxy = proxy.loadProxy(
        buddy, os.path.join(os.getcwd(), 'data', 'eyes', 'low-poly',
                            'low-poly'), 'Eyes')
    print
    mesh, obj = buddyProxy.loadMeshAndObject(buddy)
    print

    buddy.setEyesProxy(buddyProxy)
    mesh = obj.getSeedMesh()

    sys.stdout = f

    mods = []
    cats = []
    acceptableModGroups = [0, 1, 2, 7, 9, 12, 17, 18, 21]
    for i in acceptableModGroups:
        cats.append(buddy.modifierGroups[i])
    # 'Eyelashes',
    # 'Teeth',
    # 'Tongue',
    'Genitals'
]
for group in proxyGroups:
    for proxy_name in proxies[group]:
        proxy_file = proxies[group][proxy_name]
        
        # ignore the debug proxies
        if proxy_file.find('__') != -1: continue
        
        # load data
        basehuman = getHuman()
        humanargparser.addRig(basehuman, rig_file)
        prxy = mhproxy.loadProxy(basehuman, proxy_file)
        mesh, obj = prxy.loadMeshAndObject(basehuman)

        print("prxy = ", prxy)
        # export
        infile = Path(prxy.obj_file)
        outfile = outdir.joinpath(group.lower()).joinpath(prxy.name,prxy.name + '.json')
        outfile.dirname().makedirs_p()
        if outfile.isfile(): continue
        
        convert_ascii(
            infile=infile,
            morphfiles='',
            colorfiles='',
            outfile=outfile,
            licence=json.dumps(LicenseInfo().asDict()),
		def addLogMessage(self, arg1, arg2):
			"Noop"
		


	buddy = human.Human(files3d.loadMesh(mh.getSysDataPath("3dobjs/base.obj"), maxFaces = 5))
	G.app = appDummy(buddy)
	base_skel = skeleton.load(mh.getSysDataPath('rigs/default.mhskel'), buddy.meshData)
	buddy.setBaseSkeleton(base_skel)

	import humanmodifier
	humanmodifier.loadModifiers("data/modifiers/modeling_modifiers.json", buddy)
	import proxy
	print os.getcwd()
	sys.stdout = stdout
	buddyProxy = proxy.loadProxy(buddy, os.path.join(os.getcwd(), 'data', 'eyes', 'low-poly', 'low-poly'), 'Eyes')
	print
	mesh, obj = buddyProxy.loadMeshAndObject(buddy)
	print
	
	buddy.setEyesProxy(buddyProxy)
	mesh = obj.getSeedMesh()
	
	sys.stdout = f
	
	
	mods = []
	cats = []
	acceptableModGroups = [0, 1, 2, 7, 9, 12, 17, 18, 21]
	for i in acceptableModGroups:
		cats.append(buddy.modifierGroups[i])