Ejemplo n.º 1
0
def uvTransferFiles(srcPath,
                    tarPath,
                    outAbcPath,
                    srcUvSet='default',
                    tarUvSet='default',
                    tol=0.0001,
                    pBar=None):
    ''' Transfer the shape from the source to the target through uv space
	and write out the result

	Arguments:
		srcPath(str): The filepath to the source object
		tarPath(str): The filepath to the target object
		outAbcPath(str): The filepath for the result alembic file
	'''
    from blur3d.api.classes import abc
    tarVerts, tarFaces, tarUvs, tarUvFaces = uvTransferLoad(srcPath,
                                                            tarPath,
                                                            srcUvSet=srcUvSet,
                                                            tarUvSet=tarUvSet,
                                                            tol=tol,
                                                            pBar=pBar)
    abc.buildAbc(outAbcPath,
                 tarVerts,
                 tarFaces,
                 uvs=tarUvs,
                 uvFaces=tarUvFaces)
Ejemplo n.º 2
0
def uvTransferFiles(srcPath, tarPath, outAbcPath, srcUvSet='default', tarUvSet='default', tol=0.0001, pBar=None):
	'''Transfer the shape from the source to the target through uv space
		and write out the result

	Parameters
	----------
	srcPath : str
		The source mesh path (obj, abc, or smpx)
	tarPath : str
		The target mesh path (obj, abc, or smpx)
	outAbcPath : str
		The path to the output .abc file
	srcUvSet : str
		The name of the uv set to use on the source
	tarUvSet : str
		The name of the uv set to use on the target
	tol : float
		A small tolerance value, defaulting to the global EPS
	pBar : QProgressDialog, optional
		An optional progress dialog

	Returns
	-------

	'''
	from blur3d.api.classes import abc
	tarVerts, tarFaces, tarUvs, tarUvFaces = uvTransferLoad(
		srcPath, tarPath, srcUvSet=srcUvSet, tarUvSet=tarUvSet, tol=tol, pBar=pBar
	)
	abc.buildAbc(outAbcPath, tarVerts, tarFaces, uvs=tarUvs, uvFaces=tarUvFaces)
Ejemplo n.º 3
0
def simplexUvTransfer(srcSmpxPath,
                      tarPath,
                      outPath,
                      srcUvPath=None,
                      tol=0.0001,
                      pBar=None):
    """ Transfer a simplex system onto a mesh through UV space

	Arguments:
		srcSmpxPath (str): The path to the source .smpx file
		tarPath (str): The path to the mesh to recieve the blendshapes
		outPath (str): The .smpx path that will be written
		srcUvPath (str): If the .smpx file doesn't have UV's, then the UV's
			from this mesh wil be used. Defaults to None
		tol (float): The tolerance for checking if a UV is outside of a poly
		pBar (QProgressDialog): Optional progress bar
	"""
    if pBar is not None:
        pBar.setLabelText("Loading Source Mesh")
        from Qt.QtWidgets import QApplication
        QApplication.processEvents()

    srcUvPath = srcUvPath or srcSmpxPath
    if srcUvPath.endswith('.abc') or srcUvPath.endswith('.smpx'):
        src = Mesh.loadAbc(srcUvPath, ensureWinding=False)
    elif srcUvPath.endswith('.obj'):
        src = Mesh.loadObj(srcUvPath, ensureWinding=False)
    srcVerts = abc.getSampleArray(abc.getMesh(srcSmpxPath))

    if pBar is not None:
        pBar.setLabelText("Loading Target Mesh")
        from Qt.QtWidgets import QApplication
        QApplication.processEvents()
    if tarPath.endswith('.abc'):
        tar = Mesh.loadAbc(tarPath, ensureWinding=False)
    elif tarPath.endswith('.obj'):
        tar = Mesh.loadObj(tarPath, ensureWinding=False)

    srcFaces = src.faceVertArray
    srcUvFaces = src.uvFaceMap['default']
    srcUvs = np.array(src.uvMap['default'])

    tarFaces = tar.faceVertArray
    tarUvFaces = tar.uvFaceMap['default']
    tarUvs = np.array(tar.uvMap['default'])
    oldTarVerts = np.array(tar.vertArray)

    corr = getVertCorrelation(srcUvFaces,
                              srcUvs,
                              tarFaces,
                              tarUvFaces,
                              tarUvs,
                              tol=tol,
                              pBar=pBar)
    tarVerts = applyTransfer(srcVerts, srcFaces, corr, len(oldTarVerts))

    # Apply as a delta
    deltas = tarVerts - tarVerts[0][None, ...]
    writeVerts = oldTarVerts[None, ...] + deltas

    jsString, name = _loadJSString(srcSmpxPath)
    oarch = OArchive(str(outPath), OGAWA)  # false for HDF5
    abc.buildAbc(oarch,
                 writeVerts,
                 tarFaces,
                 uvs=tarUvs,
                 uvFaces=tarUvFaces,
                 name=name,
                 shapeSuffix='',
                 propDict=dict(simplex=jsString))