Last active
December 23, 2020 09:16
-
-
Save obriencole11/cfb1545a61bbbaff23498f5f9042d0e3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
A simple utility module for moving skinned joints. | |
""" | |
import math | |
import pymel.core as pmc | |
def reset_bind_matrix(joint): | |
""" | |
Sets the bindPreMatrix of each connected skinCluster to the current transformations of the given joint. | |
:param joint: [PyNode] | |
""" | |
for plug in joint.worldMatrix[0].listConnections(type='skinCluster', plugs=True): | |
cluster = plug.node() | |
index = plug.index() | |
cluster.bindPreMatrix[index].set(joint.worldInverseMatrix.get()) | |
def reset_bind_pose(joint): | |
""" | |
Resets the bindPose of the given joint. | |
:param joint: [PyNode] | |
""" | |
bind_poses = pmc.dagPose(joint, bindPose=True, q=True) | |
for bind_pose in bind_poses: | |
pmc.dagPose(joint, reset=True, n=bind_pose) | |
def freeze_joint_orientation(joint): | |
""" | |
Bakes the current joint rotation to its jointOrient. | |
:param Joint: [PyNode] | |
""" | |
local_rotation = joint.getRotation().asQuaternion() * joint.getOrientation() | |
local_angles = [math.degrees(angle) for angle in local_rotation.asEulerRotation()] | |
joint.jointOrient.set(local_angles) | |
joint.rotate.set([0,0,0]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment