def cbsTrans(*args, **kwargs): sculptTrans = kwargs.setdefault('sculptTrans', pm.ls(sl=True)[0])# (string) The mesh to get the tweak edits extracted from shape = kwargs.setdefault('shape') # (string) The shape node of the sculptTrans node tweak = kwargs.setdefault('tweak') # (string) The tweak node that is going to be cleared skin = kwargs.setdefault('skin') # (string) The skinCluster node that drives the base mesh base = kwargs.setdefault('base') # (string) The base mesh for the character #get some info sculptTrans, shape, tweak, skin = gatherInfo(sculptTrans, shape, tweak, skin) if not 'baseTransform' in pm.listAttr(sculptTrans, ud=True): pm.error('This model has not been prepared for sculpting. If you accidentally started, simply run Clear Tweaks to extract what has been done') if not base: base = sculptTrans.baseTransform.get() baseRef = sculptTrans.baseReference.get() #turn off a couple things that might mess with things pm.symmetricModelling(e=True, symmetry= False) pm.softSelect(e=True, softSelectEnabled=False) #first, let's unlock the guys from the old function pm.lockNode(base, l=False) pm.lockNode(sculptTrans, l=False) pm.setAttr('%s.v'%base, True) #extract from the sculpted shape newShape = clearTweaks(base=base, tweak=tweak) pm.delete(sculptTrans) newOrig = pm.duplicate(base, n='%s_editReference'%base)[0] pm.connectAttr(('%s.outMesh' %newOrig.getShapes()[1]), ('%s.inMesh' %newOrig.getShape())) pm.select(cl=True) deviation = False for v in range(pm.polyEvaluate(base, v=True)): refPos = pm.xform('%s.vtx[%i]'%(baseRef, v), q=True, t=True) adjPos = pm.xform('%s.vtx[%i]'%(newOrig, v), q=True, t=True) if not refPos == adjPos: deviation=True pm.move('%s.vtx[%i]' %(newShape, v), (refPos[0]-adjPos[0], refPos[1]-adjPos[1], refPos[2]-adjPos[2]), r=True) pm.move('%s.vtx[%i]'%(base, v), (refPos[0]-adjPos[0], refPos[1]-adjPos[1], refPos[2]-adjPos[2]), os=True, r=True) pm.select('%s.vtx[%i]' %(base, v), add=True) if deviation: pm.warning('It appears there were issues extracting from the mesh, steps have been taken to try and remedy, but unexpected results may occur') #apply a texture to the new shape. pm.select(newShape, r=True) pm.sets('initialShadingGroup', e=True, forceElement=True) pm.delete(newOrig, baseRef) return newShape
def cbsStart(*args, **kwargs): base = kwargs.setdefault('base', pm.ls(sl=True)[0]) # (string) The base model for the character shape = kwargs.setdefault('shape') # (string) The shape node of the base model tweak = kwargs.setdefault('tweak') # (string) The tweak node of the base model that is being skinned skin = kwargs.setdefault('skin') # (string) The skinCluster node that is driving the base model #gather some info base, shape, tweak, skin = gatherInfo(base, shape, tweak, skin) verts = pm.polyEvaluate(base, v=True) #do a quick check to make sure this part hasn't been done before if base.hasAttr('baseTransform'): pm.error('You have already run the "Start" function on this model, so it is already ready to go.' + 'If corrections have already been made, click "Extract Shape to finish the process"') for i in pm.listHistory(base, lv=1): if i.type() == 'polySmoothFace': pm.error('The selected shape is connected to a smooth modifier. This hinders the ability to track edits. %s must be deleted.' % i) #turn off a couple things that might mess with things pm.symmetricModelling(e=True, symmetry= False) pm.softSelect(e=True, softSelectEnabled=False) for i in range(verts): x = pm.getAttr(('%s.vlist[0].vertex[%i].xVertex'%(tweak, i))) y = pm.getAttr(('%s.vlist[0].vertex[%i].yVertex'%(tweak, i))) z = pm.getAttr(('%s.vlist[0].vertex[%i].zVertex'%(tweak, i))) if not (x+y+z) == 0: pm.error('You have used the tweak node. No me gusta. If you really wanna clear it, run clearTweaks and try again. It will save what you have') #ok, let's get started, first instance the original mesh sculptTrans = pm.instance(base, n=('%s_corrective_sculpt'%base))[0] pm.reorderDeformers(skin, tweak, base) pm.setAttr('%s.v'%base, False) #Here, we'll make a duplicate of the base to look back on later if need be (for instance, using sculpt geometry tends to not register on tweak) baseRef = pm.duplicate(base, n='%s_editReference'%base)[0] pm.connectAttr(('%s.outMesh' %baseRef.getShapes()[1]), ('%s.inMesh' %baseRef.getShape())) #We'll also hook up the original so we can get it later pm.addAttr(sculptTrans, ln='baseTransform', at='message') pm.addAttr(sculptTrans, ln='baseReference', at='message') pm.connectAttr('%s.message'%base, '%s.baseTransform'%sculptTrans) pm.connectAttr('%s.message'%baseRef, '%s.baseReference'%sculptTrans) #now to keep things from changing between functions, we'll lock the three nodes involved in the #other script so our pesky little user won't delete or rename anything pm.lockNode(base, l=True) pm.lockNode(sculptTrans, l=True)
def moveJaw(pAwayOrBack, *Args): pm.softSelect(softSelectEnabled=False) global jawIsAway if globalGender[0] == 'Female': jawSelection = pm.select('Body_Female.vtx[8267:9986]') if globalGender[0] == 'Male': jawSelection = pm.select('Body_Male.vtx[12853:14572]') pm.symmetricModelling(s=False) if (pAwayOrBack == 'Away'): pm.xform(translation=(0, 0, -200), relative=True) jawIsAway = 1 if (pAwayOrBack == 'Back'): pm.xform(translation=(0, 0, 200), relative=True) jawIsAway = 0 pm.softSelect(softSelectEnabled=True) pm.symmetricModelling(s=True)
def cbsStart(*args, **kwargs): base = kwargs.setdefault( 'base', pm.ls(sl=True)[0]) # (string) The base model for the character shape = kwargs.setdefault( 'shape') # (string) The shape node of the base model tweak = kwargs.setdefault( 'tweak' ) # (string) The tweak node of the base model that is being skinned skin = kwargs.setdefault( 'skin') # (string) The skinCluster node that is driving the base model #gather some info base, shape, tweak, skin = gatherInfo(base, shape, tweak, skin) verts = pm.polyEvaluate(base, v=True) #do a quick check to make sure this part hasn't been done before if base.hasAttr('baseTransform'): pm.error( 'You have already run the "Start" function on this model, so it is already ready to go.' + 'If corrections have already been made, click "Extract Shape to finish the process"' ) for i in pm.listHistory(base, lv=1): if i.type() == 'polySmoothFace': pm.error( 'The selected shape is connected to a smooth modifier. This hinders the ability to track edits. %s must be deleted.' % i) #turn off a couple things that might mess with things pm.symmetricModelling(e=True, symmetry=False) pm.softSelect(e=True, softSelectEnabled=False) for i in range(verts): x = pm.getAttr(('%s.vlist[0].vertex[%i].xVertex' % (tweak, i))) y = pm.getAttr(('%s.vlist[0].vertex[%i].yVertex' % (tweak, i))) z = pm.getAttr(('%s.vlist[0].vertex[%i].zVertex' % (tweak, i))) if not (x + y + z) == 0: pm.error( 'You have used the tweak node. No me gusta. If you really wanna clear it, run clearTweaks and try again. It will save what you have' ) #ok, let's get started, first instance the original mesh sculptTrans = pm.instance(base, n=('%s_corrective_sculpt' % base))[0] pm.reorderDeformers(skin, tweak, base) pm.setAttr('%s.v' % base, False) #Here, we'll make a duplicate of the base to look back on later if need be (for instance, using sculpt geometry tends to not register on tweak) baseRef = pm.duplicate(base, n='%s_editReference' % base)[0] pm.connectAttr(('%s.outMesh' % baseRef.getShapes()[1]), ('%s.inMesh' % baseRef.getShape())) #We'll also hook up the original so we can get it later pm.addAttr(sculptTrans, ln='baseTransform', at='message') pm.addAttr(sculptTrans, ln='baseReference', at='message') pm.connectAttr('%s.message' % base, '%s.baseTransform' % sculptTrans) pm.connectAttr('%s.message' % baseRef, '%s.baseReference' % sculptTrans) #now to keep things from changing between functions, we'll lock the three nodes involved in the #other script so our pesky little user won't delete or rename anything pm.lockNode(base, l=True) pm.lockNode(sculptTrans, l=True)
def cbsTrans(*args, **kwargs): sculptTrans = kwargs.setdefault( 'sculptTrans', pm.ls(sl=True) [0]) # (string) The mesh to get the tweak edits extracted from shape = kwargs.setdefault( 'shape') # (string) The shape node of the sculptTrans node tweak = kwargs.setdefault( 'tweak') # (string) The tweak node that is going to be cleared skin = kwargs.setdefault( 'skin') # (string) The skinCluster node that drives the base mesh base = kwargs.setdefault( 'base') # (string) The base mesh for the character #get some info sculptTrans, shape, tweak, skin = gatherInfo(sculptTrans, shape, tweak, skin) if not 'baseTransform' in pm.listAttr(sculptTrans, ud=True): pm.error( 'This model has not been prepared for sculpting. If you accidentally started, simply run Clear Tweaks to extract what has been done' ) if not base: base = sculptTrans.baseTransform.get() baseRef = sculptTrans.baseReference.get() #turn off a couple things that might mess with things pm.symmetricModelling(e=True, symmetry=False) pm.softSelect(e=True, softSelectEnabled=False) #first, let's unlock the guys from the old function pm.lockNode(base, l=False) pm.lockNode(sculptTrans, l=False) pm.setAttr('%s.v' % base, True) #extract from the sculpted shape newShape = clearTweaks(base=base, tweak=tweak) pm.delete(sculptTrans) newOrig = pm.duplicate(base, n='%s_editReference' % base)[0] pm.connectAttr(('%s.outMesh' % newOrig.getShapes()[1]), ('%s.inMesh' % newOrig.getShape())) pm.select(cl=True) deviation = False for v in range(pm.polyEvaluate(base, v=True)): refPos = pm.xform('%s.vtx[%i]' % (baseRef, v), q=True, t=True) adjPos = pm.xform('%s.vtx[%i]' % (newOrig, v), q=True, t=True) if not refPos == adjPos: deviation = True pm.move('%s.vtx[%i]' % (newShape, v), (refPos[0] - adjPos[0], refPos[1] - adjPos[1], refPos[2] - adjPos[2]), r=True) pm.move('%s.vtx[%i]' % (base, v), (refPos[0] - adjPos[0], refPos[1] - adjPos[1], refPos[2] - adjPos[2]), os=True, r=True) pm.select('%s.vtx[%i]' % (base, v), add=True) if deviation: pm.warning( 'It appears there were issues extracting from the mesh, steps have been taken to try and remedy, but unexpected results may occur' ) #apply a texture to the new shape. pm.select(newShape, r=True) pm.sets('initialShadingGroup', e=True, forceElement=True) pm.delete(newOrig, baseRef) return newShape
def createUI(pWindowTitle): windowID = 'myWindowID' globalGender[0] = getGender() if cmds.window(windowID, exists=True): cmds.deleteUI(windowID) cmds.window(windowID, title=pWindowTitle, width=440) # root column layout cmds.rowColumnLayout() cmds.image(image='icons\EqualReality\PolyMorphTitle.jpg') cmds.button(label='Load Base Model', command=importCallback, height=50, backgroundColor=(0.066, 0.447, 0.443)) cmds.separator(h=4, style='none', backgroundColor=(0.07, 0.121, 0.152)) cmds.button(label='Load Photogrammetry Reference', command=importReferenceCallback, height=35, backgroundColor=(0.109, 0.227, 0.29)) #cmds.separator(h = 20, style='none', backgroundColor = (0.133,0.164,0.239)) #cmds.button(label='Edit', command=editCallback, backgroundColor = (0.109,0.458,0.16)) cmds.separator(h=4, style='none', backgroundColor=(0.07, 0.121, 0.152)) if pm.ls('Trace'): #populate my fields by reading the files nameKey = [] nameRead = open( 'EqualRealityData\SelectionData%s.txt' % (globalGender[0]), 'r+') vertexRead = open( 'EqualRealityData\SelectedVerticies%s.txt' % (globalGender[0]), 'r+') eyeRead = open( 'EqualRealityData\SavedVertexPositions%sEye.txt' % (globalGender[0]), 'r+') for line in nameRead.readlines(): mySelName = re.sub('\r\n', '', line) nameKey.append(mySelName) if globalNameKey.count(mySelName) < 1: globalNameKey.append(mySelName) for line in vertexRead.read().split('\r\n\r\n'): if line not in globalVertexKey: globalVertexKey.append(line) for line in eyeRead.read().split('\r\n\r\n'): if line != None and line not in globalEyeKey: globalEyeKey.append(line) eyeRead.close() nameRead.close() vertexRead.close() pm.softSelect(softSelectEnabled=True) pm.symmetricModelling(s=True) cmds.separator(h=8, style='none', backgroundColor=(0.07, 0.121, 0.152)) pm.rowColumnLayout(numberOfColumns=2, columnWidth=[(1, 120), (2, 325)]) pm.separator(style='none', backgroundColor=(0.27, 0.345, 0.376)) pm.checkBox('GuidesVisible', label='Show Guides for Reference Alignment', height=25, backgroundColor=(0.27, 0.345, 0.376), onCommand=referenceLines, offCommand=referenceLines) pm.setParent('..') cmds.separator(h=4, style='none', backgroundColor=(0.07, 0.121, 0.152)) global OnStart if OnStart == 1: print('this is the first time ive run') moveJaw('Away') OnStart = 0 myState = rolloutParameters(name='modellingToolkit', query=True) cmds.frameLayout(backgroundColor=(0.301, 0.423, 0.513), collapsable=True, collapse=myState, label='Modelling Toolkit') cmds.separator(h=2, style='none') #Pick Eye Shape createImageButtonGroup('Eye') cmds.setParent('..') myState = rolloutParameters(name='bodypartSelection', query=True) cmds.frameLayout(backgroundColor=(0.25, 0.349, 0.423), collapsable=True, collapse=myState, label='Bodypart Selection') cmds.rowColumnLayout(numberOfColumns=3, columnWidth=[(1, 380), (2, 30), (3, 30)]) cmds.rowColumnLayout(numberOfColumns=3, columnWidth=[(1, 80), (2, 180), (3, 115)]) cmds.text(label=' Soft Select: ', align='left') cmds.floatSlider("SoftSelectSlider", changeCommand=sliderChangeCommand, min=0, max=8) cmds.text(label=' Move Jaw Away ', align='right') cmds.setParent('..') #cmds.setParent('..') cmds.checkBox(value=jawIsAway, label='', onCommand=functools.partial(moveJaw, 'Away'), offCommand=functools.partial(moveJaw, 'Back')) cmds.separator(h=20, style='none') cmds.separator(h=20, style='none') cmds.separator(h=20, style='none') cmds.separator(h=20, style='none') global lockedGroups for pSelection in nameKey: bodypartSelection(pSelection) cmds.separator(h=20, style='none') #lock perminant entries if pSelection in lockedGroups: cmds.separator(h=20, style='none') else: cmds.button('DeleteButton%s' % (pSelection), label='X', backgroundColor=(0.815, 0.098, 0.098), command=functools.partial(removeButtonCallback, pSelection)) cmds.setParent('..') pm.separator(h=5, style='none') pm.textFieldButtonGrp("addingNewFields", label='New Type: ', placeholderText=' selection name...', buttonLabel='Add', buttonCommand=addButtonCallback) cmds.separator(h=5, style='none') cmds.setParent('..') cmds.setParent('..') myState = rolloutParameters(name='bakeModel', query=True) cmds.frameLayout(backgroundColor=(0.329, 0.482, 0.431), collapsable=True, collapse=myState, label='Bake Model') cmds.separator(h=4, style='none') cmds.button(backgroundColor=(0.235, 0.388, 0.349), label='Place Eyes', command=eyesCallback) #cmds.separator(h = 4, style = 'none') cmds.button(backgroundColor=(0.235, 0.388, 0.349), label='Bake', command=bakeCallback) cmds.setParent('..') cmds.showWindow()