コード例 #1
0
def findObjectAndBake(target, dummyroot, suffix, oppositeSuffix,
                      copyDirection):
    bakeSources = list(sdknode.getChildren(dummyroot))
    targetChildrens = list(sdknode.getChildren(target))
    targetChildrens.append(target)
    bakeTargets = sdkutility.findObjectBySuffix(oppositeSuffix,
                                                targetChildrens)

    for bakeTarget in bakeTargets:
        bakeSource = findBakeSource(bakeTarget, bakeSources, oppositeSuffix,
                                    suffix)
        if bakeSource is not None:
            sdkutility.RemoveScaleKeys(bakeTarget)
            sdkutility.AddPositionListAndConstraint(bakeTarget)
            SetPositionConstraintTarget(bakeSource, bakeTarget)
            sdkutility.AddRotationListAndConstraint(bakeTarget)
            SetOrientationConstraintTarget(bakeSource, bakeTarget)

    selectionTab = MaxPlus.INodeTab()
    for n in bakeTargets:
        selectionTab.Append(n)
    MaxPlus.SelectionManager.SelectNodes(selectionTab)
    plotFile = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                            "plot.ms")
    plot = open(plotFile, "r")
    MaxPlus.Core.EvalMAXScript(plot.read())
コード例 #2
0
 def correct_hierachy(self, src_root, target_root):
     src_children = map(lambda x: x.GetName(),
                        sdknode.getChildren(src_root))
     src_children.sort()
     target_children = map(lambda x: x.GetName(),
                           sdknode.getChildren(target_root))
     target_children.sort()
     for f, b in itertools.izip(src_children, target_children):
         regex = r'{0}[a-zA-Z0-9]*'.format(self.left_suffix)
         target_name = re.sub(regex, self.right_suffix, f)
         if b != target_name:
             self.log_append("error in : " + b)
             return False
     return True
コード例 #3
0
def cleanUp(leftSuffix, rightSuffix, copyDirection):
    sceneRoot = MaxPlus.Core.GetRootNode()
    children = list(sdknode.getChildren(sceneRoot))
    for n in children:
        if isDummy(n):
            n.SetParent(MaxPlus.Core.GetRootNode())
            MaxPlus.INode.Delete(n)

    selection = MaxPlus.SelectionManager.GetNodes()
    for selected in selection:
        if copyDirection == 0:
            remove_unused_key(selected, rightSuffix, leftSuffix)
        elif copyDirection == 1:
            remove_unused_key(selected, leftSuffix, rightSuffix)
コード例 #4
0
def mirrorUnskinned(leftSuffix, rightSuffix, copyDirection):
    MaxPlus.Animation.SetTime(0, False)
    src_node = MaxPlus.SelectionManager.GetNodes()
    mirroredTopNode = MaxPlus.INode.CreateTreeInstance(src_node[0])
    MaxPlus.SelectionManager.SelectNode(mirroredTopNode)
    MaxPlus.Core_EvalMAXScript(
        "tm = $.transform\ntm.row1 = tm.row1 * [-1,1,1]\n$.transform  =tm")
    mirroredHierarchy = list(sdknode.getChildren(mirroredTopNode))
    mirroredHierarchy.append(mirroredTopNode)
    for n in mirroredHierarchy:
        n.SetName(n.GetName()[:-7] + "right")
        sdkutility.ResetXForm(n, True, True)
        sdkutility.remove_transform_keys(n)

    mirror_animation(src_node[0], mirroredTopNode, leftSuffix, rightSuffix,
                     copyDirection)
コード例 #5
0
def mirror_animation(source, target, src_suffix, target_suffix, copyDirection):
    # mirror from parent of selection
    # todo: if no parent add a node on center
    dummyRoot = MaxPlus.INode.CreateTreeInstance(source)
    dummyHierarchy = list(sdknode.getChildren(dummyRoot))
    dummyHierarchy.append(dummyRoot)
    for n in dummyHierarchy:
        n.SetName(n.GetName()[:-3] + "_dummy")
        setDummy(n)
    MaxPlus.SelectionManager.SelectNode(dummyRoot)
    MaxPlus.Core_EvalMAXScript(
        "tm = $.transform\ntm.row1 = tm.row1 * [-1,1,1]\n$.transform  =tm")
    try:
        findObjectAndBake(target, dummyRoot, src_suffix, target_suffix,
                          copyDirection)
    finally:
        cleanUp(src_suffix, target_suffix, copyDirection)
コード例 #6
0
    def on_mirror_hierarchy_without_skin_clicked(self):
        MaxPlus.Animation.SetTime(0, False)
        self.log_clear()
        MaxPlus.ViewportManager.DisableSceneRedraw()
        try:
            selection = MaxPlus.SelectionManager.GetNodes()
            if len(selection) <= 0:
                self.display_message("Select at least one node")
                return
            root_node_list = self.getRootNodesFromList(selection)
            for root_node in root_node_list:
                target_root = MaxPlus.INode.CreateTreeCopy(root_node)
                sdkutility.ResetXForm(target_root, True, True)
                mirror_axis = self.mirrorAxis.currentText()
                children = list(sdknode.getChildren(target_root))
                self.rename_delete_modifiers(target_root)
                for node in children:
                    self.rename_delete_modifiers(node)

                self.mirrorNode(target_root, mirror_axis)
                sdkutility.ResetXForm(target_root, True, True)
        finally:
            MaxPlus.ViewportManager.EnableSceneRedraw()
            MaxPlus.ViewportManager.ForceCompleteRedraw()