コード例 #1
0
 def createMush(self):
     mesh = self.sourceField.text()
     if not mesh:
         return
     if cmds.objExists(mesh +'_Mush'):
         print (mesh +'_Mush already exists!')
         return
     cmds.currentTime(cmds.playbackOptions(q = True, min = True))
     dup = cmds.duplicate(mesh, inputConnections =True, n = mesh +'_Mush')
     cmds.deltaMush(dup, smoothingIterations = 20, smoothingStep = 0.5, pinBorderVertices = True, envelope = 1)
コード例 #2
0
    def duplicates(self):
        self.main_joint = find_parentUp(self.joint[0])
        #if not mc.objExists(allJoint[0] + '_dup'):

        self.joint_dup = mc.duplicate(self.main_joint,
                                      n='{}'.format(self.main_joint) + '_dup')
        seachAndReplaceNamse(self.joint_dup[0])

        for model in self.model:
            obj = model
            if not obj:
                return
            if mc.objExists(obj + '_dup'):
                print(obj + '_dup already exists!')
                return

            self.obj_dup = mc.duplicate(obj, n=obj + '_dup')
            self.model_dup.append(self.obj_dup)

            skinClusterStr = 'findRelatedSkinCluster("' + obj + '")'
            skinCluster = mel.eval(skinClusterStr)
            joint = mc.skinCluster(skinCluster, q=True, inf=True)

            obj_dup = obj + '_dup'
            self.new_joint = self.main_joint + '_dup'

            try:
                mc.bakeDeformer(ss=self.main_joint,
                                sm=obj,
                                ds=self.new_joint,
                                dm=obj_dup,
                                mi=3)
                mc.deltaMush(obj_dup,
                             smoothingIterations=25,
                             smoothingStep=0.35,
                             pinBorderVertices=True,
                             inwardConstraint=1,
                             outwardConstraint=0,
                             envelope=1)
            except:
                print obj
                pass

            skinClusterStr2 = 'findRelatedSkinCluster("' + obj_dup + '")'
            skinCluster2 = mel.eval(skinClusterStr2)
            mc.select(obj_dup)
            mc.skinPercent(skinCluster2, prw=0.01)

        #self.joint_dup = mc.skinCluster(skinCluster2 ,q=True ,inf=True)

        for jnt in self.joint:
            if mc.nodeType(jnt) == 'joint':
                mc.parentConstraint(jnt, '{}'.format(jnt) + '_dup', mo=1)

        print '!!! COMPLETED !!!'
コード例 #3
0
ファイル: miscFunc.py プロジェクト: jonntd/tak_maya_preset
def applyDeltaMush(smooth=1.0, iterations=20, useBuildIn=False):
    """
    Args:
      smooth (float)
      iterations (int)
    """
    sel = cmds.ls(sl=1, ap=1)

    if not sel:
        om.MGlobal.displayError("Please select a few meshes.")
        return

    if useBuildIn:
        cmds.deltaMush(sel, si=iterations, ss=smooth, pbv=0)
    else:
        cmds.wbDeltaMush(sel, si=iterations, ss=smooth, pbv=0)
コード例 #4
0
def relaxToSelection(source, target):
	'''
	Transfer high-frequency sculpts (like wrinkles) from one shape to another

	This sets up a delta mush on a detailed mesh (source) before blending to a
	less detailed shape (target). Turning up the deltaMush re-applies the
	high-resolution deltas to that less detailed shape so then blend it back
	into the target
	'''
	sourceDup = cmds.duplicate(source, name="deltaMushMesh")[0]
	targetDup = cmds.duplicate(target, name="targetDup")[0]
	deltaMushRelax = cmds.group(sourceDup, name="deltaMushRelax")
	cmds.hide([sourceDup, targetDup, deltaMushRelax])

	cmds.addAttr(deltaMushRelax, longName="smooth_iter", attributeType="long", minValue=0, maxValue=100, defaultValue=10)
	smoothIter = "{0}.smooth_iter".format(deltaMushRelax)
	cmds.setAttr(smoothIter, edit=True, keyable=True)

	blender = cmds.blendShape(targetDup, sourceDup)
	deltaMush = cmds.deltaMush(sourceDup, smoothingIterations=10, smoothingStep=0.5, pinBorderVertices=1, envelope=1)[0]
	cmds.connectAttr(smoothIter, deltaMush+".smoothingIterations", force=True)

	cmds.delete(targetDup)
	finalBlend = cmds.blendShape(sourceDup, target)
	cmds.blendShape(finalBlend, edit=True, weight=((0, 1)))
	cmds.blendShape(blender, edit=True, weight=((0, 1)))
	
	cmds.select(deltaMushRelax)
