Esempio n. 1
0
        public static bool BindBlendShapeCtl(MFnBlendShapeDeformer bs, MDagPath ctlDagPath = null)
        {
            //MFnDependencyNode ctlNode = new MFnDependencyNode(ctlDagPath.node);
            if (bs == null)
            {
                Debug.Log("null blendShape");
                return(false);
            }
            //Debug.Log("here i am");

            if (ctlDagPath == null)
            {
                ctlDagPath = BasicFunc.CreateCTL_Crystal("ctl_bs_" + bs.name);
            }

            MFnDependencyNode ctlNode = new MFnDependencyNode(ctlDagPath.node);

            MPlug weightPlug = bs.findPlug(ConstantValue.plugName_blendShapeWeight);
            int   count      = (int)weightPlug.numElements;
            //Debug.Log("target count:" + count);

            MDGModifier dGModifier = new MDGModifier();

            for (int i = 0; i < count; i++)
            {
                //Debug.Log("process:" + i);
                MPlug  singleWeightPlug = weightPlug.elementByLogicalIndex((uint)i);
                string weightName       = singleWeightPlug.name.Split('.').Last();
                MPlug  ctlAttrPlug      = AddFloatAttr(ctlDagPath, weightName);
                dGModifier.connect(ctlAttrPlug, singleWeightPlug);
            }
            dGModifier.doIt();

            return(true);
        }
Esempio n. 2
0
        public static List <CommandData> GetCommandDatas()
        {
            List <CommandData> cmdList = new List <CommandData>();

            cmdList.Add(new CommandData("绑定属性", cmdStr, "bindBlendShape", "绑定混合变形控制器", () =>
            {
                MFnBlendShapeDeformer bs = GetBlendShape();
                BindBlendShapeCtl(bs);
            }));
            return(cmdList);
        }