Пример #1
0
        public void Create()
        {
            MItDag jointIterator = new MItDag(MItDag.TraversalType.kDepthFirst, MFn.Type.kJoint);

            //Create Joints and collect their DAG Paths
            short jointID = 0;

            for (; !jointIterator.isDone; jointIterator.next())
            {
                MFnIkJoint ikJoint      = new MFnIkJoint();
                MDagPath   jointDagPath = new MDagPath();

                jointIterator.getPath(jointDagPath);
                this.JointDagPaths.Add(jointDagPath);
                ikJoint.setObject(jointDagPath);

                MTransformationMatrix local         = new MTransformationMatrix(ikJoint.transformationMatrix);
                MTransformationMatrix inverseGlobal = new MTransformationMatrix(jointDagPath.inclusiveMatrixInverse);

                this.Joints.Add(new SKLJoint(jointID, ikJoint.name, local, inverseGlobal));
                this.JointIndices.Add(ELF.Hash(ikJoint.name), jointID);
                jointID++;
            }

            //Set Joint parents
            for (int i = 0; i < this.Joints.Count; i++)
            {
                MFnIkJoint ikJoint = new MFnIkJoint(this.JointDagPaths[i]);
                if (ikJoint.parentCount == 1 && ikJoint.parent(0).apiType == MFn.Type.kJoint)
                {
                    MFnIkJoint parentJoint   = new MFnIkJoint(ikJoint.parent(0));
                    MDagPath   parentDagPath = new MDagPath();

                    parentJoint.getPath(parentDagPath);

                    //Find index of parent
                    for (int j = 0; j < this.JointDagPaths.Count; j++)
                    {
                        if (parentDagPath.equalEqual(this.JointDagPaths[j]))
                        {
                            this.Joints[i].ParentID = (short)j;
                        }
                    }
                }
                else
                {
                    this.Joints[i].ParentID = -1;
                }
            }

            MGlobal.displayInfo("SKLFile:Create - Created SKL File");
        }
Пример #2
0
        public SKLJoint(short id, string name, MTransformationMatrix local, MTransformationMatrix inverseGlobal)
        {
            this.IsLegacy = false;

            this.Flags = 0;
            this.ID = id;
            this.Name = name;
            this.Hash = ELF.Hash(name);
            this.Local = local;
            this.InverseGlobal = inverseGlobal;

            PrintInfo();
        }