Esempio n. 1
0
    // returns the joint direction of the specified user, relative to the parent joint
    public Vector3 GetJointDirection(Int64 userId, int joint)
    {
        if (dictUserIdToIndex.ContainsKey(userId))
        {
            int index = dictUserIdToIndex[userId];

            if (index >= 0 && index < KinectWrapper.Constants.BodyCount &&
                bodyFrame.bodyData[index].bIsTracked != 0)
            {
                if (joint >= 0 && joint < KinectWrapper.Constants.JointCount)
                {
                    KinectWrapper.Joint jointData = bodyFrame.bodyData[index].joint[joint];
                    return(jointData.direction);
                }
            }
        }

        return(Vector3.zero);
    }
Esempio n. 2
0
    // returns the joint rotation of the specified user, relative to the Kinect-sensor
    public Quaternion GetJointOrientation(Int64 userId, int joint, bool flip)
    {
        if (dictUserIdToIndex.ContainsKey(userId))
        {
            int index = dictUserIdToIndex[userId];

            if (index >= 0 && index < KinectWrapper.Constants.BodyCount &&
                bodyFrame.bodyData[index].bIsTracked != 0)
            {
                if (joint >= 0 && joint < KinectWrapper.Constants.JointCount)
                {
                    KinectWrapper.Joint jointData = bodyFrame.bodyData[index].joint[joint];
                    return(jointData.orientation);
                }
            }
        }

        return(Quaternion.identity);
    }
Esempio n. 3
0
    // returns true if the given joint of the specified user is being tracked
    public bool IsJointTracked(Int64 userId, int joint)
    {
        if (dictUserIdToIndex.ContainsKey(userId))
        {
            int index = dictUserIdToIndex[userId];

            if (index >= 0 && index < KinectWrapper.Constants.BodyCount &&
                bodyFrame.bodyData[index].bIsTracked != 0)
            {
                if (joint >= 0 && joint < KinectWrapper.Constants.JointCount)
                {
                    KinectWrapper.Joint jointData = bodyFrame.bodyData[index].joint[joint];

                    return(ignoreInferredJoints ? (jointData.trackingState == KinectWrapper.TrackingState.Tracked) :
                           (jointData.trackingState != KinectWrapper.TrackingState.NotTracked));
                }
            }
        }

        return(false);
    }