Beispiel #1
0
    def changeVertexMask(self, vertsMask):
        """
        Apply a face mask to the meshes (original seed mesh, subdivided mesh
        and proxied meshes) specified by a vertex mask.
        The vertex mask is a list of booleans, one for each vertex, where True
        means not masked (visible), and False means masked (hidden).
        A face is masked if all of the vertices that define it are masked.
        """
        print "crazy------changeVertexMask------"
        if vertsMask is None:
            # Undo face mask set by vertex mask
            self.__seedMesh.changeFaceMask(self.staticFaceMask)
            self.__seedMesh.updateIndexBufferFaces()
            if self.__subdivisionMesh:
                self.__subdivisionMesh.changeFaceMask(self.staticFaceMask)
                self.__subdivisionMesh.updateIndexBufferFaces()
            if self.__proxyMesh:
                self.__proxyMesh.changeFaceMask(np.ones(self.__proxyMesh.getFaceCount(), dtype=bool))
                self.__proxyMesh.updateIndexBufferFaces()
            if self.__proxySubdivisionMesh:
                self.__proxySubdivisionMesh.changeFaceMask(np.ones(self.__proxySubdivisionMesh.getFaceCount(), dtype=bool))
                self.__proxySubdivisionMesh.updateIndexBufferFaces()
            return

        # Mask seed mesh
        faceMask = self.__seedMesh.getFaceMaskForVertices(np.argwhere(vertsMask)[...,0])
        self.__seedMesh.changeFaceMask(np.logical_and(faceMask, self.staticFaceMask))
        self.__seedMesh.updateIndexBufferFaces()

        import log
        log.debug("%s faces masked for %s", np.count_nonzero(~faceMask), self.__seedMesh.name)

        # Mask smoothed seed mesh
        if self.__subdivisionMesh:
            # Remap faceMask to subdivision mesh base faces, accounting for the
            # excluded faces of the static facemask (staticFaceMask).
            
            # Statically masked faces (staticFaceMask) are excluded from 
            # subdivision mesh geometry, for performance.
            # Dynamically masked faces (eg. using this method) are not excluded
            # from the subdivision mesh and simply masked, allowing faster
            # changes to the face mask without requiring a rebuild of the
            # subdivision mesh.
            self.__subdivisionMesh.changeFaceMask(faceMask)
            self.__subdivisionMesh.updateIndexBufferFaces()

        # Mask proxy and subdivided proxy mesh
        if self.__proxyMesh:
            import proxy
            # Transfer face mask to proxy
            proxyVertMask = proxy.transferVertexMaskToProxy(vertsMask, self.proxy)
            proxyFaceMask = self.__proxyMesh.getFaceMaskForVertices(np.argwhere(proxyVertMask)[...,0])

            self.__proxyMesh.changeFaceMask(proxyFaceMask)
            self.__proxyMesh.updateIndexBufferFaces()

            if self.__proxySubdivisionMesh:
                self.__proxySubdivisionMesh.changeFaceMask(proxyFaceMask)
                self.__proxySubdivisionMesh.updateIndexBufferFaces()
Beispiel #2
0
    def changeVertexMask(self, vertsMask):
        """
        Apply a face mask to the meshes (original seed mesh, subdivided mesh
        and proxied meshes) specified by a vertex mask.
        The vertex mask is a list of booleans, one for each vertex, where True
        means not masked (visible), and False means masked (hidden).
        A face is masked if all of the vertices that define it are masked.
        """
        if vertsMask is None:
            # Undo face mask set by vertex mask
            self.__seedMesh.changeFaceMask(self.staticFaceMask)
            self.__seedMesh.updateIndexBufferFaces()
            if self.__subdivisionMesh:
                self.__subdivisionMesh.changeFaceMask(self.staticFaceMask)
                self.__subdivisionMesh.updateIndexBufferFaces()
            if self.__proxyMesh:
                self.__proxyMesh.changeFaceMask(np.ones(self.__proxyMesh.getFaceCount(), dtype=bool))
                self.__proxyMesh.updateIndexBufferFaces()
            if self.__proxySubdivisionMesh:
                self.__proxySubdivisionMesh.changeFaceMask(np.ones(self.__proxySubdivisionMesh.getFaceCount(), dtype=bool))
                self.__proxySubdivisionMesh.updateIndexBufferFaces()
            return

        # Mask seed mesh
        faceMask = self.__seedMesh.getFaceMaskForVertices(np.argwhere(vertsMask)[...,0])
        self.__seedMesh.changeFaceMask(np.logical_and(faceMask, self.staticFaceMask))
        self.__seedMesh.updateIndexBufferFaces()

        import log
        log.debug("%s faces masked for %s", np.count_nonzero(~faceMask), self.__seedMesh.name)

        # Mask smoothed seed mesh
        if self.__subdivisionMesh:
            # Remap faceMask to subdivision mesh base faces, accounting for the
            # excluded faces of the static facemask (staticFaceMask).
            
            # Statically masked faces (staticFaceMask) are excluded from 
            # subdivision mesh geometry, for performance.
            # Dynamically masked faces (eg. using this method) are not excluded
            # from the subdivision mesh and simply masked, allowing faster
            # changes to the face mask without requiring a rebuild of the
            # subdivision mesh.
            self.__subdivisionMesh.changeFaceMask(faceMask)
            self.__subdivisionMesh.updateIndexBufferFaces()

        # Mask proxy and subdivided proxy mesh
        if self.__proxyMesh:
            import proxy
            # Transfer face mask to proxy
            proxyVertMask = proxy.transferVertexMaskToProxy(vertsMask, self.proxy)
            proxyFaceMask = self.__proxyMesh.getFaceMaskForVertices(np.argwhere(proxyVertMask)[...,0])

            self.__proxyMesh.changeFaceMask(proxyFaceMask)
            self.__proxyMesh.updateIndexBufferFaces()

            if self.__proxySubdivisionMesh:
                self.__proxySubdivisionMesh.changeFaceMask(proxyFaceMask)
                self.__proxySubdivisionMesh.updateIndexBufferFaces()
