1.3.0
This commit is contained in:
parent
6a950a644f
commit
edad969fa9
169
BatchImport.py
Normal file
169
BatchImport.py
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
import maya.cmds as cmds
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def onMayaDroppedPythonFile(*args):
|
||||||
|
FileBatchImport()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#Let's you batch import:
|
||||||
|
def FileBatchImport(*args):
|
||||||
|
if CheckForBonusTools:
|
||||||
|
multipleFilters = 'All native importable files (*.3ds *.abc *.ass *.at *.catpart *.dae *.fbx *.igs *.iges *.jt *.ma *.mb *.obj *.prt *.sat *.step *.stp *.wire);; Maya binary (*.mb);; Maya Ascii (*.ma);; WIRE_ATF (*.wire);; Obj (*.obj);; FBX (*.fbx);; DAE_FBX (*.dae);; Alembic Cache (*.abc);; Atom (*.atom);; Step (*.stp *.step);; IGES_ATF (*.igs *.iges);; ASS (*.ass);; 3DS Max (*.3ds);; CATIAV5_ATF (*.catpart);; JT_ATF (*.jt);; SAT_ATF (*.sat);; NX_ATF (*.prt)'
|
||||||
|
else:
|
||||||
|
multipleFilters = 'All native importable files (*.abc *.ass *.at *.catpart *.dae *.fbx *.igs *.iges *.jt *.ma *.mb *.obj *.prt *.sat *.step *.stp *.wire);; Maya binary (*.mb);; Maya Ascii (*.ma);; WIRE_ATF (*.wire);; Obj (*.obj);; FBX (*.fbx);; DAE_FBX (*.dae);; Alembic Cache (*.abc);; Atom (*.atom);; Step (*.stp *.step);; IGES_ATF (*.igs *.iges);; ASS (*.ass);; 3DS Max (*.3ds);; CATIAV5_ATF (*.catpart);; JT_ATF (*.jt);; SAT_ATF (*.sat);; NX_ATF (*.prt)'
|
||||||
|
files = cmds.fileDialog2(caption = 'Choose files to import', ds = 2, fileMode = 4, okCaption = 'Import', fileFilter = multipleFilters, hideNameEdit = False)
|
||||||
|
if files == None or files[0] == None or len(files) < 0:
|
||||||
|
sys.exit('You or something else canceled the selection of a directory. Did you only see empty folders? Make sure you have the requiered permissions for the folder.\n')
|
||||||
|
|
||||||
|
|
||||||
|
for x in files:
|
||||||
|
if any(y in x for y in ['.ma', '.MA']):
|
||||||
|
fileType = 'mayaAscii'
|
||||||
|
options = ''
|
||||||
|
ImportFiles(fileType, x, options)
|
||||||
|
|
||||||
|
if any(y in x for y in ['.mb', '.MB']):
|
||||||
|
fileType = 'mayaBinary'
|
||||||
|
options = ''
|
||||||
|
ImportFiles(fileType, x, options)
|
||||||
|
|
||||||
|
|
||||||
|
if any(y in x for y in ['.wire', '.WIRE']):
|
||||||
|
fileType = 'WIRE_ATF'
|
||||||
|
options = ''
|
||||||
|
LoadPlugin('ATFPlugin')
|
||||||
|
ImportFiles(fileType, x, options)
|
||||||
|
|
||||||
|
|
||||||
|
if any(y in x for y in ['.obj', '.OBJ']):
|
||||||
|
fileType = 'OBJ'
|
||||||
|
options = 'mo=0'
|
||||||
|
ImportFiles(fileType, x, options)
|
||||||
|
|
||||||
|
|
||||||
|
if any(y in x for y in ['.fbx', '.FBX']):
|
||||||
|
fileType = 'FBX'
|
||||||
|
options = ''
|
||||||
|
LoadPlugin('fbxmaya')
|
||||||
|
ImportFiles(fileType, x, options)
|
||||||
|
|
||||||
|
|
||||||
|
if any(y in x for y in ['.dae', '.DAE']):
|
||||||
|
fileType = 'DAE_FBX'
|
||||||
|
options = ''
|
||||||
|
ImportFiles(fileType, x, options)
|
||||||
|
|
||||||
|
|
||||||
|
if any(y in x for y in ['.abc', '.ABC']):
|
||||||
|
fileType = 'Alembic'
|
||||||
|
options = ''
|
||||||
|
LoadPlugin('AbcImport')
|
||||||
|
ImportFiles(fileType, x, options)
|
||||||
|
|
||||||
|
|
||||||
|
if any(y in x for y in ['.atom', '.ATOM', '.at', '.AT']):
|
||||||
|
fileType = 'atomImport'
|
||||||
|
options = ''
|
||||||
|
LoadPlugin('atomImportExport')
|
||||||
|
ImportFiles(fileType, x, options)
|
||||||
|
|
||||||
|
|
||||||
|
if any(y in x for y in ['.step', '.STEP', '.stp', '.STP']):
|
||||||
|
fileType = 'STEP_ATF'
|
||||||
|
options = ''
|
||||||
|
LoadPlugin('ATFPlugin')
|
||||||
|
ImportFiles(fileType, x, options)
|
||||||
|
|
||||||
|
|
||||||
|
if any(y in x for y in['igs.', '.IGS', '.iges', '.IGES']):
|
||||||
|
fileType = 'IGES_ATF'
|
||||||
|
options = ''
|
||||||
|
LoadPlugin('ATFPlugin')
|
||||||
|
ImportFiles(fileType, x, options)
|
||||||
|
|
||||||
|
|
||||||
|
if any(y in x for y in['.ass', '.ASS']):
|
||||||
|
fileType = 'ASS'
|
||||||
|
options = ''
|
||||||
|
LoadPlugin('mtoa')
|
||||||
|
ImportFiles(fileType, x, options)
|
||||||
|
|
||||||
|
|
||||||
|
if any(y in x for y in['.3ds', '.3DS']):
|
||||||
|
fileType = '3ds'
|
||||||
|
options = ''
|
||||||
|
if CheckForBonusTools:
|
||||||
|
LoadPlugin('3ds')
|
||||||
|
ImportFiles(fileType, x, options)
|
||||||
|
|
||||||
|
|
||||||
|
if any(y in x for y in['.catpart', '.CATPART']):
|
||||||
|
fileType = 'CATIAV5_ATF'
|
||||||
|
options = ''
|
||||||
|
LoadPlugin('ATFPlugin')
|
||||||
|
ImportFiles(fileType, x, options)
|
||||||
|
|
||||||
|
|
||||||
|
if any(y in x for y in['.jt', '.JT']):
|
||||||
|
fileType = 'JT_ATF'
|
||||||
|
options = ''
|
||||||
|
LoadPlugin('ATFPlugin')
|
||||||
|
ImportFiles(fileType, x, options)
|
||||||
|
|
||||||
|
|
||||||
|
if any(y in x for y in['.sat', '.SAT']):
|
||||||
|
fileType = 'SAT_ATF'
|
||||||
|
options = ''
|
||||||
|
LoadPlugin('ATFPlugin')
|
||||||
|
ImportFiles(fileType, x, options)
|
||||||
|
|
||||||
|
|
||||||
|
if any(y in x for y in['.prt', '.PRT']):
|
||||||
|
fileType = 'NX_ATF'
|
||||||
|
options = ''
|
||||||
|
LoadPlugin('ATFPlugin')
|
||||||
|
ImportFiles(fileType, x, options)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def CheckForBonusTools(*args):
|
||||||
|
for x in sys.path:
|
||||||
|
if 'MayaBonusTools' in x:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def LoadPlugin(plugin, *args):
|
||||||
|
if not cmds.pluginInfo(plugin, query = True, loaded = True):
|
||||||
|
try:
|
||||||
|
cmds.loadPlugin(plugin)
|
||||||
|
sys.stdout.write('Plugin "' + plugin + '" loaded.\n')
|
||||||
|
except(RuntimeError):
|
||||||
|
cmds.warning('Could not find "' + plugin + '" plugin or could not load it. Open the Plugin Manager and make sure Maya recognized the plugin and try again.\n')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def ImportFiles(fileType, file, options, *args):
|
||||||
|
namespace = file.split('/')
|
||||||
|
namespace = namespace[-1].split('.')
|
||||||
|
namespace = namespace[0]
|
||||||
|
try:
|
||||||
|
cmds.file(str(file), i = True, type = fileType, ignoreVersion = True, mergeNamespacesOnClash = False, namespace = namespace, options = options)
|
||||||
|
sys.stdout.write('Imported "' + str(file) + '".\n')
|
||||||
|
except(UnicodeEncodeError):
|
||||||
|
sys.stdout.write('Either the directory path or the file name have some special characters.\n')
|
||||||
|
sys.stdout.write('The names will be changed.\n')
|
||||||
|
cmds.file(file, i = True, type = fileType, ignoreVersion = True, mergeNamespacesOnClash = False, namespace = namespace, options = options)
|
||||||
|
sys.stdout.write('Imported "' + file + '".\n')
|
||||||
|
except(ImportError):
|
||||||
|
cmds.warning('Could not import ' + file + '. Maybe you dont have the requiered permissions to the folder.\n')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
if not cmds.about(batch = True):
|
||||||
|
FileBatchImport()
|
30
Body_Prep.py
Normal file
30
Body_Prep.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#All Rights Belongs to Uzay CALISKAN
|
||||||
|
#Artstation Marketplace Standart License
|
||||||
|
|
||||||
|
import maya.cmds as cmds
|
||||||
|
def run():
|
||||||
|
cmds.upAxis(axis='y')
|
||||||
|
cmds.delete("DHIhead:spine_04", "Lights", "export_geo_GRP", "head_grp")
|
||||||
|
cmds.rename("rig", "body_rig")
|
||||||
|
cmds.rename("geometry_grp", "body_geometry_grp")
|
||||||
|
body_grp_lock = cmds.listRelatives('body_grp', allDescendents=True, type='transform')
|
||||||
|
for obj in body_grp_lock:
|
||||||
|
cmds.setAttr(obj + '.translateX', lock=False)
|
||||||
|
cmds.setAttr(obj + '.translateY', lock=False)
|
||||||
|
cmds.setAttr(obj + '.translateZ', lock=False)
|
||||||
|
cmds.setAttr(obj + '.rotateX', lock=False)
|
||||||
|
cmds.setAttr(obj + '.rotateY', lock=False)
|
||||||
|
cmds.setAttr(obj + '.rotateZ', lock=False)
|
||||||
|
cmds.setAttr(obj + '.scaleX', lock=False)
|
||||||
|
cmds.setAttr(obj + '.scaleY', lock=False)
|
||||||
|
cmds.setAttr(obj + '.scaleZ', lock=False)
|
||||||
|
correctiveCube = cmds.polyCube()[0]
|
||||||
|
cmds.parent('root_drv', correctiveCube)
|
||||||
|
cmds.rotate(-90,0,0,correctiveCube,relative=True)
|
||||||
|
cmds.parent('root_drv',world=True)
|
||||||
|
cmds.delete(correctiveCube)
|
||||||
|
|
||||||
|
save_path = cmds.fileDialog2(fileMode=0, caption="Save Maya Scene", fileFilter="Maya Binary (*.mb)")[0]
|
||||||
|
|
||||||
|
cmds.file(rename=save_path)
|
||||||
|
cmds.file(save=True, type='mayaBinary')
|
399
BuildBody.py
Normal file
399
BuildBody.py
Normal file
@ -0,0 +1,399 @@
|
|||||||
|
#All Rights Belongs to Uzay CALISKAN
|
||||||
|
#Artstation Marketplace Standart License
|
||||||
|
|
||||||
|
import maya.cmds as cmds
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def body_transformation(gender_mesh):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def add_chain_depth_attribute(joints):
|
||||||
|
for joint in joints:
|
||||||
|
if not cmds.attributeQuery('chainDepth', node=joint, exists=True):
|
||||||
|
cmds.addAttr(joint, longName='chainDepth', attributeType='long', defaultValue=0)
|
||||||
|
cmds.setAttr(joint + '.chainDepth', keyable=True)
|
||||||
|
|
||||||
|
def set_chain_depth_value(joints, value):
|
||||||
|
for joint in joints:
|
||||||
|
cmds.setAttr(joint + '.chainDepth', value)
|
||||||
|
|
||||||
|
# Get all joints in the scene
|
||||||
|
all_joints = cmds.ls(type="joint")
|
||||||
|
|
||||||
|
# Remove joints in the "DHIhead:spine_04" hierarchy (Avoid HEAD)
|
||||||
|
exclude_joints = cmds.ls("DHIhead:spine_04", dag=True, type="joint")
|
||||||
|
all_joints = list(set(all_joints) - set(exclude_joints))
|
||||||
|
add_chain_depth_attribute(all_joints)
|
||||||
|
|
||||||
|
# Filter end joints (joints with no child joints)
|
||||||
|
end_joints = [joint for joint in all_joints if not cmds.listRelatives(joint, children=True, type='joint')]
|
||||||
|
|
||||||
|
|
||||||
|
# Set chainDepth attribute to 0 for all end joints
|
||||||
|
set_chain_depth_value(all_joints, 100)
|
||||||
|
set_chain_depth_value(end_joints, 0)
|
||||||
|
|
||||||
|
parents1 = []
|
||||||
|
|
||||||
|
for joint_name in end_joints:
|
||||||
|
p_joint = cmds.listRelatives(joint_name, parent=True, type="joint")
|
||||||
|
if p_joint:
|
||||||
|
children = cmds.listRelatives(p_joint, children=True, type="joint") or []
|
||||||
|
if all(cmds.getAttr(child + ".chainDepth") == 0 for child in children):
|
||||||
|
|
||||||
|
parents1.append(p_joint[0])
|
||||||
|
|
||||||
|
set_chain_depth_value(parents1, 1)
|
||||||
|
#Chaindepth add Attr Loop
|
||||||
|
chainDepth = 1
|
||||||
|
while parents1:
|
||||||
|
chainDepth += 1
|
||||||
|
new_parents = []
|
||||||
|
for joint_name in parents1:
|
||||||
|
p_joint = cmds.listRelatives(joint_name, parent=True, type="joint")
|
||||||
|
if p_joint:
|
||||||
|
children = cmds.listRelatives(p_joint, children=True, type="joint") or []
|
||||||
|
if all(cmds.getAttr(child + ".chainDepth") < chainDepth for child in children):
|
||||||
|
new_parents.append(p_joint[0])
|
||||||
|
if new_parents:
|
||||||
|
set_chain_depth_value(new_parents, chainDepth)
|
||||||
|
parents1 = new_parents
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
|
||||||
|
j_name = []
|
||||||
|
j_delta_x = []
|
||||||
|
j_delta_y = []
|
||||||
|
j_delta_z = []
|
||||||
|
# DELTA X CALCULATE
|
||||||
|
for joint_name in end_joints:
|
||||||
|
mesh_name = gender_mesh
|
||||||
|
|
||||||
|
# 1. Get the world-space position of the joint
|
||||||
|
joint_pos = cmds.xform(joint_name, query=True, worldSpace=True, translation=True)
|
||||||
|
|
||||||
|
# 2. Find the nearest vertex named "NVertex" on the mesh to the joint's position
|
||||||
|
closest_point_node = cmds.createNode("closestPointOnMesh")
|
||||||
|
cmds.connectAttr(mesh_name + ".worldMesh", closest_point_node + ".inMesh")
|
||||||
|
cmds.setAttr(closest_point_node + ".inPosition", joint_pos[0], joint_pos[1], joint_pos[2])
|
||||||
|
|
||||||
|
nearest_vertex_index = cmds.getAttr(closest_point_node + ".closestVertexIndex")
|
||||||
|
cmds.delete(closest_point_node)
|
||||||
|
vertex = mesh_name + ".vtx[{}]".format(nearest_vertex_index)
|
||||||
|
cmds.select(vertex, replace=True)
|
||||||
|
|
||||||
|
# Grow selection
|
||||||
|
|
||||||
|
for i in range(1):
|
||||||
|
|
||||||
|
# Get the currently selected vertices
|
||||||
|
vertices = cmds.ls(selection=True, flatten=True)
|
||||||
|
|
||||||
|
# Convert the vertices to edges
|
||||||
|
edges = []
|
||||||
|
for vertex in vertices:
|
||||||
|
edges.extend(cmds.polyListComponentConversion(vertex, fromVertex=True, toEdge=True))
|
||||||
|
|
||||||
|
# Select the edges
|
||||||
|
cmds.select(edges)
|
||||||
|
|
||||||
|
# Get the currently selected edges
|
||||||
|
edges = cmds.ls(selection=True, flatten=True)
|
||||||
|
|
||||||
|
# Convert the edges to vertices
|
||||||
|
vertices = []
|
||||||
|
for edge in edges:
|
||||||
|
vertices.extend(cmds.polyListComponentConversion(edge, fromEdge=True, toVertex=True))
|
||||||
|
|
||||||
|
# Select the vertices
|
||||||
|
cmds.select(vertices)
|
||||||
|
|
||||||
|
vertices = cmds.ls(selection=True, flatten=True)
|
||||||
|
# Add the vertices to a list
|
||||||
|
vertex_position_before = []
|
||||||
|
for vertex in vertices:
|
||||||
|
position = cmds.pointPosition(vertex, world=True)
|
||||||
|
vertex_position_before.append(position)
|
||||||
|
|
||||||
|
|
||||||
|
# 3 Set the target blendshape node to a weight of 1
|
||||||
|
cmds.setAttr("BodyShape.B2", 1)
|
||||||
|
|
||||||
|
# 4. Get the new position of NVertex and find the new position
|
||||||
|
vertex_position_after = []
|
||||||
|
for vertex in vertices:
|
||||||
|
position = cmds.pointPosition(vertex, world=True)
|
||||||
|
vertex_position_after.append(position)
|
||||||
|
|
||||||
|
delta_vertex = []
|
||||||
|
|
||||||
|
for i in range(len(vertex_position_after)):
|
||||||
|
sub_delta = []
|
||||||
|
for j in range(3):
|
||||||
|
sub_delta.append(vertex_position_after[i][j] - vertex_position_before[i][j])
|
||||||
|
delta_vertex.append(sub_delta)
|
||||||
|
|
||||||
|
average_vertex = [sum(x) / len(x) for x in zip(*delta_vertex)]
|
||||||
|
|
||||||
|
# 5. Move the joint with the distance that NVertex moved
|
||||||
|
delta_x = average_vertex[0]
|
||||||
|
delta_y = average_vertex[1]
|
||||||
|
delta_z = average_vertex[2]
|
||||||
|
|
||||||
|
if not cmds.attributeQuery("delta_x", node=joint_name, exists=True):
|
||||||
|
cmds.addAttr(joint_name, ln="delta_x", at="double")
|
||||||
|
if not cmds.attributeQuery("delta_y", node=joint_name, exists=True):
|
||||||
|
cmds.addAttr(joint_name, ln="delta_y", at="double")
|
||||||
|
if not cmds.attributeQuery("delta_z", node=joint_name, exists=True):
|
||||||
|
cmds.addAttr(joint_name, ln="delta_z", at="double")
|
||||||
|
|
||||||
|
cmds.setAttr(joint_name + ".delta_x", delta_x)
|
||||||
|
cmds.setAttr(joint_name + ".delta_y", delta_y)
|
||||||
|
cmds.setAttr(joint_name + ".delta_z", delta_z)
|
||||||
|
|
||||||
|
# 6 Reset
|
||||||
|
cmds.setAttr("BodyShape.B2", 0)
|
||||||
|
j_name.append(joint_name)
|
||||||
|
j_delta_x.append(delta_x)
|
||||||
|
j_delta_y.append(delta_y)
|
||||||
|
j_delta_z.append(delta_z)
|
||||||
|
#cmds.move(delta_x, delta_y, delta_z, joint_name, relative=True)
|
||||||
|
for i in range(len(j_name)):
|
||||||
|
cmds.move(j_delta_x[i], j_delta_y[i], j_delta_z[i], j_name[i], relative=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#Fix the body parts
|
||||||
|
moving_joint = []
|
||||||
|
target_joint = []
|
||||||
|
def fix_body(moving_joint, target_joint):
|
||||||
|
m_pos = cmds.xform(moving_joint, query=True, worldSpace=True, rotatePivot=True)
|
||||||
|
ta_pos = cmds.xform(target_joint, query=True, worldSpace=True, rotatePivot=True)
|
||||||
|
child_joints = cmds.listRelatives(moving_joint, c=True, type="joint")
|
||||||
|
child_positions = []
|
||||||
|
if child_joints:
|
||||||
|
for child_joint in child_joints:
|
||||||
|
child_positions.append(cmds.xform(child_joint, q=True, ws=True, t=True))
|
||||||
|
# Set the translate and rotate pivot attributes of the "FACIAL_C_LowerLipRotation" joint to match those of "FACIAL_C_MouthUpper"
|
||||||
|
cmds.xform(moving_joint, translation=ta_pos, rotatePivot=m_pos, worldSpace=True)
|
||||||
|
if child_joints:
|
||||||
|
for i, child_joint in enumerate(child_joints):
|
||||||
|
cmds.xform(child_joint, ws=True, t=child_positions[i])
|
||||||
|
m_pos = cmds.xform(moving_joint, query=True, worldSpace=True, rotatePivot=True)
|
||||||
|
ta_pos = cmds.xform(target_joint, query=True, worldSpace=True, rotatePivot=True)
|
||||||
|
cmds.xform(target_joint, translation=m_pos, rotatePivot=ta_pos, worldSpace=True)
|
||||||
|
|
||||||
|
# Filter joints with a chainDepth value of 0
|
||||||
|
CD = 1
|
||||||
|
lower_CD = 0
|
||||||
|
maxCD = 15
|
||||||
|
while CD <= maxCD:
|
||||||
|
joint_CD = [joint for joint in all_joints if cmds.getAttr(joint + ".chainDepth") == CD]
|
||||||
|
lower_joints = [joint for joint in all_joints if cmds.getAttr(joint + ".chainDepth") == lower_CD]
|
||||||
|
for joint_name in joint_CD:
|
||||||
|
|
||||||
|
first_place = cmds.xform(joint_name, q=True, ws=True, translation=True)
|
||||||
|
child_joints = cmds.listRelatives(joint_name, children=True, type="joint")
|
||||||
|
average_point = []
|
||||||
|
|
||||||
|
if child_joints:
|
||||||
|
|
||||||
|
target_points = []
|
||||||
|
for child_joint in child_joints:
|
||||||
|
if child_joint in lower_joints:
|
||||||
|
delta_x = cmds.getAttr(child_joint + '.delta_x')
|
||||||
|
delta_y = cmds.getAttr(child_joint + '.delta_y')
|
||||||
|
delta_z = cmds.getAttr(child_joint + '.delta_z')
|
||||||
|
target_points.append([delta_x, delta_y, delta_z])
|
||||||
|
if child_joint in end_joints:
|
||||||
|
delta_x = cmds.getAttr(child_joint + '.delta_x')
|
||||||
|
delta_y = cmds.getAttr(child_joint + '.delta_y')
|
||||||
|
delta_z = cmds.getAttr(child_joint + '.delta_z')
|
||||||
|
#print(cmds.getAttr(child_joint + ".chainDepth"))
|
||||||
|
target_points.append([delta_x, delta_y, delta_z])
|
||||||
|
target_points.append([delta_x, delta_y, delta_z])
|
||||||
|
target_points.append([delta_x, delta_y, delta_z])
|
||||||
|
target_points.append([delta_x, delta_y, delta_z])
|
||||||
|
target_points.append([delta_x, delta_y, delta_z])
|
||||||
|
average_point = [sum(x) / len(x) for x in zip(*target_points)]
|
||||||
|
if not average_point:
|
||||||
|
average_point = [0, 0, 0]
|
||||||
|
avg_x = average_point[0]
|
||||||
|
avg_y = average_point[1]
|
||||||
|
avg_z = average_point[2]
|
||||||
|
cmds.move(avg_x, avg_y, avg_z, joint_name, relative=True)
|
||||||
|
for child_joint in child_joints:
|
||||||
|
cmds.move(-avg_x, -avg_y, -avg_z, child_joint, relative=True)
|
||||||
|
pureJoint = joint_name[:-2]
|
||||||
|
last_letter = joint_name[-2:]
|
||||||
|
joint_name_corrective = pureJoint+"_correctiveRoot"+last_letter
|
||||||
|
joint_name_half = pureJoint+"_half"+last_letter
|
||||||
|
if joint_name_corrective in all_joints:
|
||||||
|
fix_body(joint_name, joint_name_corrective)
|
||||||
|
#print(joint_name + " fixed to the " + joint_name_corrective)
|
||||||
|
if joint_name_half in all_joints:
|
||||||
|
fix_body(joint_name, joint_name_half)
|
||||||
|
#print(joint_name + " fixed to the " + joint_name_half)
|
||||||
|
end_place = cmds.xform(joint_name, q=True, ws=True, translation=True)
|
||||||
|
delta_x = end_place[0] - first_place[0]
|
||||||
|
delta_y = end_place[1] - first_place[1]
|
||||||
|
delta_z = end_place[2] - first_place[2]
|
||||||
|
if not cmds.attributeQuery("delta_x", node=joint_name, exists=True):
|
||||||
|
cmds.addAttr(joint_name, ln="delta_x", at="double")
|
||||||
|
if not cmds.attributeQuery("delta_y", node=joint_name, exists=True):
|
||||||
|
cmds.addAttr(joint_name, ln="delta_y", at="double")
|
||||||
|
if not cmds.attributeQuery("delta_z", node=joint_name, exists=True):
|
||||||
|
cmds.addAttr(joint_name, ln="delta_z", at="double")
|
||||||
|
|
||||||
|
cmds.setAttr(joint_name + ".delta_x", delta_x)
|
||||||
|
cmds.setAttr(joint_name + ".delta_y", delta_y)
|
||||||
|
cmds.setAttr(joint_name + ".delta_z", delta_z)
|
||||||
|
|
||||||
|
lower_CD += 1
|
||||||
|
CD += 1
|
||||||
|
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Transfer Body original skeleton to the new head Skeleton
|
||||||
|
CD = 15
|
||||||
|
lower_CD = -1
|
||||||
|
minCD = 0
|
||||||
|
|
||||||
|
# Define the joint names and namespaces
|
||||||
|
head_joint = "DHIhead:spine_04"
|
||||||
|
body_joint = "DHIbody:spine_04"
|
||||||
|
|
||||||
|
# Split the joint names into their respective namespaces and joint names
|
||||||
|
head_namespace, head_joint_name = head_joint.split(":")
|
||||||
|
body_namespace, body_joint_name = body_joint.split(":")
|
||||||
|
|
||||||
|
# Get the list of child joints for the head joint
|
||||||
|
head_child_joints = cmds.listRelatives(head_joint, children=True, allDescendents=True,type="joint")
|
||||||
|
body_child_joints = cmds.listRelatives(body_joint, children=True, allDescendents=True, type="joint")
|
||||||
|
|
||||||
|
while CD >= minCD:
|
||||||
|
joint_CD = [joint for joint in body_child_joints if cmds.getAttr(joint + ".chainDepth") == CD]
|
||||||
|
for joint_name in joint_CD:
|
||||||
|
body_namespace, body_joint_name = joint_name.split(":")
|
||||||
|
# Build the joint names for the current joint
|
||||||
|
head_current_joint = "{}:{}".format(head_namespace, body_joint_name)
|
||||||
|
body_current_joint = "{}:{}".format(body_namespace, body_joint_name)
|
||||||
|
if cmds.objExists(head_current_joint):
|
||||||
|
moving_joint = body_current_joint
|
||||||
|
target_joint = head_current_joint
|
||||||
|
def move2target_joint():
|
||||||
|
lower_lip_rotation_pos = cmds.xform(moving_joint, query=True, worldSpace=True, rotatePivot=True)
|
||||||
|
jaw_pos = cmds.xform(target_joint, query=True, worldSpace=True, rotatePivot=True)
|
||||||
|
# Get the child joints
|
||||||
|
child_joints = cmds.listRelatives(moving_joint, c=True, type="joint")
|
||||||
|
# Store the initial positions of the child joints
|
||||||
|
child_positions = []
|
||||||
|
if child_joints:
|
||||||
|
for child_joint in child_joints:
|
||||||
|
child_positions.append(cmds.xform(child_joint, q=True, ws=True, t=True))
|
||||||
|
|
||||||
|
# Set the translate and rotate pivot attributes of the "FACIAL_C_LowerLipRotation" joint to match those of "FACIAL_C_MouthUpper"
|
||||||
|
cmds.xform(moving_joint, translation=jaw_pos, rotatePivot=lower_lip_rotation_pos, worldSpace=True)
|
||||||
|
if child_joints:
|
||||||
|
|
||||||
|
# Move each child joint back to its original position
|
||||||
|
for i, child_joint in enumerate(child_joints):
|
||||||
|
cmds.xform(child_joint, ws=True, t=child_positions[i])
|
||||||
|
|
||||||
|
move2target_joint()
|
||||||
|
|
||||||
|
|
||||||
|
lower_CD -= 1
|
||||||
|
CD -= 1
|
||||||
|
|
||||||
|
fix_body("DHIbody:spine_04", "DHIhead:spine_04")
|
||||||
|
|
||||||
|
def bind_skin(gender_mesh):
|
||||||
|
|
||||||
|
# Body
|
||||||
|
mesh_obj = cmds.ls(gender_mesh)[0]
|
||||||
|
|
||||||
|
# Duplicate the mesh
|
||||||
|
duplicated_mesh_obj = cmds.duplicate(mesh_obj)[0]
|
||||||
|
new_name = gender_mesh + "_duplicate"
|
||||||
|
cmds.rename(duplicated_mesh_obj, new_name)
|
||||||
|
bind_obj = cmds.ls(new_name)[0]
|
||||||
|
|
||||||
|
cmds.select([bind_obj, "DHIbody:root"])
|
||||||
|
|
||||||
|
# Bind skin to the mesh
|
||||||
|
skin_cluster = cmds.skinCluster("DHIbody:root", bind_obj)[0]
|
||||||
|
|
||||||
|
# Set the skinning method to "classic linear"
|
||||||
|
cmds.setAttr(skin_cluster + ".skinningMethod", 1)
|
||||||
|
|
||||||
|
cmds.select([mesh_obj, bind_obj])
|
||||||
|
|
||||||
|
cmds.copySkinWeights(noMirror=True, surfaceAssociation="closestPoint", influenceAssociation=["name", "oneToOne"])
|
||||||
|
|
||||||
|
cmds.delete(mesh_obj)
|
||||||
|
cmds.rename(bind_obj, gender_mesh)
|
||||||
|
ROOT_DIR = "c:/dna_calibration"
|
||||||
|
gender=0
|
||||||
|
gender_mesh = "f_tal_nrw_body_lod0_mesh"
|
||||||
|
skeleton_file_path = f"{ROOT_DIR}/data/Fem_Body_skeleton.fbx"
|
||||||
|
def build_body(ROOT_DIR):
|
||||||
|
#Toggle Gender
|
||||||
|
if gender == 0:
|
||||||
|
|
||||||
|
skeleton_file_path = f"{ROOT_DIR}/data/Fem_Body_skeleton.fbx"
|
||||||
|
gender_mesh = "f_tal_nrw_body_lod0_mesh"
|
||||||
|
elif gender == 1:
|
||||||
|
|
||||||
|
skeleton_file_path = f"{ROOT_DIR}/data/Ma_Body_skeleton.fbx"
|
||||||
|
gender_mesh = "m_med_nrw_body_lod0_mesh"
|
||||||
|
#Rename Selected as B2
|
||||||
|
selected_object = cmds.ls(selection=True)
|
||||||
|
cmds.rename(selected_object, "B2")
|
||||||
|
|
||||||
|
# Import the FBX file
|
||||||
|
cmds.file(skeleton_file_path, i=True, type="FBX", ignoreVersion=True, ra=True, mergeNamespacesOnClash=False, options="fbx")
|
||||||
|
|
||||||
|
cmds.select("B2", replace=True)
|
||||||
|
|
||||||
|
# Define the blendshape node and target shape names
|
||||||
|
blendshape_node = "BodyShape"
|
||||||
|
target_shape = "|body_rig|body_grp|body_geometry_grp|body_lod0_grp|"+gender_mesh+"|"+gender_mesh+"Shape"
|
||||||
|
cmds.blendShape(gender_mesh, automatic=True)
|
||||||
|
cmds.rename("blendShape1", "BodyShape")
|
||||||
|
cmds.blendShape(blendshape_node, edit=True, target=[(target_shape, 0.0, "B2", 1.0)])
|
||||||
|
cmds.setAttr("BodyShape.B2", 0)
|
||||||
|
#cmds.setAttr("B2" + ".visibility", 0)
|
||||||
|
cmds.delete('B2')
|
||||||
|
|
||||||
|
body_transformation(gender_mesh)
|
||||||
|
|
||||||
|
# Duplicate the head mesh
|
||||||
|
body_mesh = gender_mesh
|
||||||
|
new_mesh = cmds.duplicate(body_mesh)[0]
|
||||||
|
|
||||||
|
# Unlock the translate attributes
|
||||||
|
cmds.setAttr(new_mesh+'.translateX', lock=False)
|
||||||
|
cmds.setAttr(new_mesh+'.translateY', lock=False)
|
||||||
|
cmds.setAttr(new_mesh+'.translateZ', lock=False)
|
||||||
|
|
||||||
|
# Translate the duplicated mesh along the X-axis by 75 units
|
||||||
|
cmds.move(75, 0, 0, new_mesh, relative=True)
|
||||||
|
|
||||||
|
# Add the duplicated mesh as a target blend shape to the existing blend shape node
|
||||||
|
blend_shape_node = "BodyShape"
|
||||||
|
cmds.blendShape(blend_shape_node, edit=True, target=(body_mesh, 1, new_mesh, 1.0))
|
||||||
|
|
||||||
|
# Set the weight of the new_mesh target blend shape to -1
|
||||||
|
cmds.setAttr("BodyShape."+new_mesh, -1)
|
||||||
|
|
||||||
|
cmds.setAttr("BodyShape.B2", 1)
|
||||||
|
|
||||||
|
cmds.delete(gender_mesh+"1")
|
||||||
|
|
||||||
|
bind_skin(gender_mesh)
|
||||||
|
|
||||||
|
#build_body("c:/dna_calibration")
|
169
BuildBodyFree.py
Normal file
169
BuildBodyFree.py
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
#All Rights Belongs to Uzay CALISKAN
|
||||||
|
#Artstation Marketplace Standart License
|
||||||
|
import os
|
||||||
|
import maya.cmds as cmds
|
||||||
|
def fixbody():
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Transfer Body original skeleton to the new head Skeleton
|
||||||
|
CD = 15
|
||||||
|
lower_CD = -1
|
||||||
|
minCD = 0
|
||||||
|
|
||||||
|
# Define the joint names and namespaces
|
||||||
|
head_joint = "DHIhead:spine_04"
|
||||||
|
body_joint = "spine_04_drv"
|
||||||
|
|
||||||
|
# Split the joint names into their respective namespaces and joint names
|
||||||
|
head_namespace, head_joint_name = head_joint.split(":")
|
||||||
|
|
||||||
|
# Get the list of child joints for the head joint
|
||||||
|
head_child_joints = cmds.listRelatives(head_joint, children=True, allDescendents=True,type="joint")
|
||||||
|
body_child_joints = cmds.listRelatives(body_joint, children=True, allDescendents=True, type="joint")
|
||||||
|
|
||||||
|
def move2target_joint(moving_joint, target_joint):
|
||||||
|
lower_lip_rotation_pos = cmds.xform(moving_joint, query=True, worldSpace=True, rotatePivot=True)
|
||||||
|
jaw_pos = cmds.xform(target_joint, query=True, worldSpace=True, rotatePivot=True)
|
||||||
|
# Get the child joints
|
||||||
|
child_joints = cmds.listRelatives(moving_joint, c=True, type="joint")
|
||||||
|
# Store the initial positions of the child joints
|
||||||
|
child_positions = []
|
||||||
|
if child_joints:
|
||||||
|
for child_joint in child_joints:
|
||||||
|
child_positions.append(cmds.xform(child_joint, q=True, ws=True, t=True))
|
||||||
|
|
||||||
|
# Set the translate and rotate pivot attributes of the "FACIAL_C_LowerLipRotation" joint to match those of "FACIAL_C_MouthUpper"
|
||||||
|
cmds.xform(moving_joint, translation=jaw_pos, rotatePivot=lower_lip_rotation_pos, worldSpace=True)
|
||||||
|
if child_joints:
|
||||||
|
|
||||||
|
# Move each child joint back to its original position
|
||||||
|
for i, child_joint in enumerate(child_joints):
|
||||||
|
cmds.xform(child_joint, ws=True, t=child_positions[i])
|
||||||
|
moving_joint = body_joint
|
||||||
|
target_joint = head_joint
|
||||||
|
move2target_joint(moving_joint, target_joint)
|
||||||
|
while CD >= minCD:
|
||||||
|
joint_CD = [joint for joint in body_child_joints if cmds.getAttr(joint + ".chainDepth") == CD]
|
||||||
|
for joint_name in joint_CD:
|
||||||
|
|
||||||
|
drvname = joint_name.replace("_drv", "")
|
||||||
|
# Build the joint names for the current joint
|
||||||
|
|
||||||
|
|
||||||
|
head_current_joint = "{}:{}".format(head_namespace, drvname)
|
||||||
|
if cmds.objExists(head_current_joint):
|
||||||
|
if joint_name[-5] == "r":
|
||||||
|
offnamer = joint_name.replace("_r_drv", "Off_r_drv")
|
||||||
|
if cmds.objExists(offnamer):
|
||||||
|
joint_name = offnamer
|
||||||
|
if joint_name[-5] == "l":
|
||||||
|
offnamel = joint_name.replace("_l_drv", "Off_l_drv")
|
||||||
|
if cmds.objExists(offnamel):
|
||||||
|
joint_name = offnamel
|
||||||
|
moving_joint = joint_name
|
||||||
|
target_joint = head_current_joint
|
||||||
|
move2target_joint(moving_joint, target_joint)
|
||||||
|
|
||||||
|
|
||||||
|
lower_CD -= 1
|
||||||
|
CD -= 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def bind_skin(gender_mesh):
|
||||||
|
|
||||||
|
# Body
|
||||||
|
mesh_obj = cmds.ls(gender_mesh)[0]
|
||||||
|
|
||||||
|
# Duplicate the mesh
|
||||||
|
duplicated_mesh_obj = cmds.duplicate(mesh_obj)[0]
|
||||||
|
|
||||||
|
cmds.select([duplicated_mesh_obj, "DHIbody:root"])
|
||||||
|
|
||||||
|
# Bind skin to the mesh
|
||||||
|
skin_cluster = cmds.skinCluster("DHIbody:root", duplicated_mesh_obj)[0]
|
||||||
|
|
||||||
|
cmds.select([mesh_obj, duplicated_mesh_obj])
|
||||||
|
|
||||||
|
cmds.copySkinWeights(noMirror=True, surfaceAssociation="closestPoint", influenceAssociation=["name", "oneToOne"])
|
||||||
|
|
||||||
|
cmds.delete(mesh_obj)
|
||||||
|
cmds.rename(duplicated_mesh_obj, gender_mesh)
|
||||||
|
gender=0
|
||||||
|
gender_mesh = "m_med_nrw_body_lod0_mesh"
|
||||||
|
|
||||||
|
def build_body(ROOT_DIR):
|
||||||
|
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")
|
||||||
|
skeleton_file_path = f"{ROOT_DIR}/data/Body_Drv.mb"
|
||||||
|
# Import the FBX file
|
||||||
|
cmds.file(skeleton_file_path, i=True, ignoreVersion=True, mergeNamespacesOnClash=False)
|
||||||
|
def add_chain_depth_attribute(joints):
|
||||||
|
for joint in joints:
|
||||||
|
if not cmds.attributeQuery('chainDepth', node=joint, exists=True):
|
||||||
|
cmds.addAttr(joint, longName='chainDepth', attributeType='long', defaultValue=0)
|
||||||
|
cmds.setAttr(joint + '.chainDepth', keyable=True)
|
||||||
|
|
||||||
|
def set_chain_depth_value(joints, value):
|
||||||
|
for joint in joints:
|
||||||
|
cmds.setAttr(joint + '.chainDepth', value)
|
||||||
|
|
||||||
|
# Get all joints in the scene
|
||||||
|
all_joints = cmds.ls(type="joint")
|
||||||
|
|
||||||
|
# Remove joints in the "DHIhead:spine_04" hierarchy (Avoid HEAD)
|
||||||
|
exclude_joints = cmds.ls("DHIhead:spine_04", dag=True, type="joint")
|
||||||
|
all_joints = cmds.ls("root_drv", dag=True, type="joint")
|
||||||
|
add_chain_depth_attribute(all_joints)
|
||||||
|
|
||||||
|
# Filter end joints (joints with no child joints)
|
||||||
|
end_joints = [joint for joint in all_joints if not cmds.listRelatives(joint, children=True, type='joint')]
|
||||||
|
|
||||||
|
|
||||||
|
# Set chainDepth attribute to 0 for all end joints
|
||||||
|
set_chain_depth_value(all_joints, 100)
|
||||||
|
set_chain_depth_value(end_joints, 0)
|
||||||
|
|
||||||
|
parents1 = []
|
||||||
|
|
||||||
|
for joint_name in end_joints:
|
||||||
|
p_joint = cmds.listRelatives(joint_name, parent=True, type="joint")
|
||||||
|
if p_joint:
|
||||||
|
children = cmds.listRelatives(p_joint, children=True, type="joint") or []
|
||||||
|
if all(cmds.getAttr(child + ".chainDepth") == 0 for child in children):
|
||||||
|
|
||||||
|
parents1.append(p_joint[0])
|
||||||
|
|
||||||
|
set_chain_depth_value(parents1, 1)
|
||||||
|
#Chaindepth add Attr Loop
|
||||||
|
chainDepth = 1
|
||||||
|
while parents1:
|
||||||
|
chainDepth += 1
|
||||||
|
new_parents = []
|
||||||
|
for joint_name in parents1:
|
||||||
|
p_joint = cmds.listRelatives(joint_name, parent=True, type="joint")
|
||||||
|
if p_joint:
|
||||||
|
children = cmds.listRelatives(p_joint, children=True, type="joint") or []
|
||||||
|
if all(cmds.getAttr(child + ".chainDepth") < chainDepth for child in children):
|
||||||
|
new_parents.append(p_joint[0])
|
||||||
|
if new_parents:
|
||||||
|
set_chain_depth_value(new_parents, chainDepth)
|
||||||
|
parents1 = new_parents
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
DHIBODY_name = 'DHIbody:root'
|
||||||
|
bind_skin(gender_mesh)
|
||||||
|
|
||||||
|
def connect_body():
|
||||||
|
bodyNS = "DHIbody:"
|
||||||
|
headNS = "DHIhead:"
|
||||||
|
|
||||||
|
for i in cmds.ls(type="joint"):
|
||||||
|
if headNS in i:
|
||||||
|
if i.replace(headNS,bodyNS) in cmds.ls(type="joint"):
|
||||||
|
cmds.parentConstraint(i.replace(headNS,bodyNS),i,mo=True)
|
||||||
|
cmds.scaleConstraint(i.replace(headNS,bodyNS),i,mo=True)
|
||||||
|
|
||||||
|
#build_body()
|
563
BuildBody_drv.py
Normal file
563
BuildBody_drv.py
Normal file
@ -0,0 +1,563 @@
|
|||||||
|
#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)
|
54
Export_FBX.py
Normal file
54
Export_FBX.py
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
#All Rights Belongs to Uzay CALISKAN
|
||||||
|
#Artstation Marketplace Standart License
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import maya.cmds as cmds
|
||||||
|
|
||||||
|
def export_fbx(ROOT_DIR):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Set the path and filename for the FBX file
|
||||||
|
path = f"{ROOT_DIR}/output"
|
||||||
|
filename = "body.fbx"
|
||||||
|
filepath = path + "/" + filename
|
||||||
|
cmds.select(clear=True)
|
||||||
|
cmds.select("body_rig", add=True)
|
||||||
|
cmds.select("DHIbody:root", add=True)
|
||||||
|
# Export the selected objects as FBX
|
||||||
|
cmds.file(filepath, force=True, options="groups=0;ptgroups=0;materials=0;smoothing=1;normals=1", type='FBX export', exportSelected=True)
|
||||||
|
|
||||||
|
filename = "head.fbx"
|
||||||
|
filepath = path + "/" + filename
|
||||||
|
cmds.select("DHIbody:spine_04", hi=True) # Select "DHIbody:spine_04" and its children
|
||||||
|
cmds.delete() # Delete the selected objects
|
||||||
|
cmds.select("DHIbody:thigh_r", hi=True) # Select "DHIbody:spine_04" and its children
|
||||||
|
cmds.delete() # Delete the selected objects
|
||||||
|
cmds.select("DHIbody:thigh_l", hi=True) # Select "DHIbody:spine_04" and its children
|
||||||
|
cmds.delete() # Delete the selected objects
|
||||||
|
|
||||||
|
# Parent "DHIhead:spine_04" under "DHIbody:spine_03"
|
||||||
|
cmds.parent("DHIhead:spine_04", "DHIbody:spine_03")
|
||||||
|
|
||||||
|
# Print the new parent of "DHIhead:spine_04"
|
||||||
|
print(cmds.listRelatives("DHIhead:spine_04", parent=True))
|
||||||
|
|
||||||
|
cmds.select(clear=True)
|
||||||
|
cmds.select("head_grp", add=True)
|
||||||
|
cmds.select("DHIbody:root", add=True)
|
||||||
|
# Export the selected objects as FBX
|
||||||
|
cmds.file(filepath, force=True, options="groups=0;ptgroups=0;materials=0;smoothing=1;normals=1", type='FBX export', exportSelected=True)
|
||||||
|
|
||||||
|
cmds.undo()
|
||||||
|
cmds.undo()
|
||||||
|
cmds.undo()
|
||||||
|
cmds.undo()
|
||||||
|
cmds.undo()
|
||||||
|
cmds.undo()
|
||||||
|
cmds.undo()
|
||||||
|
cmds.undo()
|
||||||
|
cmds.undo()
|
||||||
|
cmds.undo()
|
||||||
|
|
||||||
|
|
417
JointTransformationTool.py
Normal file
417
JointTransformationTool.py
Normal file
@ -0,0 +1,417 @@
|
|||||||
|
#All Rights Belongs to Uzay CALISKAN
|
||||||
|
#Artstation Marketplace Standart License
|
||||||
|
|
||||||
|
import maya.cmds as qqdgffvdrevd2121
|
||||||
|
import sys
|
||||||
|
import os.path as ospathe
|
||||||
|
from os import environ
|
||||||
|
from sys import path as syspath
|
||||||
|
from sys import platform
|
||||||
|
import logging
|
||||||
|
import maya.OpenMaya as om
|
||||||
|
from maya import cmds
|
||||||
|
from os import environ, makedirs
|
||||||
|
from os import path as ospath
|
||||||
|
threshold = 0
|
||||||
|
def update_threshold(text_field):
|
||||||
|
global threshold
|
||||||
|
thresholdstr = qqdgffvdrevd2121.textField(text_field, q=True, text=True)
|
||||||
|
threshold = float(thresholdstr)
|
||||||
|
print(f"New threshold: {threshold}")
|
||||||
|
return threshold
|
||||||
|
def target_mesh():
|
||||||
|
selected_objects = qqdgffvdrevd2121.ls(selection=True)
|
||||||
|
tar = selected_objects[1]
|
||||||
|
print (tar)
|
||||||
|
if len(selected_objects) != 2:
|
||||||
|
print("Please select exactly two objects.")
|
||||||
|
return
|
||||||
|
qqdgffvdrevd2121.rename(selected_objects[0], "Custom")
|
||||||
|
qqdgffvdrevd2121.blendShape(selected_objects[1], automatic=True)
|
||||||
|
qqdgffvdrevd2121.rename("blendShape1", "TargetBS")
|
||||||
|
qqdssxoklauh2121 = qqdgffvdrevd2121.listRelatives(tar, shapes=True, fullPath=True)
|
||||||
|
print(qqdssxoklauh2121)
|
||||||
|
qqdgffvdrevd2121.blendShape("TargetBS", edit=True, target=[(qqdssxoklauh2121[0], 0.0, "CustomShape", 1.0)])
|
||||||
|
def rename_eyes():
|
||||||
|
selected_objects = qqdgffvdrevd2121.ls(selection=True)
|
||||||
|
if len(selected_objects) != 2:
|
||||||
|
print("Select 2 objects (Eyes)")
|
||||||
|
else:
|
||||||
|
qqdssxouh21210 = qqdgffvdrevd2121.getAttr(selected_objects[0] + ".visibility") == 0
|
||||||
|
qqdssxouh21211 = qqdgffvdrevd2121.getAttr(selected_objects[1] + ".visibility") == 0
|
||||||
|
if qqdssxouh21210 or qqdssxouh21211:
|
||||||
|
qqdgffvdrevd2121.setAttr(selected_objects[0] + ".visibility", 1)
|
||||||
|
qqdgffvdrevd2121.setAttr(selected_objects[1] + ".visibility", 1)
|
||||||
|
qqdgffvdrevd2121.xform(selected_objects[0], centerPivots=True)
|
||||||
|
qqdgffvdrevd2121.xform(selected_objects[1], centerPivots=True)
|
||||||
|
pos1 = qqdgffvdrevd2121.xform(selected_objects[0], query=True, worldSpace=True, rotatePivot=True)
|
||||||
|
pos2 = qqdgffvdrevd2121.xform(selected_objects[1], query=True, worldSpace=True, rotatePivot=True)
|
||||||
|
if pos1[0] > 0 and pos2[0] > 0:
|
||||||
|
print("Both eyes are on the positive X side of the origin")
|
||||||
|
elif pos1[0] < 0 and pos2[0] < 0:
|
||||||
|
print("Both eyes are on the negative X side of the origin")
|
||||||
|
elif pos1[0] < 0 and pos2[0] > 0:
|
||||||
|
if qqdgffvdrevd2121.objExists("eyeRight") or qqdgffvdrevd2121.objExists("eyeLeft"):
|
||||||
|
print("Eye names already exist, Delete or rename them")
|
||||||
|
else:
|
||||||
|
qqdgffvdrevd2121.rename(selected_objects[0], "eyeRight")
|
||||||
|
qqdgffvdrevd2121.rename(selected_objects[1], "eyeLeft")
|
||||||
|
elif pos1[0] > 0 and pos2[0] < 0:
|
||||||
|
if qqdgffvdrevd2121.objExists("eyeRight") or qqdgffvdrevd2121.objExists("eyeLeft"):
|
||||||
|
print("Eye names already exist, Delete or rename them")
|
||||||
|
else:
|
||||||
|
qqdgffvdrevd2121.rename(selected_objects[0], "eyeLeft")
|
||||||
|
qqdgffvdrevd2121.rename(selected_objects[1], "eyeRight")
|
||||||
|
elif pos1[0] == 0 or pos2[0] == 0:
|
||||||
|
print("Eye is in the middle")
|
||||||
|
qqdgffvdrevd2121.setAttr("eyeRight" + ".visibility", 0)
|
||||||
|
qqdgffvdrevd2121.setAttr("eyeLeft" + ".visibility", 0)
|
||||||
|
def eye_transformation():
|
||||||
|
eyejoint = qqdgffvdrevd2121.ls(selection=True)
|
||||||
|
def perEye(eyejoint, target, eyemesh):
|
||||||
|
import math
|
||||||
|
bounding_box = qqdgffvdrevd2121.exactWorldBoundingBox(eyemesh)
|
||||||
|
center = [
|
||||||
|
(bounding_box[0] + bounding_box[3]) / 2.0,
|
||||||
|
(bounding_box[1] + bounding_box[4]) / 2.0,
|
||||||
|
(bounding_box[2] + bounding_box[5]) / 2.0
|
||||||
|
]
|
||||||
|
min_z = bounding_box[2]
|
||||||
|
max_z = bounding_box[5]
|
||||||
|
EyeMain = qqdgffvdrevd2121.xform(eyejoint, query=True, worldSpace=True, rotatePivot=True)
|
||||||
|
EyeTarget = qqdgffvdrevd2121.xform(target, query=True, worldSpace=True, rotatePivot=True)
|
||||||
|
joint_z = EyeMain[2]
|
||||||
|
positionRatio = (joint_z - min_z)/(max_z - min_z)
|
||||||
|
bounding_box = qqdgffvdrevd2121.exactWorldBoundingBox(target)
|
||||||
|
center = [
|
||||||
|
(bounding_box[0] + bounding_box[3]) / 2.0,
|
||||||
|
(bounding_box[1] + bounding_box[4]) / 2.0,
|
||||||
|
(bounding_box[2] + bounding_box[5]) / 2.0
|
||||||
|
]
|
||||||
|
min_z = bounding_box[2]
|
||||||
|
max_z = bounding_box[5]
|
||||||
|
ratioMove_z = (max_z - min_z) * (positionRatio - 0.5)
|
||||||
|
qqdgffvdrevd2121.xform(eyejoint, translation=EyeTarget, worldSpace=True)
|
||||||
|
qqdgffvdrevd2121.move(0, 0, ratioMove_z, eyejoint, relative=True)
|
||||||
|
perEye(eyejoint[1], "eyeRight", eyejoint[3])
|
||||||
|
perEye(eyejoint[0], "eyeLeft", eyejoint[2])
|
||||||
|
def bind_skin(gender_mesh):
|
||||||
|
def select_root_bones():
|
||||||
|
# List all joints in the scene
|
||||||
|
joints = qqdgffvdrevd2121.ls(type='joint')
|
||||||
|
qqdsossdceoyth2121 = []
|
||||||
|
for joint in joints:
|
||||||
|
# Get the parent of the joints
|
||||||
|
parent = qqdgffvdrevd2121.listRelatives(joint, parent=True)
|
||||||
|
if not parent or qqdgffvdrevd2121.nodeType(parent[0]) != 'joint':
|
||||||
|
qqdsossdceoyth2121.append(joint)
|
||||||
|
qqdgffvdrevd2121.select(qqdsossdceoyth2121[0], replace=True)
|
||||||
|
select_root_bones()
|
||||||
|
qqdsoghxeoyth2121 = qqdgffvdrevd2121.ls(selection=True, flatten=True)[0]
|
||||||
|
qqdsxftuxh2121 = qqdgffvdrevd2121.ls(gender_mesh)[0]
|
||||||
|
qqdsxftuxxh2121 = qqdgffvdrevd2121.duplicate(qqdsxftuxh2121)[0]
|
||||||
|
qqdsstuxxh2121 = gender_mesh + "_duplicate"
|
||||||
|
qqdgffvdrevd2121.rename(qqdsxftuxxh2121, qqdsstuxxh2121)
|
||||||
|
qqdsstush2121 = qqdgffvdrevd2121.ls(qqdsstuxxh2121)[0]
|
||||||
|
qqdgffvdrevd2121.select([qqdsstush2121, qqdsoghxeoyth2121])
|
||||||
|
qqdsstcccch2121 = qqdgffvdrevd2121.skinCluster(qqdsoghxeoyth2121, qqdsstush2121)[0]
|
||||||
|
qqdgffvdrevd2121.setAttr(qqdsstcccch2121 + ".skinningMethod", 1)
|
||||||
|
qqdgffvdrevd2121.select([qqdsxftuxh2121, qqdsstush2121])
|
||||||
|
qqdgffvdrevd2121.copySkinWeights(noMirror=True, surfaceAssociation="closestPoint", influenceAssociation=["name", "oneToOne"])
|
||||||
|
qqdgffvdrevd2121.delete(qqdsxftuxh2121)
|
||||||
|
qqdgffvdrevd2121.rename(qqdsstush2121, gender_mesh)
|
||||||
|
qqdgffqqdssedssu2121svd2121 = []
|
||||||
|
def exclude():
|
||||||
|
global qqdgffqqdssedssu2121svd2121
|
||||||
|
qqdgffqqdssedssu2121svd2121 = []
|
||||||
|
selected_objects = qqdgffvdrevd2121.ls(selection=True)
|
||||||
|
qqdgffqqdssedssu2121svd2121 = selected_objects
|
||||||
|
def rig_transformation():
|
||||||
|
qqdgffadrevd2121 = qqdgffvdrevd2121.ls(selection=True)
|
||||||
|
global qqdgffacsvd2121
|
||||||
|
qqdgffacsvd2121 = qqdgffadrevd2121[0]
|
||||||
|
def qqdgffbbsvd2121(joints):
|
||||||
|
for joint in joints:
|
||||||
|
if not qqdgffvdrevd2121.attributeQuery('qqdghfggfvd2121', node=joint, exists=True):
|
||||||
|
qqdgffvdrevd2121.addAttr(joint, longName='qqdghfggfvd2121', attributeType='long', defaultValue=0)
|
||||||
|
qqdgffvdrevd2121.setAttr(joint + '.qqdghfggfvd2121', keyable=True)
|
||||||
|
def qqdgffcbsvd2121(joints, value):
|
||||||
|
for joint in joints:
|
||||||
|
qqdgffvdrevd2121.setAttr(joint + '.qqdghfggfvd2121', value)
|
||||||
|
global qqdgffqqdssedssu2121svd2121
|
||||||
|
qqdgffcesvd2121 = qqdgffvdrevd2121.ls(type="joint")
|
||||||
|
qqdgffcesvd2121oints = list(set(qqdgffcesvd2121) - set(qqdgffqqdssedssu2121svd2121))
|
||||||
|
qqdgffbbsvd2121(qqdgffcesvd2121)
|
||||||
|
qqdgffdesvd2121 = [joint for joint in qqdgffcesvd2121oints if not qqdgffvdrevd2121.listRelatives(joint, children=True, type='joint')]
|
||||||
|
qqdgffcbsvd2121(qqdgffcesvd2121, 100)
|
||||||
|
qqdgffcbsvd2121(qqdgffdesvd2121, 0)
|
||||||
|
qqdgffeesvd2121 = []
|
||||||
|
for qqdgffeffvd2121 in qqdgffdesvd2121:
|
||||||
|
qqdgffggfvd2121 = qqdgffvdrevd2121.listRelatives(qqdgffeffvd2121, parent=True, type="joint")
|
||||||
|
if qqdgffggfvd2121:
|
||||||
|
children = qqdgffvdrevd2121.listRelatives(qqdgffggfvd2121, children=True, type="joint") or []
|
||||||
|
if all(qqdgffvdrevd2121.getAttr(child + ".qqdghfggfvd2121") == 0 for child in children):
|
||||||
|
|
||||||
|
qqdgffeesvd2121.append(qqdgffggfvd2121[0])
|
||||||
|
qqdgffcbsvd2121(qqdgffeesvd2121, 1)
|
||||||
|
qqdghfggfvd2121 = 1
|
||||||
|
while qqdgffeesvd2121:
|
||||||
|
qqdghfggfvd2121 += 1
|
||||||
|
qqdghfgifvd2121 = []
|
||||||
|
for qqdgffeffvd2121 in qqdgffeesvd2121:
|
||||||
|
qqdgffggfvd2121 = qqdgffvdrevd2121.listRelatives(qqdgffeffvd2121, parent=True, type="joint")
|
||||||
|
if qqdgffggfvd2121:
|
||||||
|
children = qqdgffvdrevd2121.listRelatives(qqdgffggfvd2121, children=True, type="joint") or []
|
||||||
|
if all(qqdgffvdrevd2121.getAttr(child + ".qqdghfggfvd2121") < qqdghfggfvd2121 for child in children):
|
||||||
|
qqdghfgifvd2121.append(qqdgffggfvd2121[0])
|
||||||
|
if qqdghfgifvd2121:
|
||||||
|
qqdgffcbsvd2121(qqdghfgifvd2121, qqdghfggfvd2121)
|
||||||
|
qqdgffeesvd2121 = qqdghfgifvd2121
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
qqdgcsgifvd2121 = []
|
||||||
|
qqdgcsbtrud2121x = []
|
||||||
|
qqdgcsbtrud2121y = []
|
||||||
|
qqdgcsbtrud2121z = []
|
||||||
|
# DELTA X CALCULATE
|
||||||
|
for qqdgffeffvd2121 in qqdgffdesvd2121:
|
||||||
|
qqdgcsbtrod2121 = qqdgffacsvd2121
|
||||||
|
qqdgcotrod2121 = qqdgffvdrevd2121.xform(qqdgffeffvd2121, query=True, worldSpace=True, translation=True)
|
||||||
|
qqdocotrod2121 = qqdgffvdrevd2121.createNode("closestPointOnMesh")
|
||||||
|
qqdgffvdrevd2121.connectAttr(qqdgcsbtrod2121 + ".worldMesh", qqdocotrod2121 + ".inMesh")
|
||||||
|
qqdgffvdrevd2121.setAttr(qqdocotrod2121 + ".inPosition", qqdgcotrod2121[0], qqdgcotrod2121[1], qqdgcotrod2121[2])
|
||||||
|
qqdocuutrod2121 = qqdgffvdrevd2121.getAttr(qqdocotrod2121 + ".closestVertexIndex")
|
||||||
|
qqdgffvdrevd2121.delete(qqdocotrod2121)
|
||||||
|
vertex = qqdgcsbtrod2121 + ".vtx[{}]".format(qqdocuutrod2121)
|
||||||
|
qqdgffvdrevd2121.select(vertex, replace=True)
|
||||||
|
for i in range(1):
|
||||||
|
qqdocbtrtrod2121 = qqdgffvdrevd2121.ls(selection=True, flatten=True)
|
||||||
|
edges = []
|
||||||
|
for vertex in qqdocbtrtrod2121:
|
||||||
|
edges.extend(qqdgffvdrevd2121.polyListComponentConversion(vertex, fromVertex=True, toEdge=True))
|
||||||
|
qqdgffvdrevd2121.select(edges)
|
||||||
|
edges = qqdgffvdrevd2121.ls(selection=True, flatten=True)
|
||||||
|
qqdocbtrtrod2121 = []
|
||||||
|
for edge in edges:
|
||||||
|
qqdocbtrtrod2121.extend(qqdgffvdrevd2121.polyListComponentConversion(edge, fromEdge=True, toVertex=True))
|
||||||
|
qqdgffvdrevd2121.select(qqdocbtrtrod2121)
|
||||||
|
qqdocbtrtrod2121 = qqdgffvdrevd2121.ls(selection=True, flatten=True)
|
||||||
|
qqdocbtraod2121 = []
|
||||||
|
for vertex in qqdocbtrtrod2121:
|
||||||
|
position = qqdgffvdrevd2121.pointPosition(vertex, world=True)
|
||||||
|
qqdocbtraod2121.append(position)
|
||||||
|
qqdgffvdrevd2121.setAttr("TargetBS.CustomShape", 1)
|
||||||
|
qqdocbtrbod2121 = []
|
||||||
|
for vertex in qqdocbtrtrod2121:
|
||||||
|
position = qqdgffvdrevd2121.pointPosition(vertex, world=True)
|
||||||
|
qqdocbtrbod2121.append(position)
|
||||||
|
qqdssedoou2121vertex = []
|
||||||
|
for i in range(len(qqdocbtrbod2121)):
|
||||||
|
qqdodbtrbod2121 = []
|
||||||
|
for j in range(3):
|
||||||
|
qqdodbtrbod2121.append(qqdocbtrbod2121[i][j] - qqdocbtraod2121[i][j])
|
||||||
|
qqdssedoou2121vertex.append(qqdodbtrbod2121)
|
||||||
|
qqdodbtrbgd2121 = [sum(x) / len(x) for x in zip(*qqdssedoou2121vertex)]
|
||||||
|
qqdssedoou2121x = qqdodbtrbgd2121[0]
|
||||||
|
qqdssedoou2121y = qqdodbtrbgd2121[1]
|
||||||
|
qqdssedoou2121z = qqdodbtrbgd2121[2]
|
||||||
|
if not qqdgffvdrevd2121.attributeQuery("qqdssedoou2121x", node=qqdgffeffvd2121, exists=True):
|
||||||
|
qqdgffvdrevd2121.addAttr(qqdgffeffvd2121, ln="qqdssedoou2121x", at="double")
|
||||||
|
if not qqdgffvdrevd2121.attributeQuery("qqdssedoou2121y", node=qqdgffeffvd2121, exists=True):
|
||||||
|
qqdgffvdrevd2121.addAttr(qqdgffeffvd2121, ln="qqdssedoou2121y", at="double")
|
||||||
|
if not qqdgffvdrevd2121.attributeQuery("qqdssedoou2121z", node=qqdgffeffvd2121, exists=True):
|
||||||
|
qqdgffvdrevd2121.addAttr(qqdgffeffvd2121, ln="qqdssedoou2121z", at="double")
|
||||||
|
qqdgffvdrevd2121.setAttr(qqdgffeffvd2121 + ".qqdssedoou2121x", qqdssedoou2121x)
|
||||||
|
qqdgffvdrevd2121.setAttr(qqdgffeffvd2121 + ".qqdssedoou2121y", qqdssedoou2121y)
|
||||||
|
qqdgffvdrevd2121.setAttr(qqdgffeffvd2121 + ".qqdssedoou2121z", qqdssedoou2121z)
|
||||||
|
qqdgffvdrevd2121.setAttr("TargetBS.CustomShape", 0)
|
||||||
|
qqdgcsgifvd2121.append(qqdgffeffvd2121)
|
||||||
|
qqdgcsbtrud2121x.append(qqdssedoou2121x)
|
||||||
|
qqdgcsbtrud2121y.append(qqdssedoou2121y)
|
||||||
|
qqdgcsbtrud2121z.append(qqdssedoou2121z)
|
||||||
|
for i in range(len(qqdgcsgifvd2121)):
|
||||||
|
qqdgffvdrevd2121.move(qqdgcsbtrud2121x[i], qqdgcsbtrud2121y[i], qqdgcsbtrud2121z[i], qqdgcsgifvd2121[i], relative=True)
|
||||||
|
for qqdgffeffvd2121 in qqdgffcesvd2121oints:
|
||||||
|
qqdgcsbtrod2121 = qqdgffacsvd2121
|
||||||
|
qqdgcotrod2121 = qqdgffvdrevd2121.xform(qqdgffeffvd2121, query=True, worldSpace=True, translation=True)
|
||||||
|
qqdocotrod2121 = qqdgffvdrevd2121.createNode("closestPointOnMesh")
|
||||||
|
qqdgffvdrevd2121.connectAttr(qqdgcsbtrod2121 + ".worldMesh", qqdocotrod2121 + ".inMesh")
|
||||||
|
qqdgffvdrevd2121.setAttr(qqdocotrod2121 + ".inPosition", qqdgcotrod2121[0], qqdgcotrod2121[1], qqdgcotrod2121[2])
|
||||||
|
qqdocuutrod2121 = qqdgffvdrevd2121.getAttr(qqdocotrod2121 + ".closestVertexIndex")
|
||||||
|
qqdgffvdrevd2121.delete(qqdocotrod2121)
|
||||||
|
vertex = qqdgcsbtrod2121 + ".vtx[{}]".format(qqdocuutrod2121)
|
||||||
|
qqdgffvdrevd2121.select(vertex, replace=True)
|
||||||
|
for i in range(1):
|
||||||
|
qqdocbtrtrod2121 = qqdgffvdrevd2121.ls(selection=True, flatten=True)
|
||||||
|
edges = []
|
||||||
|
for vertex in qqdocbtrtrod2121:
|
||||||
|
edges.extend(qqdgffvdrevd2121.polyListComponentConversion(vertex, fromVertex=True, toEdge=True))
|
||||||
|
qqdgffvdrevd2121.select(edges)
|
||||||
|
edges = qqdgffvdrevd2121.ls(selection=True, flatten=True)
|
||||||
|
qqdocbtrtrod2121 = []
|
||||||
|
for edge in edges:
|
||||||
|
qqdocbtrtrod2121.extend(qqdgffvdrevd2121.polyListComponentConversion(edge, fromEdge=True, toVertex=True))
|
||||||
|
qqdgffvdrevd2121.select(qqdocbtrtrod2121)
|
||||||
|
qqdocbtrtrod2121 = qqdgffvdrevd2121.ls(selection=True, flatten=True)
|
||||||
|
qqdocbtraod2121 = []
|
||||||
|
for vertex in qqdocbtrtrod2121:
|
||||||
|
position = qqdgffvdrevd2121.pointPosition(vertex, world=True)
|
||||||
|
qqdocbtraod2121.append(position)
|
||||||
|
qqdgffvdrevd2121.setAttr("TargetBS.CustomShape", 1)
|
||||||
|
qqdocbtrbod2121 = []
|
||||||
|
for vertex in qqdocbtrtrod2121:
|
||||||
|
position = qqdgffvdrevd2121.pointPosition(vertex, world=True)
|
||||||
|
qqdocbtrbod2121.append(position)
|
||||||
|
qqdssedoou2121vertex = []
|
||||||
|
for i in range(len(qqdocbtrbod2121)):
|
||||||
|
qqdodbtrbod2121 = []
|
||||||
|
for j in range(3):
|
||||||
|
qqdodbtrbod2121.append(qqdocbtrbod2121[i][j] - qqdocbtraod2121[i][j])
|
||||||
|
qqdssedoou2121vertex.append(qqdodbtrbod2121)
|
||||||
|
qqdodbtrbgd2121 = [sum(x) / len(x) for x in zip(*qqdssedoou2121vertex)]
|
||||||
|
qqdssedoou2121vrtx = qqdodbtrbgd2121[0]
|
||||||
|
qqdssedoou2121vrty = qqdodbtrbgd2121[1]
|
||||||
|
qqdssedoou2121vrtz = qqdodbtrbgd2121[2]
|
||||||
|
if not qqdgffvdrevd2121.attributeQuery("qqdssedoou2121vrtx", node=qqdgffeffvd2121, exists=True):
|
||||||
|
qqdgffvdrevd2121.addAttr(qqdgffeffvd2121, ln="qqdssedoou2121vrtx", at="double")
|
||||||
|
if not qqdgffvdrevd2121.attributeQuery("qqdssedoou2121vrty", node=qqdgffeffvd2121, exists=True):
|
||||||
|
qqdgffvdrevd2121.addAttr(qqdgffeffvd2121, ln="qqdssedoou2121vrty", at="double")
|
||||||
|
if not qqdgffvdrevd2121.attributeQuery("qqdssedoou2121vrtz", node=qqdgffeffvd2121, exists=True):
|
||||||
|
qqdgffvdrevd2121.addAttr(qqdgffeffvd2121, ln="qqdssedoou2121vrtz", at="double")
|
||||||
|
qqdgffvdrevd2121.setAttr(qqdgffeffvd2121 + ".qqdssedoou2121vrtx", qqdssedoou2121vrtx)
|
||||||
|
qqdgffvdrevd2121.setAttr(qqdgffeffvd2121 + ".qqdssedoou2121vrty", qqdssedoou2121vrty)
|
||||||
|
qqdgffvdrevd2121.setAttr(qqdgffeffvd2121 + ".qqdssedoou2121vrtz", qqdssedoou2121vrtz)
|
||||||
|
qqdgffvdrevd2121.setAttr("TargetBS.CustomShape", 0)
|
||||||
|
if (-threshold < qqdgcotrod2121[0] < threshold):
|
||||||
|
qqdgffvdrevd2121.setAttr(qqdgffeffvd2121 + ".qqdssedoou2121vrtx", 0)
|
||||||
|
qqdssedssu2121 = 1
|
||||||
|
qqdssedu2121 = 0
|
||||||
|
def select_root_bones():
|
||||||
|
joints = qqdgffvdrevd2121.ls(type='joint')
|
||||||
|
qqdsossdceoyth2121 = []
|
||||||
|
for joint in joints:
|
||||||
|
# Get the parent of the joints
|
||||||
|
parent = qqdgffvdrevd2121.listRelatives(joint, parent=True)
|
||||||
|
if not parent or qqdgffvdrevd2121.nodeType(parent[0]) != 'joint':
|
||||||
|
qqdsossdceoyth2121.append(joint)
|
||||||
|
qqdgffvdrevd2121.select(qqdsossdceoyth2121[0], replace=True)
|
||||||
|
select_root_bones()
|
||||||
|
selected_joint = qqdgffvdrevd2121.ls(selection=True, flatten=True)[0]
|
||||||
|
rootqqdssedssu2121 = qqdgffvdrevd2121.getAttr(selected_joint + ".qqdghfggfvd2121")
|
||||||
|
maxqqdssedssu2121 = rootqqdssedssu2121-1
|
||||||
|
while qqdssedssu2121 <= maxqqdssedssu2121:
|
||||||
|
joint_qqdssedssu2121 = [joint for joint in qqdgffcesvd2121oints if qqdgffvdrevd2121.getAttr(joint + ".qqdghfggfvd2121") == qqdssedssu2121]
|
||||||
|
qqdscscedssu2121 = [joint for joint in qqdgffcesvd2121oints if qqdgffvdrevd2121.getAttr(joint + ".qqdghfggfvd2121") == qqdssedu2121]
|
||||||
|
for qqdgffeffvd2121 in joint_qqdssedssu2121:
|
||||||
|
first_place = qqdgffvdrevd2121.xform(qqdgffeffvd2121, q=True, ws=True, translation=True)
|
||||||
|
child_joints = qqdgffvdrevd2121.listRelatives(qqdgffeffvd2121, children=True, type="joint")
|
||||||
|
qqdscscsedscbtu2121 = []
|
||||||
|
if child_joints:
|
||||||
|
qqdscscedscbtu2121 = []
|
||||||
|
for child_joint in child_joints:
|
||||||
|
if child_joint in qqdscscedssu2121:
|
||||||
|
qqdssedoou2121x = qqdgffvdrevd2121.getAttr(child_joint + '.qqdssedoou2121x')
|
||||||
|
qqdssedoou2121y = qqdgffvdrevd2121.getAttr(child_joint + '.qqdssedoou2121y')
|
||||||
|
qqdssedoou2121z = qqdgffvdrevd2121.getAttr(child_joint + '.qqdssedoou2121z')
|
||||||
|
qqdscscedscbtu2121.append([qqdssedoou2121x, qqdssedoou2121y, qqdssedoou2121z])
|
||||||
|
qqdscscedscbtu2121.append([qqdgffvdrevd2121.getAttr(qqdgffeffvd2121 + '.qqdssedoou2121vrtx'), qqdgffvdrevd2121.getAttr(qqdgffeffvd2121 + '.qqdssedoou2121vrty'), qqdgffvdrevd2121.getAttr(qqdgffeffvd2121 + '.qqdssedoou2121vrtz')])
|
||||||
|
qqdscscedscbtu2121.append([qqdgffvdrevd2121.getAttr(qqdgffeffvd2121 + '.qqdssedoou2121vrtx'), qqdgffvdrevd2121.getAttr(qqdgffeffvd2121 + '.qqdssedoou2121vrty'), qqdgffvdrevd2121.getAttr(qqdgffeffvd2121 + '.qqdssedoou2121vrtz')])
|
||||||
|
qqdscscedscbtu2121.append([qqdgffvdrevd2121.getAttr(qqdgffeffvd2121 + '.qqdssedoou2121vrtx'), qqdgffvdrevd2121.getAttr(qqdgffeffvd2121 + '.qqdssedoou2121vrty'), qqdgffvdrevd2121.getAttr(qqdgffeffvd2121 + '.qqdssedoou2121vrtz')])
|
||||||
|
qqdscscsedscbtu2121 = [sum(x) / len(x) for x in zip(*qqdscscedscbtu2121)]
|
||||||
|
if not qqdscscsedscbtu2121:
|
||||||
|
qqdscscsedscbtu2121 = [0, 0, 0]
|
||||||
|
qqdsouoyth2121x = qqdscscsedscbtu2121[0]
|
||||||
|
qqdsouoyth2121y = qqdscscsedscbtu2121[1]
|
||||||
|
qqdsouoyth2121z = qqdscscsedscbtu2121[2]
|
||||||
|
qqdgffvdrevd2121.move(qqdsouoyth2121x, qqdsouoyth2121y, qqdsouoyth2121z, qqdgffeffvd2121, relative=True)
|
||||||
|
for child_joint in child_joints:
|
||||||
|
qqdgffvdrevd2121.move(-qqdsouoyth2121x, -qqdsouoyth2121y, -qqdsouoyth2121z, child_joint, relative=True)
|
||||||
|
end_place = qqdgffvdrevd2121.xform(qqdgffeffvd2121, q=True, ws=True, translation=True)
|
||||||
|
qqdssedoou2121x = end_place[0] - first_place[0]
|
||||||
|
qqdssedoou2121y = end_place[1] - first_place[1]
|
||||||
|
qqdssedoou2121z = end_place[2] - first_place[2]
|
||||||
|
if not qqdgffvdrevd2121.attributeQuery("qqdssedoou2121x", node=qqdgffeffvd2121, exists=True):
|
||||||
|
qqdgffvdrevd2121.addAttr(qqdgffeffvd2121, ln="qqdssedoou2121x", at="double")
|
||||||
|
if not qqdgffvdrevd2121.attributeQuery("qqdssedoou2121y", node=qqdgffeffvd2121, exists=True):
|
||||||
|
qqdgffvdrevd2121.addAttr(qqdgffeffvd2121, ln="qqdssedoou2121y", at="double")
|
||||||
|
if not qqdgffvdrevd2121.attributeQuery("qqdssedoou2121z", node=qqdgffeffvd2121, exists=True):
|
||||||
|
qqdgffvdrevd2121.addAttr(qqdgffeffvd2121, ln="qqdssedoou2121z", at="double")
|
||||||
|
qqdgffvdrevd2121.setAttr(qqdgffeffvd2121 + ".qqdssedoou2121x", qqdssedoou2121x)
|
||||||
|
qqdgffvdrevd2121.setAttr(qqdgffeffvd2121 + ".qqdssedoou2121y", qqdssedoou2121y)
|
||||||
|
qqdgffvdrevd2121.setAttr(qqdgffeffvd2121 + ".qqdssedoou2121z", qqdssedoou2121z)
|
||||||
|
qqdssedu2121 += 1
|
||||||
|
qqdssedssu2121 += 1
|
||||||
|
def complete():
|
||||||
|
new_mesh = qqdgffvdrevd2121.duplicate(qqdgffacsvd2121)[0]
|
||||||
|
qqdgffvdrevd2121.setAttr(new_mesh+'.translateX', lock=False)
|
||||||
|
qqdgffvdrevd2121.setAttr(new_mesh+'.translateY', lock=False)
|
||||||
|
qqdgffvdrevd2121.setAttr(new_mesh+'.translateZ', lock=False)
|
||||||
|
qqdgffvdrevd2121.move(75, 0, 0, new_mesh, relative=True)
|
||||||
|
qqdsosuoyth2121 = "TargetBS"
|
||||||
|
qqdgffvdrevd2121.blendShape(qqdsosuoyth2121, edit=True, target=(qqdgffacsvd2121, 1, new_mesh, 1.0))
|
||||||
|
qqdgffvdrevd2121.setAttr("TargetBS."+new_mesh, -1)
|
||||||
|
qqdgffvdrevd2121.setAttr("TargetBS.CustomShape", 1)
|
||||||
|
qqdgffvdrevd2121.setAttr(new_mesh + ".visibility", 0)
|
||||||
|
qqdgffvdrevd2121.setAttr("CustomShape" + ".visibility", 0)
|
||||||
|
gender_mesh = qqdgffacsvd2121
|
||||||
|
bind_skin(gender_mesh)
|
||||||
|
def move2target_joint():
|
||||||
|
qqdgffadrevd2121 = qqdgffvdrevd2121.ls(selection=True)
|
||||||
|
moving_joint = qqdgffadrevd2121[0]
|
||||||
|
target_joint = qqdgffadrevd2121[1]
|
||||||
|
mov_pos = qqdgffvdrevd2121.xform(moving_joint, query=True, worldSpace=True, rotatePivot=True)
|
||||||
|
tar_pos = qqdgffvdrevd2121.xform(target_joint, query=True, worldSpace=True, rotatePivot=True)
|
||||||
|
child_joints = qqdgffvdrevd2121.listRelatives(moving_joint, c=True, type="joint")
|
||||||
|
child_positions = []
|
||||||
|
for child_joint in child_joints:
|
||||||
|
child_positions.append(qqdgffvdrevd2121.xform(child_joint, q=True, ws=True, t=True))
|
||||||
|
qqdgffvdrevd2121.xform(moving_joint, translation=tar_pos, rotatePivot=mov_pos, worldSpace=True)
|
||||||
|
for i, child_joint in enumerate(child_joints):
|
||||||
|
qqdgffvdrevd2121.xform(child_joint, ws=True, t=child_positions[i])
|
||||||
|
def refMove():
|
||||||
|
qqdgffadrevd2121 = qqdgffvdrevd2121.ls(selection=True)
|
||||||
|
moving = qqdgffadrevd2121[0]
|
||||||
|
ref = qqdgffadrevd2121[1]
|
||||||
|
xMoving = qqdgffvdrevd2121.xform(moving, query=True, worldSpace=True, rotatePivot=True)
|
||||||
|
xRef = qqdgffvdrevd2121.xform(ref, query=True, worldSpace=True, rotatePivot=True)
|
||||||
|
qqdgffvdrevd2121.xform(moving, translation=xRef, worldSpace=True)
|
||||||
|
def export_fbx():
|
||||||
|
path = outPath
|
||||||
|
filename = "Rigged_Character.fbx"
|
||||||
|
filepath = path + "/" + filename
|
||||||
|
# Export the selected objects as FBX
|
||||||
|
qqdgffvdrevd2121.file(filepath, force=True, options="groups=0;ptgroups=0;materials=0;smoothing=1;normals=1", type='FBX export', exportSelected=True)
|
||||||
|
qqdgffacsvd2121="ok"
|
||||||
|
def show_dna_edit_window(outPath):
|
||||||
|
window_name = "JOINT TRANSFORMATION TOOL"
|
||||||
|
if qqdgffvdrevd2121.window(window_name, exists=True):
|
||||||
|
qqdgffvdrevd2121.deleteUI(window_name)
|
||||||
|
qqdgffvdrevd2121.window(window_name, title=window_name, width=360, height=500, sizeable=False, resizeToFitChildren=True)
|
||||||
|
color = (0.164, 0.384, 0) # RGB values for #0077c2
|
||||||
|
colorbuttons = (.2, 0.2, 0.2) # RGB values for #0077c2
|
||||||
|
layout = qqdgffvdrevd2121.rowColumnLayout(numberOfColumns=1, columnWidth=[(1, 120)], columnSpacing=[(1,120)], backgroundColor=(0.1, 0.1, 0.1))
|
||||||
|
qqdgffvdrevd2121.text(label="", height=10)
|
||||||
|
qqdgffvdrevd2121.text(label="JOINT TRNS", height=60, font="boldLabelFont")
|
||||||
|
qqdgffvdrevd2121.text(label="", height=5)
|
||||||
|
qqdgffvdrevd2121.button(label="Set Target Mesh", command=lambda x: target_mesh(), backgroundColor=colorbuttons, height=40)
|
||||||
|
qqdgffvdrevd2121.text(label="", height=5)
|
||||||
|
qqdgffvdrevd2121.button(label="Set Eyes", command=lambda x: rename_eyes(), backgroundColor=colorbuttons, height=40)
|
||||||
|
qqdgffvdrevd2121.text(label="", height=5)
|
||||||
|
qqdgffvdrevd2121.button(label="Eye Trns", command=lambda x: eye_transformation(), backgroundColor=colorbuttons, height=40)
|
||||||
|
qqdgffvdrevd2121.text(label="", height=25)
|
||||||
|
text_field = qqdgffvdrevd2121.textField(text="0")
|
||||||
|
qqdgffvdrevd2121.button(label="Threshold", command=lambda x: update_threshold(text_field), backgroundColor=color, height=20)
|
||||||
|
qqdgffvdrevd2121.button(label="Exclude", command=lambda x: exclude(), backgroundColor=colorbuttons, height=20)
|
||||||
|
qqdgffvdrevd2121.button(label="Joint Trns", command=lambda x: rig_transformation(), backgroundColor=colorbuttons, height=40)
|
||||||
|
qqdgffvdrevd2121.text(label="", height=5)
|
||||||
|
qqdgffvdrevd2121.button(label="Complete", command=lambda x: complete(), backgroundColor=colorbuttons, height=40)
|
||||||
|
qqdgffvdrevd2121.text(label="", height=25)
|
||||||
|
qqdgffvdrevd2121.button(label="Move Independent", command=lambda x: move2target_joint(), backgroundColor=colorbuttons, height=40)
|
||||||
|
qqdgffvdrevd2121.text(label="", height=5)
|
||||||
|
qqdgffvdrevd2121.button(label="Reference Move", command=lambda x: refMove(), backgroundColor=colorbuttons, height=40)
|
||||||
|
qqdgffvdrevd2121.text(label="", height=5)
|
||||||
|
qqdgffvdrevd2121.button(label="Export", command=lambda x: export_fbx(outPath), backgroundColor=color, height=40)
|
||||||
|
qqdgffvdrevd2121.text(label="", height=5)
|
||||||
|
qqdgffvdrevd2121.text(label="ARTS AND SPELLS©2023",height=40, font="boldLabelFont")
|
||||||
|
qqdgffvdrevd2121.showWindow()
|
||||||
|
outPath = "C:\Arts and Spells"
|
174
MetaPipeFree.py
Normal file
174
MetaPipeFree.py
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
import maya.cmds as cmds
|
||||||
|
import os
|
||||||
|
import os.path as ospathe
|
||||||
|
from os import environ
|
||||||
|
from sys import path as syspath
|
||||||
|
from sys import platform
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import maya.OpenMaya as om
|
||||||
|
from maya import cmds
|
||||||
|
|
||||||
|
from os import environ, makedirs
|
||||||
|
from os import path as ospath
|
||||||
|
|
||||||
|
import BuildBodyFree
|
||||||
|
import dna_viewer
|
||||||
|
|
||||||
|
maya_version = int(cmds.about(version=True))
|
||||||
|
if maya_version == 2023:
|
||||||
|
if sys.version_info < (3, 9, 7):
|
||||||
|
raise ValueError("Python 3.9.7 or above is required. Please download correct Python Version!")
|
||||||
|
if maya_version == 2022:
|
||||||
|
if sys.version_info < (3, 7, 0):
|
||||||
|
raise ValueError("Python 3.9.7 or above is required. Please download correct Python Version!")
|
||||||
|
|
||||||
|
auto_keyframe_toggle = cmds.autoKeyframe(q=True, state=True)
|
||||||
|
|
||||||
|
if auto_keyframe_toggle:
|
||||||
|
raise ValueError("Auto Keyframe Toggle is On! Turn it of and try again.")
|
||||||
|
|
||||||
|
def OpenDNA(ROOT_DIR):
|
||||||
|
calib_check = f"{ROOT_DIR}/dna_calibration.mod"
|
||||||
|
if not os.path.isfile(calib_check):
|
||||||
|
raise ValueError("Please download Epic Games Dna Calibration 1.1.0 Version. Files not found!")
|
||||||
|
metapipe_vcheck = f"{ROOT_DIR}/Metapipe_Free.py"
|
||||||
|
if os.path.isfile(metapipe_vcheck):
|
||||||
|
raise ValueError("Old Version file found. Please delete Metapipe_Free.py file in your dna_calibration path!")
|
||||||
|
root_check = f"{ROOT_DIR}/examples/dna_viewer_grab_changes_from_scene_and_propagate_to_dna.py"
|
||||||
|
if not os.path.isfile(root_check):
|
||||||
|
raise ValueError("Please check ROOT_DIR path for the dna_calibration files! Files are not in ROOT_DIR")
|
||||||
|
dna_datas = f"{ROOT_DIR}/examples/datas_dna.py"
|
||||||
|
|
||||||
|
if not os.path.isfile(dna_datas):
|
||||||
|
raise ValueError("Please press Update button first")
|
||||||
|
import dna_viewer_run_in_maya
|
||||||
|
dna_viewer_run_in_maya.dna_viewer.show()
|
||||||
|
|
||||||
|
def codeblock (dnaPath, ROOT_DIR, CHARACTER_NAME):
|
||||||
|
output_file_path = os.path.join(f"{ROOT_DIR}/examples", "datas_dna.py")
|
||||||
|
# Open the Python file and read the lines
|
||||||
|
with open(f"{ROOT_DIR}/examples/dna_viewer_grab_changes_from_scene_and_propagate_to_dna.py") as file:
|
||||||
|
lines_all = file.readlines()
|
||||||
|
lines = lines_all[43:204]
|
||||||
|
lineslists = lines_all[211:214]
|
||||||
|
linesload = lines_all[214:220]
|
||||||
|
lines2 = lines_all[226:242]
|
||||||
|
defload = ["def load_dna_data():\n"]
|
||||||
|
defsave = ["def save_dna_data():\n"]
|
||||||
|
lines = [line.replace('f"{ospath.dirname(ospath.abspath(__file__))}/..".replace("\\\\", "/")','"'+ROOT_DIR+'"') for line in lines]
|
||||||
|
lines = [line.replace('f"{DNA_DIR}/{CHARACTER_NAME}.dna"', '"'+dnaPath+'"') for line in lines]
|
||||||
|
lines = [line.replace('"Ada"','"'+CHARACTER_NAME+'"') for line in lines]
|
||||||
|
linesload = [" " + line for line in linesload]
|
||||||
|
lines2 = [" " + line for line in lines2]
|
||||||
|
|
||||||
|
code_block = ''.join(lines + lineslists + defload + linesload + defsave + lines2)
|
||||||
|
|
||||||
|
with open(output_file_path, "w") as output_file:
|
||||||
|
output_file.write(code_block)
|
||||||
|
|
||||||
|
dnaCalibPath=ROOT_DIR
|
||||||
|
|
||||||
|
def update_dna_dir(text_dna, ROOT_DIR):
|
||||||
|
character_dna = cmds.textField(text_dna, q=True, text=True)
|
||||||
|
CHARACTER_DNA = ospathe.abspath(character_dna)
|
||||||
|
CHARACTER_DNA = CHARACTER_DNA.replace("\\", "/")
|
||||||
|
CHARACTER_NAME = os.path.basename(CHARACTER_DNA).split(".")[0]
|
||||||
|
print(f"New DNA_DIR: {CHARACTER_DNA}")
|
||||||
|
print(f"New DNA_Name: {CHARACTER_NAME}")
|
||||||
|
codeblock (CHARACTER_DNA, ROOT_DIR, CHARACTER_NAME)
|
||||||
|
return CHARACTER_DNA, CHARACTER_NAME
|
||||||
|
|
||||||
|
# Create a function that will be called when the button is clicked
|
||||||
|
def button_callback(text_field, *args):
|
||||||
|
path = cmds.textField(text_field, query=True, text=True)
|
||||||
|
run_dna_viewer(path, text_field)
|
||||||
|
cmds.scriptEditorInfo(suppressWarnings=True, echoAllCommands=False)
|
||||||
|
|
||||||
|
def prepare_export():
|
||||||
|
|
||||||
|
# Detach spine_04 from head_grp and move it to the top level of the Outliner
|
||||||
|
cmds.parent('spine_04', w=True, r=True)
|
||||||
|
|
||||||
|
if not cmds.namespace(exists="DHIhead"):
|
||||||
|
cmds.namespace(add="DHIhead", parent=":")
|
||||||
|
cmds.namespace(set="DHIhead")
|
||||||
|
cmds.namespace(set=":")
|
||||||
|
|
||||||
|
# Get a list of all the joints in the scene
|
||||||
|
joints = cmds.ls(type="joint")
|
||||||
|
|
||||||
|
# Add every joint to the "DHIhead" namespace and print a message if it already has the "DHIhead" prefix
|
||||||
|
for joint in joints:
|
||||||
|
if joint.startswith("DHIhead:"):
|
||||||
|
print(joint + " is already in the DHIhead namespace")
|
||||||
|
else:
|
||||||
|
cmds.rename(joint, "DHIhead:" + joint)
|
||||||
|
|
||||||
|
|
||||||
|
print("Ready")
|
||||||
|
|
||||||
|
def loadimport(ROOT_DIR):
|
||||||
|
dna_datas = f"{ROOT_DIR}/examples/datas_dna.py"
|
||||||
|
|
||||||
|
if not os.path.isfile(dna_datas):
|
||||||
|
raise ValueError("Please press Update button first")
|
||||||
|
sys.path.append(f"{ROOT_DIR}/examples")
|
||||||
|
import datas_dna
|
||||||
|
datas_dna.load_dna_data()
|
||||||
|
cmds.warning("Loaded Succesfully!")
|
||||||
|
def saveimport(ROOT_DIR):
|
||||||
|
sys.path.append(f"{ROOT_DIR}/examples")
|
||||||
|
import datas_dna
|
||||||
|
datas_dna.save_dna_data()
|
||||||
|
|
||||||
|
dnaPath=""
|
||||||
|
dnaCalibPath=""
|
||||||
|
def show_dna_edit_window(dnaPath, ROOT_DIR):
|
||||||
|
# Create window
|
||||||
|
window_name = "MetaPipe"
|
||||||
|
if cmds.window(window_name, exists=True):
|
||||||
|
cmds.deleteUI(window_name)
|
||||||
|
cmds.window(window_name, title=window_name, width=300, height=380, sizeable=False, resizeToFitChildren=True)
|
||||||
|
|
||||||
|
# Create layout
|
||||||
|
|
||||||
|
color = (0.164, 0.384, 0) # RGB values for #0077c2
|
||||||
|
colorbuttons = (.2, 0.2, 0.2) # RGB values for #0077c2
|
||||||
|
layout = cmds.rowColumnLayout(numberOfColumns=1, columnWidth=[(1, 150)], columnSpacing=[(1,75)], backgroundColor=(0.1, 0.1, 0.1))
|
||||||
|
|
||||||
|
cmds.text(label="", height=15)
|
||||||
|
cmds.text(label="METAPIPE DNA CALIB UI 1.2.0", height=20, font="boldLabelFont")
|
||||||
|
cmds.text(label="(Free Edition)", height=20, font="boldLabelFont")
|
||||||
|
cmds.text(label="", height=15)
|
||||||
|
cmds.text(label="Metahuman DNA:",height=20)
|
||||||
|
text_dna = cmds.textField(text=dnaPath)
|
||||||
|
cmds.text(label="", height=5)
|
||||||
|
cmds.button(label="Update", command=lambda x: update_dna_dir(text_dna, ROOT_DIR), backgroundColor=color, height=20)
|
||||||
|
cmds.text(label="", height=20)
|
||||||
|
cmds.button(label="Open DNA Viewer", command=lambda x: dna_viewer.show(), backgroundColor=colorbuttons, height=40)
|
||||||
|
cmds.text(label="", height=5)
|
||||||
|
cmds.button(label="Load Dna", command=lambda x: loadimport(ROOT_DIR), backgroundColor=colorbuttons, height=40)
|
||||||
|
cmds.text(label="", height=5)
|
||||||
|
cmds.button(label="Save Dna", command=lambda x: saveimport(ROOT_DIR), backgroundColor=colorbuttons, height=40)
|
||||||
|
cmds.text(label="", height=5)
|
||||||
|
cmds.button(label="Prepare to Export", command=lambda x: prepare_export(), backgroundColor=colorbuttons, height=40)
|
||||||
|
cmds.text(label="", height=5)
|
||||||
|
cmds.button(label="Load Body", command=lambda x: BuildBodyFree.build_body(ROOT_DIR), backgroundColor=colorbuttons, height=40)
|
||||||
|
cmds.text(label="", height=5)
|
||||||
|
cmds.button(label="Fix Body", command=lambda x: BuildBodyFree.fixbody(), backgroundColor=colorbuttons, height=40)
|
||||||
|
cmds.text(label="", height=5)
|
||||||
|
cmds.button(label="Connect Body", command=lambda x: BuildBodyFree.connect_body(), backgroundColor=colorbuttons, height=40)
|
||||||
|
cmds.text(label="", height=5)
|
||||||
|
|
||||||
|
#cmds.image(image='C:/Arts and Spells/pps.png', w=64, h=64)
|
||||||
|
cmds.text(label="ARTS AND SPELLS",height=40, font="boldLabelFont")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Show window
|
||||||
|
cmds.showWindow()
|
||||||
|
|
||||||
|
# Show window
|
||||||
|
#show_dna_edit_window(dnaPath)
|
119
MetaPipeStudio.py
Normal file
119
MetaPipeStudio.py
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
import importlib
|
||||||
|
import sys
|
||||||
|
import maya.cmds as cmds
|
||||||
|
import os
|
||||||
|
import dat
|
||||||
|
importlib.reload(dat)
|
||||||
|
from os import path as ospath
|
||||||
|
from sys import path as syspath
|
||||||
|
from sys import platform
|
||||||
|
from dat import ROOT_DIR
|
||||||
|
from dat import MAIN_PATH
|
||||||
|
from dat import MAYA_VERSION
|
||||||
|
from dat import dnaPath
|
||||||
|
from dat import body_type
|
||||||
|
|
||||||
|
ROOT_LIB_DIR = f"{ROOT_DIR}/lib/Maya{MAYA_VERSION}"
|
||||||
|
if platform == "win32":
|
||||||
|
LIB_DIR = f"{ROOT_LIB_DIR}/windows"
|
||||||
|
elif platform == "linux":
|
||||||
|
LIB_DIR = f"{ROOT_LIB_DIR}/linux"
|
||||||
|
else:
|
||||||
|
raise OSError(
|
||||||
|
"OS not supported, please compile dependencies and add value to LIB_DIR"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Adds directories to path
|
||||||
|
syspath.insert(0, ROOT_DIR)
|
||||||
|
sys.path.append(f"{ROOT_DIR}/examples")
|
||||||
|
syspath.insert(0, LIB_DIR)
|
||||||
|
sys.path.append(MAIN_PATH)
|
||||||
|
import MetaPipeFree
|
||||||
|
import BatchImport
|
||||||
|
import BuildBody_drv
|
||||||
|
import Export_FBX
|
||||||
|
import MetaTrans
|
||||||
|
import Prepare
|
||||||
|
importlib.reload(MetaPipeFree)
|
||||||
|
|
||||||
|
def studio_load_dna():
|
||||||
|
if not cmds.objExists('wpGRP'):
|
||||||
|
MetaPipeFree.loadimport(ROOT_DIR)
|
||||||
|
def repExtra(repBase, tartar):
|
||||||
|
# Define the base mesh and target mesh
|
||||||
|
base_mesh = cmds.duplicate(repBase)
|
||||||
|
cmds.rename(base_mesh, repBase + "_CS")
|
||||||
|
target_mesh = tartar
|
||||||
|
cmds.select([repBase + "_CS", target_mesh], r=True)
|
||||||
|
cmds.CreateWrap()
|
||||||
|
|
||||||
|
repExtra('cartilage_lod0_mesh', 'head_lod0_mesh')
|
||||||
|
repExtra('saliva_lod0_mesh', 'teeth_lod0_mesh')
|
||||||
|
|
||||||
|
head_mesh = 'head_lod0_mesh'
|
||||||
|
eye_meshes = ['eyeRight_lod0_mesh', 'eyeLeft_lod0_mesh'] # Replace with actual eye mesh names
|
||||||
|
|
||||||
|
# Create a group
|
||||||
|
group_name = 'wpGRP'
|
||||||
|
if not cmds.objExists(group_name):
|
||||||
|
cmds.group(em=True, name=group_name)
|
||||||
|
|
||||||
|
# Parent the head mesh and eye meshes to the group
|
||||||
|
cmds.parent(head_mesh, eye_meshes, group_name)
|
||||||
|
cmds.parent(group_name, "head_lod0_grp")
|
||||||
|
|
||||||
|
repExtra('eyeshell_lod0_mesh', 'wpGRP')
|
||||||
|
repExtra('eyeEdge_lod0_mesh', 'head_lod0_mesh')
|
||||||
|
repExtra('eyelashes_lod0_mesh', 'head_lod0_mesh')
|
||||||
|
cmds.warning("Loaded Succesfully!")
|
||||||
|
else:
|
||||||
|
cmds.warning("Already Loaded!")
|
||||||
|
def studio_save_dna(body_type):
|
||||||
|
BuildBody_drv.LODS(body_type)
|
||||||
|
MetaPipeFree.saveimport(ROOT_DIR)
|
||||||
|
|
||||||
|
#DNA Calib File Path
|
||||||
|
dnaCalibPath=ROOT_DIR
|
||||||
|
CHARACTER_NAME = os.path.basename(dnaPath).split(".")[0]
|
||||||
|
MetaPipeFree.codeblock (dnaPath, ROOT_DIR, CHARACTER_NAME)
|
||||||
|
def show_dna_edit_window():
|
||||||
|
studio_window_name = "MetaPipe Studio 2023 1.3.0"
|
||||||
|
if cmds.window(studio_window_name, exists = True):
|
||||||
|
cmds.deleteUI(studio_window_name)
|
||||||
|
cmds.window(studio_window_name, title=studio_window_name, width=350, height=550, sizeable=False, resizeToFitChildren=True)
|
||||||
|
|
||||||
|
color = (0.164, 0.384, 0) # RGB Values
|
||||||
|
colorbuttons = (.2, .2, .2)
|
||||||
|
layout = cmds.rowColumnLayout(numberOfColumns=1, columnWidth=[(1,150)], columnSpacing=[(1,100)], backgroundColor=(0.1,0.1,0.1))
|
||||||
|
|
||||||
|
cmds.text(label="", height = 25)
|
||||||
|
cmds.text(label="METAPIPE STUDIO 1.3.0", height = 40, font="boldLabelFont")
|
||||||
|
cmds.text(label="", height = 15)
|
||||||
|
cmds.text(label="Metahuman DNA", height = 20)
|
||||||
|
text_dna = cmds.textField(text=dnaPath)
|
||||||
|
cmds.text(label="", height = 5)
|
||||||
|
cmds.button(label="Update", command=lambda x: MetaPipeFree.update_dna_dir(text_dna, ROOT_DIR), backgroundColor=color, height= 20)
|
||||||
|
cmds.text(label="", height = 20)
|
||||||
|
cmds.button(label="Open DNA Viewer", command=lambda x: MetaPipeFree.OpenDNA(ROOT_DIR), backgroundColor=colorbuttons, height= 40)
|
||||||
|
cmds.text(label="", height = 5)
|
||||||
|
cmds.button(label="Load DNA", command=lambda x: studio_load_dna(), backgroundColor=colorbuttons, height= 40)
|
||||||
|
cmds.text(label="", height = 5)
|
||||||
|
cmds.button(label="Batch Import", command=lambda x: BatchImport.FileBatchImport(), backgroundColor=colorbuttons, height= 40)
|
||||||
|
cmds.text(label="", height = 5)
|
||||||
|
cmds.button(label="Joint Trns", command=lambda x: MetaTrans.joint_transformation(), backgroundColor=colorbuttons, height= 40)
|
||||||
|
cmds.text(label="", height = 5)
|
||||||
|
cmds.button(label="Save Dna", command=lambda x: studio_save_dna(body_type), backgroundColor=colorbuttons, height= 40)
|
||||||
|
cmds.text(label="", height = 5)
|
||||||
|
cmds.button(label="Prepare To Export", command=lambda x: MetaPipeFree.prepare_export(), backgroundColor=colorbuttons, height= 40)
|
||||||
|
cmds.text(label="", height = 5)
|
||||||
|
cmds.button(label="Build Body", command=lambda x: BuildBody_drv.build_body(ROOT_DIR, body_type), backgroundColor=colorbuttons, height= 40)
|
||||||
|
cmds.text(label="", height = 5)
|
||||||
|
cmds.button(label="Material Assign", command=lambda x: Prepare.matSet(), backgroundColor=colorbuttons, height= 40)
|
||||||
|
cmds.text(label="", height = 5)
|
||||||
|
cmds.button(label="Export", command=lambda x: Export_FBX.export_fbx(dnaCalibPath), backgroundColor=colorbuttons, height= 40)
|
||||||
|
cmds.text(label="", height = 5)
|
||||||
|
cmds.text(label="ARTS AND SPELLS", height = 40, font="boldLabelFont")
|
||||||
|
|
||||||
|
cmds.showWindow()
|
||||||
|
|
||||||
|
#show_dna_edit_window()
|
5
MetaPipeStudioSource.py
Normal file
5
MetaPipeStudioSource.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
ROOT_DIR = "c:/dna_calibration"
|
||||||
|
MAIN_PATH = "c:/Arts and Spells/Scripts"
|
||||||
|
MAYA_VERSION = "2023"
|
||||||
|
dnaPath= "C:/Users/Uzay/Documents/Megascans Library/Downloaded/DHI/h344NMUV_asset/1k/asset_source/MetaHumans/CustomDNA/SourceAssets/CustomDNA.dna"
|
||||||
|
body_type = "m_med_nrw"
|
597
MetaTrans.py
Normal file
597
MetaTrans.py
Normal file
@ -0,0 +1,597 @@
|
|||||||
|
#All Rights Belongs to Uzay CALISKAN
|
||||||
|
#Artstation Marketplace Standart License
|
||||||
|
|
||||||
|
import maya.cmds as qqgdshfal2121
|
||||||
|
|
||||||
|
def qqgdshfbl2121(qqgdshfcl2121):
|
||||||
|
qqgdshfdl2121 = ["upperarm_out_r", "upperarm_fwd_r", "upperarm_in_r", "upperarm_bck_r", "upperarm_out_l", "upperarm_fwd_l", "upperarm_in_l", "upperarm_bck_l", "clavicle_scap_r", "clavicle_scap_l", "clavicle_pec_r", "spine_04_latissimus_r", "clavicle_pec_l", "spine_04_latissimus_l"]
|
||||||
|
qqgdskfl2121 = [7420, 15138, 13808, 15219, 3830, 22769, 3008, 7636, 15223, 7640, 3903, 7567, 135, 3784]
|
||||||
|
qqgdshfel2121 = [[0.1699024408155907, -0.3332040870206754, -0.1930344920760314], [0.11690040570693228, 0.4939978561934879, -0.5805660764047733], [-0.2436459075293591, -0.03142811166006254, -0.3419563754727857], [0.04564125269769903, -0.2062310438095949, 0.6427715557300022], [-0.13804414820311095, -0.28261345695474915, -0.2134991563147417], [-0.7951241448210702, -0.7667491520491296, -0.5928049004566498], [-0.08825486525945436, -0.04778734136820617, -0.22201713310833826], [0.07160935714900063, -0.1496830381595089, 0.6151630903657406], [-0.17246398789486683, 0.5437517868399198, -1.6740717477777523], [0.27201854904233436, 0.5620542515761997, -1.6886435488079847], [0.550594227909599, 0.09054584226376505, 2.5818363397219883], [2.172409727224437, 0.6596836537776056, -8.546846179167737], [-0.23494616609070107, 0.13905025247231606, 2.794228629223454], [-2.1713319272131066, 0.6589998397599288, -8.546785529723104]]
|
||||||
|
def qqgdshffl2121():
|
||||||
|
qqgdshgfl2121 = qqgdshfcl2121
|
||||||
|
if not qqgdshgfl2121:
|
||||||
|
qqgdshfal2121.warning("No mesh selected.")
|
||||||
|
return
|
||||||
|
qqgdshhfl2121 = qqgdshfal2121.listRelatives(qqgdshgfl2121, shapes=True, type="mesh")
|
||||||
|
if not qqgdshhfl2121:
|
||||||
|
qqgdshfal2121.warning("Selected object is not a mesh.")
|
||||||
|
return
|
||||||
|
qqgdshhfl2121 = qqgdshhfl2121[0]
|
||||||
|
for i in range(min(len(qqgdshfdl2121), len(qqgdskfl2121))):
|
||||||
|
qqgdshifl2121 = qqgdshfdl2121[i]
|
||||||
|
qqgdshjfl2121 = qqgdskfl2121[i]
|
||||||
|
qqgdslfl2121 = "{}.vtx[{}]".format(qqgdshgfl2121, qqgdshjfl2121)
|
||||||
|
qqgdshfal2121.select(qqgdslfl2121)
|
||||||
|
qqgdsmlfl2121 = qqgdshfal2121.pointPosition(qqgdslfl2121, world=True)
|
||||||
|
qqgdshfal2121.move(qqgdsmlfl2121[0], qqgdsmlfl2121[1], qqgdsmlfl2121[2], qqgdshifl2121, absolute=True, worldSpace=True)
|
||||||
|
qqgdsnlfl2121x = qqgdshfel2121[i][0]
|
||||||
|
qqgdsnlfl2121y = qqgdshfel2121[i][1]
|
||||||
|
qqgdsnlfl2121z = qqgdshfel2121[i][2]
|
||||||
|
qqgdshfal2121.move(-qqgdsnlfl2121x,-qqgdsnlfl2121y,-qqgdsnlfl2121z,qqgdshfdl2121[i], relative=True)
|
||||||
|
qqgdshffl2121()
|
||||||
|
qqgdsolfl2121 = qqgdshfal2121.xform("upperarm_out_r", query=True, translation=True, worldSpace=True)
|
||||||
|
qqgdsolfl21212 = qqgdshfal2121.xform("upperarm_in_r", query=True, translation=True, worldSpace=True)
|
||||||
|
t = 0.5
|
||||||
|
qqgdsplfl2121 = [(qqgdsolfl2121[i] + t * (qqgdsolfl21212[i] - qqgdsolfl2121[i])) for i in range(3)]
|
||||||
|
qqgdsrlfl2121 = qqgdshfal2121.polyCube()[0]
|
||||||
|
qqgdshfal2121.xform(qqgdsrlfl2121, translation=qqgdsplfl2121, rotatePivot=qqgdsplfl2121, worldSpace=True)
|
||||||
|
qqjxeretsolfl21212 = qqgdshfal2121.xform("upperarm_r", query=True, translation=True, worldSpace=True)
|
||||||
|
midqqgdsrlfl2121_position = qqgdshfal2121.xform(qqgdsrlfl2121, query=True, translation=True, worldSpace=True)
|
||||||
|
qqgdsnlfl2121x = (midqqgdsrlfl2121_position[0] - qqjxeretsolfl21212[0])+2.34
|
||||||
|
qqgdsnlfl2121y = (midqqgdsrlfl2121_position[1] - qqjxeretsolfl21212[1])+2.18
|
||||||
|
qqgdsnlfl2121z = (midqqgdsrlfl2121_position[2] - qqjxeretsolfl21212[2])-0.26
|
||||||
|
qqgdshfal2121.delete(qqgdsrlfl2121)
|
||||||
|
qqgdshfal2121.move(qqgdsnlfl2121x,qqgdsnlfl2121y,qqgdsnlfl2121z,"upperarm_r", relative=True)
|
||||||
|
qqgdshfal2121.move(-qqgdsnlfl2121x,-qqgdsnlfl2121y,-qqgdsnlfl2121z,"upperarm_out_r", relative=True)
|
||||||
|
qqgdshfal2121.move(-qqgdsnlfl2121x,-qqgdsnlfl2121y,-qqgdsnlfl2121z,"upperarm_fwd_r", relative=True)
|
||||||
|
qqgdshfal2121.move(-qqgdsnlfl2121x,-qqgdsnlfl2121y,-qqgdsnlfl2121z,"upperarm_in_r", relative=True)
|
||||||
|
qqgdshfal2121.move(-qqgdsnlfl2121x,-qqgdsnlfl2121y,-qqgdsnlfl2121z,"upperarm_bck_r", relative=True)
|
||||||
|
qqgdsolfl2121 = qqgdshfal2121.xform("upperarm_out_l", query=True, translation=True, worldSpace=True)
|
||||||
|
qqgdsolfl21212 = qqgdshfal2121.xform("upperarm_in_l", query=True, translation=True, worldSpace=True)
|
||||||
|
t = 0.5
|
||||||
|
qqgdsplfl2121 = [(qqgdsolfl2121[i] + t * (qqgdsolfl21212[i] - qqgdsolfl2121[i])) for i in range(3)]
|
||||||
|
qqgdsrlfl2121 = qqgdshfal2121.polyCube()[0]
|
||||||
|
qqgdshfal2121.xform(qqgdsrlfl2121, translation=qqgdsplfl2121, rotatePivot=qqgdsplfl2121, worldSpace=True)
|
||||||
|
qqjxeretsolfl21212 = qqgdshfal2121.xform("upperarm_l", query=True, translation=True, worldSpace=True)
|
||||||
|
midqqgdsrlfl2121_position = qqgdshfal2121.xform(qqgdsrlfl2121, query=True, translation=True, worldSpace=True)
|
||||||
|
qqgdsnlfl2121x = (midqqgdsrlfl2121_position[0] - qqjxeretsolfl21212[0])-2.34
|
||||||
|
qqgdsnlfl2121y = (midqqgdsrlfl2121_position[1] - qqjxeretsolfl21212[1])+2.18
|
||||||
|
qqgdsnlfl2121z = (midqqgdsrlfl2121_position[2] - qqjxeretsolfl21212[2])-0.26
|
||||||
|
qqgdshfal2121.delete(qqgdsrlfl2121)
|
||||||
|
qqgdshfal2121.move(qqgdsnlfl2121x,qqgdsnlfl2121y,qqgdsnlfl2121z,"upperarm_l", relative=True)
|
||||||
|
qqgdshfal2121.move(-qqgdsnlfl2121x,-qqgdsnlfl2121y,-qqgdsnlfl2121z,"upperarm_out_l", relative=True)
|
||||||
|
qqgdshfal2121.move(-qqgdsnlfl2121x,-qqgdsnlfl2121y,-qqgdsnlfl2121z,"upperarm_fwd_l", relative=True)
|
||||||
|
qqgdshfal2121.move(-qqgdsnlfl2121x,-qqgdsnlfl2121y,-qqgdsnlfl2121z,"upperarm_in_l", relative=True)
|
||||||
|
qqgdshfal2121.move(-qqgdsnlfl2121x,-qqgdsnlfl2121y,-qqgdsnlfl2121z,"upperarm_bck_l", relative=True)
|
||||||
|
qqjxerjolfl21212 = [55,63]
|
||||||
|
qqgdslfl2121 = "{}.vtx[{}]".format(qqgdshfcl2121, qqjxerjolfl21212[0])
|
||||||
|
qqgdslfl21212 = "{}.vtx[{}]".format(qqgdshfcl2121, qqjxerjolfl21212[1])
|
||||||
|
qqgdsmlfl2121 = qqgdshfal2121.pointPosition(qqgdslfl2121, world=True)
|
||||||
|
qqgdsmlfl21212 = qqgdshfal2121.pointPosition(qqgdslfl21212, world=True)
|
||||||
|
qqgdsplfl2121 = [(qqgdsmlfl2121[i] + t * (qqgdsmlfl21212[i] - qqgdsmlfl2121[i])) for i in range(3)]
|
||||||
|
qqjxerjqwel21212 = qqgdshfal2121.xform("spine_04", query=True, translation=True, worldSpace=True)
|
||||||
|
qqgdsnlfl2121x = (qqgdsplfl2121[0] - qqjxerjqwel21212[0])
|
||||||
|
qqgdsnlfl2121y = (qqgdsplfl2121[1] - qqjxerjqwel21212[1])-0.28812594771619615
|
||||||
|
qqgdsnlfl2121z = (qqgdsplfl2121[2] - qqjxerjqwel21212[2])+0.885471853421449
|
||||||
|
qqgdshfal2121.move(0,qqgdsnlfl2121y,qqgdsnlfl2121z,"spine_04", relative=True)
|
||||||
|
qqgdshfal2121.move(0,-qqgdsnlfl2121y,-qqgdsnlfl2121z,"spine_05", relative=True)
|
||||||
|
qqgdssslfl2121 = qqgdshfal2121.xform("spine_04", query=True, translation=True, worldSpace=True)
|
||||||
|
qqgdssslfl21212 = qqgdshfal2121.xform("neck_01", query=True, translation=True, worldSpace=True)
|
||||||
|
t = 0.6
|
||||||
|
qqgdsplfl2121 = [(qqgdssslfl2121[i] + t * (qqgdssslfl21212[i] - qqgdssslfl2121[i])) for i in range(3)]
|
||||||
|
qqgdstslfl2121 = qqgdshfal2121.listRelatives("spine_05", c=True, type="joint")
|
||||||
|
qqgdutslfl2121 = []
|
||||||
|
for child_joint in qqgdstslfl2121:
|
||||||
|
qqgdutslfl2121.append(qqgdshfal2121.xform(child_joint, q=True, ws=True, t=True))
|
||||||
|
qqgdshfal2121.xform("spine_05", translation=qqgdsplfl2121, rotatePivot=qqgdsplfl2121, worldSpace=True)
|
||||||
|
for i, child_joint in enumerate(qqgdstslfl2121):
|
||||||
|
qqgdshfal2121.xform(child_joint, ws=True, t=qqgdutslfl2121[i])
|
||||||
|
# Get vertex position
|
||||||
|
vertex_positionJaw = qqgdshfal2121.pointPosition("head_lod0_mesh.vtx[17640]", world=True)
|
||||||
|
qqgdzqzqwersstslfl2121 = qqgdshfal2121.xform("clavicle_r", query=True, translation=True, worldSpace=True)
|
||||||
|
qqgdzqaqwersstslfl2121 = qqgdshfal2121.listRelatives("clavicle_r", c=True, type="joint")
|
||||||
|
qqgdzqbqwersstslfl2121 = []
|
||||||
|
for child_joint in qqgdzqaqwersstslfl2121:
|
||||||
|
qqgdzqbqwersstslfl2121.append(qqgdshfal2121.xform(child_joint, q=True, ws=True, t=True))
|
||||||
|
# Set new joint position using vertex y-coordinate
|
||||||
|
qqgdshfal2121.xform("clavicle_r", translation=(vertex_positionJaw[0], qqgdzqzqwersstslfl2121[1], qqgdzqzqwersstslfl2121[2]), worldSpace=True)
|
||||||
|
|
||||||
|
for i, child_joint in enumerate(qqgdzqaqwersstslfl2121):
|
||||||
|
qqgdshfal2121.xform(child_joint, ws=True, t=qqgdzqbqwersstslfl2121[i])
|
||||||
|
# Get vertex position
|
||||||
|
vertex_positionJaw = qqgdshfal2121.pointPosition("head_lod0_mesh.vtx[11591]", world=True)
|
||||||
|
qqgdzqzqwersstslfl2121 = qqgdshfal2121.xform("clavicle_l", query=True, translation=True, worldSpace=True)
|
||||||
|
qqgdzqaqwersstslfl2121 = qqgdshfal2121.listRelatives("clavicle_l", c=True, type="joint")
|
||||||
|
qqgdzqbqwersstslfl2121 = []
|
||||||
|
for child_joint in qqgdzqaqwersstslfl2121:
|
||||||
|
qqgdzqbqwersstslfl2121.append(qqgdshfal2121.xform(child_joint, q=True, ws=True, t=True))
|
||||||
|
# Set new joint position using vertex y-coordinate
|
||||||
|
qqgdshfal2121.xform("clavicle_l", translation=(vertex_positionJaw[0], qqgdzqzqwersstslfl2121[1], qqgdzqzqwersstslfl2121[2]), worldSpace=True)
|
||||||
|
|
||||||
|
for i, child_joint in enumerate(qqgdzqaqwersstslfl2121):
|
||||||
|
qqgdshfal2121.xform(child_joint, ws=True, t=qqgdzqbqwersstslfl2121[i])
|
||||||
|
def qqgdutylfl2121():
|
||||||
|
import maya.cmds as qqgdshfal2121
|
||||||
|
def qqgdutzzzl2121(qqgduabgzl2121, target, qqgduacgzl2121):
|
||||||
|
import math
|
||||||
|
qqgdutzazl2121 = qqgdshfal2121.exactWorldBoundingBox(qqgduacgzl2121)
|
||||||
|
center = [
|
||||||
|
(qqgdutzazl2121[0] + qqgdutzazl2121[3]) / 2.0,
|
||||||
|
(qqgdutzazl2121[1] + qqgdutzazl2121[4]) / 2.0,
|
||||||
|
(qqgdutzazl2121[2] + qqgdutzazl2121[5]) / 2.0
|
||||||
|
]
|
||||||
|
qqgdutzbzl2121 = qqgdutzazl2121[2]
|
||||||
|
qqgdutzczl2121 = qqgdutzazl2121[5]
|
||||||
|
qqgdutzdzl2121 = qqgdshfal2121.xform(qqgduabgzl2121, query=True, worldSpace=True, rotatePivot=True)
|
||||||
|
qqgdutzezl2121 = qqgdshfal2121.xform(target, query=True, worldSpace=True, rotatePivot=True)
|
||||||
|
qqgdutzgzl2121 = qqgdutzdzl2121[2]
|
||||||
|
positionRatio = (qqgdutzgzl2121 - qqgdutzbzl2121)/(qqgdutzczl2121 - qqgdutzbzl2121)
|
||||||
|
qqgdutzazl2121 = qqgdshfal2121.exactWorldBoundingBox(target)
|
||||||
|
center = [
|
||||||
|
(qqgdutzazl2121[0] + qqgdutzazl2121[3]) / 2.0,
|
||||||
|
(qqgdutzazl2121[1] + qqgdutzazl2121[4]) / 2.0,
|
||||||
|
(qqgdutzazl2121[2] + qqgdutzazl2121[5]) / 2.0
|
||||||
|
]
|
||||||
|
qqgdutzbzl2121 = qqgdutzazl2121[2]
|
||||||
|
qqgdutzczl2121 = qqgdutzazl2121[5]
|
||||||
|
qqgduaagzl2121 = (qqgdutzczl2121 - qqgdutzbzl2121) * (positionRatio - 0.5)
|
||||||
|
qqgdshfal2121.xform(qqgduabgzl2121, translation=qqgdutzezl2121, worldSpace=True)
|
||||||
|
qqgdshfal2121.move(0, 0, qqgduaagzl2121, qqgduabgzl2121, relative=True)
|
||||||
|
qqgdutzzzl2121("FACIAL_R_Eye", "eyeRight", "eyeRight_lod0_mesh")
|
||||||
|
qqgdutzzzl2121("FACIAL_L_Eye", "eyeLeft", "eyeLeft_lod0_mesh")
|
||||||
|
def joint_transformation ():
|
||||||
|
import maya.cmds as qqgdshfal2121
|
||||||
|
import sys
|
||||||
|
qqgdshfcl2121 = qqgdshfal2121.ls(selection=True)
|
||||||
|
tar = "head_lod0_mesh"
|
||||||
|
for obj in qqgdshfcl2121:
|
||||||
|
qqgdshfdsdual2991 = 0
|
||||||
|
qqgdshfdsdual2891 = qqgdshfal2121.polyEvaluate(obj, vertex=True)
|
||||||
|
if qqgdshfdsdual2891 == 24049:
|
||||||
|
qqgdshfal2121.rename(obj, "CustomShape")
|
||||||
|
qqgdshfdsdual2991 = 1
|
||||||
|
continue
|
||||||
|
elif qqgdshfdsdual2891 == 4246:
|
||||||
|
qqgdshfal2121.rename(obj, "teeth_lod0_mesh_CS")
|
||||||
|
qqgdshfdsdual2991 = 1
|
||||||
|
continue
|
||||||
|
elif qqgdshfdsdual2891 == 660:
|
||||||
|
qqgdshfal2121.rename(obj, "saliva_lod0_mesh_CBS")
|
||||||
|
qqgdshfdsdual2991 = 1
|
||||||
|
continue
|
||||||
|
elif qqgdshfdsdual2891 == 770:
|
||||||
|
if not qqgdshfal2121.objExists("eyeLeft_lod0_mesh_CS1"):
|
||||||
|
qqgdshfal2121.rename(obj, "eyeLeft_lod0_mesh_CS")
|
||||||
|
qqgdshfdsdual2991 = 1
|
||||||
|
else:
|
||||||
|
qqgdshfal2121.error("1 or more of your Custom Mesh Topology not matching!")
|
||||||
|
continue
|
||||||
|
elif qqgdshfdsdual2891 == 552:
|
||||||
|
qqgdshfal2121.rename(obj, "eyeshell_lod0_mesh_CBS")
|
||||||
|
qqgdshfdsdual2991 = 1
|
||||||
|
continue
|
||||||
|
elif qqgdshfdsdual2891 == 2144:
|
||||||
|
qqgdshfal2121.rename(obj, "eyelashes_lod0_mesh_CBS")
|
||||||
|
qqgdshfdsdual2991 = 1
|
||||||
|
continue
|
||||||
|
elif qqgdshfdsdual2891 == 268:
|
||||||
|
qqgdshfal2121.rename(obj, "eyeEdge_lod0_mesh_CBS")
|
||||||
|
qqgdshfdsdual2991 = 1
|
||||||
|
continue
|
||||||
|
elif qqgdshfdsdual2891 == 386:
|
||||||
|
qqgdshfal2121.rename(obj, "cartilage_lod0_mesh_CBS")
|
||||||
|
qqgdshfdsdual2991 = 1
|
||||||
|
continue
|
||||||
|
elif qqgdshfdsdual2891 == 30455:
|
||||||
|
qqgdshfal2121.rename(obj, "body_mesh_CS")
|
||||||
|
qqgdshfdsdual2991 = 1
|
||||||
|
continue
|
||||||
|
if qqgdshfdsdual2991 == 0:
|
||||||
|
if not qqgdshfal2121.objExists("eyeLeft_lod0_mesh_CS1"):
|
||||||
|
qqgdshfal2121.rename(obj, "eyeLeft_lod0_mesh_CS")
|
||||||
|
qqgdshfdsdual2991 = 1
|
||||||
|
else:
|
||||||
|
qqgdshfal2121.error("1 or more of your Custom Mesh Topology not matching!")
|
||||||
|
|
||||||
|
if not qqgdshfal2121.objExists("CustomShape"):
|
||||||
|
qqgdshfal2121.error("Custom Head Mesh is missing or topology is not matching!")
|
||||||
|
qqgdshfal2121.blendShape(tar, automatic=True)
|
||||||
|
qqgdshfal2121.rename("blendShape1", "TargetBS")
|
||||||
|
qqgduaegzl2121 = qqgdshfal2121.listRelatives(tar, shapes=True, fullPath=True)
|
||||||
|
qqgdshfal2121.blendShape("TargetBS", edit=True, target=[(qqgduaegzl2121[0], 0.0, "CustomShape", 1.0)])
|
||||||
|
qqgdshfcl2121 = qqgdshfal2121.ls(selection=True)
|
||||||
|
|
||||||
|
is_hidden0 = qqgdshfal2121.getAttr("eyeLeft_lod0_mesh_CS" + ".visibility") == 0
|
||||||
|
is_hidden1 = qqgdshfal2121.getAttr("eyeLeft_lod0_mesh_CS1" + ".visibility") == 0
|
||||||
|
if is_hidden0 or is_hidden1:
|
||||||
|
qqgdshfal2121.setAttr("eyeLeft_lod0_mesh_CS" + ".visibility", 1)
|
||||||
|
qqgdshfal2121.setAttr("eyeLeft_lod0_mesh_CS1" + ".visibility", 1)
|
||||||
|
qqgdshfal2121.xform("eyeLeft_lod0_mesh_CS", centerPivots=True)
|
||||||
|
qqgdshfal2121.xform("eyeLeft_lod0_mesh_CS1", centerPivots=True)
|
||||||
|
pos1 = qqgdshfal2121.xform("eyeLeft_lod0_mesh_CS", query=True, worldSpace=True, rotatePivot=True)
|
||||||
|
pos2 = qqgdshfal2121.xform("eyeLeft_lod0_mesh_CS1", query=True, worldSpace=True, rotatePivot=True)
|
||||||
|
if pos1[0] > 0 and pos2[0] > 0:
|
||||||
|
print("Both eyes are on the positive X side of the origin")
|
||||||
|
elif pos1[0] < 0 and pos2[0] < 0:
|
||||||
|
print("Both eyes are on the negative X side of the origin")
|
||||||
|
elif pos1[0] < 0 and pos2[0] > 0:
|
||||||
|
if qqgdshfal2121.objExists("eyeRight") or qqgdshfal2121.objExists("eyeLeft"):
|
||||||
|
print("Eye names already exist, Delete or rename them")
|
||||||
|
else:
|
||||||
|
qqgdshfal2121.rename("eyeLeft_lod0_mesh_CS", "eyeRight")
|
||||||
|
qqgdshfal2121.rename("eyeLeft_lod0_mesh_CS1", "eyeLeft")
|
||||||
|
elif pos1[0] > 0 and pos2[0] < 0:
|
||||||
|
if qqgdshfal2121.objExists("eyeRight") or qqgdshfal2121.objExists("eyeLeft"):
|
||||||
|
print("Eye names already exist, Delete or rename them")
|
||||||
|
else:
|
||||||
|
qqgdshfal2121.rename("eyeLeft_lod0_mesh_CS", "eyeLeft")
|
||||||
|
qqgdshfal2121.rename("eyeLeft_lod0_mesh_CS1", "eyeRight")
|
||||||
|
elif pos1[0] == 0 or pos2[0] == 0:
|
||||||
|
print("Eye is in the middle")
|
||||||
|
qqgdshfal2121.setAttr("eyeRight" + ".visibility", 0)
|
||||||
|
qqgdshfal2121.setAttr("eyeLeft" + ".visibility", 0)
|
||||||
|
qqgdutylfl2121()
|
||||||
|
qqgduaggzl2121 = "body_mesh_CS"
|
||||||
|
import maya.cmds as qqgdshfal2121
|
||||||
|
#Adding the new chaind depth attribute
|
||||||
|
def qqgduahgzl2121(joints):
|
||||||
|
for joint in joints:
|
||||||
|
if not qqgdshfal2121.attributeQuery('qqsgdsbzl2121', node=joint, exists=True):
|
||||||
|
qqgdshfal2121.addAttr(joint, longName='qqsgdsbzl2121', attributeType='long', defaultValue=0)
|
||||||
|
qqgdshfal2121.setAttr(joint + '.qqsgdsbzl2121', keyable=True)
|
||||||
|
def qqgduajgzl2121(joints, value):
|
||||||
|
for joint in joints:
|
||||||
|
qqgdshfal2121.setAttr(joint + '.qqsgdsbzl2121', value)
|
||||||
|
qqgduajkzl2121 = qqgdshfal2121.ls(type="joint")
|
||||||
|
qqgduahgzl2121(qqgduajkzl2121)
|
||||||
|
qqgdlajkzl2121 = [joint for joint in qqgduajkzl2121 if not qqgdshfal2121.listRelatives(joint, children=True, type='joint')]
|
||||||
|
qqgdlamkzl2121 = 'FACIAL_C_TeethLower'
|
||||||
|
qqgdstslfl2121 = qqgdshfal2121.listRelatives(qqgdlamkzl2121, allDescendents=True, type='joint')
|
||||||
|
qqtrewzxjuzztru2121 = [qqgdlamkzl2121] + qqgdstslfl2121 + ['FACIAL_R_Pupil', 'FACIAL_L_Pupil']
|
||||||
|
qqgdlannkzl2121 = [joint for joint in qqgduajkzl2121 if not qqgdshfal2121.listRelatives(joint, children=True, type='joint')
|
||||||
|
and joint not in qqtrewzxjuzztru2121]
|
||||||
|
l1 = qqgdshfal2121.ls('FACIAL_L_EyelidUpperA1', type='joint')
|
||||||
|
l2 = qqgdshfal2121.ls('FACIAL_L_EyelidUpperA2', type='joint')
|
||||||
|
l3 = qqgdshfal2121.ls('FACIAL_L_EyelidUpperA3', type='joint')
|
||||||
|
r1 = qqgdshfal2121.ls('FACIAL_L_EyelidUpperA1', type='joint')
|
||||||
|
r2 = qqgdshfal2121.ls('FACIAL_L_EyelidUpperA2', type='joint')
|
||||||
|
r3 = qqgdshfal2121.ls('FACIAL_L_EyelidUpperA3', type='joint')
|
||||||
|
qqsgdlannkzl2121 = [l1[0], l2[0], l3[0]]
|
||||||
|
qqsgdlannkzl2121_r = [r1[0], r2[0], r3[0]]
|
||||||
|
qqsgnnkzl2121 = []
|
||||||
|
for joint in qqsgdlannkzl2121:
|
||||||
|
qqsgbbzl2121 = qqgdshfal2121.xform(joint, query=True, worldSpace=True, translation=True)
|
||||||
|
qqsgnnkzl2121.append(qqsgbbzl2121)
|
||||||
|
qqrtjwfffhzl2121 = len(qqsgnnkzl2121)
|
||||||
|
if qqrtjwfffhzl2121 > 0:
|
||||||
|
qqsgjjkzl2121 = [sum(coord) / qqrtjwfffhzl2121 for coord in zip(*qqsgnnkzl2121)]
|
||||||
|
else:
|
||||||
|
qqsgjjkzl2121 = [0, 0, 0]
|
||||||
|
for joint in qqsgdlannkzl2121:
|
||||||
|
qqgdlamkzl2121=qqgdshfal2121.ls(joint)[0]
|
||||||
|
qqsgbbzl2121 = qqgdshfal2121.xform(joint, query=True, worldSpace=True, translation=True)
|
||||||
|
qqgdsnlfl2121_center_x= qqsgbbzl2121[0] - qqsgjjkzl2121[0]
|
||||||
|
qqgdsnlfl2121_center_y= qqsgbbzl2121[1] - qqsgjjkzl2121[1]
|
||||||
|
qqgdsnlfl2121_center_z= qqsgbbzl2121[2] - qqsgjjkzl2121[2]
|
||||||
|
if not qqgdshfal2121.attributeQuery("dc_x", node=qqgdlamkzl2121, exists=True):
|
||||||
|
qqgdshfal2121.addAttr(qqgdlamkzl2121, ln="dc_x", at="double")
|
||||||
|
if not qqgdshfal2121.attributeQuery("dc_y", node=qqgdlamkzl2121, exists=True):
|
||||||
|
qqgdshfal2121.addAttr(qqgdlamkzl2121, ln="dc_y", at="double")
|
||||||
|
if not qqgdshfal2121.attributeQuery("dc_z", node=qqgdlamkzl2121, exists=True):
|
||||||
|
qqgdshfal2121.addAttr(qqgdlamkzl2121, ln="dc_z", at="double")
|
||||||
|
qqgdshfal2121.setAttr(qqgdlamkzl2121 + ".dc_x", qqgdsnlfl2121_center_x)
|
||||||
|
qqgdshfal2121.setAttr(qqgdlamkzl2121 + ".dc_y", qqgdsnlfl2121_center_y)
|
||||||
|
qqgdshfal2121.setAttr(qqgdlamkzl2121 + ".dc_z", qqgdsnlfl2121_center_z)
|
||||||
|
qqsgnnkzl2121 = []
|
||||||
|
for joint in qqsgdlannkzl2121_r:
|
||||||
|
qqsgbbzl2121 = qqgdshfal2121.xform(joint, query=True, worldSpace=True, translation=True)
|
||||||
|
qqsgnnkzl2121.append(qqsgbbzl2121)
|
||||||
|
qqrtjwfffhzl2121 = len(qqsgnnkzl2121)
|
||||||
|
if qqrtjwfffhzl2121 > 0:
|
||||||
|
qqsgjjkzl2121 = [sum(coord) / qqrtjwfffhzl2121 for coord in zip(*qqsgnnkzl2121)]
|
||||||
|
else:
|
||||||
|
qqsgjjkzl2121 = [0, 0, 0]
|
||||||
|
for joint in qqsgdlannkzl2121_r:
|
||||||
|
qqgdlamkzl2121=qqgdshfal2121.ls(joint)[0]
|
||||||
|
qqsgbbzl2121 = qqgdshfal2121.xform(joint, query=True, worldSpace=True, translation=True)
|
||||||
|
qqgdsnlfl2121_center_x= qqsgbbzl2121[0] - qqsgjjkzl2121[0]
|
||||||
|
qqgdsnlfl2121_center_y= qqsgbbzl2121[1] - qqsgjjkzl2121[1]
|
||||||
|
qqgdsnlfl2121_center_z= qqsgbbzl2121[2] - qqsgjjkzl2121[2]
|
||||||
|
if not qqgdshfal2121.attributeQuery("dc_x", node=qqgdlamkzl2121, exists=True):
|
||||||
|
qqgdshfal2121.addAttr(qqgdlamkzl2121, ln="dc_x", at="double")
|
||||||
|
if not qqgdshfal2121.attributeQuery("dc_y", node=qqgdlamkzl2121, exists=True):
|
||||||
|
qqgdshfal2121.addAttr(qqgdlamkzl2121, ln="dc_y", at="double")
|
||||||
|
if not qqgdshfal2121.attributeQuery("dc_z", node=qqgdlamkzl2121, exists=True):
|
||||||
|
qqgdshfal2121.addAttr(qqgdlamkzl2121, ln="dc_z", at="double")
|
||||||
|
qqgdshfal2121.setAttr(qqgdlamkzl2121 + ".dc_x", qqgdsnlfl2121_center_x)
|
||||||
|
qqgdshfal2121.setAttr(qqgdlamkzl2121 + ".dc_y", qqgdsnlfl2121_center_y)
|
||||||
|
qqgdshfal2121.setAttr(qqgdlamkzl2121 + ".dc_z", qqgdsnlfl2121_center_z)
|
||||||
|
qqgduajgzl2121(qqgduajkzl2121, 100)
|
||||||
|
qqgduajgzl2121(qqgdlajkzl2121, 0)
|
||||||
|
qqsgcsbzl2121 = []
|
||||||
|
for qqgdlamkzl2121 in qqgdlajkzl2121:
|
||||||
|
qqsgdsczl2121 = qqgdshfal2121.listRelatives(qqgdlamkzl2121, parent=True, type="joint")
|
||||||
|
if qqsgdsczl2121:
|
||||||
|
children = qqgdshfal2121.listRelatives(qqsgdsczl2121, children=True, type="joint") or []
|
||||||
|
if all(qqgdshfal2121.getAttr(child + ".qqsgdsbzl2121") == 0 for child in children):
|
||||||
|
qqsgcsbzl2121.append(qqsgdsczl2121[0])
|
||||||
|
qqgduajgzl2121(qqsgcsbzl2121, 1)
|
||||||
|
qqsgdsbzl2121 = 1
|
||||||
|
while qqsgcsbzl2121:
|
||||||
|
qqsgdsbzl2121 += 1
|
||||||
|
qqsgdsdzl2121 = []
|
||||||
|
for qqgdlamkzl2121 in qqsgcsbzl2121:
|
||||||
|
qqsgdsczl2121 = qqgdshfal2121.listRelatives(qqgdlamkzl2121, parent=True, type="joint")
|
||||||
|
if qqsgdsczl2121:
|
||||||
|
children = qqgdshfal2121.listRelatives(qqsgdsczl2121, children=True, type="joint") or []
|
||||||
|
if all(qqgdshfal2121.getAttr(child + ".qqsgdsbzl2121") < qqsgdsbzl2121 for child in children):
|
||||||
|
qqsgdsdzl2121.append(qqsgdsczl2121[0])
|
||||||
|
if qqsgdsdzl2121:
|
||||||
|
qqgduajgzl2121(qqsgdsdzl2121, qqsgdsbzl2121)
|
||||||
|
qqsgcsbzl2121 = qqsgdsdzl2121
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
qqsgdsezl2121 = []
|
||||||
|
qqrtedsfgzl2121 = []
|
||||||
|
qqsgdsfgzl2121 = []
|
||||||
|
qrtedsfgzl2121 = []
|
||||||
|
for qqgdlamkzl2121 in qqgdlannkzl2121:
|
||||||
|
qqrtedasfgzl2121 = "head_lod0_mesh"
|
||||||
|
qqrtebasfgzl2121 = qqgdshfal2121.xform(qqgdlamkzl2121, query=True, worldSpace=True, translation=True)
|
||||||
|
qqrtebcsfgzl2121 = qqgdshfal2121.createNode("closestPointOnMesh")
|
||||||
|
qqgdshfal2121.connectAttr(qqrtedasfgzl2121 + ".worldMesh", qqrtebcsfgzl2121 + ".inMesh")
|
||||||
|
qqgdshfal2121.setAttr(qqrtebcsfgzl2121 + ".inPosition", qqrtebasfgzl2121[0], qqrtebasfgzl2121[1], qqrtebasfgzl2121[2])
|
||||||
|
qqrtedcsfgzl2121 = qqgdshfal2121.getAttr(qqrtebcsfgzl2121 + ".closestVertexIndex")
|
||||||
|
qqgdshfal2121.delete(qqrtebcsfgzl2121)
|
||||||
|
vertex = qqrtedasfgzl2121 + ".vtx[{}]".format(qqrtedcsfgzl2121)
|
||||||
|
qqgdshfal2121.select(vertex, replace=True)
|
||||||
|
for i in range(1):
|
||||||
|
qqrteecslklkzl2121 = qqgdshfal2121.ls(selection=True, flatten=True)
|
||||||
|
qqrteecsfgzl2121 = []
|
||||||
|
for vertex in qqrteecslklkzl2121:
|
||||||
|
qqrteecsfgzl2121.extend(qqgdshfal2121.polyListComponentConversion(vertex, fromVertex=True, toEdge=True))
|
||||||
|
qqgdshfal2121.select(qqrteecsfgzl2121)
|
||||||
|
qqrteecsfgzl2121 = qqgdshfal2121.ls(selection=True, flatten=True)
|
||||||
|
qqrteecslklkzl2121 = []
|
||||||
|
for edge in qqrteecsfgzl2121:
|
||||||
|
qqrteecslklkzl2121.extend(qqgdshfal2121.polyListComponentConversion(edge, fromEdge=True, toVertex=True))
|
||||||
|
qqgdshfal2121.select(qqrteecslklkzl2121)
|
||||||
|
qqrteecslklkzl2121 = qqgdshfal2121.ls(selection=True, flatten=True)
|
||||||
|
qqgdsmlfl2121_before = []
|
||||||
|
for vertex in qqrteecslklkzl2121:
|
||||||
|
position = qqgdshfal2121.pointPosition(vertex, world=True)
|
||||||
|
qqgdsmlfl2121_before.append(position)
|
||||||
|
qqgdshfal2121.setAttr("TargetBS.CustomShape", 1)
|
||||||
|
qqgdsmlfl2121_after = []
|
||||||
|
for vertex in qqrteecslklkzl2121:
|
||||||
|
position = qqgdshfal2121.pointPosition(vertex, world=True)
|
||||||
|
qqgdsmlfl2121_after.append(position)
|
||||||
|
qqgdsnlfl2121_vertex = []
|
||||||
|
for i in range(len(qqgdsmlfl2121_after)):
|
||||||
|
sub_qqgdsnlfl2121 = []
|
||||||
|
for j in range(3):
|
||||||
|
sub_qqgdsnlfl2121.append(qqgdsmlfl2121_after[i][j] - qqgdsmlfl2121_before[i][j])
|
||||||
|
qqgdsnlfl2121_vertex.append(sub_qqgdsnlfl2121)
|
||||||
|
qqrtakzl2121 = [sum(x) / len(x) for x in zip(*qqgdsnlfl2121_vertex)]
|
||||||
|
qqgdsnlfl2121_x = qqrtakzl2121[0]
|
||||||
|
qqgdsnlfl2121_y = qqrtakzl2121[1]
|
||||||
|
qqgdsnlfl2121_z = qqrtakzl2121[2]
|
||||||
|
if not qqgdshfal2121.attributeQuery("qqgdsnlfl2121_x", node=qqgdlamkzl2121, exists=True):
|
||||||
|
qqgdshfal2121.addAttr(qqgdlamkzl2121, ln="qqgdsnlfl2121_x", at="double")
|
||||||
|
if not qqgdshfal2121.attributeQuery("qqgdsnlfl2121_y", node=qqgdlamkzl2121, exists=True):
|
||||||
|
qqgdshfal2121.addAttr(qqgdlamkzl2121, ln="qqgdsnlfl2121_y", at="double")
|
||||||
|
if not qqgdshfal2121.attributeQuery("qqgdsnlfl2121_z", node=qqgdlamkzl2121, exists=True):
|
||||||
|
qqgdshfal2121.addAttr(qqgdlamkzl2121, ln="qqgdsnlfl2121_z", at="double")
|
||||||
|
qqgdshfal2121.setAttr(qqgdlamkzl2121 + ".qqgdsnlfl2121_x", qqgdsnlfl2121_x)
|
||||||
|
qqgdshfal2121.setAttr(qqgdlamkzl2121 + ".qqgdsnlfl2121_y", qqgdsnlfl2121_y)
|
||||||
|
qqgdshfal2121.setAttr(qqgdlamkzl2121 + ".qqgdsnlfl2121_z", qqgdsnlfl2121_z)
|
||||||
|
qqgdshfal2121.setAttr("TargetBS.CustomShape", 0)
|
||||||
|
qqsgdsezl2121.append(qqgdlamkzl2121)
|
||||||
|
qqrtedsfgzl2121.append(qqgdsnlfl2121_x)
|
||||||
|
qqsgdsfgzl2121.append(qqgdsnlfl2121_y)
|
||||||
|
qrtedsfgzl2121.append(qqgdsnlfl2121_z)
|
||||||
|
for i in range(len(qqsgdsezl2121)):
|
||||||
|
qqgdshfal2121.move(qqrtedsfgzl2121[i], qqsgdsfgzl2121[i], qrtedsfgzl2121[i], qqsgdsezl2121[i], relative=True)
|
||||||
|
qqrtckzl2121 = 1
|
||||||
|
qqrtbkzl2121 = 0
|
||||||
|
maxqqrtckzl2121 = 11
|
||||||
|
while qqrtckzl2121 <= maxqqrtckzl2121:
|
||||||
|
qqrtfeezl2121 = [joint for joint in qqgduajkzl2121 if qqgdshfal2121.getAttr(joint + ".qqsgdsbzl2121") == qqrtckzl2121]
|
||||||
|
qqrtdezl2121 = [joint for joint in qqgduajkzl2121 if qqgdshfal2121.getAttr(joint + ".qqsgdsbzl2121") == qqrtbkzl2121]
|
||||||
|
for qqgdlamkzl2121 in qqrtfeezl2121:
|
||||||
|
qqrtfehzl2121 = qqgdshfal2121.xform(qqgdlamkzl2121, q=True, ws=True, translation=True)
|
||||||
|
qqgdstslfl2121 = qqgdshfal2121.listRelatives(qqgdlamkzl2121, children=True, type="joint")
|
||||||
|
qqrtjjjhzl2121 = []
|
||||||
|
if qqgdstslfl2121:
|
||||||
|
qqrtfegzl2121 = []
|
||||||
|
for child_joint in qqgdstslfl2121:
|
||||||
|
if child_joint in qqrtdezl2121 and child_joint not in qqtrewzxjuzztru2121:
|
||||||
|
qqgdsnlfl2121_x = qqgdshfal2121.getAttr(child_joint + '.qqgdsnlfl2121_x')
|
||||||
|
qqgdsnlfl2121_y = qqgdshfal2121.getAttr(child_joint + '.qqgdsnlfl2121_y')
|
||||||
|
qqgdsnlfl2121_z = qqgdshfal2121.getAttr(child_joint + '.qqgdsnlfl2121_z')
|
||||||
|
qqrtfegzl2121.append([qqgdsnlfl2121_x, qqgdsnlfl2121_y, qqgdsnlfl2121_z])
|
||||||
|
if child_joint in qqgdlajkzl2121 and child_joint not in qqtrewzxjuzztru2121:
|
||||||
|
qqgdsnlfl2121_x = qqgdshfal2121.getAttr(child_joint + '.qqgdsnlfl2121_x')
|
||||||
|
qqgdsnlfl2121_y = qqgdshfal2121.getAttr(child_joint + '.qqgdsnlfl2121_y')
|
||||||
|
qqgdsnlfl2121_z = qqgdshfal2121.getAttr(child_joint + '.qqgdsnlfl2121_z')
|
||||||
|
qqrtfegzl2121.append([qqgdsnlfl2121_x, qqgdsnlfl2121_y, qqgdsnlfl2121_z])
|
||||||
|
qqrtfegzl2121.append([qqgdsnlfl2121_x, qqgdsnlfl2121_y, qqgdsnlfl2121_z])
|
||||||
|
qqrtfegzl2121.append([qqgdsnlfl2121_x, qqgdsnlfl2121_y, qqgdsnlfl2121_z])
|
||||||
|
qqrtfegzl2121.append([qqgdsnlfl2121_x, qqgdsnlfl2121_y, qqgdsnlfl2121_z])
|
||||||
|
qqrtfegzl2121.append([qqgdsnlfl2121_x, qqgdsnlfl2121_y, qqgdsnlfl2121_z])
|
||||||
|
qqrtfegzl2121.append([qqgdsnlfl2121_x, qqgdsnlfl2121_y, qqgdsnlfl2121_z])
|
||||||
|
qqrtjjjhzl2121 = [sum(x) / len(x) for x in zip(*qqrtfegzl2121)]
|
||||||
|
if not qqrtjjjhzl2121:
|
||||||
|
qqrtjjjhzl2121 = [0, 0, 0]
|
||||||
|
avg_x = qqrtjjjhzl2121[0]
|
||||||
|
avg_y = qqrtjjjhzl2121[1]
|
||||||
|
avg_z = qqrtjjjhzl2121[2]
|
||||||
|
qqgdshfal2121.move(avg_x, avg_y, avg_z, qqgdlamkzl2121, relative=True)
|
||||||
|
for child_joint in qqgdstslfl2121:
|
||||||
|
qqgdshfal2121.move(-avg_x, -avg_y, -avg_z, child_joint, relative=True)
|
||||||
|
end_place = qqgdshfal2121.xform(qqgdlamkzl2121, q=True, ws=True, translation=True)
|
||||||
|
qqgdsnlfl2121_x = end_place[0] - qqrtfehzl2121[0]
|
||||||
|
qqgdsnlfl2121_y = end_place[1] - qqrtfehzl2121[1]
|
||||||
|
qqgdsnlfl2121_z = end_place[2] - qqrtfehzl2121[2]
|
||||||
|
if not qqgdshfal2121.attributeQuery("qqgdsnlfl2121_x", node=qqgdlamkzl2121, exists=True):
|
||||||
|
qqgdshfal2121.addAttr(qqgdlamkzl2121, ln="qqgdsnlfl2121_x", at="double")
|
||||||
|
if not qqgdshfal2121.attributeQuery("qqgdsnlfl2121_y", node=qqgdlamkzl2121, exists=True):
|
||||||
|
qqgdshfal2121.addAttr(qqgdlamkzl2121, ln="qqgdsnlfl2121_y", at="double")
|
||||||
|
if not qqgdshfal2121.attributeQuery("qqgdsnlfl2121_z", node=qqgdlamkzl2121, exists=True):
|
||||||
|
qqgdshfal2121.addAttr(qqgdlamkzl2121, ln="qqgdsnlfl2121_z", at="double")
|
||||||
|
qqgdshfal2121.setAttr(qqgdlamkzl2121 + ".qqgdsnlfl2121_x", qqgdsnlfl2121_x)
|
||||||
|
qqgdshfal2121.setAttr(qqgdlamkzl2121 + ".qqgdsnlfl2121_y", qqgdsnlfl2121_y)
|
||||||
|
qqgdshfal2121.setAttr(qqgdlamkzl2121 + ".qqgdsnlfl2121_z", qqgdsnlfl2121_z)
|
||||||
|
qqrtbkzl2121 += 1
|
||||||
|
qqrtckzl2121 += 1
|
||||||
|
qqrtjwdfhzl2121 = 4
|
||||||
|
for qqgdlamkzl2121 in qqgduajkzl2121:
|
||||||
|
if qqgdshfal2121.attributeQuery("qqgdsnlfl2121_x", node=qqgdlamkzl2121, exists=True):
|
||||||
|
qqgdshfal2121.deleteAttr(qqgdlamkzl2121 + ".qqgdsnlfl2121_x")
|
||||||
|
if qqgdshfal2121.attributeQuery("avg_y", node=qqgdlamkzl2121, exists=True):
|
||||||
|
qqgdshfal2121.deleteAttr(qqgdlamkzl2121 + ".qqgdsnlfl2121_y")
|
||||||
|
if qqgdshfal2121.attributeQuery("qqgdsnlfl2121_z", node=qqgdlamkzl2121, exists=True):
|
||||||
|
qqgdshfal2121.deleteAttr(qqgdlamkzl2121 + ".qqgdsnlfl2121_z")
|
||||||
|
qqsgnnkzl2121 = []
|
||||||
|
for joint in qqsgdlannkzl2121:
|
||||||
|
qqsgbbzl2121 = qqgdshfal2121.xform(joint, query=True, worldSpace=True, translation=True)
|
||||||
|
qqsgnnkzl2121.append(qqsgbbzl2121)
|
||||||
|
qqrtjwfffhzl2121 = len(qqsgnnkzl2121)
|
||||||
|
if qqrtjwfffhzl2121 > 0:
|
||||||
|
qqsgjjkzl2121 = [sum(coord) / qqrtjwfffhzl2121 for coord in zip(*qqsgnnkzl2121)]
|
||||||
|
else:
|
||||||
|
qqsgjjkzl2121 = [0, 0, 0]
|
||||||
|
for joint in qqsgdlannkzl2121:
|
||||||
|
qqgdlamkzl2121=joint
|
||||||
|
qqsgbbzl2121 = qqgdshfal2121.xform(joint, query=True, worldSpace=True, translation=True)
|
||||||
|
qqgdshfal2121.move(-qqsgbbzl2121[0]/qqrtjwdfhzl2121, -qqsgbbzl2121[1]/qqrtjwdfhzl2121, -qqsgbbzl2121[2]/qqrtjwdfhzl2121, joint, relative=True)
|
||||||
|
qqgdshfal2121.move(qqsgjjkzl2121[0]/qqrtjwdfhzl2121, qqsgjjkzl2121[1]/qqrtjwdfhzl2121, qqsgjjkzl2121[2]/qqrtjwdfhzl2121, joint, relative=True)
|
||||||
|
qqgdshfal2121.move(qqgdshfal2121.getAttr(qqgdlamkzl2121 + ".dc_x")/qqrtjwdfhzl2121, qqgdshfal2121.getAttr(qqgdlamkzl2121 + ".dc_y")/qqrtjwdfhzl2121, qqgdshfal2121.getAttr(qqgdlamkzl2121 + ".dc_z")/qqrtjwdfhzl2121, joint, relative=True)
|
||||||
|
qqsgnnkzl2121 = []
|
||||||
|
for joint in qqsgdlannkzl2121_r:
|
||||||
|
qqsgbbzl2121 = qqgdshfal2121.xform(joint, query=True, worldSpace=True, translation=True)
|
||||||
|
qqsgnnkzl2121.append(qqsgbbzl2121)
|
||||||
|
qqrtjwfffhzl2121 = len(qqsgnnkzl2121)
|
||||||
|
if qqrtjwfffhzl2121 > 0:
|
||||||
|
qqsgjjkzl2121 = [sum(coord) / qqrtjwfffhzl2121 for coord in zip(*qqsgnnkzl2121)]
|
||||||
|
else:
|
||||||
|
qqsgjjkzl2121 = [0, 0, 0]
|
||||||
|
for joint in qqsgdlannkzl2121_r:
|
||||||
|
qqgdlamkzl2121=joint
|
||||||
|
qqsgbbzl2121 = qqgdshfal2121.xform(joint, query=True, worldSpace=True, translation=True)
|
||||||
|
qqgdshfal2121.move(-qqsgbbzl2121[0]/qqrtjwdfhzl2121, -qqsgbbzl2121[1]/qqrtjwdfhzl2121, -qqsgbbzl2121[2]/qqrtjwdfhzl2121, joint, relative=True)
|
||||||
|
qqgdshfal2121.move(qqsgjjkzl2121[0]/qqrtjwdfhzl2121, qqsgjjkzl2121[1]/qqrtjwdfhzl2121, qqsgjjkzl2121[2]/qqrtjwdfhzl2121, joint, relative=True)
|
||||||
|
qqgdshfal2121.move(qqgdshfal2121.getAttr(qqgdlamkzl2121 + ".dc_x")/qqrtjwdfhzl2121, qqgdshfal2121.getAttr(qqgdlamkzl2121 + ".dc_y")/qqrtjwdfhzl2121, qqgdshfal2121.getAttr(qqgdlamkzl2121 + ".dc_z")/qqrtjwdfhzl2121, joint, relative=True)
|
||||||
|
def qqgdshffl2121(qqgdshifl2121, target_joint):
|
||||||
|
mov_pos = qqgdshfal2121.xform(qqgdshifl2121, query=True, worldSpace=True, rotatePivot=True)
|
||||||
|
tar_pos = qqgdshfal2121.xform(target_joint, query=True, worldSpace=True, rotatePivot=True)
|
||||||
|
qqgdstslfl2121 = qqgdshfal2121.listRelatives(qqgdshifl2121, c=True, type="joint")
|
||||||
|
qqgdutslfl2121 = []
|
||||||
|
for child_joint in qqgdstslfl2121:
|
||||||
|
qqgdutslfl2121.append(qqgdshfal2121.xform(child_joint, q=True, ws=True, t=True))
|
||||||
|
qqgdshfal2121.xform(qqgdshifl2121, translation=tar_pos, rotatePivot=mov_pos, worldSpace=True)
|
||||||
|
for i, child_joint in enumerate(qqgdstslfl2121):
|
||||||
|
qqgdshfal2121.xform(child_joint, ws=True, t=qqgdutslfl2121[i])
|
||||||
|
|
||||||
|
qqgdzqqqwersstslfl2121 = qqgdshfal2121.pointPosition("head_lod0_mesh.vtx[22350]", world=True)
|
||||||
|
qqgdzqqwersstslfl2121 = qqgdshfal2121.pointPosition("head_lod0_mesh.vtx[19337]", world=True)
|
||||||
|
qqgdzqzqwersstslfl2121 = qqgdshfal2121.xform("FACIAL_C_Jaw", query=True, translation=True, worldSpace=True)
|
||||||
|
qqgdzqaqwersstslfl2121 = qqgdshfal2121.listRelatives("FACIAL_C_Jaw", c=True, type="joint")
|
||||||
|
qqgdzqbqwersstslfl2121 = []
|
||||||
|
for child_joint in qqgdzqaqwersstslfl2121:
|
||||||
|
qqgdzqbqwersstslfl2121.append(qqgdshfal2121.xform(child_joint, q=True, ws=True, t=True))
|
||||||
|
# Set new joint position using vertex y-coordinate
|
||||||
|
qqgdshfal2121.xform("FACIAL_C_Jaw", translation=(qqgdzqzqwersstslfl2121[0], (qqgdzqqqwersstslfl2121[1] + qqgdzqqwersstslfl2121[1]) / 2, (qqgdzqqqwersstslfl2121[2] + qqgdzqqwersstslfl2121[2]) / 2), worldSpace=True)
|
||||||
|
|
||||||
|
for i, child_joint in enumerate(qqgdzqaqwersstslfl2121):
|
||||||
|
qqgdshfal2121.xform(child_joint, ws=True, t=qqgdzqbqwersstslfl2121[i])
|
||||||
|
qqgdshffl2121("FACIAL_C_LowerLipRotation", "FACIAL_C_Jaw")
|
||||||
|
def qqtrepuu2121(moving, ref, distance_joints_x, distance_joints_y, distance_joints_z):
|
||||||
|
qqrtjkslhzl2121 = qqgdshfal2121.xform(moving, query=True, worldSpace=True, rotatePivot=True)
|
||||||
|
qqtrepu2121 = qqgdshfal2121.xform(ref, query=True, worldSpace=True, rotatePivot=True)
|
||||||
|
qqgdshfal2121.xform(moving, translation=qqtrepu2121, worldSpace=True)
|
||||||
|
qqgdshfal2121.move(distance_joints_x, distance_joints_y, distance_joints_z, moving, relative=True)
|
||||||
|
qqtrepuu2121("FACIAL_C_TeethUpper", "FACIAL_C_LipUpper2", 0.02062227716338219, 1.3000883278700712, -3.352522450123213)
|
||||||
|
qqtrepuu2121("FACIAL_C_TeethLower", "FACIAL_C_TeethUpper", 0, -1.7288506204431826, -0.16130734354544174)
|
||||||
|
qqgdshffl2121("neck_01", "FACIAL_C_Neck1Root")
|
||||||
|
qqgdshfal2121.move(-8.756818659788437e-07, -1.2664320775647866, -3.184565397183476, "spine_04", relative=True)
|
||||||
|
qqgdshfal2121.move(8.756818659788437e-07, 1.2664320775647866, 3.184565397183476, "FACIAL_C_Neck1Root", relative=True)
|
||||||
|
qqgdshfal2121.move(8.756818659788437e-07, 1.2664320775647866, 3.184565397183476, "neck_02", relative=True)
|
||||||
|
qqgdshfal2121.move(8.756818659788437e-07, 1.2664320775647866, 3.184565397183476, "clavicle_l", relative=True)
|
||||||
|
qqgdshfal2121.move(8.756818659788437e-07, 1.2664320775647866, 3.184565397183476, "clavicle_r", relative=True)
|
||||||
|
qqgdshffl2121("neck_02", "FACIAL_C_Neck2Root")
|
||||||
|
qqgdshfal2121.move(-1.133513918706999e-06, 0.1523474504930391, -2.64695004846428, "neck_02", relative=True)
|
||||||
|
qqgdshfal2121.move(1.133513918706999e-06, -0.1523474504930391, 2.64695004846428, "FACIAL_C_Neck2Root", relative=True)
|
||||||
|
qqgdshfal2121.move(1.133513918706999e-06, -0.1523474504930391, 2.64695004846428, "head", relative=True)
|
||||||
|
qqgdshffl2121("head", "neck_02")
|
||||||
|
qqgdshfal2121.move(-2.4067497106321516e-07, 5.243699897720944, 1.1424691094592987, "head", relative=True)
|
||||||
|
qqgdshfal2121.move(2.4067497106321516e-07, -5.243699897720944, -1.1424691094592987, "FACIAL_C_FacialRoot", relative=True)
|
||||||
|
qqgdshffl2121("FACIAL_L_EyelidUpperA", "FACIAL_L_Eye")
|
||||||
|
qqgdshffl2121("FACIAL_L_EyelidLowerB", "FACIAL_L_Eye")
|
||||||
|
qqgdshffl2121("FACIAL_L_EyelidLowerA", "FACIAL_L_Eye")
|
||||||
|
qqgdshffl2121("FACIAL_L_EyelidUpperB", "FACIAL_L_Eye")
|
||||||
|
qqgdshffl2121("FACIAL_R_EyelidUpperA", "FACIAL_R_Eye")
|
||||||
|
qqgdshffl2121("FACIAL_R_EyelidLowerB", "FACIAL_R_Eye")
|
||||||
|
qqgdshffl2121("FACIAL_R_EyelidLowerA", "FACIAL_R_Eye")
|
||||||
|
qqgdshffl2121("FACIAL_R_EyelidUpperB", "FACIAL_R_Eye")
|
||||||
|
if qqgdshfal2121.objExists("body_mesh_CS"):
|
||||||
|
qqgdshfbl2121(qqgduaggzl2121)
|
||||||
|
qqtrewtru2121 = "head_lod0_mesh"
|
||||||
|
qqtrewzztru2121 = qqgdshfal2121.duplicate(qqtrewtru2121)[0]
|
||||||
|
qqgdshfal2121.setAttr(qqtrewzztru2121+'.translateX', lock=False)
|
||||||
|
qqgdshfal2121.setAttr(qqtrewzztru2121+'.translateY', lock=False)
|
||||||
|
qqgdshfal2121.setAttr(qqtrewzztru2121+'.translateZ', lock=False)
|
||||||
|
qqgdshfal2121.move(75, 0, 0, qqtrewzztru2121, relative=True)
|
||||||
|
blend_shape_node = "TargetBS"
|
||||||
|
qqgdshfal2121.blendShape(blend_shape_node, edit=True, target=(qqtrewtru2121, 1, qqtrewzztru2121, 1.0))
|
||||||
|
qqgdshfal2121.setAttr("TargetBS."+qqtrewzztru2121, -1)
|
||||||
|
qqgdshfal2121.setAttr("TargetBS.CustomShape", 1)
|
||||||
|
qqgdshfal2121.setAttr(qqtrewzztru2121 + ".visibility", 0)
|
||||||
|
qqgdshfal2121.setAttr("CustomShape" + ".visibility", 0)
|
||||||
|
qqgdsdfbt5hfal2121 = qqgdshfal2121.listRelatives("head_lod0_grp", children=True, type="transform")
|
||||||
|
for qqgdsdfbt5hfal21 in qqgdsdfbt5hfal2121:
|
||||||
|
if not qqgdsdfbt5hfal21 == "head_lod0_mesh":
|
||||||
|
if qqgdshfal2121.objExists(qqgdsdfbt5hfal21 + "_CBS"):
|
||||||
|
qqgdsdfbt5hfal21CS = qqgdsdfbt5hfal21 + "_CBS"
|
||||||
|
qqgdshfal2121.hide(qqgdsdfbt5hfal21 + "_CS")
|
||||||
|
else:
|
||||||
|
qqgdsdfbt5hfal21CS = qqgdsdfbt5hfal21 + "_CS"
|
||||||
|
if qqgdshfal2121.objExists(qqgdsdfbt5hfal21CS):
|
||||||
|
BS_CST = qqgdshfal2121.blendShape(qqgdsdfbt5hfal21, automatic=True)
|
||||||
|
qqgdshfal2121.rename(BS_CST, qqgdsdfbt5hfal21 + "BS")
|
||||||
|
dubqqgdsdfbt5hfal21 = qqgdshfal2121.duplicate(qqgdsdfbt5hfal21)[0]
|
||||||
|
qqgdshfal2121.rename(dubqqgdsdfbt5hfal21, qqgdsdfbt5hfal21 + "dub")
|
||||||
|
qqgdshfal2121.blendShape(qqgdsdfbt5hfal21 + "BS", edit=True, target=[(qqgdsdfbt5hfal21, 0, qqgdsdfbt5hfal21 + "dub", 1.0)])
|
||||||
|
qqgdshfal2121.blendShape(qqgdsdfbt5hfal21 + "BS", edit=True, target=[(qqgdsdfbt5hfal21, 1, qqgdsdfbt5hfal21CS, 1.0)])
|
||||||
|
qqgdshfal2121.setAttr(qqgdsdfbt5hfal21 + "BS." + qqgdsdfbt5hfal21 + "dub", -1)
|
||||||
|
qqgdshfal2121.setAttr(qqgdsdfbt5hfal21 + "BS." + qqgdsdfbt5hfal21CS, 1)
|
||||||
|
qqgdshfal2121.delete(qqgdsdfbt5hfal21 + "dub")
|
||||||
|
qqgdshfal2121.hide(qqgdsdfbt5hfal21CS)
|
||||||
|
qqgdshfal2121.hide("body_mesh_CS")
|
||||||
|
if qqgdshfal2121.objExists("eyeLeft"):
|
||||||
|
tuyt5 = qqgdshfal2121.polyEvaluate("eyeLeft", vertex=True)
|
||||||
|
if tuyt5 == 770:
|
||||||
|
qqgdwwddwal211221 = "eyeLeft_lod0_mesh"
|
||||||
|
BS_CST = qqgdshfal2121.blendShape(qqgdwwddwal211221, automatic=True)
|
||||||
|
qqgdshfal2121.rename(BS_CST, qqgdwwddwal211221 + "BS")
|
||||||
|
dubOBJ = qqgdshfal2121.duplicate(qqgdwwddwal211221)[0]
|
||||||
|
qqgdshfal2121.rename(dubOBJ, qqgdwwddwal211221 + "dub")
|
||||||
|
qqgdshfal2121.blendShape(qqgdwwddwal211221 + "BS", edit=True, target=[(qqgdwwddwal211221, 0, qqgdwwddwal211221 + "dub", 1.0)])
|
||||||
|
qqgdshfal2121.blendShape(qqgdwwddwal211221 + "BS", edit=True, target=[(qqgdwwddwal211221, 1, "eyeLeft", 1.0)])
|
||||||
|
qqgdshfal2121.setAttr(qqgdwwddwal211221 + "BS." + qqgdwwddwal211221 + "dub", -1)
|
||||||
|
qqgdshfal2121.setAttr(qqgdwwddwal211221 + "BS." + "eyeLeft", 1)
|
||||||
|
qqgdshfal2121.delete(qqgdwwddwal211221 + "dub")
|
||||||
|
if qqgdshfal2121.objExists("eyeRight"):
|
||||||
|
tuyt5 = qqgdshfal2121.polyEvaluate("eyeRight", vertex=True)
|
||||||
|
if tuyt5 == 770:
|
||||||
|
qqgdwwddwal211221 = "eyeRight_lod0_mesh"
|
||||||
|
BS_CST = qqgdshfal2121.blendShape(qqgdwwddwal211221, automatic=True)
|
||||||
|
qqgdshfal2121.rename(BS_CST, qqgdwwddwal211221 + "BS")
|
||||||
|
dubOBJ = qqgdshfal2121.duplicate(qqgdwwddwal211221)[0]
|
||||||
|
qqgdshfal2121.rename(dubOBJ, qqgdwwddwal211221 + "dub")
|
||||||
|
qqgdshfal2121.blendShape(qqgdwwddwal211221 + "BS", edit=True, target=[(qqgdwwddwal211221, 0, qqgdwwddwal211221 + "dub", 1.0)])
|
||||||
|
qqgdshfal2121.blendShape(qqgdwwddwal211221 + "BS", edit=True, target=[(qqgdwwddwal211221, 1, "eyeRight", 1.0)])
|
||||||
|
qqgdshfal2121.setAttr(qqgdwwddwal211221 + "BS." + qqgdwwddwal211221 + "dub", -1)
|
||||||
|
qqgdshfal2121.setAttr(qqgdwwddwal211221 + "BS." + "eyeRight", 1)
|
||||||
|
qqgdshfal2121.delete(qqgdwwddwal211221 + "dub")
|
||||||
|
|
65
Prepare.py
Normal file
65
Prepare.py
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
#All Rights Belongs to Uzay CALISKAN
|
||||||
|
#Artstation Marketplace Standart License
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import maya.cmds as cmds
|
||||||
|
import random
|
||||||
|
def matSet():
|
||||||
|
# Get the selection
|
||||||
|
selection = cmds.ls(selection=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Assign the material to each selected object
|
||||||
|
for obj in selection:
|
||||||
|
# Create a new aiStandardSurface material
|
||||||
|
ai_material = cmds.shadingNode('aiStandardSurface', asShader=True)
|
||||||
|
|
||||||
|
# Generate a random base color
|
||||||
|
base_color = [random.uniform(0, 1) for i in range(3)]
|
||||||
|
|
||||||
|
# Set the material's base color
|
||||||
|
cmds.setAttr(ai_material + '.baseColor', *base_color)
|
||||||
|
|
||||||
|
# Assign the material to the object
|
||||||
|
cmds.select(obj)
|
||||||
|
cmds.hyperShade(assign=ai_material)
|
||||||
|
|
||||||
|
def prepare_export():
|
||||||
|
|
||||||
|
import random
|
||||||
|
# Select the meshes under Head
|
||||||
|
cmds.select("head_grp|geometry_grp", hierarchy=True)
|
||||||
|
selection = cmds.ls(selection=True)
|
||||||
|
|
||||||
|
# Assign the material to each selected object
|
||||||
|
for obj in selection:
|
||||||
|
# Create a new Lambert material
|
||||||
|
material = cmds.shadingNode('lambert', asShader=True)
|
||||||
|
base_color = [random.uniform(0, 1) for i in range(3)]
|
||||||
|
|
||||||
|
# Set the material's base color
|
||||||
|
cmds.setAttr(material + '.color', *base_color, type='double3')
|
||||||
|
cmds.select(obj)
|
||||||
|
cmds.hyperShade(assign=material)
|
||||||
|
# Detach spine_04 from head_grp and move it to the top level of the Outliner
|
||||||
|
cmds.parent('spine_04', w=True, r=True)
|
||||||
|
|
||||||
|
if not cmds.namespace(exists="DHIhead"):
|
||||||
|
cmds.namespace(add="DHIhead", parent=":")
|
||||||
|
cmds.namespace(set="DHIhead")
|
||||||
|
cmds.namespace(set=":")
|
||||||
|
|
||||||
|
# Get a list of all the joints in the scene
|
||||||
|
joints = cmds.ls(type="joint")
|
||||||
|
|
||||||
|
# Add every joint to the "DHIhead" namespace and print a message if it already has the "DHIhead" prefix
|
||||||
|
for joint in joints:
|
||||||
|
if joint.startswith("DHIhead:"):
|
||||||
|
print(joint + " is already in the DHIhead namespace")
|
||||||
|
else:
|
||||||
|
cmds.rename(joint, "DHIhead:" + joint)
|
||||||
|
|
||||||
|
|
||||||
|
print("Ready")
|
36
bsIndex.py
Normal file
36
bsIndex.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#GNU General Public License
|
||||||
|
import pymel.core as pm
|
||||||
|
import maya.cmds as cmds
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def calc():
|
||||||
|
selected_meshes = cmds.ls(sl=True)
|
||||||
|
targetblend = selected_meshes[0]
|
||||||
|
# Assuming 'rl4Embedded_Archtype' is the name of the node
|
||||||
|
node_name = 'head_lod0_mesh_blendShapes'
|
||||||
|
|
||||||
|
# Get the PyNode for the specified node
|
||||||
|
node = pm.PyNode(node_name)
|
||||||
|
|
||||||
|
# Assuming 'bs_Output' is the name of the output attribute
|
||||||
|
output_attr = node.weight
|
||||||
|
|
||||||
|
# Get the connected plugs from the output attribute
|
||||||
|
connected_plugs = output_attr.connections(plugs=True)
|
||||||
|
blendIndex = []
|
||||||
|
# Iterate over the connected plugs and print their values
|
||||||
|
for index, plug in enumerate(connected_plugs, start=1):
|
||||||
|
sub_node_value = plug.get()
|
||||||
|
if sub_node_value == 1:
|
||||||
|
print("Sub-node {} value: {}".format(index-1, sub_node_value))
|
||||||
|
blendIndex = index-1
|
||||||
|
print (blendIndex)
|
||||||
|
blend_shape_node = 'head_lod0_mesh_blendShapes'
|
||||||
|
rebuild_mesh = cmds.sculptTarget(blend_shape_node, e=True, regenerate=True, target=blendIndex)
|
||||||
|
cmds.select(rebuild_mesh)
|
||||||
|
blend_shape_node = "blendShape1"
|
||||||
|
cmds.blendShape(rebuild_mesh[0], automatic=True)
|
||||||
|
cmds.blendShape(blend_shape_node, edit=True, target=(rebuild_mesh[0], 2, targetblend+"_corrective", 1.0))
|
||||||
|
cmds.setAttr(blend_shape_node+"."+targetblend+"_corrective", 1)
|
||||||
|
#cmds.delete(rebuild_mesh[0])
|
||||||
|
cmds.delete(targetblend+"_corrective")
|
41
correctiveBlendshape.txt
Normal file
41
correctiveBlendshape.txt
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
python("import sys");
|
||||||
|
string $selected[] = `ls -selection`;
|
||||||
|
global proc performExtractDeltas()
|
||||||
|
{
|
||||||
|
string $sel[] = `ls -sl -tr`;
|
||||||
|
string $shapes[];
|
||||||
|
for ($s in $sel)
|
||||||
|
{
|
||||||
|
$shapes = `listRelatives -s $s`;
|
||||||
|
for ($sh in $shapes)
|
||||||
|
{
|
||||||
|
if (`nodeType $sh` != "mesh")
|
||||||
|
{
|
||||||
|
error "The selected geometry is no polygon object!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (size($sel) == 2)
|
||||||
|
{
|
||||||
|
$shapes = `listRelatives -s $sel[0]`;
|
||||||
|
string $skin[] = `listConnections -type "skinCluster" $shapes[0]`;
|
||||||
|
if (!`size($skin)`)
|
||||||
|
{
|
||||||
|
error "The first selected object is not bound to a skin cluster!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
error "Please select two polygonal objects!";
|
||||||
|
}
|
||||||
|
extractDeltas -s $sel[0] -c $sel[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
performExtractDeltas();
|
||||||
|
select -r $selected[1];
|
||||||
|
python("import importlib");
|
||||||
|
python("sys.path.append('c:/Arts and Spells/Scripts')");
|
||||||
|
python("import bsIndex");
|
||||||
|
python("importlib.reload(bsIndex)");
|
||||||
|
python("bsIndex.calc()");
|
||||||
|
//delete;
|
443
extractDeltas.py
Normal file
443
extractDeltas.py
Normal file
@ -0,0 +1,443 @@
|
|||||||
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# extractDeltas.py
|
||||||
|
# v1.4
|
||||||
|
#
|
||||||
|
# extract a modeled corrective shape from a deformed skinned mesh
|
||||||
|
#
|
||||||
|
# original c++ extract deltas plugin by James Jacobs
|
||||||
|
#
|
||||||
|
# python conversion, improvements and maintenance by Ingo Clemens
|
||||||
|
# www.braverabbit.com
|
||||||
|
#
|
||||||
|
# brave rabbit, Ingo Clemens 2014
|
||||||
|
#
|
||||||
|
# versions:
|
||||||
|
#
|
||||||
|
# 1.4 - included mel scripts
|
||||||
|
# 1.3 - improved shape comparison without the need of blendshapes
|
||||||
|
# 1.2 - added the vertex list flag to work only on a given component list
|
||||||
|
# 1.1 - optimized performance because it now works on sculpted points only
|
||||||
|
# (0.06 - c++ version, 1.88 - version 1.0, 0.14 - version 1.1)
|
||||||
|
# 1.0 - initial python conversion
|
||||||
|
#
|
||||||
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# USE AND MODIFY AT YOUR OWN RISK!!
|
||||||
|
#
|
||||||
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
import maya.OpenMaya as OpenMaya
|
||||||
|
import maya.OpenMayaMPx as OpenMayaMPx
|
||||||
|
import maya.cmds as cmds
|
||||||
|
from maya.mel import eval as meval
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
kPluginCmdName = 'extractDeltas'
|
||||||
|
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------------
|
||||||
|
# argument flags
|
||||||
|
# --------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
helpFlag = '-h'
|
||||||
|
helpFlagLong = '-help'
|
||||||
|
|
||||||
|
skinFlag = '-s'
|
||||||
|
skinFlagLong = '-skin'
|
||||||
|
|
||||||
|
correctiveFlag = '-c'
|
||||||
|
correctiveFlagLong = '-corrective'
|
||||||
|
|
||||||
|
vertexListFlag = '-vl'
|
||||||
|
vertexListFlagLong = '-vertexList'
|
||||||
|
|
||||||
|
helpText = ''
|
||||||
|
helpText += '\n Description: Extract a modeled corrective shape from a deformed skinned mesh.'
|
||||||
|
helpText += '\n'
|
||||||
|
helpText += '\n Flags: extractDeltas -h -help <n/a> this message'
|
||||||
|
helpText += '\n -s -skin <string> the name of the skinned mesh'
|
||||||
|
helpText += '\n -c -corrective <string> the name of the sculpted shape'
|
||||||
|
helpText += '\n -vl -vertexList <string> optional list of vertices, comma separated string'
|
||||||
|
helpText += '\n Usage: Execute the command with the following arguments:'
|
||||||
|
helpText += '\n Execute: extractDeltas -s <mesh with skin cluster> -c <corrective mesh name>'
|
||||||
|
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------------
|
||||||
|
# main command
|
||||||
|
# --------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class extractDeltas(OpenMayaMPx.MPxCommand):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
OpenMayaMPx.MPxCommand.__init__(self)
|
||||||
|
|
||||||
|
def doIt(self, args):
|
||||||
|
|
||||||
|
self.dagModifier = OpenMaya.MDagModifier()
|
||||||
|
|
||||||
|
skinName = ''
|
||||||
|
correctiveName = ''
|
||||||
|
resultName = ''
|
||||||
|
listString = ''
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------------
|
||||||
|
# parse the arguments
|
||||||
|
# --------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
argData = OpenMaya.MArgDatabase(self.syntax(), args)
|
||||||
|
|
||||||
|
# help flag
|
||||||
|
if argData.isFlagSet(helpFlag):
|
||||||
|
self.setResult(helpText)
|
||||||
|
return
|
||||||
|
|
||||||
|
# skin flag
|
||||||
|
if argData.isFlagSet(skinFlag):
|
||||||
|
skinName = argData.flagArgumentString(skinFlag, 0)
|
||||||
|
|
||||||
|
# corrective flag
|
||||||
|
if argData.isFlagSet(correctiveFlag):
|
||||||
|
correctiveName = argData.flagArgumentString(correctiveFlag, 0)
|
||||||
|
|
||||||
|
# vertex list flag
|
||||||
|
if argData.isFlagSet(vertexListFlag):
|
||||||
|
listString = argData.flagArgumentString(vertexListFlag, 0)
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------------
|
||||||
|
# check the selection
|
||||||
|
# --------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
sel = []
|
||||||
|
if skinName != '' and correctiveName != '':
|
||||||
|
sel.append(skinName)
|
||||||
|
sel.append(correctiveName)
|
||||||
|
else:
|
||||||
|
sel = cmds.ls(sl = True, tr = True)
|
||||||
|
|
||||||
|
shapeList = []
|
||||||
|
|
||||||
|
for i in range(len(sel)):
|
||||||
|
shapes = cmds.listRelatives(sel[i], s = True)
|
||||||
|
if shapes == None:
|
||||||
|
OpenMaya.MGlobal.displayError(sel[i] + ' has no shape node.')
|
||||||
|
return
|
||||||
|
if cmds.nodeType(shapes[0]) != 'mesh':
|
||||||
|
OpenMaya.MGlobal.displayError(shapes[0] + ' is not a mesh object.')
|
||||||
|
return
|
||||||
|
elif i == 0 and len(shapes) > 1:
|
||||||
|
skin = cmds.listConnections(shapes[0], type = 'skinCluster')
|
||||||
|
if skin == None:
|
||||||
|
OpenMaya.MGlobal.displayError(shapes[0] + ' is not bound to a skin cluster.')
|
||||||
|
return
|
||||||
|
if cmds.getAttr(shapes[1] + '.intermediateObject'):
|
||||||
|
shapeList.append(shapes[1])
|
||||||
|
else:
|
||||||
|
OpenMaya.MGlobal.displayError(shapes[1] + ' is not an intermediate/original shape node.')
|
||||||
|
return
|
||||||
|
shapeList.append(shapes[0])
|
||||||
|
|
||||||
|
if len(shapeList) != 3:
|
||||||
|
OpenMaya.MGlobal.displayError('Select a skinned mesh with a valid original shape node and a target mesh object.')
|
||||||
|
return
|
||||||
|
|
||||||
|
selList = OpenMaya.MSelectionList()
|
||||||
|
for sl in shapeList:
|
||||||
|
selList.add(sl)
|
||||||
|
|
||||||
|
intermediateObj = OpenMaya.MObject()
|
||||||
|
skinObj = OpenMaya.MObject()
|
||||||
|
targetObj = OpenMaya.MObject()
|
||||||
|
|
||||||
|
selList.getDependNode(0, intermediateObj)
|
||||||
|
selList.getDependNode(1, skinObj)
|
||||||
|
selList.getDependNode(2, targetObj)
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------------
|
||||||
|
# define the mesh functions and get the points
|
||||||
|
# --------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
skinFn = OpenMaya.MFnMesh()
|
||||||
|
skinFn.setObject(skinObj)
|
||||||
|
targetFn = OpenMaya.MFnMesh()
|
||||||
|
targetFn.setObject(targetObj)
|
||||||
|
intermediateFn = OpenMaya.MFnMesh()
|
||||||
|
intermediateFn.setObject(intermediateObj)
|
||||||
|
|
||||||
|
skinPoints = OpenMaya.MPointArray()
|
||||||
|
skinFn.getPoints(skinPoints)
|
||||||
|
targetPoints = OpenMaya.MPointArray()
|
||||||
|
targetFn.getPoints(targetPoints)
|
||||||
|
intermediatePoints = OpenMaya.MPointArray()
|
||||||
|
intermediateFn.getPoints(intermediatePoints)
|
||||||
|
|
||||||
|
extractPoints = OpenMaya.MPointArray(intermediatePoints)
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------------
|
||||||
|
# get the delta points through a temporary blendShape node
|
||||||
|
# --------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
pointList = []
|
||||||
|
for i in range(0, skinPoints.length()):
|
||||||
|
if skinPoints[i] != targetPoints[i]:
|
||||||
|
pointList.append(i)
|
||||||
|
|
||||||
|
if len(pointList) == 0:
|
||||||
|
OpenMaya.MGlobal.displayError('No shape extracted. Both meshes are identical.')
|
||||||
|
return
|
||||||
|
|
||||||
|
# create an intersection list between the delta points and the given vertex list
|
||||||
|
vList = []
|
||||||
|
if listString != '':
|
||||||
|
array = listString.split(',')
|
||||||
|
array = map(int, array)
|
||||||
|
intersectList = list(set(pointList) & set(array))
|
||||||
|
pointList = intersectList
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------------
|
||||||
|
# duplicate the original
|
||||||
|
# --------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
resultFn = OpenMaya.MFnMesh()
|
||||||
|
resultObj = OpenMaya.MObject()
|
||||||
|
|
||||||
|
# copies the mesh using API functions but its not easily undoable
|
||||||
|
#resultObj = resultFn.copy(intermediateObj, OpenMaya.cvar.MObject_kNullObj)
|
||||||
|
# duplicating the mesh through maya commands is a bit more complex
|
||||||
|
# but the undo comes for free
|
||||||
|
|
||||||
|
resultMesh = cmds.duplicate(shapeList[0], rc = True)
|
||||||
|
shapes = cmds.listRelatives(resultMesh, s = True)
|
||||||
|
# delete the main shape node and deactivate the intermediate object
|
||||||
|
cmds.delete(shapes[0])
|
||||||
|
cmds.setAttr(shapes[1] + '.intermediateObject', 0)
|
||||||
|
cmds.rename(shapes[1], shapes[0])
|
||||||
|
attrList = ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz']
|
||||||
|
for a in attrList:
|
||||||
|
cmds.setAttr(resultMesh[0] + '.' + a, l = False)
|
||||||
|
|
||||||
|
selList.clear()
|
||||||
|
selList.add(shapes[0])
|
||||||
|
selList.getDependNode(0, resultObj)
|
||||||
|
resultFn.setObject(resultObj)
|
||||||
|
|
||||||
|
resultPoints = OpenMaya.MPointArray()
|
||||||
|
resultFn.getPoints(resultPoints)
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------------
|
||||||
|
# build a relative coordinate space by first preturbing
|
||||||
|
# the origional mesh and then building a coordinate space
|
||||||
|
# on the skinned mesh
|
||||||
|
# --------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
xArray = OpenMaya.MPointArray(intermediatePoints)
|
||||||
|
yArray = OpenMaya.MPointArray(intermediatePoints)
|
||||||
|
zArray = OpenMaya.MPointArray(intermediatePoints)
|
||||||
|
|
||||||
|
xPointArray = OpenMaya.MPointArray()
|
||||||
|
yPointArray = OpenMaya.MPointArray()
|
||||||
|
zPointArray = OpenMaya.MPointArray()
|
||||||
|
|
||||||
|
for i in pointList:
|
||||||
|
xArray.set(i, intermediatePoints[i].x + 1.0, intermediatePoints[i].y, intermediatePoints[i].z)
|
||||||
|
yArray.set(i, intermediatePoints[i].x, intermediatePoints[i].y + 1.0, intermediatePoints[i].z)
|
||||||
|
zArray.set(i, intermediatePoints[i].x, intermediatePoints[i].y, intermediatePoints[i].z + 1.0)
|
||||||
|
|
||||||
|
intermediateFn.setPoints(xArray)
|
||||||
|
skinFn.getPoints(xPointArray)
|
||||||
|
|
||||||
|
for i in pointList:
|
||||||
|
offX = xPointArray[i].x - skinPoints[i].x
|
||||||
|
offY = xPointArray[i].y - skinPoints[i].y
|
||||||
|
offZ = xPointArray[i].z - skinPoints[i].z
|
||||||
|
xPointArray.set(i, offX, offY, offZ)
|
||||||
|
|
||||||
|
intermediateFn.setPoints(yArray)
|
||||||
|
skinFn.getPoints(yPointArray)
|
||||||
|
|
||||||
|
for i in pointList:
|
||||||
|
offX = yPointArray[i].x - skinPoints[i].x
|
||||||
|
offY = yPointArray[i].y - skinPoints[i].y
|
||||||
|
offZ = yPointArray[i].z - skinPoints[i].z
|
||||||
|
yPointArray.set(i, offX, offY, offZ)
|
||||||
|
|
||||||
|
intermediateFn.setPoints(zArray)
|
||||||
|
skinFn.getPoints(zPointArray)
|
||||||
|
|
||||||
|
for i in pointList:
|
||||||
|
offX = zPointArray[i].x - skinPoints[i].x
|
||||||
|
offY = zPointArray[i].y - skinPoints[i].y
|
||||||
|
offZ = zPointArray[i].z - skinPoints[i].z
|
||||||
|
zPointArray.set(i, offX, offY, offZ)
|
||||||
|
|
||||||
|
# set the original points back
|
||||||
|
intermediateFn.setPoints(intermediatePoints)
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------------
|
||||||
|
# perform the extraction from the skinned mesh
|
||||||
|
# --------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
for i in pointList:
|
||||||
|
extractItems = [zPointArray[i].x, zPointArray[i].y, zPointArray[i].z, 0.0,
|
||||||
|
xPointArray[i].x, xPointArray[i].y, xPointArray[i].z, 0.0,
|
||||||
|
yPointArray[i].x, yPointArray[i].y, yPointArray[i].z, 0.0,
|
||||||
|
skinPoints[i].x, skinPoints[i].y, skinPoints[i].z, 1.0]
|
||||||
|
|
||||||
|
resultItems = [0.0, 0.0, 1.0, 0.0,
|
||||||
|
1.0, 0.0, 0.0, 0.0,
|
||||||
|
0.0, 1.0, 0.0, 0.0,
|
||||||
|
resultPoints[i].x, resultPoints[i].y, resultPoints[i].z, 1.0]
|
||||||
|
|
||||||
|
extractMatrix = OpenMaya.MMatrix()
|
||||||
|
OpenMaya.MScriptUtil.createMatrixFromList(extractItems, extractMatrix)
|
||||||
|
|
||||||
|
resultMatrix = OpenMaya.MMatrix()
|
||||||
|
OpenMaya.MScriptUtil.createMatrixFromList(resultItems, resultMatrix)
|
||||||
|
|
||||||
|
point = OpenMaya.MPoint()
|
||||||
|
point = targetPoints[i] * extractMatrix.inverse()
|
||||||
|
point *= resultMatrix
|
||||||
|
extractPoints.set(point, i)
|
||||||
|
|
||||||
|
resultFn.setPoints(extractPoints)
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------------
|
||||||
|
# cleanup
|
||||||
|
# --------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
cmds.sets(resultFn.fullPathName(), e = True, fe = 'initialShadingGroup')
|
||||||
|
parentNode = cmds.listRelatives(resultFn.fullPathName(), p = True)
|
||||||
|
resultName = cmds.rename(parentNode, sel[1] + '_corrective')
|
||||||
|
|
||||||
|
self.setResult(resultName)
|
||||||
|
|
||||||
|
return self.redoIt()
|
||||||
|
|
||||||
|
def redoIt(self):
|
||||||
|
self.dagModifier.doIt()
|
||||||
|
|
||||||
|
def undoIt(self):
|
||||||
|
self.dagModifier.undoIt()
|
||||||
|
|
||||||
|
def isUndoable(self):
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------------
|
||||||
|
# define the syntax, needed to make it work with mel and python
|
||||||
|
# --------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# creator
|
||||||
|
def cmdCreator():
|
||||||
|
return OpenMayaMPx.asMPxPtr(extractDeltas())
|
||||||
|
|
||||||
|
def syntaxCreator():
|
||||||
|
syn = OpenMaya.MSyntax()
|
||||||
|
syn.addFlag(helpFlag, helpFlagLong)
|
||||||
|
syn.addFlag(skinFlag, skinFlagLong, OpenMaya.MSyntax.kString)
|
||||||
|
syn.addFlag(correctiveFlag, correctiveFlagLong, OpenMaya.MSyntax.kString)
|
||||||
|
syn.addFlag(vertexListFlag, vertexListFlagLong, OpenMaya.MSyntax.kString)
|
||||||
|
return syn
|
||||||
|
|
||||||
|
# initialization
|
||||||
|
def initializePlugin(mobject):
|
||||||
|
mplugin = OpenMayaMPx.MFnPlugin(mobject, 'Original plugin by James Jacobs / Python adaption by Ingo Clemens', '1.4', 'Any')
|
||||||
|
try:
|
||||||
|
mplugin.registerCommand(kPluginCmdName, cmdCreator, syntaxCreator)
|
||||||
|
except:
|
||||||
|
sys.stderr.write('Failed to register command: %s\n' % kPluginCmdName)
|
||||||
|
raise
|
||||||
|
|
||||||
|
def uninitializePlugin(mobject):
|
||||||
|
mplugin = OpenMayaMPx.MFnPlugin(mobject)
|
||||||
|
try:
|
||||||
|
mplugin.deregisterCommand(kPluginCmdName)
|
||||||
|
except:
|
||||||
|
sys.stderr.write( 'Failed to unregister command: %s\n' % kPluginCmdName )
|
||||||
|
raise
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------------
|
||||||
|
# mel procedures
|
||||||
|
# --------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
mel = '''
|
||||||
|
|
||||||
|
global proc extractDeltasDuplicateMesh()
|
||||||
|
{
|
||||||
|
string $sel[] = `ls -sl`;
|
||||||
|
string $shapes[] = `listRelatives -s $sel[0]`;
|
||||||
|
string $skin[] = `listConnections -type "skinCluster" $shapes[0]`;
|
||||||
|
if (`size($skin)`)
|
||||||
|
{
|
||||||
|
string $dup[] = `duplicate -rr -rc $sel`;
|
||||||
|
$shapes = `listRelatives -s $dup[0]`;
|
||||||
|
for ($s in $shapes)
|
||||||
|
{
|
||||||
|
if (`getAttr ($s + ".intermediateObject")`)
|
||||||
|
{
|
||||||
|
delete $s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setAttr -l 0 ($dup[0] + ".tx");
|
||||||
|
setAttr -l 0 ($dup[0] + ".ty");
|
||||||
|
setAttr -l 0 ($dup[0] + ".tz");
|
||||||
|
setAttr -l 0 ($dup[0] + ".rx");
|
||||||
|
setAttr -l 0 ($dup[0] + ".ry");
|
||||||
|
setAttr -l 0 ($dup[0] + ".rz");
|
||||||
|
setAttr -l 0 ($dup[0] + ".sx");
|
||||||
|
setAttr -l 0 ($dup[0] + ".sy");
|
||||||
|
setAttr -l 0 ($dup[0] + ".sz");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
global proc performExtractDeltas()
|
||||||
|
{
|
||||||
|
string $sel[] = `ls -sl -tr`;
|
||||||
|
string $shapes[];
|
||||||
|
for ($s in $sel)
|
||||||
|
{
|
||||||
|
$shapes = `listRelatives -s $s`;
|
||||||
|
for ($sh in $shapes)
|
||||||
|
{
|
||||||
|
if (`nodeType $sh` != "mesh")
|
||||||
|
{
|
||||||
|
error "The selected geometry is no polygon object!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (size($sel) == 2)
|
||||||
|
{
|
||||||
|
$shapes = `listRelatives -s $sel[0]`;
|
||||||
|
string $skin[] = `listConnections -type "skinCluster" $shapes[0]`;
|
||||||
|
if (!`size($skin)`)
|
||||||
|
{
|
||||||
|
error "The first selected object is not bound to a skin cluster!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
error "Please select two polygonal objects!";
|
||||||
|
}
|
||||||
|
extractDeltas -s $sel[0] -c $sel[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
'''
|
||||||
|
meval(mel)
|
88
metapipe.py
Normal file
88
metapipe.py
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
import tkinter as tk
|
||||||
|
from tkinter import ttk
|
||||||
|
from tkinter.filedialog import askdirectory, askopenfilename
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
|
||||||
|
class MainWindow(tk.Tk):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.title("Main Window")
|
||||||
|
|
||||||
|
self.sutun_1_veriler = ["f", "m"]
|
||||||
|
self.sutun_2_veriler = ["tal", "med", "srt"]
|
||||||
|
self.sutun_3_veriler = ["nrw", "unw"]
|
||||||
|
|
||||||
|
self.sutun_1_cb = ttk.Combobox(self, values=self.sutun_1_veriler)
|
||||||
|
|
||||||
|
self.sutun_2_cb = ttk.Combobox(self, values=self.sutun_2_veriler)
|
||||||
|
|
||||||
|
self.sutun_3_cb = ttk.Combobox(self, values=self.sutun_3_veriler)
|
||||||
|
|
||||||
|
self.sutun_4_secim = ttk.Entry(self)
|
||||||
|
|
||||||
|
self.sutun_1_lbl = ttk.Label(self, text="Gender:")
|
||||||
|
self.sutun_2_lbl = ttk.Label(self, text="Size:")
|
||||||
|
self.sutun_3_lbl = ttk.Label(self, text="Type:")
|
||||||
|
self.sutun_4_lbl = ttk.Label(self, text="MAYA VERSION(e.g. 2023 or 2022):")
|
||||||
|
|
||||||
|
self.sonuc_btn = ttk.Button(self, text="Next", command=self.sonuc_goster)
|
||||||
|
|
||||||
|
self.sutun_1_lbl.grid(row=0, column=0, padx=10, pady=10, sticky=tk.W)
|
||||||
|
self.sutun_1_cb.grid(row=0, column=1, padx=10, pady=10)
|
||||||
|
|
||||||
|
self.sutun_2_lbl.grid(row=1, column=0, padx=10, pady=10, sticky=tk.W)
|
||||||
|
self.sutun_2_cb.grid(row=1, column=1, padx=10, pady=10)
|
||||||
|
|
||||||
|
self.sutun_3_lbl.grid(row=2, column=0, padx=10, pady=10, sticky=tk.W)
|
||||||
|
self.sutun_3_cb.grid(row=2, column=1, padx=10, pady=10)
|
||||||
|
|
||||||
|
self.sutun_4_lbl.grid(row=3, column=0, padx=10, pady=10, sticky=tk.W)
|
||||||
|
self.sutun_4_secim.grid(row=3, column=1, padx=10, pady=10)
|
||||||
|
|
||||||
|
self.sonuc_btn.grid(row=4, column=0, padx=10, pady=10, sticky=tk.W)
|
||||||
|
|
||||||
|
def sonuc_goster(self):
|
||||||
|
sutun_1_secim = self.sutun_1_cb.get()
|
||||||
|
sutun_2_secim = self.sutun_2_cb.get()
|
||||||
|
sutun_3_secim = self.sutun_3_cb.get()
|
||||||
|
sutun_4_secim = self.sutun_4_secim.get().replace("\\", "/")
|
||||||
|
ROOT_DIR = askdirectory(title="Select ROOT DIR for dna_calib Path")
|
||||||
|
dnaPath = askopenfilename(title="Select Metahuman Dna Path")
|
||||||
|
body_type = "{}_{}_{}".format(sutun_1_secim, sutun_2_secim, sutun_3_secim)
|
||||||
|
source_folder = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
MAYA_VERSION = sutun_4_secim
|
||||||
|
self.codeblock(dnaPath, ROOT_DIR, body_type, MAYA_VERSION)
|
||||||
|
self.move_files(source_folder, "c:/Arts and Spells/Scripts")
|
||||||
|
|
||||||
|
def codeblock(self, dnaPath, ROOT_DIR, body_type, MAYA_VERSION):
|
||||||
|
output_file_path = os.path.join("c:/Arts and Spells/Scripts", "dat.py")
|
||||||
|
source_py = os.path.join(os.path.dirname(os.path.abspath(__file__)), "MetaPipeStudioSource.py")
|
||||||
|
with open(source_py) as file:
|
||||||
|
lines = file.readlines()
|
||||||
|
lines = [line.replace('c:/dna_calibration', ROOT_DIR) for line in lines]
|
||||||
|
lines = [line.replace("2023", MAYA_VERSION) for line in lines]
|
||||||
|
lines = [line.replace("C:/Users/Uzay/Documents/Megascans Library/Downloaded/DHI/h344NMUV_asset/1k/asset_source/MetaHumans/CustomDNA/SourceAssets/CustomDNA.dna", dnaPath) for line in lines]
|
||||||
|
lines = [line.replace("m_med_nrw", body_type) for line in lines]
|
||||||
|
|
||||||
|
code_block = ''.join(lines)
|
||||||
|
|
||||||
|
with open(output_file_path, "w") as output_file:
|
||||||
|
output_file.write(code_block)
|
||||||
|
|
||||||
|
def move_files(self, source_folder, destination_folder):
|
||||||
|
files = os.listdir(source_folder)
|
||||||
|
os.makedirs(destination_folder, exist_ok=True)
|
||||||
|
|
||||||
|
for file_name in files:
|
||||||
|
source = os.path.join(source_folder, file_name)
|
||||||
|
destination = os.path.join(destination_folder, file_name)
|
||||||
|
shutil.copy(source, destination)
|
||||||
|
print(f"{file_name} moved.")
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
mw = MainWindow()
|
||||||
|
mw.mainloop()
|
Loading…
Reference in New Issue
Block a user