Ejemplo n.º 1
0
        public void UpdateRootTransform()
        {
            if (_usePreciseRootTransformDirection)
            {
                _preciseRootTransformDirection = _recordRootTransformDirection
                    ? GestureObject.Skeleton.GetRootTransformVector3Direction(GestureObject.TrackThisInRelationTo)
                    : Vector3.zero;
            }
            else
            {
                _rootTransformDirection = _recordRootTransformDirection
                    ? GestureObject.Skeleton.GetRootTransformPoseDirection(GestureObject.TrackThisInRelationTo)
                    : PoseDirection.Undefined;
            }
            if (_usePreciseRootTransformOrientation)
            {
                _preciseRootTransformOrientation = _recordRootTransformOrientation
                    ? GestureObject.Skeleton.GetRootTransformVector3Orientation(GestureObject.TrackThisInRelationTo)
                    : Vector3.zero;
            }
            else
            {
                _rootTransformOrientation = _recordRootTransformOrientation
                    ? GestureObject.Skeleton.GetRootTransformPoseOrientation(GestureObject.TrackThisInRelationTo)
                    : PoseDirection.Undefined;
            }

            _rootTransformPosition = _recordRootTransformPosition
                ? GestureObject.Skeleton.GetRootTransformRelativePosition(GestureObject.TrackThisInRelationTo)
                : Vector3.zero;
        }
        public static PoseDirection CalculateRelativeDirection(Transform origin, Vector3 direction)
        {
            Vector3[] directions =
            {
                origin.forward, origin.forward * -1,
                origin.up,      origin.up * -1,
                origin.right,   origin.right * -1
            };

            PoseDirection[] poses =
            {
                PoseDirection.Forward,
                PoseDirection.Backward,
                PoseDirection.Up,
                PoseDirection.Down,
                PoseDirection.Right,
                PoseDirection.Left
            };

            float         score       = float.MaxValue;
            PoseDirection closestPose = PoseDirection.Undefined;

            for (int i = 0; i < 6; i++)
            {
                float tempScore = Vector3.Angle(directions[i], direction);
                if (tempScore < score)
                {
                    score       = tempScore;
                    closestPose = poses[i];
                }
            }

            return(closestPose);
        }
        private Gesture GenerateSwipeGesure(string name, PoseDirection direction)
        {
            var fingers   = new[] { Finger.Index, Finger.Middle, Finger.Ring };
            var fingerSet = new HandPose("FingersSet", new PalmPose(new AnyHandContext(), direction, orientation: PoseDirection.Forward),
                                         new FingertipDistanceRelation(Finger.Middle, RelativeDistance.Touching, new[] { Finger.Index, Finger.Ring }),
                                         new FingerPose(fingers, PoseDirection.Forward));

            var fingersBent = new HandPose("FingersBent", new PalmPose(new AnyHandContext(), direction, orientation: PoseDirection.Forward),
                                           new FingertipDistanceRelation(Finger.Middle, RelativeDistance.Touching, new[] { Finger.Index, Finger.Ring }),
                                           new FingerPose(fingers, direction | PoseDirection.Backward));

            var swipeGesture = new Gesture(name, fingerSet, fingersBent);

            return(swipeGesture);
        }