Beispiel #3
0
    def updateFaceMasks(self, enableFaceHiding=True):
        """
        Apply facemask (deleteVerts) defined on clothes to body and lower layers
        of clothing. Uses order as defined in self.clothesList.
        """
        if self.blockFaceMasking:
            return

        import proxy
        log.debug("Clothes library: updating face masks (face hiding %s).",
                  "enabled" if enableFaceHiding else "disabled")

        human = self.human
        if not enableFaceHiding:
            human.changeVertexMask(None)

            proxies = self.getSelection()
            if self.human.genitalsProxy:
                proxies.append(self.human.genitalsProxy)
            for pxy in proxies:
                obj = pxy.object
                obj.changeVertexMask(None)
            return

        vertsMask = np.ones(human.meshData.getVertexCount(), dtype=bool)

        stackedProxies = [
            human.clothesProxies[uuid]
            for uuid in reversed(self.getClothesByRenderOrder())
        ]
        # Mask genitals too
        if self.human.genitalsProxy:
            stackedProxies.append(self.human.genitalsProxy)

        for pxy in stackedProxies:
            obj = pxy.object

            # Remap vertices from basemesh to proxy verts
            proxyVertMask = proxy.transferVertexMaskToProxy(vertsMask, pxy)

            # Apply accumulated mask from previous clothes layers on this clothing piece
            obj.changeVertexMask(proxyVertMask)

            if pxy.deleteVerts != None and len(pxy.deleteVerts > 0):
                log.debug(
                    "Loaded %s deleted verts (%s faces) from %s proxy.",
                    np.count_nonzero(pxy.deleteVerts),
                    len(
                        human.meshData.getFacesForVertices(
                            np.argwhere(pxy.deleteVerts)[..., 0])), pxy.name)

                # Modify accumulated (basemesh) verts mask
                verts = np.argwhere(pxy.deleteVerts)[..., 0]
                vertsMask[verts] = False

        human.changeVertexMask(vertsMask)
    def updateFaceMasks(self, enableFaceHiding = True):
        """
        Apply facemask (deleteVerts) defined on clothes to body and lower layers
        of clothing. Uses order as defined in self.clothesList.
        """
        if self.blockFaceMasking:
            return

        import proxy
        log.debug("Clothes library: updating face masks (face hiding %s).", "enabled" if enableFaceHiding else "disabled")

        human = self.human
        if not enableFaceHiding:
            human.changeVertexMask(None)

            proxies = self.getSelection()
            if self.human.genitalsProxy:
                proxies.append(self.human.genitalsProxy)
            for pxy in proxies:
                obj = pxy.object
                obj.changeVertexMask(None)
            return


        vertsMask = np.ones(human.meshData.getVertexCount(), dtype=bool)

        stackedProxies = [human.clothesProxies[uuid] for uuid in reversed(self.getClothesByRenderOrder())]
        # Mask genitals too
        if self.human.genitalsProxy:
            stackedProxies.append( self.human.genitalsProxy )

        for pxy in stackedProxies:
            obj = pxy.object

            # Remap vertices from basemesh to proxy verts
            proxyVertMask = proxy.transferVertexMaskToProxy(vertsMask, pxy)

            # Apply accumulated mask from previous clothes layers on this clothing piece
            obj.changeVertexMask(proxyVertMask)

            if pxy.deleteVerts != None and len(pxy.deleteVerts > 0):
                log.debug("Loaded %s deleted verts (%s faces) from %s proxy.", np.count_nonzero(pxy.deleteVerts), len(human.meshData.getFacesForVertices(np.argwhere(pxy.deleteVerts)[...,0])),pxy.name)

                # Modify accumulated (basemesh) verts mask
                verts = np.argwhere(pxy.deleteVerts)[...,0]
                vertsMask[verts] = False

        human.changeVertexMask(vertsMask)
Beispiel #5
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