Exemplo n.º 1
0
        public ISVisualizationJoint(MMICSharp.Common.RJoint jBase, Transform RootBone, Dictionary <MJointType, string> bonenameMap)
        {
            if (bonenameMap.ContainsKey(jBase.GetMJoint().Type))
            {
                string name = bonenameMap[jBase.GetMJoint().Type];
                this.reference = RootBone.GetChildRecursiveByName(name);
            }
            else
            {
                this.reference = null;
            }

            /*
             * if (bonemap.ContainsKey(jBase.GetMJoint().ID))
             * {
             *  this.referenceBone = bonemap[jBase.GetMJoint().ID];
             * }
             * else
             * {
             *  //Debug.LogWarning("Retargeting: there is a bone without a reference: " + jBase.GetMJoint().ID);
             *  this.referenceBone = HumanBodyBones.LastBone;
             * }*/
            //this.anim = anim;
            this.j = jBase;

            for (int i = 0; i < jBase.children.Count; i++)
            {
                MMICSharp.Common.RJoint child    = (RJoint)jBase.children[i];
                ISVisualizationJoint    retjoint = new ISVisualizationJoint(child, RootBone, bonenameMap);
                retjoint.parent = this;
                this.children.Add(retjoint);
            }
        }
Exemplo n.º 2
0
        private void SetFingerJoints(ISVisualizationJoint j)
        {
            //set index joint to target index joint position
            Vector3 targetPos = getJointPosition(j.reference);
            Vector3 newOffset = j.parent.GetGlobalMatrix().inverse.MultiplyPoint3x4(targetPos);

            j.reference.position = new Vector3(j.GetGlobalMatrix().GetColumn(3).x, j.GetGlobalMatrix().GetColumn(3).y, j.GetGlobalMatrix().GetColumn(3).z);
        }
Exemplo n.º 3
0
        private void AlignJoint(ISVisualizationJoint start, ISVisualizationJoint end)
        {
            Vector3    source_dir = getJointPosition(end.reference) - getJointPosition(start.reference);
            Vector3    endPos     = end.GetGlobalMatrix().GetColumn(3);//end.gameJoint.transform.position;
            Vector3    target_dir = endPos - getJointPosition(start.reference);
            Quaternion q          = Quaternion.FromToRotation(source_dir, target_dir);

            start.reference.rotation = q * start.reference.rotation;

            //this.anim.GetBoneTransform (start.referenceBone).rotation = q * this.anim.GetBoneTransform(start.referenceBone).rotation;
        }
        public SkeletonVisualization(IntermediateSkeleton skeleton, RetargetingService retargetingService, Transform RootBone, Dictionary <string, MJointType> bonenameMap, string AvatarID, GameObject gameJointPrefab)
        {
            //this.anim = anim;

            this.RootBone    = RootBone;
            this.bonenameMap = bonenameMap.Invert();

            this.skeleton = skeleton;
            this.AvatarID = AvatarID;

            this.retargetingService = retargetingService;

            root = new ISVisualizationJoint((RJoint)skeleton.GetRoot(this.AvatarID), RootBone, this.bonenameMap);
            //root.AlignAvatar(anim);
            root.CreateGameObjSkel(gameJointPrefab);
            //root.SetToZero(this.AvatarID);
        }