Beispiel #1
0
        public static bool BindFinger(MDagPath rootJointDagPath, MDagPath middleJointDagPath, MDagPath finalJointDagPath, string fingerTag, bool useIK = false)
        {
            JointProcess.SetJointLimit(rootJointDagPath, JointProcess.JointType.FingerRoot);
            JointProcess.SetJointLimit(middleJointDagPath, JointProcess.JointType.FingerMiddle);
            JointProcess.SetJointLimit(finalJointDagPath, JointProcess.JointType.FingerMiddle);

            if (useIK)
            {
            }
            else
            {
                MDagPath          ctlDagPath         = BasicFunc.AddParentCircle(rootJointDagPath, true);
                MFnDependencyNode remapNode_root     = BasicFunc.CreateRemapValueNode(-2, 3, 60, -90);
                MFnDependencyNode remapNode_rootSide = BasicFunc.CreateRemapValueNode(-1, 1, 30, -30);
                MFnDependencyNode remapNode_middle   = BasicFunc.CreateRemapValueNode(-1, 3, 30, -90);
                MFnDependencyNode remapNode_final    = BasicFunc.CreateRemapValueNode(-1, 3, 30, -90);
                //MFnDependencyNode** ptr_remapNode_root = &remapNode_root,


                //string remapValueNodeName_root = BasicFunc.CreateRemapValueNode(-2, 3, 60, -90, ptr_remapNode_root);
                //string remapValueNodeName_rootSide = BasicFunc.CreateRemapValueNode(-1, 1, 30, -30, ptr_remapNode_rootSide);
                //string remapValueNodeName_middle = BasicFunc.CreateRemapValueNode(-1, 3, 30, -90, ptr_remapNode_middle);
                //string remapValueNodeName_final = BasicFunc.CreateRemapValueNode(-1, 3, 30, -90, ptr_remapNode_final);
                string            ctlName   = ctlDagPath.fullPathName;
                MFnDependencyNode dn_ctl    = new MFnDependencyNode(ctlDagPath.node);
                MFnDependencyNode dn_root   = new MFnDependencyNode(rootJointDagPath.node);
                MFnDependencyNode dn_middle = new MFnDependencyNode(middleJointDagPath.node);
                MFnDependencyNode dn_final  = new MFnDependencyNode(finalJointDagPath.node);

                /*MPlug plug_ctlTy = dn_ctl.findPlug("translateY");
                 * Debug.Log("plug name:" + plug_ctlTy.partialName() + " fullname:" + plug_ctlTy.name());*/
                //MStatus status;
                //MPlug plug_remapNode_root_input = remapNode_root.findPlug("inputValue", &status);
                //if (status == MStatus::kSuccess)
                //{
                //	Debug.Log("success 634634");
                //	//Debug.Log("plug name:" + plug_remapNode_root_input.partialName() + " fullname:" + plug_remapNode_root_input.name());
                //}
                //else
                //{
                //	Debug.Log("failed a23234234");
                //}
                MDGModifier dgModifier = new MDGModifier();
                dgModifier.doIt();
                dgModifier.connect(dn_ctl.findPlug("translateY"), remapNode_root.findPlug("inputValue"));
                dgModifier.connect(remapNode_root.findPlug("outValue"), dn_root.findPlug("rotateZ"));

                dgModifier.connect(dn_ctl.findPlug("translateZ"), remapNode_rootSide.findPlug("inputValue"));
                dgModifier.connect(remapNode_rootSide.findPlug("outValue"), dn_root.findPlug("rotateY"));

                dgModifier.connect(dn_ctl.findPlug("translateX"), remapNode_middle.findPlug("inputValue"));
                dgModifier.connect(remapNode_middle.findPlug("outValue"), dn_middle.findPlug("rotateZ"));

                dgModifier.connect(dn_ctl.findPlug("translateX"), remapNode_final.findPlug("inputValue"));
                dgModifier.connect(remapNode_final.findPlug("outValue"), dn_final.findPlug("rotateZ"));
                dgModifier.doIt();

                BasicFunc.SetTranslateLimit(new MFnTransform(ctlDagPath), -1, -2, -1, 3, 3, 1);
            }
            return(true);
        }