public HandRepresentation(HandModelManager parent, Hand hand, Chirality repChirality, ModelType repType)
 {
     this.parent         = parent;
     HandID              = hand.Id;
     this.RepChirality   = repChirality;
     this.RepType        = repType;
     this.MostRecentHand = hand;
 }
예제 #2
0
        void AutoRigMecanim()
        {
            //Assigning these here since this component gets added and used at editor time
            AnimatorForMapping = gameObject.GetComponent <Animator>();
            HandPoolToPopulate = GameObject.FindObjectOfType <HandModelManager>();
            Reset();

            //Find hands and assign RiggedHands
            Transform Hand_L = AnimatorForMapping.GetBoneTransform(HumanBodyBones.LeftHand);

            if (Hand_L.GetComponent <RiggedHand>())
            {
                RiggedHand_L = Hand_L.GetComponent <RiggedHand>();
            }
            else
            {
                RiggedHand_L = Hand_L.gameObject.AddComponent <RiggedHand>();
            }
            HandTransitionBehavior_L       = Hand_L.gameObject.AddComponent <HandDrop>();
            RiggedHand_L.Handedness        = Chirality.Left;
            RiggedHand_L.SetEditorLeapPose = false;

            Transform Hand_R = AnimatorForMapping.GetBoneTransform(HumanBodyBones.RightHand);

            if (Hand_R.GetComponent <RiggedHand>())
            {
                RiggedHand_R = Hand_R.GetComponent <RiggedHand>();
            }
            else
            {
                RiggedHand_R = Hand_R.gameObject.AddComponent <RiggedHand>();
            }
            HandTransitionBehavior_R       = Hand_R.gameObject.AddComponent <HandDrop>();
            RiggedHand_R.Handedness        = Chirality.Right;
            RiggedHand_R.SetEditorLeapPose = false;

            //Find palms and assign to RiggedHands
            RiggedHand_L.palm           = AnimatorForMapping.GetBoneTransform(HumanBodyBones.LeftHand);
            RiggedHand_R.palm           = AnimatorForMapping.GetBoneTransform(HumanBodyBones.RightHand);
            RiggedHand_R.UseMetaCarpals = UseMetaCarpals;
            RiggedHand_L.UseMetaCarpals = UseMetaCarpals;

            findAndAssignRiggedFingers(UseMetaCarpals);

            RiggedHand_L.AutoRigRiggedHand(RiggedHand_L.palm, RiggedFinger_L_Pinky.transform, RiggedFinger_L_Index.transform);
            RiggedHand_R.AutoRigRiggedHand(RiggedHand_R.palm, RiggedFinger_R_Pinky.transform, RiggedFinger_R_Index.transform);
            if (ModelGroupName == "" || ModelGroupName != null)
            {
                ModelGroupName = transform.name;
            }
            HandPoolToPopulate.AddNewGroup(ModelGroupName, RiggedHand_L, RiggedHand_R);

            modelFingerPointing_L = RiggedHand_L.modelFingerPointing;
            modelPalmFacing_L     = RiggedHand_L.modelPalmFacing;
            modelFingerPointing_R = RiggedHand_R.modelFingerPointing;
            modelPalmFacing_R     = RiggedHand_R.modelPalmFacing;
        }
예제 #3
0
 public void AutoRig()
 {
     HandPoolToPopulate = GameObject.FindObjectOfType <HandModelManager>();
     AnimatorForMapping = gameObject.GetComponent <Animator>();
     if (AnimatorForMapping != null)
     {
         if (AnimatorForMapping.isHuman == true)
         {
             AutoRigMecanim();
             RiggedHand_L.StoreJointsStartPose();
             RiggedHand_R.StoreJointsStartPose();
             return;
         }
         else
         {
             Debug.LogWarning("The Mecanim Avatar for this asset does not contain a valid IsHuman definition.  Attempting to auto map by name.");
         }
     }
     AutoRigByName();
 }
예제 #4
0
        void AutoRigByName()
        {
            List <string> LeftHandStrings = new List <string> {
                "left"
            };
            List <string> RightHandStrings = new List <string> {
                "right"
            };

            //Assigning these here since this component gets added and used at editor time
            HandPoolToPopulate = GameObject.FindObjectOfType <HandModelManager>();
            Reset();

            //Find hands and assigns RiggedHands
            Transform Hand_L = null;

            foreach (Transform t in transform)
            {
                if (LeftHandStrings.Any(w => t.name.ToLower().Contains(w)))
                {
                    Hand_L = t;
                }
            }
            if (Hand_L != null)
            {
                RiggedHand_L                   = Hand_L.gameObject.AddComponent <RiggedHand>();
                HandTransitionBehavior_L       = Hand_L.gameObject.AddComponent <HandEnableDisable>();
                RiggedHand_L.Handedness        = Chirality.Left;
                RiggedHand_L.SetEditorLeapPose = false;
                RiggedHand_L.UseMetaCarpals    = UseMetaCarpals;
                RiggedHand_L.SetupRiggedHand();

                RiggedFinger_L_Thumb = (RiggedFinger)RiggedHand_L.fingers[0];
                RiggedFinger_L_Index = (RiggedFinger)RiggedHand_L.fingers[1];
                RiggedFinger_L_Mid   = (RiggedFinger)RiggedHand_L.fingers[2];
                RiggedFinger_L_Ring  = (RiggedFinger)RiggedHand_L.fingers[3];
                RiggedFinger_L_Pinky = (RiggedFinger)RiggedHand_L.fingers[4];

                modelFingerPointing_L = RiggedHand_L.modelFingerPointing;
                modelPalmFacing_L     = RiggedHand_L.modelPalmFacing;

                RiggedHand_L.StoreJointsStartPose();
            }
            Transform Hand_R = null;

            foreach (Transform t in transform)
            {
                if (RightHandStrings.Any(w => t.name.ToLower().Contains(w)))
                {
                    Hand_R = t;
                }
            }
            if (Hand_R != null)
            {
                RiggedHand_R                   = Hand_R.gameObject.AddComponent <RiggedHand>();
                HandTransitionBehavior_R       = Hand_R.gameObject.AddComponent <HandEnableDisable>();
                RiggedHand_R.Handedness        = Chirality.Right;
                RiggedHand_R.SetEditorLeapPose = false;
                RiggedHand_R.UseMetaCarpals    = UseMetaCarpals;
                RiggedHand_R.SetupRiggedHand();

                RiggedFinger_R_Thumb = (RiggedFinger)RiggedHand_R.fingers[0];
                RiggedFinger_R_Index = (RiggedFinger)RiggedHand_R.fingers[1];
                RiggedFinger_R_Mid   = (RiggedFinger)RiggedHand_R.fingers[2];
                RiggedFinger_R_Ring  = (RiggedFinger)RiggedHand_R.fingers[3];
                RiggedFinger_R_Pinky = (RiggedFinger)RiggedHand_R.fingers[4];

                modelFingerPointing_R = RiggedHand_R.modelFingerPointing;
                modelPalmFacing_R     = RiggedHand_R.modelPalmFacing;

                RiggedHand_R.StoreJointsStartPose();
            }
            //Find palms and assign to RiggedHands
            //RiggedHand_L.palm = AnimatorForMapping.GetBoneTransform(HumanBodyBones.LeftHand);
            //RiggedHand_R.palm = AnimatorForMapping.GetBoneTransform(HumanBodyBones.RightHand);

            if (ModelGroupName == "" || ModelGroupName != null)
            {
                ModelGroupName = transform.name;
            }
            HandPoolToPopulate.AddNewGroup(ModelGroupName, RiggedHand_L, RiggedHand_R);
        }