Metapipe/BuildBody_drv.py
2025-01-15 03:07:36 +08:00

563 lines
37 KiB
Python

#All Rights Belongs to Uzay CALISKAN
#Artstation Marketplace Standart License
import maya.cmds as qqaqxx2212
import sys
import os
qqdsvevuea22212se0 = [2997, 11795, 17854, 2815, 5886, 17856, 11798, 2816, 5887, 11799, 17859, 5888, 2817, 11802, 17860, 2818, 5889, 17863, 11803, 2819, 5890, 17865, 11805, 2820, 5891, 17867, 11807, 2821, 5892, 17869, 11809, 2822, 5893, 17871, 11811, 2823, 5894, 17972, 11910, 5947, 2876, 11909, 17968, 5944, 2873, 2965, 11567, 17614, 11899, 17962, 5885, 2814, 11569, 17617, 5895, 2824, 2813, 5884, 11600, 17647, 17607, 11560, 2812, 5883, 5876, 2805, 17610, 11564, 11582, 17629, 2811, 5882, 5877, 2806, 17619, 11572, 11578, 17626, 2810, 5881, 5878, 2807, 11575, 17622, 11587, 17635, 5880, 2809, 5879, 2808, 11585, 17632]
qqdsveuuea22212se0 = [13, 21578, 13968, 12, 34, 13966, 21577, 14, 35, 21575, 13964, 36, 15, 21573, 13962, 16, 37, 13960, 21571, 17, 38, 13958, 21569, 18, 39, 13957, 21566, 19, 40, 13955, 21564, 20, 41, 13927, 21540, 21, 42, 13931, 21542, 44, 23, 16774, 9186, 43, 22, 3, 16795, 9211, 16775, 9192, 27, 4, 16794, 9207, 33, 11, 0, 25, 22801, 15158, 9206, 16789, 1, 24, 3818, 9, 9203, 16786, 16779, 9195, 2, 26, 30, 8, 9198, 16784, 22814, 15170, 5, 28, 31, 7, 7645, 15227, 22824, 15180, 29, 6, 32, 10, 22833, 15189]
qqdsvevuea22212se2 = [2997, 2815, 5886, 2816, 5887, 5888, 2817, 2818, 5889, 2819, 5890, 2820, 5891, 2821, 5892, 2822, 5893, 2823, 5894, 5947, 2876, 5944, 2873, 2965, 5885, 2814, 5895, 2824, 2813, 5884, 2812, 5883, 5876, 2805, 2811, 5882, 5877, 2806, 2810, 5881, 5878, 2807, 5880, 2809, 5879, 2808]
qqdsveuuea22212se1 = [13, 12, 34, 14, 35, 36, 15, 16, 37, 17, 38, 18, 39, 19, 40, 20, 41, 21, 42, 44, 23, 43, 22, 3, 27, 4, 33, 11, 0, 25, 1, 24, 3818, 9, 2, 26, 30, 8, 5, 28, 31, 7, 29, 6, 32, 10]
qqdsvevuea22212se4 = [19, 713, 45, 29, 697, 6, 685, 678, 1290, 1278, 665, 12, 23, 691, 1276, 663, 24, 692, 705, 37, 1279, 666]
qqdsveuuea22212se2 = [747, 2418, 746, 1049, 2700, 1050, 2701, 748, 2419, 2420, 749, 741, 740, 2413, 2416, 744, 742, 2414, 2417, 745, 2415, 743]
qqdsvevuea22212se6 = [11, 165, 21, 4, 156, 13, 158, 269, 151, 7, 20, 164, 160, 15, 263, 144]
qqdsveuuea22212se3 = [198, 693, 197, 312, 795, 199, 694, 695, 200, 193, 194, 690, 692, 196, 691, 195]
qqdsvevuea22212se = [qqdsvevuea22212se0,qqdsvevuea22212se2,qqdsvevuea22212se4,qqdsvevuea22212se6]
qqdsveuuea22212se = [qqdsveuuea22212se0,qqdsveuuea22212se1,qqdsveuuea22212se2,qqdsveuuea22212se3]
qqdsvevuea22212se1 = [5532, 11479, 5565, 6081, 11971, 5564, 11478, 5516, 11444, 11487, 5573, 11972, 6082, 11502, 5588, 5596, 11510, 5604, 11518, 6083, 11973, 5612, 11526, 5620, 11534, 5628, 11542, 6084, 11974, 5636, 11550, 5644, 11558, 5652, 11566, 6086, 11976, 5517, 11445, 11754, 5854, 11829, 5935, 11975, 6085, 5524, 11452, 5538, 11850, 5956, 11964, 6074, 11453, 5539, 11849, 5955, 5515, 11443, 11970, 6080, 6075, 11965, 5545, 11459, 11848, 5954, 5556, 11470, 11847, 5953, 6076, 11966, 11846, 5952, 6013, 11907, 11969, 6079, 5999, 11893, 11845, 5951, 11967, 6077, 11844, 5950, 11879, 5985, 11968, 6078, 11865, 5971]
qqdsvevuea22212se3 = [72, 2532, 2533, 100, 1394, 1355, 47, 2536, 2537, 85, 1379, 2534, 2535, 48, 1356, 49, 1357, 2538, 2539, 1358, 50, 1403, 110, 64, 1372, 78, 2541, 2540, 2542, 2543, 80, 1374, 1413, 120, 2544, 2545, 1405, 112, 115, 1408, 1407, 114, 1409, 116, 2547, 2546]
qqdsvevuea22212se5 = [262, 534, 274, 305, 562, 271, 532, 254, 523, 551, 293, 257, 279, 539, 527, 266, 306, 563, 549, 291, 554, 296]
qqdsvevuea22212se7 = [8, 134, 79, 3, 83, 9, 84, 132, 77, 5, 78, 133, 86, 11, 89, 15]
qqkjhgfdsse2212se1 = [qqdsvevuea22212se1,qqdsvevuea22212se3,qqdsvevuea22212se5,qqdsvevuea22212se7]
def qqdsveuueg2212se(qqdsveuueh2212se, qqdsveuuej2212se,ei):
for i in range(len(qqdsvevuea22212se[ei])):
qqdsveuueb2212se = qqdsvevuea22212se[ei]
qqdsveuuec2212se = qqdsveuuea22212se[ei]
qqdsveuued2212se = qqdsveuuej2212se+".vtx[" + str(qqdsveuueb2212se[i]) + "]"
qqdsveuuee2212se = qqdsveuueh2212se +".vtx[" + str(qqdsveuuec2212se[i]) + "]"
qqdsveuueb2212setex_pos = qqaqxx2212.xform(qqdsveuued2212se, query=True, translation=True, worldSpace=True)
qqaqxx2212.xform(qqdsveuuee2212se, translation=qqdsveuueb2212setex_pos, worldSpace=True)
def qqdsveuuef2212se(qqdsveuueh2212se, qqdsveuuej2212se,ei):
for i in range(len(qqdsvevuea22212se[ei])):
qqdsveuueb2212se = qqdsvevuea22212se[ei]
h2_ver = qqkjhgfdsse2212se1[ei]
qqdsveuued2212se = qqdsveuuej2212se+".vtx[" + str(qqdsveuueb2212se[i]) + "]"
qqdsveuuee2212se = qqdsveuueh2212se +".vtx[" + str(h2_ver[i]) + "]"
qqdsveuueb2212setex_pos = qqaqxx2212.xform(qqdsveuued2212se, query=True, translation=True, worldSpace=True)
qqaqxx2212.xform(qqdsveuuee2212se, translation=qqdsveuueb2212setex_pos, worldSpace=True)
def qqdsveuuek2212se(qqkjhgfcsue2212se, qqkjcxcfcsue2212se):
qqaqxx2212.select(qqkjhgfcsue2212se, qqkjcxcfcsue2212se)
qqaqxx2212.transferAttributes(
transferPositions=1,
transferNormals=1,
transferUVs=0,
transferColors=0,
sampleSpace=3,
searchMethod=3,
flipUVs=0,
colorBorders=1,
)
def qqdsveuuel2212se(qqkjhgfcsse2212se1, qqkjhgfcsse2212sd):
qqaqxx2212.select(qqkjhgfcsse2212se1, qqkjhgfcsse2212sd)
qqaqxx2212.transferAttributes(
transferPositions=0,
transferNormals=1,
transferUVs=0,
transferColors=0,
sampleSpace=3,
searchMethod=3,
flipUVs=0,
colorBorders=1,
)
def qqdsveuuem2212se(mesh_obj, qqdsveuuen2212se, root_joint):
skin_cluster = qqaqxx2212.skinCluster(root_joint, qqdsveuuen2212se)[0]
qqaqxx2212.select([mesh_obj, qqdsveuuen2212se])
qqaqxx2212.copySkinWeights(noMirror=True, surfaceAssociation="closestPoint", uvSpace= ['map1','map1'], influenceAssociation=["name", "oneToOne"])
qqaqxx2212.delete(mesh_obj)
qqaqxx2212.rename(qqdsveuuen2212se, mesh_obj)
def qqdsveuueo2212se(source_verts, target_verts, ei, body_type):
for i in range(len(source_verts)):
qqdsveuueub2212se = source_verts[i]
qqdsveuueuc2212se = target_verts[i]
qqdsveuuep2212se = qqaqxx2212.polyNormalPerVertex(body_type + "_body_lod" + str(ei)+"_mesh.vtx[" + str(qqdsveuueub2212se) + "]", q=True, xyz=True)[0:3]
qqdsveuueus2212se = qqaqxx2212.polyNormalPerVertex("head_lod"+str(2*ei)+"_mesh.vtx[" + str(qqdsveuueuc2212se) + "]", q=True, xyz=True)[0:3]
qqdsveuueuv2212se = [(qqdsveuuep2212se[j] + qqdsveuueus2212se[j]) / 2 for j in range(3)]
qqaqxx2212.polyNormalPerVertex(body_type + "_body_lod" + str(ei)+"_mesh.vtx[" + str(qqdsveuueub2212se) + "]", xyz=qqdsveuueuv2212se)
qqaqxx2212.polyNormalPerVertex("head_lod"+str(2*ei)+"_mesh.vtx[" + str(qqdsveuueuc2212se) + "]", xyz=qqdsveuueuv2212se)
def qqdsveuueuy2212se(source_verts, target_verts, ei, body_type):
for i in range(len(source_verts)):
qqdsveuueub2212se = source_verts[i]
qqdsveuueuc2212se = target_verts[i]
normal = qqaqxx2212.polyNormalPerVertex(body_type + "_body_lod" + str(ei)+"_mesh.vtx[" + str(qqdsveuueub2212se) + "]", q=True, xyz=True)[0:3]
qqaqxx2212.polyNormalPerVertex("head_lod"+str(2*ei + 1)+"_mesh.vtx[" + str(qqdsveuueuc2212se) + "]", xyz=normal)
def qqdsveuueuz2212se(araLODcs, ei):
head_mesh = "head_lod"+str(ei)+"_mesh"
new_mesh = qqaqxx2212.duplicate(head_mesh)[0]
qqaqxx2212.setAttr(new_mesh+'.translateX', lock=False)
qqaqxx2212.setAttr(new_mesh+'.translateY', lock=False)
qqaqxx2212.setAttr(new_mesh+'.translateZ', lock=False)
tarB = qqaqxx2212.blendShape(head_mesh, automatic=True)
qqaqxx2212.rename(tarB, new_mesh+"TargetBS")
blend_shape_node = new_mesh+"TargetBS"
qqaqxx2212.blendShape(blend_shape_node, edit=True, target=(head_mesh, 1, new_mesh, 1.0))
qqaqxx2212.blendShape(blend_shape_node, edit=True, target=(head_mesh, 0.0, araLODcs, 1.0))
qqaqxx2212.setAttr(new_mesh+"TargetBS."+new_mesh, -1)
qqaqxx2212.setAttr(new_mesh+"TargetBS."+araLODcs, 1)
qqaqxx2212.setAttr(new_mesh + ".visibility", 0)
qqaqxx2212.setAttr(araLODcs + ".visibility", 0)
def qqdsveuueua2212se(qqkjcxcfcsue2212se):
qqdsveuueub2212se = qqkjcxcfcsue2212se + ".vtx[866]"
qqdsveuueuc2212se = qqkjcxcfcsue2212se + ".vtx[386]"
source_pos = qqaqxx2212.xform(qqdsveuueub2212se, query=True, translation=True, worldSpace=True)
qqaqxx2212.xform(qqdsveuueuc2212se, translation=[-source_pos[0], source_pos[1], source_pos[2]], worldSpace=True)
def LODS(body_type):
if qqaqxx2212.objExists("DHIhead:spine_04"):
polygon_count0 = qqaqxx2212.duplicate("head_lod0_mesh")
qqaqxx2212.delete(polygon_count0, constructionHistory=True)
qqaqxx2212.parent(polygon_count0, world=True)
qqaqxx2212.rename(polygon_count0, "NMHead")
for i in range(3):
qqkjhgfcsue2212se = body_type + "_body_lod0_mesh"
y=i+1
douby= 2*y
if qqaqxx2212.objExists(body_type + "_body_lod{}_mesh".format(y)):
qqkjcxcfcsue2212se = qqaqxx2212.duplicate(body_type + "_body_lod{}_mesh".format(y))
qqaqxx2212.rename(qqkjcxcfcsue2212se[0], qqkjcxcfcsue2212se[0] + "TL")
qqdsveuuek2212se(qqkjhgfcsue2212se, qqkjcxcfcsue2212se[0] + "TL")
qqaqxx2212.delete(qqkjcxcfcsue2212se[0] + "TL", constructionHistory=True)
qqdsveuueg2212se(qqkjcxcfcsue2212se[0] + "TL", "head_lod{}_mesh".format(douby),y)
qqaqxx2212.polyNormalPerVertex(qqkjcxcfcsue2212se[0] + "TL", ufn=True)
if y ==3:
qqdsveuueua2212se(qqkjcxcfcsue2212se[0] + "TL")
qqdsveuuem2212se(body_type + "_body_lod{}_mesh".format(y), qqkjcxcfcsue2212se[0] + "TL", "DHIbody:root")
for i in range(4):
if qqaqxx2212.objExists(body_type + "_body_lod{}_mesh".format(i)):
qqdsveuueo2212se(qqdsveuuea22212se[i], qqdsvevuea22212se[i], i, body_type)
qqdsveuueuy2212se(qqdsveuuea22212se[i], qqkjhgfdsse2212se1[i], i, body_type)
qqdsveuuel2212se("head_lod0_mesh", "NMHead")
qqdsveuuel2212se(body_type + "_body_lod0_mesh", "NMBody")
DubNM = qqaqxx2212.duplicate("NMHead")
NMMeshes = [DubNM[0], "NMBody"]
qqaqxx2212.hide("NMHead")
merged_mesh = qqaqxx2212.polyUnite(NMMeshes, ch=False, mergeUVSets=True)[0]
qqaqxx2212.rename(merged_mesh, "NMCombined")
qqkjhgfcsue2212se = "NMCombined"
qqkjcxcfcsue2212se = qqaqxx2212.duplicate(body_type + "_combined_lod0_mesh")
qqaqxx2212.rename(qqkjcxcfcsue2212se[0], qqkjcxcfcsue2212se[0] + "TL")
qqdsveuuek2212se(qqkjhgfcsue2212se, qqkjcxcfcsue2212se[0] + "TL")
qqaqxx2212.polyNormalPerVertex(qqkjcxcfcsue2212se[0] + "TL", ufn=True)
qqdsveuuem2212se(body_type + "_combined_lod0_mesh", qqkjcxcfcsue2212se[0] + "TL", "DHIbody:root")
qqaqxx2212.hide("NMCombined")
else:
for i in range(7):
qqkjhgfcsue2212se = "head_lod0_mesh"
y=i+1
if qqaqxx2212.objExists("head_lod{}_mesh".format(y)):
qqkjcxcfcsue2212se = qqaqxx2212.duplicate("head_lod{}_mesh".format(y))
qqaqxx2212.rename(qqkjcxcfcsue2212se[0], "head" + str(y) + "TL")
qqdsveuuek2212se(qqkjhgfcsue2212se, "head" + str(y) + "TL")
for i in range(7):
qqkjhgfcsue2212se = "teeth_lod{}_mesh".format(i)
y=i+1
if qqaqxx2212.objExists("teeth_lod{}_mesh".format(y)):
qqkjcxcfcsue2212se = "teeth_lod{}_mesh".format(y)
qqdsveuuek2212se(qqkjhgfcsue2212se, qqkjcxcfcsue2212se)
for i in range(7):
qqkjhgfcsue2212se = "eyeLeft_lod{}_mesh".format(i)
y=i+1
if qqaqxx2212.objExists("eyeLeft_lod{}_mesh".format(y)):
qqkjcxcfcsue2212se = "eyeLeft_lod{}_mesh".format(y)
qqdsveuuek2212se(qqkjhgfcsue2212se, qqkjcxcfcsue2212se)
for i in range(7):
qqkjhgfcsue2212se = "eyeRight_lod{}_mesh".format(i)
y=i+1
if qqaqxx2212.objExists("eyeRight_lod{}_mesh".format(y)):
qqkjcxcfcsue2212se = "eyeRight_lod{}_mesh".format(y)
qqdsveuuek2212se(qqkjhgfcsue2212se, qqkjcxcfcsue2212se)
for i in range(2):
qqkjhgfcsue2212se = "saliva_lod{}_mesh".format(i)
y=i+1
if qqaqxx2212.objExists("saliva_lod{}_mesh".format(y)):
qqkjcxcfcsue2212se = "saliva_lod{}_mesh".format(y)
qqdsveuuek2212se(qqkjhgfcsue2212se, qqkjcxcfcsue2212se)
#for i in range(4):
#qqkjhgfcsue2212se = "eyeshell_lod{}_mesh".format(i)
#y=i+1
#qqkjcxcfcsue2212se = "eyeshell_lod{}_mesh".format(y)
#qqdsveuuek2212se(qqkjhgfcsue2212se, qqkjcxcfcsue2212se)
for i in range(3):
qqkjhgfcsue2212se = "eyelashes_lod{}_mesh".format(i)
y=i+1
if qqaqxx2212.objExists("eyelashes_lod{}_mesh".format(y)):
qqkjcxcfcsue2212se = "eyelashes_lod{}_mesh".format(y)
qqdsveuuek2212se(qqkjhgfcsue2212se, qqkjcxcfcsue2212se)
for i in range(3):
qqkjhgfcsue2212se = "eyeEdge_lod{}_mesh".format(i)
y=i+1
if qqaqxx2212.objExists("eyeEdge_lod{}_mesh".format(y)):
qqkjcxcfcsue2212se = "eyeEdge_lod{}_mesh".format(y)
qqdsveuuek2212se(qqkjhgfcsue2212se, qqkjcxcfcsue2212se)
for i in range(1):
qqkjhgfcsue2212se = "cartilage_lod{}_mesh".format(i)
y=i+1
if qqaqxx2212.objExists("cartilage_lod{}_mesh".format(y)):
qqkjcxcfcsue2212se = "cartilage_lod{}_mesh".format(y)
qqdsveuuek2212se(qqkjhgfcsue2212se, qqkjcxcfcsue2212se)
for i in range(4):
douby=i*2
if qqaqxx2212.objExists("head" + str(douby + 1) + "TL"):
qqaqxx2212.delete("head" + str(douby + 1) + "TL", constructionHistory=True)
if i == 0:
head_mesh_fix="head_lod0_mesh"
else:
if qqaqxx2212.objExists("head" + str(douby) + "TL"):
head_mesh_fix="head" + str(douby) + "TL"
if qqaqxx2212.objExists("head" + str(douby + 1) + "TL"):
qqdsveuuef2212se("head" + str(douby + 1) + "TL", head_mesh_fix,i)
for i in range(7):
douby=i+1
araLOD="head" + str(douby) + "TL"
#qqdsveuuem2212se("head_lod{}_mesh".format(douby), araLOD + "TL", "spine_04")
if qqaqxx2212.objExists(araLOD):
qqdsveuueuz2212se(araLOD, douby)
def qqdsvewvea2212(qqdsvevvea2212):
def qqdsvevveq2212(qqdevevveq2212):
for joint in qqdevevveq2212:
if not qqaqxx2212.attributeQuery('qqdeckljeq2212', node=joint, exists=True):
qqaqxx2212.addAttr(joint, longName='qqdeckljeq2212', attributeType='long', defaultValue=0)
qqaqxx2212.setAttr(joint + '.qqdeckljeq2212', keyable=True)
def qqdeczxvveq2212(qqdevevveq2212, value):
for joint in qqdevevveq2212:
qqaqxx2212.setAttr(joint + '.qqdeckljeq2212', value)
qqaaczxvveq2212 = qqaqxx2212.ls(type="joint")
exclude_qqdevevveq2212 = qqaqxx2212.ls("DHIhead:spine_04", dag=True, type="joint")
qqaaczxvveq2212 = qqaqxx2212.ls("root_drv", dag=True, type="joint")
qqdsvevveq2212(qqaaczxvveq2212)
qqaaczxxseq2212 = [joint for joint in qqaaczxvveq2212 if not qqaqxx2212.listRelatives(joint, children=True, type='joint')]
qqdeczxvveq2212(qqaaczxvveq2212, 100)
qqdeczxvveq2212(qqaaczxxseq2212, 0)
qqaamqxxseq2212 = []
for qqaamqxx2212 in qqaaczxxseq2212:
qqaamppqxx2212 = qqaqxx2212.listRelatives(qqaamqxx2212, parent=True, type="joint")
if qqaamppqxx2212:
children = qqaqxx2212.listRelatives(qqaamppqxx2212, children=True, type="joint") or []
if all(qqaqxx2212.getAttr(child + ".qqdeckljeq2212") == 0 for child in children):
qqaamqxxseq2212.append(qqaamppqxx2212[0])
qqdeczxvveq2212(qqaamqxxseq2212, 1)
qqdeckljeq2212 = 1
while qqaamqxxseq2212:
qqdeckljeq2212 += 1
qqdewyutyeq2212 = []
for qqaamqxx2212 in qqaamqxxseq2212:
qqaamppqxx2212 = qqaqxx2212.listRelatives(qqaamqxx2212, parent=True, type="joint")
if qqaamppqxx2212:
children = qqaqxx2212.listRelatives(qqaamppqxx2212, children=True, type="joint") or []
if all(qqaqxx2212.getAttr(child + ".qqdeckljeq2212") < qqdeckljeq2212 for child in children):
qqdewyutyeq2212.append(qqaamppqxx2212[0])
if qqdewyutyeq2212:
qqdeczxvveq2212(qqdewyutyeq2212, qqdeckljeq2212)
qqaamqxxseq2212 = qqdewyutyeq2212
else:
break
qqdeckutyeq2212 = []
for joint in qqaaczxvveq2212:
if joint.endswith("Off_r_drv"):
qqdeckutyeq2212.append(joint)
if joint.endswith("Off_l_drv"):
qqdeckutyeq2212.append(joint)
qqdmzveq2212 = []
qqdmzvfeq2212 = []
qqdmzvsseq2212 = []
qqdmtqsseq2212 = []
for qqaamqxx2212 in qqaaczxvveq2212:
qqdmtqsjjeq2212 = qqaqxx2212.getAttr(qqaamqxx2212 + ".qqdeckljeq2212")
if qqdmtqsjjeq2212 == 1:
qqdjmtqsjjeq2212 = qqdsvevvea2212
qqdjmqsjjeq2212 = qqaqxx2212.xform(qqaamqxx2212, query=True, worldSpace=True, translation=True)
qqdjqqsjjeq2212 = qqaqxx2212.createNode("closestPointOnMesh")
qqaqxx2212.connectAttr(qqdjmtqsjjeq2212 + ".worldMesh", qqdjqqsjjeq2212 + ".inMesh")
qqaqxx2212.setAttr(qqdjqqsjjeq2212 + ".inPosition", qqdjmqsjjeq2212[0], qqdjmqsjjeq2212[1], qqdjmqsjjeq2212[2])
qqdqspjpzz2212 = qqaqxx2212.getAttr(qqdjqqsjjeq2212 + ".closestVertexIndex")
qqaqxx2212.delete(qqdjqqsjjeq2212)
vertex = qqdjmtqsjjeq2212 + ".vtx[{}]".format(qqdqspjpzz2212)
qqaqxx2212.select(vertex, replace=True)
for i in range(1):
qqdqspjpzxz2212 = qqaqxx2212.ls(selection=True, flatten=True)
edges = []
for vertex in qqdqspjpzxz2212:
edges.extend(qqaqxx2212.polyListComponentConversion(vertex, fromVertex=True, toEdge=True))
qqaqxx2212.select(edges)
edges = qqaqxx2212.ls(selection=True, flatten=True)
qqdqspjpzxz2212 = []
for edge in edges:
qqdqspjpzxz2212.extend(qqaqxx2212.polyListComponentConversion(edge, fromEdge=True, toVertex=True))
qqaqxx2212.select(qqdqspjpzxz2212)
qqdqspjpzxz2212 = qqaqxx2212.ls(selection=True, flatten=True)
qqcjjdswjefftfr2212_before = []
for vertex in qqdqspjpzxz2212:
position = qqaqxx2212.pointPosition(vertex, world=True)
qqcjjdswjefftfr2212_before.append(position)
qqaqxx2212.setAttr("BodyShape.B2", 1)
qqcjjdswjefftfr2212_after = []
for vertex in qqdqspjpzxz2212:
position = qqaqxx2212.pointPosition(vertex, world=True)
qqcjjdswjefftfr2212_after.append(position)
delta_vertex = []
for i in range(len(qqcjjdswjefftfr2212_after)):
sub_delta = []
for j in range(3):
sub_delta.append(qqcjjdswjefftfr2212_after[i][j] - qqcjjdswjefftfr2212_before[i][j])
delta_vertex.append(sub_delta)
average_vertex = [sum(x) / len(x) for x in zip(*delta_vertex)]
qqdqspjpvvxz2212 = average_vertex[0]
qqdqspjptrxz2212 = average_vertex[1]
qqdqjjjtdx2212 = average_vertex[2]
if not qqaqxx2212.attributeQuery("qqdqspjpvvxz2212", node=qqaamqxx2212, exists=True):
qqaqxx2212.addAttr(qqaamqxx2212, ln="qqdqspjpvvxz2212", at="double")
if not qqaqxx2212.attributeQuery("qqdqspjptrxz2212", node=qqaamqxx2212, exists=True):
qqaqxx2212.addAttr(qqaamqxx2212, ln="qqdqspjptrxz2212", at="double")
if not qqaqxx2212.attributeQuery("qqdqjjjtdx2212", node=qqaamqxx2212, exists=True):
qqaqxx2212.addAttr(qqaamqxx2212, ln="qqdqjjjtdx2212", at="double")
qqaqxx2212.setAttr(qqaamqxx2212 + ".qqdqspjpvvxz2212", qqdqspjpvvxz2212)
qqaqxx2212.setAttr(qqaamqxx2212 + ".qqdqspjptrxz2212", qqdqspjptrxz2212)
qqaqxx2212.setAttr(qqaamqxx2212 + ".qqdqjjjtdx2212", qqdqjjjtdx2212)
qqaqxx2212.setAttr("BodyShape.B2", 0)
qqdmzveq2212.append(qqaamqxx2212)
qqdmzvfeq2212.append(qqdqspjpvvxz2212)
qqdmzvsseq2212.append(qqdqspjptrxz2212)
qqdmtqsseq2212.append(qqdqjjjtdx2212)
for i in range(len(qqdmzveq2212)):
qqaqxx2212.move(qqdmzvfeq2212[i], qqdmzvsseq2212[i], qqdmtqsseq2212[i], qqdmzveq2212[i], relative=True)
qqdqjxxxtdx2212 = []
qqdqjxkdxrr2212 = []
def qqdqjxkosffr2212(qqdqjxxxtdx2212, qqdqjxkdxrr2212):
m_pos = qqaqxx2212.xform(qqdqjxxxtdx2212, query=True, worldSpace=True, rotatePivot=True)
ta_pos = qqaqxx2212.xform(qqdqjxkdxrr2212, query=True, worldSpace=True, rotatePivot=True)
child_qqdevevveq2212 = qqaqxx2212.listRelatives(qqdqjxxxtdx2212, c=True, type="joint")
qqdqjxkooffr2212 = []
if child_qqdevevveq2212:
for child_joint in child_qqdevevveq2212:
qqdqjxkooffr2212.append(qqaqxx2212.xform(child_joint, q=True, ws=True, t=True))
qqaqxx2212.xform(qqdqjxxxtdx2212, translation=ta_pos, rotatePivot=m_pos, worldSpace=True)
if child_qqdevevveq2212:
for i, child_joint in enumerate(child_qqdevevveq2212):
qqaqxx2212.xform(child_joint, ws=True, t=qqdqjxkooffr2212[i])
m_pos = qqaqxx2212.xform(qqdqjxxxtdx2212, query=True, worldSpace=True, rotatePivot=True)
ta_pos = qqaqxx2212.xform(qqdqjxkdxrr2212, query=True, worldSpace=True, rotatePivot=True)
qqaqxx2212.xform(qqdqjxkdxrr2212, translation=m_pos, rotatePivot=ta_pos, worldSpace=True)
qqdqjxtofr2212 = 2
qqdwjhqjxtofr2212 = 1
qqdtyhjxtofr2212 = 15
while qqdqjxtofr2212 <= qqdtyhjxtofr2212:
joint_qqdqjxtofr2212 = [joint for joint in qqaaczxvveq2212 if qqaqxx2212.getAttr(joint + ".qqdeckljeq2212") == qqdqjxtofr2212]
lower_qqdevevveq2212 = [joint for joint in qqaaczxvveq2212 if qqaqxx2212.getAttr(joint + ".qqdeckljeq2212") == qqdwjhqjxtofr2212]
for qqaamqxx2212 in joint_qqdqjxtofr2212:
qqdtyhjxtojofr2212 = qqaqxx2212.xform(qqaamqxx2212, q=True, ws=True, translation=True)
child_qqdevevveq2212 = qqaqxx2212.listRelatives(qqaamqxx2212, children=True, type="joint")
qqdtyhjtfr2212 = []
if qqaamqxx2212 == "upperarm_twistCor_02_r_drv":
qqaamqxx2212 = "upperarm_twist_02_r_drv"
if qqaamqxx2212 == "upperarm_twistCor_02_l_drv":
qqaamqxx2212 = "upperarm_twist_02_l_drv"
if qqaamqxx2212 == "upperarm_correctiveRootCor_r_drv":
qqaamqxx2212 = "upperarm_correctiveRoot_r_drv"
if qqaamqxx2212 == "upperarm_correctiveRootCor_l_drv":
qqaamqxx2212 = "upperarm_correctiveRoot_l_drv"
qqdtysssstfr2212 = qqaamqxx2212.replace("_r_drv", "") + "_correctiveRoot_r_drv"
qqdtyszjqsstfr2212 = qqaamqxx2212.replace("_l_drv", "") + "_correctiveRoot_l_drv"
if qqaqxx2212.objExists(qqdtysssstfr2212):
qqdqjxkosffr2212(qqaamqxx2212, qqdtysssstfr2212)
continue
if qqaqxx2212.objExists(qqdtyszjqsstfr2212):
qqdqjxkosffr2212(qqaamqxx2212, qqdtyszjqsstfr2212)
continue
if child_qqdevevveq2212:
qqdtouutfr2212 = []
for child_joint in child_qqdevevveq2212:
if child_joint == "upperarm_twistCor_02_r_drv":
child_joint = "upperarm_twist_02_r_drv"
if child_joint == "upperarm_twistCor_02_l_drv":
child_joint = "upperarm_twist_02_l_drv"
if child_joint == "upperarm_correctiveRootCor_r_drv":
child_joint = "upperarm_correctiveRoot_r_drv"
if child_joint == "upperarm_correctiveRootCor_l_drv":
child_joint = "upperarm_correctiveRoot_l_drv"
if child_joint == "upperarm_r_drv":
child_joint = "upperarm_correctiveRoot_r_drv"
if child_joint == "upperarm_l_drv":
child_joint = "upperarm_correctiveRoot_l_drv"
if child_joint in lower_qqdevevveq2212 and qqdqjxtofr2212 > 2:
qqdqspjpvvxz2212 = qqaqxx2212.getAttr(child_joint + '.qqdqspjpvvxz2212')
qqdqspjptrxz2212 = qqaqxx2212.getAttr(child_joint + '.qqdqspjptrxz2212')
qqdqjjjtdx2212 = qqaqxx2212.getAttr(child_joint + '.qqdqjjjtdx2212')
qqdtouutfr2212.append([qqdqspjpvvxz2212, qqdqspjptrxz2212, qqdqjjjtdx2212])
if child_joint in qqdeckutyeq2212:
qqdqspjpvvxz2212 = qqaqxx2212.getAttr(child_joint + '.qqdqspjpvvxz2212')
qqdqspjptrxz2212 = qqaqxx2212.getAttr(child_joint + '.qqdqspjptrxz2212')
qqdqjjjtdx2212 = qqaqxx2212.getAttr(child_joint + '.qqdqjjjtdx2212')
qqdtouutfr2212.append([qqdqspjpvvxz2212, qqdqspjptrxz2212, qqdqjjjtdx2212])
qqdtouutfr2212.append([qqdqspjpvvxz2212, qqdqspjptrxz2212, qqdqjjjtdx2212])
qqdtouutfr2212.append([qqdqspjpvvxz2212, qqdqspjptrxz2212, qqdqjjjtdx2212])
qqdtouutfr2212.append([qqdqspjpvvxz2212, qqdqspjptrxz2212, qqdqjjjtdx2212])
qqdtouutfr2212.append([qqdqspjpvvxz2212, qqdqspjptrxz2212, qqdqjjjtdx2212])
qqdtyhjtfr2212 = [sum(x) / len(x) for x in zip(*qqdtouutfr2212)]
if not qqdtyhjtfr2212:
qqdtyhjtfr2212 = [0, 0, 0]
avg_x = qqdtyhjtfr2212[0]
avg_y = qqdtyhjtfr2212[1]
avg_z = qqdtyhjtfr2212[2]
for child_joint in child_qqdevevveq2212:
qqaqxx2212.move(-avg_x, -avg_y, -avg_z, child_joint, relative=True)
qqaqxx2212.move(avg_x, avg_y, avg_z, qqaamqxx2212, relative=True)
end_place = qqaqxx2212.xform(qqaamqxx2212, q=True, ws=True, translation=True)
qqdqspjpvvxz2212 = end_place[0] - qqdtyhjxtojofr2212[0]
qqdqspjptrxz2212 = end_place[1] - qqdtyhjxtojofr2212[1]
qqdqjjjtdx2212 = end_place[2] - qqdtyhjxtojofr2212[2]
if not qqaqxx2212.attributeQuery("qqdqspjpvvxz2212", node=qqaamqxx2212, exists=True):
qqaqxx2212.addAttr(qqaamqxx2212, ln="qqdqspjpvvxz2212", at="double")
if not qqaqxx2212.attributeQuery("qqdqspjptrxz2212", node=qqaamqxx2212, exists=True):
qqaqxx2212.addAttr(qqaamqxx2212, ln="qqdqspjptrxz2212", at="double")
if not qqaqxx2212.attributeQuery("qqdqjjjtdx2212", node=qqaamqxx2212, exists=True):
qqaqxx2212.addAttr(qqaamqxx2212, ln="qqdqjjjtdx2212", at="double")
qqaqxx2212.setAttr(qqaamqxx2212 + ".qqdqspjpvvxz2212", qqdqspjpvvxz2212)
qqaqxx2212.setAttr(qqaamqxx2212 + ".qqdqspjptrxz2212", qqdqspjptrxz2212)
qqaqxx2212.setAttr(qqaamqxx2212 + ".qqdqjjjtdx2212", qqdqjjjtdx2212)
qqdwjhqjxtofr2212 += 1
qqdqjxtofr2212 += 1
for qqaamqxx2212 in qqaaczxvveq2212:
pureJoint = qqaamqxx2212[:-6]
last_letter = qqaamqxx2212[-6:]
qqaamqxx2212_corrective = pureJoint+"_correctiveRoot"+last_letter
qqaamqxx2212_half = pureJoint+"_half"+last_letter
if qqaamqxx2212_half in qqaaczxvveq2212:
qqdqjxkosffr2212(qqaamqxx2212, qqaamqxx2212_half)
qqdqjxkosffr2212("ball_r_drv", "indextoe_01_r_drv")
qqaqxx2212.move(-0.17429999283555375, -0.6591177786778863, 0.17690208845928623, "ball_r_drv", relative=True)
qqaqxx2212.move(+0.17429999283555375, +0.6591177786778863, -0.17690208845928623, "indextoe_01_r_drv", relative=True)
qqaqxx2212.move(+0.17429999283555375, +0.6591177786778863, -0.17690208845928623, "littletoe_01_r_drv", relative=True)
qqaqxx2212.move(+0.17429999283555375, +0.6591177786778863, -0.17690208845928623, "ringtoe_01_r_drv", relative=True)
qqaqxx2212.move(+0.17429999283555375, +0.6591177786778863, -0.17690208845928623, "middletoe_01_r_drv", relative=True)
qqaqxx2212.move(+0.17429999283555375, +0.6591177786778863, -0.17690208845928623, "bigtoe_01_r_drv", relative=True)
qqdqjxkosffr2212("ball_l_drv", "indextoe_01_l_drv")
qqaqxx2212.move(-0.17429999283555375, -0.6591177786778863, 0.17690208845928623, "ball_l_drv", relative=True)
qqaqxx2212.move(+0.17429999283555375, +0.6591177786778863, -0.17690208845928623, "indextoe_01_l_drv", relative=True)
qqaqxx2212.move(+0.17429999283555375, +0.6591177786778863, -0.17690208845928623, "littletoe_01_l_drv", relative=True)
qqaqxx2212.move(+0.17429999283555375, +0.6591177786778863, -0.17690208845928623, "ringtoe_01_l_drv", relative=True)
qqaqxx2212.move(+0.17429999283555375, +0.6591177786778863, -0.17690208845928623, "middletoe_01_l_drv", relative=True)
qqaqxx2212.move(+0.17429999283555375, +0.6591177786778863, -0.17690208845928623, "bigtoe_01_l_drv", relative=True)
qqaqxx2212.move(0,0,1, "upperarm_r_drv", relative=True)
qqaqxx2212.move(0,0,-1, "upperarm_r_drv", relative=True)
qqaqxx2212.move(0,0,1, "upperarm_l_drv", relative=True)
qqaqxx2212.move(0,0,-1, "upperarm_l_drv", relative=True)
qqdqjxtofr2212 = 15
qqdwjhqjxtofr2212 = -1
minqqdqjxtofr2212 = 0
qqdtoussdetfr2212 = "DHIhead:spine_04"
qqdtousdetfr2212 = "spine_04_drv"
qqdtousvrdetfr2212, head_qqaamqxx2212 = qqdtoussdetfr2212.split(":")
qqdtovrrdetfr2212qqdevevveq2212 = qqaqxx2212.listRelatives(qqdtoussdetfr2212, children=True, allDescendents=True,type="joint")
qqdtdjxovrrdetfr2212 = qqaqxx2212.listRelatives(qqdtousdetfr2212, children=True, allDescendents=True, type="joint")
while qqdqjxtofr2212 >= minqqdqjxtofr2212:
joint_qqdqjxtofr2212 = [joint for joint in qqdtdjxovrrdetfr2212 if qqaqxx2212.getAttr(joint + ".qqdeckljeq2212") == qqdqjxtofr2212]
for qqaamqxx2212 in joint_qqdqjxtofr2212:
qqdtyuoprretfr2212 = qqaamqxx2212.replace("_drv", "")
head_current_joint = "{}:{}".format(qqdtousvrdetfr2212, qqdtyuoprretfr2212)
if qqaqxx2212.objExists(head_current_joint):
if qqaamqxx2212[-5] == "r":
offnamer = qqaamqxx2212.replace("_r_drv", "Off_r_drv")
if qqaqxx2212.objExists(offnamer):
qqaamqxx2212 = offnamer
if qqaamqxx2212[-5] == "l":
offnamel = qqaamqxx2212.replace("_l_drv", "Off_l_drv")
if qqaqxx2212.objExists(offnamel):
qqaamqxx2212 = offnamel
qqdqjxxxtdx2212 = qqaamqxx2212
qqdqjxkdxrr2212 = head_current_joint
def move2qqdqjxkdxrr2212():
qqdtycdcdetfr2212 = qqaqxx2212.xform(qqdqjxxxtdx2212, query=True, worldSpace=True, rotatePivot=True)
qqdtyvfcdetfr2212 = qqaqxx2212.xform(qqdqjxkdxrr2212, query=True, worldSpace=True, rotatePivot=True)
child_qqdevevveq2212 = qqaqxx2212.listRelatives(qqdqjxxxtdx2212, c=True, type="joint")
qqdqjxkooffr2212 = []
if child_qqdevevveq2212:
for child_joint in child_qqdevevveq2212:
qqdqjxkooffr2212.append(qqaqxx2212.xform(child_joint, q=True, ws=True, t=True))
qqaqxx2212.xform(qqdqjxxxtdx2212, translation=qqdtyvfcdetfr2212, rotatePivot=qqdtycdcdetfr2212, worldSpace=True)
if child_qqdevevveq2212:
for i, child_joint in enumerate(child_qqdevevveq2212):
qqaqxx2212.xform(child_joint, ws=True, t=qqdqjxkooffr2212[i])
move2qqdqjxkdxrr2212()
qqdwjhqjxtofr2212 -= 1
qqdqjxtofr2212 -= 1
qqaqxx2212.rotate(-90, 0, 0, "B2", r=True, os=True)
qqdqjxkosffr2212("spine_04_drv", "DHIhead:spine_04")
qqcdswswetfr2212 = ["pelvis_drv", "spine_01_drv", "spine_02_drv", "spine_03_drv"]
qqcdswswetfr22122 = [["spine_01_drv","thigh_l_drv", "thigh_r_drv"], ["spine_02_drv"], ["spine_03_drv"],["spine_04_drv"]]
qqcdswswjjetfr2212 = [[74,98],[70,22165],[60,21511],[55,21503]]
qqcjjdswswjjetfr2212=[[-2.343694098897814e-08, 0.9277631243174369, -0.21888295717229145], [-2.3436941044906144e-08, 5.931293797182775, 1.2575180855589356], [-2.3436951549334987e-08, 6.420269092887452, 0.340663810861062], [-5.204295709558898e-05, 7.954560644645298, -1.473320475684294]]
selected_object=qqaqxx2212.ls(selection=True)
qqcjjdswjjetfr2212="B2"
for i in range(len(qqcdswswetfr2212)):
qqcjjdswjjefftfr2212 = "{}.vtx[{}]".format(qqcjjdswjjetfr2212, qqcdswswjjetfr2212[i][0])
qqcjjdswjjefftfr22122 = "{}.vtx[{}]".format(qqcjjdswjjetfr2212, qqcdswswjjetfr2212[i][1])
qqcjjdswjefftfr2212 = qqaqxx2212.pointPosition(qqcjjdswjjefftfr2212, world=True)
qqcjjdswjefftfr22122 = qqaqxx2212.pointPosition(qqcjjdswjjefftfr22122, world=True)
t=0.5
midpoint = [(qqcjjdswjefftfr2212[i] + t * (qqcjjdswjefftfr22122[i] - qqcjjdswjefftfr2212[i])) for i in range(3)]
sp_position = qqaqxx2212.xform(qqcdswswetfr2212[i], query=True, translation=True, worldSpace=True)
qqcjjdsftfr2212 = (midpoint[0] - sp_position[0])
qqcjjdsftfrp2212 = (midpoint[1] - sp_position[1])-qqcjjdswswjjetfr2212[i][1]
qqcxxjjdsftfrp2212 = (midpoint[2] - sp_position[2])-qqcjjdswswjjetfr2212[i][2]
qqaqxx2212.move(0,qqcjjdsftfrp2212,qqcxxjjdsftfrp2212, qqcdswswetfr2212[i], relative=True)
if i ==0:
qqaqxx2212.move(0,-qqcjjdsftfrp2212,-qqcxxjjdsftfrp2212, qqcdswswetfr22122[i][0], relative=True)
qqaqxx2212.move(0,-qqcjjdsftfrp2212,-qqcxxjjdsftfrp2212, qqcdswswetfr22122[i][1], relative=True)
qqaqxx2212.move(0,-qqcjjdsftfrp2212,-qqcxxjjdsftfrp2212, qqcdswswetfr22122[i][2], relative=True)
if i >0:
qqaqxx2212.move(0,-qqcjjdsftfrp2212,-qqcxxjjdsftfrp2212, qqcdswswetfr22122[i][0], relative=True)
def bind_skin(qqdsvevvea2212):
mesh_obj = qqaqxx2212.ls(qqdsvevvea2212)[0]
qqcxxjjdsdrtftfrp2212 = qqaqxx2212.duplicate(mesh_obj)[0]
qqaqxx2212.select([qqcxxjjdsdrtftfrp2212, "DHIbody:root"])
skin_cluster = qqaqxx2212.skinCluster("DHIbody:root", qqcxxjjdsdrtftfrp2212)[0]
qqaqxx2212.select([mesh_obj, qqcxxjjdsdrtftfrp2212])
qqaqxx2212.copySkinWeights(noMirror=True, surfaceAssociation="closestPoint", influenceAssociation=["name", "oneToOne"])
qqaqxx2212.delete(mesh_obj)
qqaqxx2212.rename(qqcxxjjdsdrtftfrp2212, qqdsvevvea2212)
gender=0
qqdsvevvea2212 = "m_med_nrw_body_lod0_mesh"
def build_body(ROOT_DIR, body_type):
Body_DRV = f"{ROOT_DIR}/data/Body_Drv.mb"
if not os.path.isfile(Body_DRV):
raise ValueError("Please prepare the body file first. Body_Drv file is not found")
qqdsvevvea2212 = body_type + "_body_lod0_mesh"
skeleton_file_path = f"{ROOT_DIR}/data/Body_Drv.mb"
qqdsvevvea2212sel = qqaqxx2212.ls(selection=True)[0]
qqaqxx2212.rename(qqdsvevvea2212sel, "B2")
qqdsvevvea22212se = qqaqxx2212.duplicate("B2")
qqaqxx2212.rename(qqdsvevvea22212se, "NMBody")
qqaqxx2212.rotate(90, 0, 0, "B2", r=True, os=True)
qqaqxx2212.makeIdentity("B2", apply=True, t=True, r=True, s=True)
qqaqxx2212.file(skeleton_file_path, i=True, ignoreVersion=True, mergeNamespacesOnClash=False)
qqaqxx2212.select("B2", replace=True)
blendShape_node = "BodyShape"
qqcxytmgftfrp2212 = "|body_rig|body_grp|body_geometry_grp|body_lod0_grp|"+qqdsvevvea2212+"|"+qqdsvevvea2212+"Shape"
qqaqxx2212.blendShape(qqdsvevvea2212, automatic=True)
qqaqxx2212.rename("blendShape1", "BodyShape")
qqaqxx2212.blendShape(blendShape_node, edit=True, target=[(qqcxytmgftfrp2212, 0.0, "B2", 1.0)])
qqaqxx2212.setAttr("BodyShape.B2", 0)
body_mesh = qqdsvevvea2212
blend_shape_node = "BodyShape"
DHIBODY_name = 'DHIbody:root'
qqaqxx2212.showHidden(DHIBODY_name)
qqdsvewvea2212(qqdsvevvea2212)
qqaqxx2212.delete('B2')
qqaqxx2212.hide(DHIBODY_name)
qqaqxx2212.setAttr("BodyShape.B2", 0)
fix_mesh = qqaqxx2212.duplicate(body_mesh)[0]
qqaqxx2212.rotate(90, 0, 0, fix_mesh, r=True, os=True)
qqaqxx2212.makeIdentity(fix_mesh, apply=True, t=True, r=True, s=True)
qqaqxx2212.blendShape(blend_shape_node, edit=True, target=(body_mesh, 2, fix_mesh, 1.0))
qqaqxx2212.setAttr("BodyShape."+fix_mesh, -1)
qqaqxx2212.setAttr("BodyShape.B2", 1)
qqaqxx2212.delete(qqdsvevvea2212+"1")
bodyNS = "DHIbody:"
headNS = "DHIhead:"
for i in qqaqxx2212.ls(type="joint"):
if headNS in i:
if i.replace(headNS,bodyNS) in qqaqxx2212.ls(type="joint"):
qqaqxx2212.parentConstraint(i.replace(headNS,bodyNS),i,mo=True)
qqaqxx2212.scaleConstraint(i.replace(headNS,bodyNS),i,mo=True)
bind_skin(qqdsvevvea2212)
LODS(body_type)