SHARE
TWEET

Untitled

a guest Jul 24th, 2019 275 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import maya.cmds as mc
  2.    
  3. def transferUVs():
  4.     triFlatObject = mc.textField('triFlat', query = True, text = True)
  5.     quadFlatObject = mc.textField('quadFlat', query = True, text = True)
  6.    
  7.     print triFlatObject
  8.     print quadFlatObject
  9.     mc.transferAttributes(triFlatObject, quadFlatObject, transferUVs = 2)
  10.  
  11.     #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
  12.     mc.delete(quadFlatObject, ch = True)
  13.     mc.delete(triFlatObject)
  14.    
  15. def reformQuadedMesh():
  16.    
  17.     quadFlatObject = mc.textField('quadFlat', query = True, text = True)
  18.     triObject = mc.textField('triMesh', query = True, text = True)
  19.    
  20.     mc.transferAttributes(triObject, quadFlatObject, transferPositions = 1, sampleSpace = 3)
  21.    
  22.     #We no longer need the Triangulated Clothing Object so removing it from the scene
  23.     mc.delete(quadFlatObject, ch = True)
  24.     mc.delete(triObject)
  25.    
  26.     mc.rename(quadFlatObject, 'Quadrified Object')
  27.      
  28. def identifyMeshes():
  29.     selectedObjects = mc.ls(orderedSelection = True)
  30.    
  31.     if(len(selectedObjects) < 3):
  32.         print 'Please select at least 3 objects'
  33.        
  34.     else:
  35.        
  36.         mc.rename(selectedObjects[0], 'Tri_Flat_Mesh')
  37.         mc.textField('triFlat', edit = True, text = 'Tri_Flat_Mesh')
  38.         triFlatObject = mc.textField('triFlat', query = True, text = True)
  39.        
  40.         #Remove the tri mesh from the selection so we can deal with the quadrified meshes
  41.         mc.select(triFlatObject, deselect = True)
  42.        
  43.         #Repeat process for the normal triangulated mesh
  44.         mc.rename(selectedObjects[1], 'Tri_Mesh')
  45.         mc.textField('triMesh', edit = True, text = 'Tri_Mesh')
  46.         triMeshObject = mc.textField('triMesh', query = True, text = True)
  47.        
  48.         mc.select(triMeshObject, deselect = True)      
  49.        
  50.         #Combine the remaining quad meshes together into one object. All objects are renamed and history is deleted to keep the outliner clean
  51.         selectedObjects = mc.ls(orderedSelection = True)    
  52.         currentUnitedPoly = selectedObjects[0]
  53.        
  54.         if(len(selectedObjects) > 1):
  55.            
  56.             for i in range (1, len(selectedObjects)):
  57.                    
  58.                 currentUnitedPoly = mc.polyUnite( currentUnitedPoly, selectedObjects[i], name = "Quad_Flat_Mesh", ch = False, mergeUVSets = 1, centerPivot = True)
  59.         else:
  60.             mc.rename(currentUnitedPoly, 'Quad_Flat_Mesh')    
  61.              
  62.         mc.textField('quadFlat', edit = True, text = 'Quad_Flat_Mesh')
  63.         quadFlatObject = mc.textField('quadFlat', query = True, text = True)
  64.         mc.select(quadFlatObject, deselect = True)
  65.                      
  66. def myWindow():
  67.    
  68.     if mc.window('MD_Quad_Transfer_Tool', exists = True):
  69.         mc.deleteUI('MD_Quad_Transfer_Tool')
  70.    
  71.     mc.window('MD_Quad_Transfer_Tool', widthHeight = (250,250), s = False)
  72.     #mc.frameLayout(marginHeight=5, marginWidth=50, labelVisible=False)
  73.     mc.columnLayout(columnWidth=200, co = ['both', 10])
  74.     mc.separator (h=10, style = 'none')
  75.     mc.text(label = 'MD Quad Transfer Tool', width = 250, height = 25, font = 'boldLabelFont', bgc = [255, 255, 0])
  76.     mc.separator (h=10, style = 'none')
  77.     mc.text(label = 'Triangulated Flat Mesh', width = 250)
  78.     mc.textField('triFlat', width = 250 )
  79.     mc.text(label = 'Triangulated Mesh', width = 250)
  80.     mc.textField('triMesh', width = 250 )
  81.     mc.text(label = 'Quadrified Flat Mesh', width = 250)
  82.     mc.textField('quadFlat', width = 250 )
  83.     mc.separator (h=10, style = 'none')
  84.     #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
  85.     #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.
  86.     mc.button(label = 'Step 1 - Identify meshes', command = 'identifyMeshes()', width = 250)
  87.    
  88.     #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
  89.     mc.button(label = 'Step 2 - Transfer UVs to Quad Mesh', command = 'transferUVs()', width = 250)
  90.    
  91.     #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
  92.     mc.button(label = 'Step 3 - Reform Quad Mesh', command = 'reformQuadedMesh()', width = 250)
  93.    
  94.     mc.showWindow('MD_Quad_Transfer_Tool')
  95.     mc.window('MD_Quad_Transfer_Tool', widthHeight = (275,235), e = True)
  96.    
  97. myWindow()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top