Ejemplo n.º 1
0
def orientAdjustArms():
    """orient the guide nodes on the arm to point down the chain
    """
    # arm_guides = ["arm_L0_root", "arm_L0_elbow", "arm_L0_wrist", "arm_L0_eff"]
    arm_guides = ["arm_L0_root", "arm_L0_elbow", "arm_L0_eff"]
    orientChainNodes(arm_guides)
    arm_guides1 = ["arm_L0_wrist", "arm_L0_eff"]
    orientChainNodes(arm_guides1)
    arm_guides = [m_string.convertRLName(x) for x in arm_guides]
    arm_guides1 = [m_string.convertRLName(x) for x in arm_guides1]
    orientChainNodes(arm_guides)
    orientChainNodes(arm_guides1)
Ejemplo n.º 2
0
def makeEmbedArmsPlanar(shoulder="left_shoulder",
                        wrist="left_hand",
                        elbow="left_elbow",
                        favor_side="left"):
    """specific to the arms only. Try to align the arms on a plane for more
    ideal results when the guides are applied

    Args:
        shoulder (str, optional): shoulder, root of chain
        wrist (str, optional): wrist, end of chain
        elbow (str, optional): position elbow
        favor_side (str, optional): left or right
    """
    if favor_side == "right":
        shoulder = m_string.convertRLName(shoulder)
        wrist = m_string.convertRLName(wrist)
        elbow = m_string.convertRLName(elbow)
    constrainPointToVectorPlanar(shoulder, wrist, elbow, ws=True)
Ejemplo n.º 3
0
def duplicateSym(*args):
    """Duplicate one dag hierarchy to/from X/-X renaming "L" to "R" """

    oSelection = pm.selected()
    if oSelection:
        oSel = oSelection[0]
        oTarget = pm.duplicate()[0]

        t = oSel.getTransformation()
        t = transform.getSymmetricalTransform(t)
        oTarget.setTransformation(t)

        # Quick rename
        pm.select(oTarget, hi=True)

        for x in pm.selected():
            x.rename(string.convertRLName(x.name().split("|")[-1]))
        oTarget.rename(string.convertRLName(oSel.name()))
    else:
        pm.displayWarning("Select something before duplicate symmetry.")
Ejemplo n.º 4
0
def adjustHandPosition(wrist="arm_L0_wrist",
                       metacarpal="arm_L0_eff",
                       favor_side="left"):
    """estimate the position of the hand. The embed nodes only provide an end
    point for the arm and no position for the wrist.

    Args:
        wrist (str, optional): node to position
        metacarpal (str, optional): end of the guide arm, hand
        favor_side (str, optional): left or right
    """
    if favor_side != "left":
        wrist = m_string.convertRLName(wrist)
        metacarpal = m_string.convertRLName(metacarpal)
    a = pm.PyNode(wrist)
    a.setRotation([0, 0, 0])
    b = pm.PyNode(metacarpal)
    b.setRotation([0, 0, 0])

    diff_vect = b.getMatrix(ws=True).translate - a.getMatrix(ws=True).translate

    mat = a.getMatrix(ws=True).translate - (diff_vect)
    a.setTranslation(mat, space="world")
Ejemplo n.º 5
0
    def symmetrize(self):
        """Inverse the transform of each element of the guide."""

        if self.values["comp_side"] not in ["R", "L"]:
            mgear.log("Can't symmetrize central component", mgear.sev_error)
            return False
        for name, paramDef in self.paramDefs.items():
            if paramDef.valueType == "string":
                self.setParamDefValue(name,
                                      string.convertRLName(self.values[name]))
        for name, t in self.tra.items():
            self.tra[name] = transform.getSymmetricalTransform(t)
        for name, blade in self.blades.items():
            self.blades[name] = vector.Blade(
                transform.getSymmetricalTransform(blade.transform))

        return True
Ejemplo n.º 6
0
def getMirror(node):
    """Get the mirrored node usin _L and _R replacement

    Arguments:
        node (dagNode or list of dagNodes): The dagNode to look for a
            mirror

    Returns:
        dagNode or list of dagNodes: The dagNode contrapart on the other
            side _L or _R

    """
    if not isinstance(node, list):
        node = [node]
    mirrorNodes = []
    for n in node:
        try:
            mirrorNodes.append(pm.PyNode(string.convertRLName(n.name())))
        except Exception:
            pm.displayInfo("The object: %s doesn't have mirror _L or _R "
                           "contrapart. Skipped!" % n.name())
            mirrorNodes.append(n)

    return mirrorNodes
Ejemplo n.º 7
0
def makeAssoicationInfoSymmetrical(association_info, favor_side="left"):
    """ensures the association information provided is equal on both sides

    Args:
        association_info (dict): embed point: guide name
        favor_side (str, optional): side to mirror from

    Returns:
        dict: symmetrical association info
    """
    replace = SIDE_MIRROR_INFO[favor_side]
    mirrored_association_info = copy.deepcopy(association_info)
    for embed, guides in association_info.items():
        if embed.startswith(favor_side):
            mirror_embed = embed.replace(favor_side, replace)
            mirrored_guides = []
            for guide in guides:
                mirror = m_string.convertRLName(guide)
                if cmds.objExists(mirror):
                    mirrored_guides.append(mirror)
                else:
                    mirrored_guides.append(guide)
            mirrored_association_info[mirror_embed] = mirrored_guides
    return mirrored_association_info