Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import maya.cmds as mc
- def transferUVs():
- triFlatObject = mc.textField('triFlat', query = True, text = True)
- quadFlatObject = mc.textField('quadFlat', query = True, text = True)
- print triFlatObject
- print quadFlatObject
- mc.transferAttributes(triFlatObject, quadFlatObject, transferUVs = 2)
- #We no longer need the Tri-Flat Object so removing it from the scene but deleting history on the Quad Flat Object first to maintain UVs
- mc.delete(quadFlatObject, ch = True)
- mc.delete(triFlatObject)
- def reformQuadedMesh():
- quadFlatObject = mc.textField('quadFlat', query = True, text = True)
- triObject = mc.textField('triMesh', query = True, text = True)
- mc.transferAttributes(triObject, quadFlatObject, transferPositions = 1, sampleSpace = 3)
- #We no longer need the Triangulated Clothing Object so removing it from the scene
- mc.delete(quadFlatObject, ch = True)
- mc.delete(triObject)
- mc.rename(quadFlatObject, 'Quadrified Object')
- def identifyMeshes():
- selectedObjects = mc.ls(orderedSelection = True)
- if(len(selectedObjects) < 3):
- print 'Please select at least 3 objects'
- else:
- mc.rename(selectedObjects[0], 'Tri_Flat_Mesh')
- mc.textField('triFlat', edit = True, text = 'Tri_Flat_Mesh')
- triFlatObject = mc.textField('triFlat', query = True, text = True)
- #Remove the tri mesh from the selection so we can deal with the quadrified meshes
- mc.select(triFlatObject, deselect = True)
- #Repeat process for the normal triangulated mesh
- mc.rename(selectedObjects[1], 'Tri_Mesh')
- mc.textField('triMesh', edit = True, text = 'Tri_Mesh')
- triMeshObject = mc.textField('triMesh', query = True, text = True)
- mc.select(triMeshObject, deselect = True)
- #Combine the remaining quad meshes together into one object. All objects are renamed and history is deleted to keep the outliner clean
- selectedObjects = mc.ls(orderedSelection = True)
- currentUnitedPoly = selectedObjects[0]
- if(len(selectedObjects) > 1):
- for i in range (1, len(selectedObjects)):
- currentUnitedPoly = mc.polyUnite( currentUnitedPoly, selectedObjects[i], name = "Quad_Flat_Mesh", ch = False, mergeUVSets = 1, centerPivot = True)
- else:
- mc.rename(currentUnitedPoly, 'Quad_Flat_Mesh')
- mc.textField('quadFlat', edit = True, text = 'Quad_Flat_Mesh')
- quadFlatObject = mc.textField('quadFlat', query = True, text = True)
- mc.select(quadFlatObject, deselect = True)
- def myWindow():
- if mc.window('MD_Quad_Transfer_Tool', exists = True):
- mc.deleteUI('MD_Quad_Transfer_Tool')
- mc.window('MD_Quad_Transfer_Tool', widthHeight = (250,250), s = False)
- #mc.frameLayout(marginHeight=5, marginWidth=50, labelVisible=False)
- mc.columnLayout(columnWidth=200, co = ['both', 10])
- mc.separator (h=10, style = 'none')
- mc.text(label = 'MD Quad Transfer Tool', width = 250, height = 25, font = 'boldLabelFont', bgc = [255, 255, 0])
- mc.separator (h=10, style = 'none')
- mc.text(label = 'Triangulated Flat Mesh', width = 250)
- mc.textField('triFlat', width = 250 )
- mc.text(label = 'Triangulated Mesh', width = 250)
- mc.textField('triMesh', width = 250 )
- mc.text(label = 'Quadrified Flat Mesh', width = 250)
- mc.textField('quadFlat', width = 250 )
- mc.separator (h=10, style = 'none')
- #Begin the process with your Marvelous Designer flat triangulated mesh, your quick retopo mesh created from something like Zbrush ZRemesher, and the exported non-flat model from Marvelous Designer
- #Your first select objected should be the triangulated flat mesh. Second should be the triangulated non-flat mesh. The remaining meshes should be the quadrified ones.
- mc.button(label = 'Step 1 - Identify meshes', command = 'identifyMeshes()', width = 250)
- #The triangulaed mesh will still have UV's however ZRemesher wipes them out. This first step will transfer the triangulated clean Marvelous Designer UVs to the quadrified mesh
- mc.button(label = 'Step 2 - Transfer UVs to Quad Mesh', command = 'transferUVs()', width = 250)
- #The last step will take the flat quadrified mesh and use the UV Space to "reshape" the mesh how it should be. The end result is much cleaner quad topology than what you would get out of Marvelous Designer
- mc.button(label = 'Step 3 - Reform Quad Mesh', command = 'reformQuadedMesh()', width = 250)
- mc.showWindow('MD_Quad_Transfer_Tool')
- mc.window('MD_Quad_Transfer_Tool', widthHeight = (275,235), e = True)
- myWindow()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement