def deltaMushDeformer(geo, smoothingIterations=10, smoothingStep=0.5): """ Apply Mush Deformer :param geo: str :param smoothingIterations: float :param smoothingStep: float :return: deformer node """ deformerNode = pm.deltaMush(geo, smoothingIterations=smoothingIterations, smoothingStep=smoothingStep)[0] return deformerNode
def apply_delta_mush(mesh, distanceWeight=1.0, displacement=1.0, **deltaMush_kwargs): default_deltaMush_kwargs = {'smoothingIterations': 20, 'smoothingStep': 1.0, 'pinBorderVertices': False, 'envelope': 1.0, 'inwardConstraint': 0.0, 'outwardConstraint': 0.0} default_deltaMush_kwargs.update(deltaMush_kwargs) delta_mush_node = pm.deltaMush(mesh, **default_deltaMush_kwargs) # these are arguments that the Delta Mush UI has but are not valid arguments for the deltaMush() command. delta_mush_node.distanceWeight.set(distanceWeight) delta_mush_node.displacement.set(displacement) return delta_mush_node
def wrapSetUp(_HiRez = pm.selected(), _LoRez=pm.selected()): """ Custom wrapDeformer Setup Select target - HiRez first, then the source - LoRez The script will create a duplicate of the HiRez with a blenshape and add a DeltaMush on the HiRez @param Hirez: Target which will receive the wrap @param Lorez: Source ## EXTERIOR CLASS BUILD #------------------------ import adb_utils.Script__WrapDeformer_Setup as adbWrapSetUp reload(adbWrapSetUp) #or from adb_utils.Script__WrapDeformer_Setup import wrapSetUp """ ## Define Variable type if isinstance(_HiRez, str) and isinstance(_LoRez, str): hi = _HiRez lo = _LoRez elif len(_HiRez) == 2: hi = _HiRez[0] lo = _LoRez[1] dup = pm.duplicate(hi, n='{}__{}__'.format(hi,'duplicate_wrap'), ic=1, rr=1)[0] wrapData = adbWrap.wrapDeformer(str(dup),str(lo)) ## add custom attribute on wrap node wrap_node = adbAttr.NodeAttr([wrapData]) wrap_node.addAttr('mushEnveloppe', 1) wrap_node.addAttr('smoothingIterations', 10) wrap_node.addAttr('smoothingStep', 0.5) ## blendShape blendShape = pm.blendShape(dup, hi, exclusive="deformPartition#", o = "world", w = [(0, 1.0)], ib=1, n = '{}__{}__'.format(hi, 'BLS'))[0] ## Mush mush = pm.deltaMush(hi, smoothingIterations=10, envelope=1, smoothingStep=0.5, pinBorderVertices=1, n = '{}_{}'.format(hi, 'mush')) pm.PyNode(wrapData).mushEnveloppe >> pm.PyNode(mush).envelope pm.PyNode(wrapData).smoothingIterations >> pm.PyNode(mush).smoothingIterations pm.PyNode(wrapData).smoothingStep >> pm.PyNode(mush).smoothingStep ## Clean Up pm.PyNode(dup).v.set(0)
def reset(obj): obj = pym.PyNode(obj) dmN = pym.listHistory(obj, type="deltaMush")[0] scenePath = os.path.dirname(pym.sceneName()) if scenePath == "": scenePath = pym.workspace.path fileName = os.path.basename(pym.sceneName()) wmPath = os.path.join( scenePath, "_deformer_wm" ).replace("\\", "/") if not os.path.exists(wmPath): os.makedirs(wmPath) partName = obj.name() if ":" in partName: partName = partName.split(":")[-1] assetName = fileName.split("_")[0] wmName = "deltaMush_{0}_{1}.xml".format(partName, assetName) pym.deformerWeights(wmName, export=True, path=wmPath, deformer=dmN) dmAttrs = {} for attr in DeltaMush_Attrs: val = dmN.getAttr(attr) dmAttrs[attr] = val dmN.setGeometry([obj], rm=True) pym.delete(dmN) if obj.namespace() != '': dmNewName = "{0}:{1}_{2}_deltaMush".format( obj.namespace(), partName, assetName ) else: dmNewName = "{0}_{1}_deltaMush".format(partName, assetName) dmN = pym.deltaMush(obj, n=dmNewName) for attr in dmAttrs: dmN.setAttr(attr, dmAttrs[attr]) pym.deformerWeights(wmName, im=True, path=wmPath, deformer=dmN)
dM.reset("iBird43:BODY") p dm = pym.ls(sl=1)[0] dm.name() dm.listAttr() pym.workspace.path mainCTL = pym.ls("main_control", type="transform", r=True)[0] wiregrp = pym.ls("WIRE", r=True)[0] for child in wiregrp.listRelatives(ad=True, type="mesh"): dMN = child.listHistory(type="deltaMush") if dMN: print child.name() dM.connectScale(child, mainCTL) dM.connectScale("iBird43:BODY", "iBird43:main_control") dm = pym.deltaMush("BODY", n="iBird43_BODY_dm") pym.deltaMush("deltaMush20", g=["BODY"], rm=True, e=True) pym.deltaMush("BODY", n="iBird43_deltaMush") dm20 = pym.PyNode("BODY") dm20.namespace() pym.delete(dm20) pym.sceneName() dmN = pym.listHistory("BODY", type="deltaMush")[0] pym.deformerWeights("deltamush_BODY_iBird43.xml", export=True, path="E:/FreeLanceWork/Genoma/PRJ_FLOWER/scenes/iBird43/_deformer_wm", deformer=dmN) dmN.setGeometry(["BODY"], rm=True) pym.delete(dmN) dmN = pym.deltaMush("BODY", n="iBird43_deltaMush") pym.deformerWeights("deltamush_BODY_iBird43.xml", im=True, path="E:/FreeLanceWork/Genoma/PRJ_FLOWER/scenes/iBird43/_deformer_wm", deformer=dmN)