bool IExtensionPlugin.InitializePlugin()
        {
            totalMenuName = GetMayaWindowName();
            cds.AddRange(BasicFunc.GetCommandDatas());
            cds.AddRange(BindHumanBody.GetCommandDatas());
            cds.AddRange(DynamicConverter.GetCommandDatas());
            cds.AddRange(JointProcess.GetCommandDatas());
            cds.AddRange(MaterialManage.GetCommandDatas());
            cds.AddRange(BindAttr.GetCommandDatas());
            cds.AddRange(Selector.GetCommandDatas());
            cds.AddRange(BindSwitch.GetCommandDatas());
            cds.AddRange(MeshTool.GetCommandDatas());

            foreach (CommandData cd in cds)
            {
                AddOneCommand(cd);
            }
            //int paramInt = (int)MPCMap.MPCType.Test;
            //AddMenuItem("Test", totalMenuName, "InazumaCommand", paramInt);

            //string subMenuName_bodyBind = AddSubMenu(totalMenuName, "Body Bind", true);
            //string subMenuName_create = AddSubMenu(totalMenuName, "Create", true);

            //paramInt = (int)MPCMap.MPCType.AddRPIK;
            //AddMenuItem("add rpik", subMenuName_bodyBind, "InazumaCommand", paramInt);

            //paramInt = (int)MPCMap.MPCType.AddRPIKPole;
            //AddMenuItem("add rpik pole", subMenuName_create, "InazumaCommand", paramInt);

            //paramInt = (int)MPCMap.MPCType.CreateCTL_CrysTal;
            //AddMenuItem("create cystal ctl", subMenuName_create, "InazumaCommand", paramInt);

            //paramInt = (int)MPCMap.MPCType.AddChildCtl;
            //AddMenuItem("add child ctl", subMenuName_create, "InazumaCommand", paramInt);

            //paramInt = (int)MPCMap.MPCType.AddParentCtl;
            //AddMenuItem("add parent ctl", subMenuName_create, "InazumaCommand", paramInt);

            //paramInt = (int)MPCMap.MPCType.AddReverseFootBones;
            //AddMenuItem("add reverse foot bones", subMenuName_create, "InazumaCommand", paramInt);

            //paramInt = (int)MPCMap.MPCType.BindReverseFootRPIK;
            //AddMenuItem("Bind Reverse Foot RPIK", subMenuName_bodyBind, "InazumaCommand", paramInt);

            //paramInt = (int)MPCMap.MPCType.BindFinger_CTL_L;
            //AddMenuItem("Bind Finger using CTL L", subMenuName_bodyBind, "InazumaCommand", paramInt);

            //paramInt = (int)MPCMap.MPCType.CreateJointsCurve;
            //AddMenuItem("Create Joints Curve", subMenuName_create, "InazumaCommand", paramInt);

            //paramInt = (int)MPCMap.MPCType.MakeHairJointsChain;
            //AddMenuItem("Make Hair Joints To Chain", subMenuName_bodyBind, "InazumaCommand", paramInt);
            Debug.Log("-回港了-");
            return(true);
        }
Ejemplo n.º 2
0
        public static void BindBodySplineIK(MSelectionList jointList = null)
        {
            if (jointList == null)
            {
                jointList = BasicFunc.GetSelectedList();
            }
            //check if all of selected objects are joint
            int count = (int)jointList.length;

            if (count < 2)
            {
                return;
            }
            MDagPath dag_breastJoint = new MDagPath(), dag_hipJoint = new MDagPath();

            for (int i = 0; i < count; i++)
            {
                MDagPath jtDagPath = new MDagPath();
                jointList.getDagPath((uint)i, jtDagPath);
                if (jtDagPath != null)
                {
                    if (!jtDagPath.hasFn(MFn.Type.kJoint))
                    {
                        return;
                    }
                }
                else
                {
                    return;
                }
            }

            jointList.getDagPath((uint)(count - 1), dag_breastJoint);
            jointList.getDagPath(0, dag_hipJoint);

            MFnIkJoint     breastJoint       = new MFnIkJoint(dag_breastJoint);
            MFnIkJoint     hipJoint          = new MFnIkJoint(dag_hipJoint);
            MDagPath       dag_curve         = JointProcess.CreateJointsCurve(jointList);
            MDagPath       dag_jtctl_breast  = JointProcess.CreateJoint(breastJoint, "jtctl_breast");
            MDagPath       dag_jtctl_hip     = JointProcess.CreateJoint(hipJoint, "jtctl_hip");
            MSelectionList bindSelectionList = new MSelectionList();

            bindSelectionList.add(dag_curve);
            bindSelectionList.add(dag_jtctl_breast);
            bindSelectionList.add(dag_jtctl_hip);
            BasicFunc.Select(bindSelectionList);

            MGlobal.executeCommand("SmoothBindSkin");
            string   ikName = JointProcess.AddIKHandle(dag_hipJoint, dag_breastJoint, JointProcess.IKSolverType.Spline, dag_curve.fullPathName)[0];
            MDagPath dag_ik = BasicFunc.GetDagPathByName(ikName);

            BasicFunc.ConnectAttr(dag_jtctl_breast.fullPathName + ".rotate.rotateY", dag_ik.fullPathName + ".twist", true, true);
        }
