Beispiel #1
0
        /// <summary>
        ///     Position fingers on hand pose
        /// </summary>
        private IEnumerable <MInstruction> MakeHandPose(GameObject go, string side)
        {
            List <MInstruction> list = new List <MInstruction>();

            if (side.Equals("Left"))
            {
                //Get UnitySceneAccess ID of hand
                //GameObject hand = go.transform.Find("LeftHand(Clone)").gameObject;
                GameObject hand = HandChecker.GetLeftHand(go);

                //The desired Hand pose (rotations of the finger Joints)
                UnityHandPose leftHandPose = hand.GetComponent <UnityHandPose>();

                _handPoseIdManager.CurrentHandIdLeft = Guid.NewGuid().ToString();

                //Create the instruction to move the fingers
                MInstruction moveFingersInstructionsLeft = new MInstruction(_handPoseIdManager.CurrentHandIdLeft, "Move Fingers", "Pose/MoveFingers")
                {
                    Properties = new Dictionary <string, string>()
                    {
                        { "Release", "false" },
                        { "Hand", "Left" }
                    },
                    Constraints = new List <MConstraint>()
                };

                //Add properties to the instruction
                var constraintID = Guid.NewGuid().ToString();
                moveFingersInstructionsLeft.Properties.Add("HandPose", constraintID);
                moveFingersInstructionsLeft.Constraints.Add(new MConstraint()
                {
                    ID = constraintID,
                    PostureConstraint = leftHandPose.GetPostureConstraint()
                });

                list.Add(moveFingersInstructionsLeft);
            }

            if (side.Equals("Right"))
            {
                //Get UnitySceneAccess ID of hand
                //GameObject hand = go.transform.Find("RightHand(Clone)").gameObject;
                GameObject hand = HandChecker.GetRightHand(go);
                //String objectID = hand.GetComponent<MMISceneObject>().MSceneObject.ID;

                //The desired Hand pose (rotations of the finger Joints)
                UnityHandPose leftHandPose = hand.GetComponent <UnityHandPose>();

                _handPoseIdManager.CurrentHandIdRight = Guid.NewGuid().ToString();

                //Create the instruction to move the fingers
                MInstruction moveFingersInstructionsRight = new MInstruction(_handPoseIdManager.CurrentHandIdRight, "Move Fingers", "Pose/MoveFingers")
                {
                    Properties = new Dictionary <string, string>()
                    {
                        { "Release", "false" },
                        { "Hand", "Right" }
                    },
                    Constraints = new List <MConstraint>()
                };

                //Add properties to the instruction
                var constraintID = Guid.NewGuid().ToString();
                moveFingersInstructionsRight.Properties.Add("HandPose", constraintID);
                moveFingersInstructionsRight.Constraints.Add(new MConstraint()
                {
                    ID = constraintID,
                    PostureConstraint = leftHandPose.GetPostureConstraint()
                });

                list.Add(moveFingersInstructionsRight);
            }

            return(list);
        }