protected void UpdateBones(HeadSensor sensor)
        {
            if (headTarget.head.target.confidence.position > KinectDevice.TrackingConfidence(KinectDevice.JointID.Head))
            {
                if (headTarget.humanoid.leftHandTarget.hand.target.confidence.position > KinectDevice.TrackingConfidence(KinectDevice.JointID.WristLeft) &&
                    headTarget.humanoid.rightHandTarget.hand.target.confidence.position > KinectDevice.TrackingConfidence(KinectDevice.JointID.WristRight))
                {
                    CalibrateWithHeadAndHands();
                }
                else
                {
                    CalibrateWithHead();
                }
                return;
            }

            //if (headTarget.head.target.confidence.rotation > 0) {
            //    headTarget.head.target.transform.rotation = Kinect2Tracker.SmoothRotation(headTarget.head.target.transform.rotation, sensor.head.rotation);
            //    headTarget.head.target.confidence.rotation = sensor.head.confidence.rotation;

            //    headTarget.head.target.transform.position = Kinect2Tracker.SmoothPosition(headTarget.head.target.transform.position, sensor.head.position);
            //    headTarget.head.target.confidence.position = sensor.head.confidence.position;
            //}

            //if (headTarget.neck.target.confidence.rotation > 0) {
            //    headTarget.neck.target.transform.rotation = Kinect2Tracker.SmoothRotation(headTarget.neck.target.transform.rotation, sensor.neck.rotation);
            //    headTarget.neck.target.confidence.rotation = sensor.neck.confidence.rotation;

            //    headTarget.neck.target.transform.position = Kinect2Tracker.SmoothPosition(headTarget.neck.target.transform.position, sensor.neck.position);
            //    headTarget.neck.target.confidence.position = sensor.neck.confidence.position;
            //}
            else
            {
                if (headTarget.neck.target.transform != null)
                {
                    headTarget.neck.target.transform.position = Target.ToVector3(sensor.neck.position);
                    headTarget.neck.target.transform.rotation = Target.ToQuaternion(sensor.neck.rotation);
                    headTarget.neck.target.confidence         = sensor.neck.confidence;
                }

                if (headTarget.head.target.transform != null)
                {
                    headTarget.head.target.transform.position = Target.ToVector3(sensor.head.position);
                    headTarget.head.target.transform.rotation = Target.ToQuaternion(sensor.head.rotation);
                    headTarget.head.target.confidence         = sensor.head.confidence;
                }


                if (rotationTrackingAxis == RotationTrackingAxis.XY)
                {
                    headTarget.head.target.transform.rotation = Quaternion.LookRotation(headTarget.head.target.transform.rotation * Vector3.forward);
                }
            }
            if (headTarget.virtual3d)
            {
                UpdateVirtual3D();
            }
        }
Exemplo n.º 2
0
        private void UpdateBones()
        {
            head.position            = kinectDevice.GetTargetPosition(KinectDevice.JointID.Head);
            head.confidence.position = KinectDevice.TrackingConfidence(KinectDevice.JointID.Head);

            Rotation localRotation = KinectDevice.GetHeadOrientation();

            head.rotation            = device.ToWorldOrientation(localRotation);
            head.confidence.rotation = 0.6F;

            neck.position            = kinectDevice.GetTargetPosition(KinectDevice.JointID.Neck);
            neck.confidence.position = KinectDevice.TrackingConfidence(KinectDevice.JointID.Neck);

            neck.rotation            = head.rotation;
            neck.confidence.rotation = 0.6F;
        }
Exemplo n.º 3
0
        public override Status Update()
        {
            if (!KinectDevice.JointIsTracked(KinectDevice.JointID.HipCenter))
            {
                status = Status.Present;
                return(status);
            }

            status = Status.Tracking;

            hips.position            = kinectDevice.GetTargetPosition(KinectDevice.JointID.HipCenter);
            hips.confidence.position = KinectDevice.TrackingConfidence(KinectDevice.JointID.HipCenter);

            chest.position            = kinectDevice.GetTargetPosition(KinectDevice.JointID.SpineShoulder);
            chest.confidence.position = KinectDevice.TrackingConfidence(KinectDevice.JointID.SpineShoulder);

            Vector lHipPosition = kinectDevice.GetTargetPosition(KinectDevice.JointID.HipLeft);
            Vector rHipPosition = kinectDevice.GetTargetPosition(KinectDevice.JointID.HipRight);
            Vector lrDirection  = rHipPosition - lHipPosition;
            Vector lrDirection2 = Rotation.AngleAxis(90, Vector.forward) * lrDirection;

            Vector direction = chest.position - hips.position;

            hips.rotation            = kinectDevice.ToWorldOrientation(Rotation_.FromToRotation(direction, lrDirection2) * Rotation.AngleAxis(180, Vector.up));
            hips.confidence.rotation = 0.8F;

            hips.length            = Vector.Magnitude(hips.position - chest.position);
            hips.confidence.length = 0.6F;

            Vector neckPosition = kinectDevice.GetTargetPosition(KinectDevice.JointID.Neck);

            chest.rotation            = CalculateBoneRotation(neckPosition, chest.position, hips.rotation * Vector.forward) * Rotation.AngleAxis(90, Vector.right) * Rotation.AngleAxis(180, Vector.up);
            chest.confidence.rotation = 0.8F;

            chest.length            = Vector.Magnitude(neckPosition - chest.position);
            chest.confidence.length = 0.6F;

            return(status);
        }