Ejemplo n.º 3
0
        public static MDagPath[] BindIKControl(MDagPath rootDagPath, MDagPath endDagPath, JointProcess.IKSolverType iKSolverType = JointProcess.IKSolverType.RotatePlane, MDagPath ctlDagPath = null)
        {
            MFnTransform endTrans      = new MFnTransform(endDagPath);
            MDagPath     middleDagPath = MDagPath.getAPathTo(endTrans.parent(0));

            if (ctlDagPath == null)
            {
                ctlDagPath = BasicFunc.AddChildCircle(endDagPath);
                BasicFunc.UnparentTransform(ctlDagPath);
                BasicFunc.FreezeTransform(new MFnTransform(ctlDagPath));
            }


            //string resultStr = MGlobal.executeCommandStringResult("ikHandle -sj " + rootObject.fullPathName() + " -ee " + endObject.fullPathName() + " -sol ikRPsolver -n ik_" + rootObject.partialPathName() + "_" + endObject.partialPathName(),true);
            //string resultStr = MGlobal.executePythonCommandStringResult("cmds.ikHandle(sj='" + rootDagPath.fullPathName + "',ee='" + endDagPath.fullPathName + "',sol='ikRPsolver',n='ik_" + rootDagPath.partialPathName + "_" + endDagPath.partialPathName + "')");

            //[u'ik_joint1_joint4', u'effector1']
            string[] resultArr = JointProcess.AddIKHandle(rootDagPath, endDagPath, iKSolverType, ctlDagPath.fullPathName);
            MGlobal.executeCommandStringResult("pointConstraint " + ctlDagPath.fullPathName + " " + resultArr[0]);

            if (iKSolverType == JointProcess.IKSolverType.RotatePlane)
            {
                MDagPath locDagPath = AddRPIKPole(middleDagPath);
                if (locDagPath != null)
                {
                    BasicFunc.FreezeTransform(new MFnTransform(locDagPath));
                    //begin to add constriant
                    BasicFunc.AddConstraint(locDagPath.fullPathName, resultArr[0], ConstantValue.ConstraintType.PoleVector);
                    //string poleConstraintResult = MGlobal.executeCommandStringResult("poleVectorConstraint " + locDagPath.fullPathName + " " + resultArr[0]);
                    //Debug.Log(poleConstraintResult);
                    return(new MDagPath[3] {
                        BasicFunc.GetDagPathByName(resultArr[0]), ctlDagPath, locDagPath
                    });
                }
            }

            return(new MDagPath[2] {
                BasicFunc.GetDagPathByName(resultArr[0]), ctlDagPath
            });
        }
        private void UpdateJoints(object sender, RoutedEventArgs e)
        {
            if (joints == null && joints.Count < 2)
            {
                return;
            }
            MFnIkJoint lastJoint          = joints[joints.Count - 1];
            MVector    lastJointWorldPos  = lastJoint.getTranslation(MSpace.Space.kWorld);
            MVector    firstJointWorldPos = joints[0].getTranslation(MSpace.Space.kWorld);
            MVector    direct             = lastJointWorldPos - firstJointWorldPos;

            for (int i = 1; i < joints.Count - 1; i++)
            {
                if (i >= sliders.Count || sliders[i] == null)
                {
                    continue;
                }
                double percent = sliders[i].Value;
                JointProcess.MoveSkinJointsTool(joints[i].dagPath);
                joints[i].setTranslation(direct * percent + firstJointWorldPos, MSpace.Space.kWorld);
            }
            JointProcess.MoveSkinJointsTool(lastJoint.dagPath);
            lastJoint.setTranslation(lastJointWorldPos, MSpace.Space.kWorld);
        }
Ejemplo n.º 5
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);
        }