コード例 #5
0
ファイル: ARTools.py プロジェクト: Jap3dWorks/autoRig_Tools
    def deltaCorrective(joints, bShape):
        """
        extract and apply delto to a blendShape
        """

        mesh = pm.PyNode(bShape.getGeometry()[0])
        meshTransform = mesh.getTransform()

        for joint in joints:
            # create poseInterpolator
            poseInterpolator = pm.PyNode(
                pm.poseInterpolator(joint,
                                    name=str(joint) + '_poseInterpolator')[0])
            poseInterpolatorShape = poseInterpolator.getShape()
            print poseInterpolator

            # create basic poses
            for i, pose in enumerate(
                ['neutral', 'neutralSwing', 'neutralTwist']):
                pm.poseInterpolator(poseInterpolator, e=True, addPose=pose)
                poseInterpolatorShape.pose[i].poseType.set(i)

            for rot in ([0, 90, 0], [0, -90, 0], [0, 0, 90], [0, 0, -90]):
                baseMesh = meshTransform.duplicate(name=str(joint) +
                                                   ('_baseMesh'))[0]
                baseMesh.setParent(w=True)

                joint.setRotation(rot, 'object')
                negativeMesh = meshTransform.duplicate(name=str(joint) +
                                                       ('_negative'))[0]
                negativeMesh.setParent(w=True)
                joint.setRotation([0, 0, 0], 'object')

                deltaMush = cmds.deltaMush(str(meshTransform), si=180, ss=0.1)
                cmds.dgeval(deltaMush)
                # set poses
                joint.setRotation(rot, 'object')
                namePose = str(joint) + ('_%s_%s_%s' %
                                         (rot[0], rot[1], rot[2])).replace(
                                             '-', 'n')
                pm.poseInterpolator(poseInterpolator, e=True, addPose=namePose)

                # duplicate mesh
                positive = meshTransform.duplicate(name=namePose)[0]
                positive.setParent(w=True)

                # get delta
                deltaShape = PSDUtils.getDelta(positive.getShape(),
                                               negativeMesh.getShape(),
                                               baseMesh.getShape())

                pm.delete(baseMesh)
                cmds.delete(deltaMush)

                # create bShape
                weightIndex = bShape.numWeights()
                bShape.addTarget(mesh, weightIndex, deltaShape, 1.0)

                joint.setRotation([0, 0, 0], 'object')
コード例 #6
0
ファイル: animation.py プロジェクト: vondras/pymel
def deltaMush(*args, **kwargs):
    res = cmds.deltaMush(*args, **kwargs)
    if not kwargs.get('query', kwargs.get('q', False)):
        res = _factories.maybeConvert(res, _general.PyNode)
    if isinstance(res, list) and len(res) == 1:
        if kwargs.get('query', kwargs.get('q', False)):
            # unpack for specific query flags
            unpackFlags = {'en', 'envelope', 'inwardConstraint', 'iwc', 'outwardConstraint', 'owc', 'pbv', 'pinBorderVertices', 'smoothingStep', 'ss'}
            if not unpackFlags.isdisjoint(kwargs):
                res = res[0]
        else:
            # unpack create/edit result
            res = res[0]
    return res
コード例 #7
0
def _applyDeltaMush(geo):

    deltaMushDf = mc.deltaMush(geo, smoothingIterations=50)[0]
コード例 #8
0
    def _applyDeltaMush(self, geometry):

        res = cmds.deltaMush(geometry, smoothingIterations=50)[0]
        return res
コード例 #9
0
def applyWtsDir(directory):
    '''
    This function will take a directory with properly named weight files,
    i.e.(geometryName__deformerName.xml), and apply them if both the deformer and geometry
    are in the current scene.

    .. TODO::
        We need to make sure we create the other deformers if they don't exist. Currently We're only
        creating skinClusters.

    If the deformers isn't in the scene but the geometry is, we will create the deformer for you.

    :param directory: Directory path with weight files inside of it.
    :type directory: str
    '''
    # Check to see if the directory past into this function exists.
    if os.path.isdir(directory):
        # loop through all of the files in the directory and make sure they're weights files.
        for filename in os.listdir(directory):
            filepath = os.path.join(directory, filename)
            fileSplit = filename.split("__")
            if ".xml" != os.path.splitext(filepath)[-1]:
                continue
            # get the geometry, deformer, and deformerType from the file name.
            geometry = fileSplit[0]
            deformer = fileSplit[1].split(".")[0]
            deformerType = deformer.split("_")[-1]
            # Continue if the geo doesn't exist
            if not mc.objExists(geometry):
                print('Loading {}: Geometry [ {} ] does not exist'.format(
                    deformer, geometry))
                continue
            # if the deformer doesn't exist, then we will create it.
            if not mc.objExists(deformer):
                tree = et.parse(filepath)
                root = tree.getroot()
                # create skinCluster deformer if it doesn't exist in the current session.
                if deformerType == "skinCluster":
                    jointList = [
                        wts.get('source') for wts in root.findall('weights')
                    ]
                    jointListExists = mc.ls(jointList)
                    jointListMissing = list(
                        set(jointList) - set(jointListExists))
                    if jointListMissing:
                        print('Loading {}: Missing joints [ {} ]'.format(
                            deformer, jointListMissing))
                    if not jointListExists:
                        print('No joints could be fournd for [ {} ]'.format(
                            deformer))
                        continue
                    skin = mc.skinCluster(jointListExists,
                                          geometry,
                                          name=deformer,
                                          tsb=True)[0]
                    # Set to dual quaternion mode
                    mc.setAttr('{}.skinningMethod'.format(skin), 1)
                if deformerType == "deltaMush":
                    mc.deltaMush(geometry,
                                 name=deformer,
                                 smoothingIterations=10,
                                 smoothingStep=0.5,
                                 pinBorderVertices=True,
                                 envelope=True)
            # apply the weights
            if not mc.objExists(deformer):
                print('deformer does not exist [ {} ]'.format(deformer))
                continue
            rigrepo.libs.weights.importWeights(geometry, deformer, filepath)
            # this ensures that our skinCluster is normalized.
            if deformerType == "skinCluster":
                mc.skinCluster(deformer, e=True, fnw=True)
コード例 #10
0
def apply_deltaMush(geometry):
    delta_mush = cmds.deltaMush(geometry, smoothingIterations=50)