IsJointTracked() публичный Метод

public IsJointTracked ( uint UserId, int joint ) : bool
UserId uint
joint int
Результат bool
Пример #1
0
    private bool GetUserBodyHeight(KinectManager manager, float scaleFactor, ref float height)
    {
        height = 0f;

        if (manager && manager.IsJointTracked(currentUserId, (int)KinectInterop.JointType.HipLeft) &&
            manager.IsJointTracked(currentUserId, (int)KinectInterop.JointType.HipRight) &&
            manager.IsJointTracked(currentUserId, (int)KinectInterop.JointType.ShoulderLeft) &&
            manager.IsJointTracked(currentUserId, (int)KinectInterop.JointType.ShoulderRight))
        {
            //Vector3 posHipCenter = manager.GetJointPosition(currentUserId, (int)KinectInterop.JointType.SpineBase);
            Vector3 posHipLeft   = manager.GetJointPosition(currentUserId, (int)KinectInterop.JointType.HipLeft);
            Vector3 posHipRight  = manager.GetJointPosition(currentUserId, (int)KinectInterop.JointType.HipRight);
            Vector3 posHipCenter = (posHipLeft + posHipRight) / 2;

            Vector3 posShoulderLeft   = manager.GetJointPosition(currentUserId, (int)KinectInterop.JointType.ShoulderLeft);
            Vector3 posShoulderRight  = manager.GetJointPosition(currentUserId, (int)KinectInterop.JointType.ShoulderRight);
            Vector3 posShoulderCenter = (posShoulderLeft + posShoulderRight) / 2;

            height = (posShoulderCenter.y - posHipCenter.y) * scaleFactor;

            return(true);
        }

        return(false);
    }
Пример #2
0
    private void KinectController()
    {
        if (getPosZ(Kepala, 1) != zKepala)
        {
            if (kinect.IsJointTracked(Kepala))
            {
                zKepala = getPosZ(Kepala, 1);
            }

            if (kinect.IsJointTracked(Kepala))
            {
                yKepala = getPosY(Kepala, 2);
            }
        }

        if (kinect.IsJointTracked(Bahu))
        {
            yBahu = getPosY(Bahu, 2);
        }

        if (kinect.IsJointTracked(BahuKanan))
        {
            xBahuKanan = getPosX(BahuKanan, 1);
        }

        if (kinect.IsJointTracked(BahuKiri))
        {
            xBahuKiri = getPosX(BahuKiri, 1);
        }
    }
    void Update()
    {
        KinectManager manager = KinectManager.Instance;

        if (manager && manager.IsInitialized())
        {
            if (manager.IsUserDetected(playerIndex))
            {
                long userId = manager.GetUserIdByIndex(playerIndex);

                if (manager.IsJointTracked(userId, (int)KinectInterop.JointType.ShoulderLeft) &&
                    manager.IsJointTracked(userId, (int)KinectInterop.JointType.ShoulderRight))
                {
                    Vector3 posLeftShoulder  = manager.GetJointPosition(userId, (int)KinectInterop.JointType.ShoulderLeft);
                    Vector3 posRightShoulder = manager.GetJointPosition(userId, (int)KinectInterop.JointType.ShoulderRight);

                    posLeftShoulder.z  = -posLeftShoulder.z;
                    posRightShoulder.z = -posRightShoulder.z;

                    Vector3 dirLeftRight = posRightShoulder - posLeftShoulder;
                    dirLeftRight -= Vector3.Project(dirLeftRight, Vector3.up);

                    Quaternion rotationShoulders = Quaternion.FromToRotation(Vector3.right, dirLeftRight);

                    transform.rotation = rotationShoulders;
                }
            }
        }
    }
Пример #4
0
    protected void TransformSpecialBone(uint userId, Kinect.JointType joint, Kinect.JointType jointParent, int boneIndex, Vector2 baseDir, bool flip)
    {
        Transform boneTransform = bones[boneIndex];

        if (boneTransform == null || kinectManager == null)
        {
            return;
        }

        if (!kinectManager.IsJointTracked(userId, (int)joint) || !kinectManager.IsJointTracked(userId, (int)jointParent))
        {
            return;
        }

        Vector3    jointDir      = kinectManager.GetDirectionBetweenJoints(userId, (int)jointParent, (int)joint, false, true);
        Quaternion jointRotation = jointDir != Vector3.zero ? Quaternion.FromToRotation(baseDir, jointDir) : Quaternion.identity;

        if (jointRotation != Quaternion.identity)
        {
            Quaternion newRotation = Kinect2AvatarRot(jointRotation, boneIndex);

            if (smoothFactor != 0f)
            {
                boneTransform.rotation = Quaternion.Slerp(boneTransform.rotation, newRotation, smoothFactor * Time.deltaTime);
            }
            else
            {
                boneTransform.rotation = newRotation;
            }
        }
    }
Пример #5
0
    void Update()
    {
        KinectManager manager = KinectManager.Instance;

        if (manager && manager.IsInitialized())
        {
            if (manager.IsUserDetected())
            {
                uint userId = manager.GetPlayer1ID();
                if (manager.IsJointTracked(userId, (int)KinectWrapper.NuiSkeletonPositionIndex.ShoulderLeft) &&
                    manager.IsJointTracked(userId, (int)KinectWrapper.NuiSkeletonPositionIndex.ShoulderRight))
                {
                    Vector3 posLeftShoulder  = manager.GetJointPosition(userId, (int)KinectWrapper.NuiSkeletonPositionIndex.ShoulderLeft);
                    Vector3 posRightShoulder = manager.GetJointPosition(userId, (int)KinectWrapper.NuiSkeletonPositionIndex.ShoulderRight);
                    posLeftShoulder.z  = -posLeftShoulder.z;
                    posRightShoulder.z = -posRightShoulder.z;

                    Vector3 dirLeftRight = posRightShoulder - posLeftShoulder;
                    dirLeftRight -= Vector3.Project(dirLeftRight, Vector3.up);
                    Quaternion rotationShoulders = Quaternion.FromToRotation(Vector3.right, dirLeftRight);

                    transform.rotation = rotationShoulders;
                }
            }
        }
    }
Пример #6
0
    public void FloatWithArm()
    {
        KinectInterop.JointType handJoint     = KinectInterop.JointType.HandRight;
        KinectInterop.JointType shoulderJoint = KinectInterop.JointType.ShoulderRight;
        KinectManager           manager       = KinectManager.Instance;

        if (manager && manager.IsInitialized())
        {
            if (manager.IsUserDetected())
            {
                long    userId = manager.GetPrimaryUserID();
                Vector3 handPos, shoulderPos;
                if (manager.IsJointTracked(userId, (int)shoulderJoint))
                {
                    shoulderPos = manager.GetJointPosition(userId, (int)shoulderJoint);
                    if (manager.IsJointTracked(userId, (int)handJoint))
                    {
                        handPos   = manager.GetJointPosition(userId, (int)handJoint);
                        armEffect = new Vector3(-3 * (handPos.x - shoulderPos.x), 3 * (handPos.y - shoulderPos.y), -3 * (handPos.z - shoulderPos.z));
                        ParticleSystem.VelocityOverLifetimeModule module = particle.velocityOverLifetime;
                    }
                }
            }
        }
    }
Пример #7
0
    void Update()
    {
        if (scalerInited && kinectManager && kinectManager.IsInitialized())
        {
            // get the plane rectangle to be used for object overlay
            if (backgroundPlane && !planeRectSet)
            {
                planeRectSet = true;

                planeRect.width  = 10f * Mathf.Abs(backgroundPlane.localScale.x);
                planeRect.height = 10f * Mathf.Abs(backgroundPlane.localScale.z);
                planeRect.x      = backgroundPlane.position.x - planeRect.width / 2f;
                planeRect.y      = backgroundPlane.position.y - planeRect.height / 2f;
            }

            long userId = kinectManager.GetUserIdByIndex(playerIndex);

            // check user distance and hand positions
            if (userId != 0 && minUserDistance > 0f)
            {
                Vector3 userPos = kinectManager.GetUserPosition(userId);

                bool    lHandTracked = kinectManager.IsJointTracked(userId, (int)KinectInterop.JointType.WristLeft);
                Vector3 lHandPos     = lHandTracked ? kinectManager.GetJointPosition(userId, (int)KinectInterop.JointType.WristLeft) : Vector3.zero;

                bool    rHandTracked = kinectManager.IsJointTracked(userId, (int)KinectInterop.JointType.WristRight);
                Vector3 rHandPos     = rHandTracked ? kinectManager.GetJointPosition(userId, (int)KinectInterop.JointType.WristRight) : Vector3.zero;

                if (userPos.z < minUserDistance ||
                    !lHandTracked || (lHandPos.z - userPos.z) <= -0.3f ||
                    !rHandTracked || (rHandPos.z - userPos.z) <= -0.3f)
                {
                    // don't scale the model
                    userId = 0;
                    //Debug.Log ("Avatar scaling skipped.");
                }
            }

            if (userId != currentUserId)
            {
                currentUserId = userId;

                if (userId != 0)
                {
                    GetUserBodySize(true, true, true);

//					if (fixModelHipsAndShoulders)
//						FixJointsBeforeScale();
                    ScaleAvatar(0f, true);
                }
            }
        }

        if (currentUserId != 0 && continuousScaling)
        {
            GetUserBodySize(true, true, true);
            ScaleAvatar(smoothFactor, false);
        }
    }
Пример #8
0
 //get current joint position and store them in _joints
 void getJointPosition()
 {
     for (int i = 0; i < _numJoints; i++)
     {
         if (manager.IsJointTracked(UserId, i))
         {
             newPos[i] = manager.GetJointPosition(UserId, i);
         }
     }
 }
        void Update()
        {
            if (kinectManager && kinectManager.IsInitialized() && kinectManager.IsUserDetected())
            {
                // 检测站在指定位置的人是否离开指定区域
                if (kinectManager.GetAllUserIds().Contains(oldUserID))
                {
                    Vector3 SpineBasePos = kinectManager.GetJointKinectPosition(oldUserID, jointIndex);
                    if (!IsInRect(SpineBasePos))
                    {
                        //Debug.Log("**********不在指定区域");
                        if (PlayerNotInRect != null)
                        {
                            PlayerNotInRect(oldUserID);
                        }
                    }
                }

                foreach (var userId in kinectManager.GetAllUserIds())
                {
                    // 追踪当前用户骨骼
                    if (kinectManager.IsJointTracked(userId, jointIndex))
                    {
                        Vector3 SpineBasePos = kinectManager.GetJointKinectPosition(userId, jointIndex);
                        if (IsInRect(SpineBasePos))
                        {
                            //var posX = SpineBasePos.x.ToString("F2");
                            //var posZ = SpineBasePos.z.ToString("F2");
                            //Debug.Log(string.Format("*********Pos: [{0}, {1}]" , posX,posZ));
                            oldUserID = userId;
                            if (PlayerInRect != null)
                            {
                                PlayerInRect(userId);
                            }
                        }
                    }
                }
            }

            if (Input.GetKeyDown(KeyCode.Tab))
            {
                foreach (var item in kinectManager.GetAllUserIds())
                {
                    if (kinectManager.IsJointTracked(item, jointIndex))
                    {
                        Vector3 SpineBasePos = kinectManager.GetJointKinectPosition(item, jointIndex);
                        kinectConfig.PlayerPosX = SpineBasePos.x;
                        kinectConfig.PlayerPosZ = SpineBasePos.z;
                        Debug.Log("PosX:" + kinectConfig.PlayerPosX);
                        Debug.Log("PosZ:" + kinectConfig.PlayerPosZ);
                        DataManager.Instance.SaveKinectConfig(kinectConfig);
                    }
                }
            }
        }
Пример #10
0
    //// time counter
    //void timeCounter()
    //{
    //    Stopwatch stopwatch = new Stopwatch();
    //    stopwatch.Start();

    //    for (int i = 0; i < 500; i++)
    //    {
    //        System.Threading.Thread.Sleep(10);
    //    }

    //    stopwatch.Stop();

    //}



    bool IsAllJointTracked()
    {
        for (int i = 0; i < _numJoints; i++)
        {
            if (manager.IsJointTracked(UserId, i) == false)
            {
                return(false);
            }
        }
        return(true);
    }
Пример #11
0
    // Apply the rotations tracked by kinect to the joints.
    protected void TransformBone(Int64 userId, KinectInterop.JointType joint, int boneIndex, bool flip)
    {
        Transform boneTransform = bones[boneIndex];

        if (boneTransform == null || kinectManager == null)
        {
            return;
        }
        int iJoint = (int)joint;

        if (iJoint < 0 || !kinectManager.IsJointTracked(userId, iJoint))
        {
            return;
        }

        // Get Kinect joint orientation
        Quaternion jointRotation = kinectManager.GetJointOrientation(userId, iJoint, flip);

        if (jointRotation == Quaternion.identity)
        {
            return;
        }

        // calculate the new orientation
        Quaternion newRotation = Kinect2AvatarRot(jointRotation, boneIndex);



        if (externalRootMotion)
        {
            newRotation = transform.rotation * newRotation;
        }

        // Smoothly transition to the new rotation
        if (smoothFactor != 0f)
        {
            if (flaten && boneIndex > 4)
            {
                newRotation.x = 0.0f;
                newRotation.y = 0.0f;
            }
            if (flaten && boneIndex < 5)
            {
                newRotation.x = 90.0f;
                newRotation.y = 90.0f;
            }
            boneTransform.rotation = Quaternion.Slerp(boneTransform.rotation, newRotation, smoothFactor * Time.deltaTime);
        }

        else
        {
            boneTransform.rotation = newRotation;
        }
    }
Пример #12
0
 //get current joint position and store them in _joints
 void getJointPosition()
 {
     UserId = manager.GetPlayer1ID();
     for (int i = 0; i < _numJoints; i++)
     {
         if (manager.IsJointTracked(UserId, i))
         {
             _joints[i] = manager.GetJointPosition(UserId, i); //-manager.GetUserPosition(UserID);
         }
     }
 }
Пример #13
0
    private void Update()
    {
        // If left arrow pressed --> side selection
        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            LoadPreviousScene();
        }
        // If right arrow pressed --> start exercise
        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            LoadNextScene();
        }

        if (_kinectManager && _kinectManager.IsInitialized() && _kinectManager.IsUserDetected())
        {
            long userId = _kinectManager.GetPrimaryUserID();

            if (_kinectManager.IsJointTracked(userId, (int)_jointFootRight) &&
                _kinectManager.IsJointTracked(userId, (int)_jointFootLeft))
            {
                float jointPosFootLeftHeight  = _kinectManager.GetJointKinectPosition(userId, (int)_jointFootLeft).y;
                float jointPosFootRightHeight = _kinectManager.GetJointKinectPosition(userId, (int)_jointFootRight).y;
                float jointPosFootLeftDepth   = _kinectManager.GetJointKinectPosition(userId, (int)_jointFootLeft).z;
                float jointPosFootRightDepth  = _kinectManager.GetJointKinectPosition(userId, (int)_jointFootRight).z;

                depthFootLeftText.text   = "L Depth: " + jointPosFootLeftDepth.ToString();
                depthFootRightText.text  = "R Depth: " + jointPosFootRightDepth.ToString();
                heightFootLeftText.text  = "L Height: " + jointPosFootLeftHeight.ToString();
                heightFootRightText.text = "R Height: " + jointPosFootRightHeight.ToString();

                if (((jointPosFootLeftDepth > jointPosFootRightDepth - tolerance) && (jointPosFootLeftDepth < jointPosFootRightDepth + tolerance) &&
                     (jointPosFootRightDepth > jointPosFootLeftDepth - tolerance) && (jointPosFootRightDepth < jointPosFootLeftDepth + tolerance)) &&
                    ((jointPosFootLeftHeight > jointPosFootRightHeight - tolerance) && (jointPosFootLeftHeight < jointPosFootRightHeight + tolerance) &&
                     (jointPosFootRightHeight > jointPosFootLeftHeight - tolerance) && (jointPosFootRightHeight < jointPosFootLeftHeight + tolerance)))
                {
                    if (!buttonExerciseStart.GetComponent <Button>().interactable)
                    {
                        buttonExerciseStart.GetComponent <Button>().interactable = true;
                        buttonExerciseStart.GetComponentInChildren <Text>().text = "Click to start exercise";
                        inRange.text = true.ToString();
                    }
                }
                else
                {
                    if (buttonExerciseStart.GetComponent <Button>().interactable)
                    {
                        inRange.text = false.ToString();
                        buttonExerciseStart.GetComponent <Button>().interactable = false;
                        buttonExerciseStart.GetComponentInChildren <Text>().text = "Please go into starting position";
                    }
                }
            }
        }
    }
Пример #14
0
 private void isCutFruit(RectTransform curFruitRt, ref bool needDestroyFruit)
 {
     if (kinectManager.IsUserDetected())
     {
         //获取用户ID
         long userId    = kinectManager.GetPrimaryUserID();
         int  jointType = (int)KinectInterop.JointType.HandRight;
         if (kinectManager.IsJointTracked(userId, jointType))
         {
             // 获取用户相对Kinect的位置信息
             Vector3 rHandPosition = kinectManager.GetJointKinectPosition(userId, jointType);
             rightTrail.position = rHandPosition;
             Vector3 screenPositionV3           = Camera.main.WorldToScreenPoint(rHandPosition);       //右手位置信息转换成在屏幕上的三维坐标
             Vector2 screenPositionV2           = new Vector2(screenPositionV3.x, screenPositionV3.y); //转换成屏幕上的二维坐标
             KinectInterop.HandState rHandState = kinectManager.GetRightHandState(userId);
             if (rHandState == KinectInterop.HandState.Open && RectTransformUtility.RectangleContainsScreenPoint(curFruitRt, screenPositionV2, Camera.main))
             {
                 //右手切中水果了
                 needDestroyFruit = true;
                 if (curFruit.getType() != Constant.Type_Bomb)
                 {
                     splatterAudio.Play();
                 }
                 else
                 {
                     boomAudio.Play();
                 }
             }
         }
         jointType = (int)KinectInterop.JointType.HandLeft;
         if (kinectManager.IsJointTracked(userId, jointType))
         {
             Vector3 lHandPosition = kinectManager.GetJointKinectPosition(userId, jointType);
             leftTrail.position = lHandPosition;
             Vector3 screenPositionV3           = Camera.main.WorldToScreenPoint(lHandPosition);
             Vector2 screenPositionV2           = new Vector2(screenPositionV3.x, screenPositionV3.y);
             KinectInterop.HandState lHandState = kinectManager.GetLeftHandState(userId);
             if (lHandState == KinectInterop.HandState.Open && RectTransformUtility.RectangleContainsScreenPoint(curFruitRt, screenPositionV2, Camera.main))
             {
                 needDestroyFruit = true;
                 if (curFruit.getType() != Constant.Type_Bomb)
                 {
                     splatterAudio.Play();
                 }
                 else
                 {
                     boomAudio.Play();
                 }
             }
         }
     }
 }
Пример #15
0
    void Update()
    {
        KinectManager manager = KinectManager.Instance;

        if (manager && manager.IsInitialized())
        {
//			Vector3 vRight = BottomRight - BottomLeft;
//			Vector3 vUp = TopLeft - BottomLeft;

            int b = (int)TrackedJoint;
            int a = (int)TrackedJoint2;
            if (manager.IsUserDetected())
            {
                uint userId = manager.GetPlayer1ID();

                if (manager.IsJointTracked(userId, b) && manager.IsJointTracked(userId, a))
                {
                    Vector3 B        = manager.GetRawSkeletonJointPos(userId, b);
                    Vector3 A        = manager.GetRawSkeletonJointPos(userId, a);
                    Vector3 posJoint = new Vector3(4.3f * A.x - 3.3f * B.x, 4.3f * A.y - 3.3f * B.y, 4.3f * A.z - 3.3f * B.z);

                    if (posJoint != Vector3.zero)
                    {
                        // 3d position to depth
                        Vector2 posDepth = manager.GetDepthMapPosForJointPos(posJoint);

                        // depth pos to color pos
                        Vector2 posColor = manager.GetColorMapPosForDepthPos(posDepth);

                        float scaleX = ((float)posColor.x / KinectWrapper.Constants.ColorImageWidth);
                        float scaleY = 0.85f * (1.0f - (float)posColor.y / KinectWrapper.Constants.ColorImageHeight);

                        float scaleX2 = ((float)posColor.x / KinectWrapper.Constants.ColorImageWidth);
                        float scaleY2 = 0.85f * (1.0f - (float)posColor.y / KinectWrapper.Constants.ColorImageHeight);

                        //						Vector3 localPos = new Vector3(scaleX * 10f - 5f, 0f, scaleY * 10f - 5f); // 5f is 1/2 of 10f - size of the plane
                        //						Vector3 vPosOverlay = backgroundImage.transform.TransformPoint(localPos);
                        //Vector3 vPosOverlay = BottomLeft + ((vRight * scaleX) + (vUp * scaleY));

                        if (Sphere2 && Sphere)
                        {
                            Vector3 vPosOverlay  = Camera.main.ViewportToWorldPoint(new Vector3(scaleX, scaleY, distanceToCamera));
                            Vector3 vPosOverlay2 = Camera.main.ViewportToWorldPoint(new Vector3(scaleX2, scaleY2, distanceToCamera2));

                            Sphere.transform.position  = Vector3.Lerp(Sphere.transform.position, vPosOverlay, smoothFactor * Time.deltaTime);
                            Sphere2.transform.position = Vector3.Lerp(Sphere2.transform.position, vPosOverlay2, smoothFactor * Time.deltaTime);
                        }
                    }
                }
            }
        }
    }
Пример #16
0
    // Apply the rotations tracked by kinect to a special joint
    protected virtual void TransformSpecialBone(uint userId, KinectWrapper.NuiSkeletonPositionIndex joint, KinectWrapper.NuiSkeletonPositionIndex jointParent, int boneIndex, Vector3 baseDir, bool flip)
    {
        Transform boneTransform = bones[boneIndex];

        if (boneTransform == null || kinectManager == null)
        {
            return;
        }

        if (!kinectManager.IsJointTracked(userId, (int)joint) ||
            !kinectManager.IsJointTracked(userId, (int)jointParent))
        {
            return;
        }

        Vector3    jointDir      = kinectManager.GetDirectionBetweenJoints(userId, (int)jointParent, (int)joint, false, true);
        Quaternion jointRotation = jointDir != Vector3.zero ? Quaternion.FromToRotation(baseDir, jointDir) : Quaternion.identity;

//		if(!flip)
//		{
//			Vector3 mirroredAngles = jointRotation.eulerAngles;
//			mirroredAngles.y = -mirroredAngles.y;
//			mirroredAngles.z = -mirroredAngles.z;
//
//			jointRotation = Quaternion.Euler(mirroredAngles);
//		}

        if (jointRotation != Quaternion.identity)
        {
            // Smoothly transition to the new rotation
            Quaternion newRotation = Kinect2AvatarRot(jointRotation, boneIndex);

            if (smoothFactor != 0f)
            {
                boneTransform.rotation = Quaternion.Slerp(boneTransform.rotation, newRotation, smoothFactor * Time.deltaTime);
            }
            else
            {
                boneTransform.rotation = newRotation;
            }
        }

//		Vector3 jointPosition = kinectManager.GetJointPosition(userId, (int)joint);
//		Vector3 newPosition = Kinect2AvatarPos(jointPosition, true);
//
//		if(smoothFactor != 0f)
//			boneTransform.position = Vector3.Lerp(boneTransform.position, newPosition, smoothFactor * Time.deltaTime);
//		else
//			boneTransform.position = newPosition;
    }
Пример #17
0
    public bool FixJointsBeforeScale()
    {
        Animator      animatorComponent = GetComponent <Animator>();
        KinectManager manager           = KinectManager.Instance;

        if (animatorComponent && modelBodyHeight > 0f && bodyHeight > 0f)
        {
            Transform hipCenter = animatorComponent.GetBoneTransform(HumanBodyBones.Hips);
            if ((hipCenter.localScale - Vector3.one).magnitude > 0.01f)
            {
                return(false);
            }

            Transform leftUpperLeg  = animatorComponent.GetBoneTransform(HumanBodyBones.LeftUpperLeg);
            Transform rightUpperLeg = animatorComponent.GetBoneTransform(HumanBodyBones.RightUpperLeg);

            Transform leftUpperArm  = animatorComponent.GetBoneTransform(HumanBodyBones.LeftUpperArm);
            Transform rightUpperArm = animatorComponent.GetBoneTransform(HumanBodyBones.RightUpperArm);

            if (leftUpperArm && rightUpperArm && leftUpperLeg && rightUpperLeg)
            {
                if (manager && manager.IsJointTracked(currentUserId, (int)KinectInterop.JointType.ShoulderLeft) &&
                    manager.IsJointTracked(currentUserId, (int)KinectInterop.JointType.ShoulderRight) &&
                    manager.IsJointTracked(currentUserId, (int)KinectInterop.JointType.HipLeft) &&
                    manager.IsJointTracked(currentUserId, (int)KinectInterop.JointType.HipRight))
                {
                    Vector3 posHipCenter = manager.GetJointPosition(currentUserId, (int)KinectInterop.JointType.SpineBase);

                    Vector3 posHipLeft  = manager.GetJointPosition(currentUserId, (int)KinectInterop.JointType.HipLeft);
                    Vector3 posHipRight = manager.GetJointPosition(currentUserId, (int)KinectInterop.JointType.HipRight);

                    Vector3 posShoulderLeft  = manager.GetJointPosition(currentUserId, (int)KinectInterop.JointType.ShoulderLeft);
                    Vector3 posShoulderRight = manager.GetJointPosition(currentUserId, (int)KinectInterop.JointType.ShoulderRight);

                    SetupUnscaledJoint(hipCenter, leftUpperLeg, posHipCenter, (!mirroredAvatar ? posHipLeft : posHipRight), modelBodyHeight, bodyHeight);
                    SetupUnscaledJoint(hipCenter, rightUpperLeg, posHipCenter, (!mirroredAvatar ? posHipRight : posHipLeft), modelBodyHeight, bodyHeight);

                    SetupUnscaledJoint(hipCenter, leftUpperArm, posHipCenter, (!mirroredAvatar ? posShoulderLeft : posShoulderRight), modelBodyHeight, bodyHeight);
                    SetupUnscaledJoint(hipCenter, rightUpperArm, posHipCenter, (!mirroredAvatar ? posShoulderRight : posShoulderLeft), modelBodyHeight, bodyHeight);

                    // recalculate model joints
                    Start();

                    return(true);
                }
            }
        }

        return(false);
    }
    // Update is called once per frame
    void Update()
    {
        // If right arrow pressed --> load user menu
        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            LoadNextScene();
        }

        if (_kinectManager && _kinectManager.IsInitialized() && _kinectManager.IsUserDetected())
        {
            long userId = _kinectManager.GetPrimaryUserID();

            if (_kinectManager.IsJointTracked(userId, (int)_jointFootRight) &&
                _kinectManager.IsJointTracked(userId, (int)_jointFootLeft))
            {
                float jointPosFootLeftDepth  = _kinectManager.GetJointKinectPosition(userId, (int)_jointFootLeft).z;
                float jointPosFootRightDepth = _kinectManager.GetJointKinectPosition(userId, (int)_jointFootRight).z;

                if (((jointPosFootLeftDepth > jointPosFootRightDepth - tolerance) && (jointPosFootLeftDepth < jointPosFootRightDepth + tolerance) &&
                     (jointPosFootRightDepth > jointPosFootLeftDepth - tolerance) && (jointPosFootRightDepth < jointPosFootLeftDepth + tolerance)))
                {
                    if (!buttonUserSelectionStart.GetComponent <Button>().interactable)
                    {
                        if (audioFail.isPlaying)
                        {
                            audioFail.Stop();
                        }
                        audioSuccess.Play();

                        buttonUserSelectionStart.GetComponent <Button>().interactable = true;
                        buttonUserSelectionStart.GetComponentInChildren <Text>().text = "Click me";
                    }
                }
                else
                {
                    if (buttonUserSelectionStart.GetComponent <Button>().interactable)
                    {
                        if (audioSuccess.isPlaying)
                        {
                            audioSuccess.Stop();
                        }
                        audioFail.Play();

                        buttonUserSelectionStart.GetComponent <Button>().interactable = false;
                        buttonUserSelectionStart.GetComponentInChildren <Text>().text = "Please go into starting position";
                    }
                }
            }
        }
    }
Пример #19
0
    void Update()
    {
        manager = KinectManager.Instance;

        if (manager && manager.IsInitialized())
        {
            if (manager.IsUserDetected())
            {
                uint userId = manager.GetPlayer1ID();
                //firstButterfly.GetComponent<firstButterflyMove>().setTarget (firstTrackObject.transform.position);
                //firstButterfly.GetComponent<firstButterflyMove>().moveDistance = false;


                if (manager.IsJointTracked(userId, (int)firstTrackId))
                {
                    Vector3 posJoint         = manager.GetRawSkeletonJointPos(userId, (int)firstTrackId);
                    Vector3 firstMapPosition = getPosition(posJoint);

                    firstButterfly.GetComponent <ButterflyMove>().setTarget(firstTrackObject.transform.position);
                    firstButterfly.GetComponent <ButterflyMove>().roamAround = false;

                    if (firstMapPosition != Vector3.zero)
                    {
                        firstTrackObject.transform.position = Vector3.Lerp(firstTrackObject.transform.position, firstMapPosition, smoothFactor * Time.deltaTime);
                    }
                }

                if (manager.IsJointTracked(userId, (int)secondTrackId))
                {
                    Vector3 posJoint          = manager.GetRawSkeletonJointPos(userId, (int)secondTrackId);
                    Vector3 secondMapPosition = getPosition(posJoint);

                    secondButterfly.GetComponent <ButterflyMove>().setTarget(secondTrackObject.transform.position);
                    secondButterfly.GetComponent <ButterflyMove>().roamAround = false;

                    if (secondMapPosition != Vector3.zero)
                    {
                        secondTrackObject.transform.position = Vector3.Lerp(secondTrackObject.transform.position, secondMapPosition, smoothFactor * Time.deltaTime);
                    }
                }
            }
            else
            {
                firstButterfly.GetComponent <ButterflyMove>().roamAround  = true;
                secondButterfly.GetComponent <ButterflyMove>().roamAround = true;
            }
        }
    }
Пример #20
0
    void Update()
    {
        if (kinectManager && kinectManager.IsInitialized())
        {
            long userId = kinectManager.GetUserIdByIndex(playerIndex);

            if (kinectManager.IsUserTracked(userId) && kinectManager.IsJointTracked(userId, (int)KinectInterop.JointType.SpineBase))
            {
                Vector3 userPos = kinectManager.GetJointPosition(userId, (int)KinectInterop.JointType.SpineBase);

                if (userPos.x >= -limitLeftRight && userPos.x <= limitLeftRight)
                {
                    // calculate the relative position in the movie
                    float relPos = (userPos.x + limitLeftRight) / (2f * limitLeftRight);
                    currentFrame = Mathf.RoundToInt(relPos * (numberOfFrames - 1));

                    if (statusText)
                    {
                        statusText.text = string.Format("X-Pos: {0:F2}, RelPos: {1:F3}, Frame: {2}", userPos.x, relPos, currentFrame);
                    }
                }
            }

            // add here code to display the frame with 'currentFrame' number
            // ...
        }
    }
Пример #21
0
    //根据颜色图像和视口矩形获取骨骼节点位置
    public static Vector3 GetJointPosColorOverlay(int playerIndex, int iJointIndex, Camera camera)
    {
        KinectManager manager = KinectManager.Instance;

        if (manager && manager.IsInitialized() && camera)
        {
            // 得到背景矩形(使用肖像的背景,如果可用)
            Rect backgroundRect             = camera.pixelRect;
            PortraitBackground portraitBack = PortraitBackground.Instance;
            if (portraitBack && portraitBack.enabled)
            {
                backgroundRect = portraitBack.GetBackgroundRect();
            }
            // overlay the joint
            if (manager.IsUserDetected())
            {
                long userId = manager.GetUserIdByIndex(playerIndex);

                if (manager.IsJointTracked(userId, iJointIndex))
                {
                    Vector3 posJoint = manager.GetJointPosColorOverlay(userId, iJointIndex, camera, backgroundRect);
                    return(posJoint);
                }
            }
        }
        return(Vector3.zero);
    }
Пример #22
0
    // Moves the avatar in 3D space - pulls the tracked position of the spine and applies it to root.
    // Only pulls positional, not rotational.
    void MoveAvatar(uint UserID)
    {
        if (Root == null || Root.parent == null || kinectManager == null)
        {
            return;
        }
        if (!kinectManager.IsJointTracked(UserID, (int)KinectWrapper.SkeletonJoint.HIPS))
        {
            return;
        }

        // Get the position of the body and store it.
        Vector3 trans = kinectManager.GetUserPosition(UserID);

        // If this is the first time we're moving the avatar, set the offset. Otherwise ignore it.
        if (!OffsetCalibrated)
        {
            OffsetCalibrated = true;

            XOffset = !MirroredMovement ? trans.x * MoveRate : -trans.x * MoveRate;
            YOffset = trans.y * MoveRate;
            ZOffset = -trans.z * MoveRate;
        }

        // Smoothly transition to the new position
        Vector3 targetPos = Kinect2AvatarPos(trans, VerticalMovement);

        Root.parent.localPosition = Vector3.Lerp(Root.parent.localPosition, targetPos, SmoothFactor * Time.deltaTime);
    }
Пример #23
0
    // joint の処理
    IEnumerator GetJoint()
    {
        while (true)
        {
            KinectManager manager = KinectManager.Instance;

            if (manager && manager.IsInitialized() && manager.IsUserDetected())
            {
                // userIdを取得
                uint userId = manager.GetPlayer1ID();

                // 感知したかどうか
                SetIsDetected(true);

                // jointが動いたかどうか
                if (manager.IsJointTracked(userId, JointKinectNumber))
                {
                    JointPosObjUpdate(manager, userId); // 関節のpositionを更新
                }
            }
            else
            {
                // 感知したかどうか
                SetIsDetected(false);
            }

            yield return(new WaitForSeconds(TimeDiff));
        }
    }
Пример #24
0
    void Update()
    {
        if (kinectManager && kinectManager.IsInitialized())
        {
            long userId = kinectManager.GetUserIdByIndex(playerIndex);

            if (userId != 0 && kinectManager.IsJointTracked(userId, (int)playerJoint))
            {
                Vector3 headPos = kinectManager.GetJointPosition(userId, (int)playerJoint);
                if (invertedZMovement)
                {
                    headPos.z = -headPos.z;
                }

                headPos           += originPosition;
                transform.position = headPos + transform.forward * 0.1f;

                if (applyJointRotation)
                {
                    Quaternion headRot = kinectManager.GetJointOrientation(userId, (int)playerJoint, !mirroredView);

                    Vector3    jointDir    = kinectManager.GetJointDirection(userId, (int)playerJoint, mirroredView, invertedZMovement);
                    Quaternion invPitchRot = Quaternion.FromToRotation(jointDir, Vector3.up);
                    headRot = headRot * invPitchRot;

                    transform.rotation = Quaternion.Slerp(transform.rotation, initialHeadRot * headRot, smoothFactor * Time.deltaTime);
                }
            }
        }
    }
Пример #25
0
    public Vector3 test(KinectInterop.JointType jointType)
    {
        int           joint         = (int)jointType;
        KinectManager kinectManager = KinectManager.Instance;

        if (kinectManager && kinectManager.IsInitialized())
        {
            if (kinectManager.IsUserDetected())
            {
                long userId = kinectManager.GetPrimaryUserID();
                if (kinectManager.IsJointTracked(userId, joint))
                {
                    Vector3 jointPostion = kinectManager.GetJointKinectPosition(userId, joint);
                    if (jointPostion != Vector3.zero)
                    {
                        Vector2 depthPosition = kinectManager.MapSpacePointToDepthCoords(jointPostion);
                        ushort  depthValue    = kinectManager.GetDepthForPixel((int)depthPosition.x, (int)depthPosition.y);
                        if (depthValue > 0)
                        {
                            Vector2 colorPosition = kinectManager.MapDepthPointToColorCoords(depthPosition, depthValue);
                            float   xNorm         = colorPosition.x / kinectManager.GetColorImageWidth();
                            float   yNorm         = colorPosition.x / kinectManager.GetColorImageHeight();
                            Vector3 v3            = Camera.main.ViewportToScreenPoint(new Vector3(xNorm, yNorm, 0));
                            return(v3);
                        }
                    }
                }
            }
        }
        return(Vector3.zero);
    }
Пример #26
0
    // Update is called once per frame
    void Update()
    {
        KinectManager manager = KinectManager.Instance;

        if (!manager)
        {
            return;
        }
        long userId = manager.GetUserIdByIndex(0);                                                                                                 //获取玩家ID

        if (manager.IsJointTracked(userId, (int)KinectInterop.JointType.SpineMid))                                                                 //追踪到玩家脊柱骨骼
        {
            Vector3 posJoint = manager.GetJointPosColorOverlay(userId, (int)KinectInterop.JointType.SpineMid, Camera.main, Camera.main.pixelRect); //获取位置

            if (posJoint != Vector3.zero)
            {
                Vector3 viewportPos = Camera.main.WorldToViewportPoint(posJoint); //转换为视口坐标
                if (viewportPos.x > 0.4f && viewportPos.x < 0.6f)                 //限定范围(从左到右 0到1)
                {
                    isMid = true;
                }
                else
                {
                    isMid = false;
                }
            }
        }
    }
Пример #27
0
    void Update()
    {
        KinectManager manager = KinectManager.Instance;

        if (manager && manager.IsInitialized())
        {
            //backgroundImage.renderer.material.mainTexture = manager.GetUsersClrTex();
            if (backgroundImage && (backgroundImage.texture == null))
            {
                backgroundImage.texture = manager.GetUsersClrTex();
            }

//			Vector3 vRight = BottomRight - BottomLeft;
//			Vector3 vUp = TopLeft - BottomLeft;

            if (manager.IsUserDetected())
            {
                uint userId = manager.GetPlayer1ID();

                foreach (GameObject joint in this.OverlayObjects)
                {
                    KinectWrapper.NuiSkeletonPositionIndex skelton = joint.GetComponent <SkeltonPosIndexName>().getSkelton();
                    int iJointIndex = this.TrackedJoints.IndexOf(skelton);
                    Debug.Log("Pos : " + iJointIndex);

                    if (manager.IsJointTracked(userId, iJointIndex))
                    {
                        Vector3 posJoint = manager.GetRawSkeletonJointPos(userId, (int)skelton);

                        if (posJoint != Vector3.zero)
                        {
                            // 3d position to depth
                            Vector2 posDepth = manager.GetDepthMapPosForJointPos(posJoint);

                            // depth pos to color pos
                            Vector2 posColor = manager.GetColorMapPosForDepthPos(posDepth);

                            float scaleX = (float)posColor.x / KinectWrapper.Constants.ColorImageWidth;
                            float scaleY = 1.0f - (float)posColor.y / KinectWrapper.Constants.ColorImageHeight;

                            //						Vector3 localPos = new Vector3(scaleX * 10f - 5f, 0f, scaleY * 10f - 5f); // 5f is 1/2 of 10f - size of the plane
                            //						Vector3 vPosOverlay = backgroundImage.transform.TransformPoint(localPos);
                            //Vector3 vPosOverlay = BottomLeft + ((vRight * scaleX) + (vUp * scaleY));

                            if (debugText)
                            {
                                debugText.GetComponent <GUIText> ().text = "Tracked user ID: " + userId;                                 // new Vector2(scaleX, scaleY).ToString();
                            }

                            if (OverlayObjects[0])
                            {
                                Vector3 vPosOverlay = Camera.main.ViewportToWorldPoint(new Vector3(scaleX, scaleY, distanceToCamera));
                                OverlayObjects[iJointIndex].transform.position = Vector3.Lerp(OverlayObjects[iJointIndex].transform.position, vPosOverlay, smoothFactor * Time.deltaTime);
                            }
                        }
                    }
                }
            }
        }
    }
    // gets the joint position in space
    private Vector3 GetJointPosition(KinectManager manager, int joint)
    {
        Vector3 vPosJoint = Vector3.zero;

        if (manager.IsJointTracked(currentUserId, joint))
        {
            if (foregroundCamera)
            {
                // get the background rectangle (use the portrait background, if available)
                Rect backgroundRect             = foregroundCamera.pixelRect;
                PortraitBackground portraitBack = PortraitBackground.Instance;

                if (portraitBack && portraitBack.enabled)
                {
                    backgroundRect = portraitBack.GetBackgroundRect();
                }

                // get the color overlay position
                vPosJoint = manager.GetJointPosColorOverlay(currentUserId, joint, foregroundCamera, backgroundRect);
            }

//			else
            if (vPosJoint == Vector3.zero)
            {
                vPosJoint = manager.GetJointPosition(currentUserId, joint);
            }
        }

        return(vPosJoint);
    }
Пример #29
0
    void Update()
    {
        if (isSaving)
        {
            // create the file, if needed
            if (!File.Exists(saveFilePath))
            {
                using (StreamWriter writer = File.CreateText(saveFilePath))
                {
                    // csv file header
                    string sLine = "time,joint,pos_x,pos_y,poz_z";
                    writer.WriteLine(sLine);
                }
            }

            // check the start time
            if (saveStartTime < 0f)
            {
                saveStartTime = Time.time;
            }
        }

        // get the joint position
        KinectManager manager = KinectManager.Instance;

        if (manager && manager.IsInitialized())
        {
            if (manager.IsUserDetected(playerIndex))
            {
                long userId = manager.GetUserIdByIndex(playerIndex);

                foreach (int joint in Enum.GetValues(typeof(KinectInterop.JointType)))
                {
                    if (manager.IsJointTracked(userId, (int)joint))
                    {
                        // output the joint position for easy tracking
                        Vector3 jointPos = manager.GetJointPosition(userId, joint);
                        jointPosition = jointPos;

                        if (isSaving)
                        {
                            if ((secondsToSave == 0f) || ((Time.time - saveStartTime) <= secondsToSave))
                            {
#if !UNITY_WSA
                                using (StreamWriter writer = File.AppendText(saveFilePath))
                                {
                                    string sLine = string.Format("{0:F3},{1},{2:F3},{3:F3},{4:F3}", Time.time, ((KinectInterop.JointType)joint).ToString(), jointPos.x, jointPos.y, jointPos.z);
                                    writer.WriteLine(sLine);
                                }
#else
                                string sLine = string.Format("{0:F3},{1},{2:F3},{3:F3},{4:F3}", Time.time, ((KinectInterop.JointType)joint).ToString(), jointPos.x, jointPos.y, jointPos.z);
                                Debug.Log(sLine);
#endif
                            }
                        }
                    }
                }
            }
        }
    }
Пример #30
0
        void Update()
        {
            KinectManager kinectManager = KinectManager.Instance;

            if (kinectManager && kinectManager.IsInitialized())
            {
                int iJointIndex = (int)trackedJoint;

                if (kinectManager.IsUserDetected(playerIndex))
                {
                    ulong userId = kinectManager.GetUserIdByIndex(playerIndex);

                    if (kinectManager.IsJointTracked(userId, iJointIndex))
                    {
                        if (sensorTransform != null)
                        {
                            vPosJoint = kinectManager.GetJointKinectPosition(userId, iJointIndex, true);
                        }
                        else
                        {
                            vPosJoint = kinectManager.GetJointPosition(userId, iJointIndex);
                        }

                        vPosJoint.z = invertedZMovement ? -vPosJoint.z : vPosJoint.z;


                        if (sensorTransform)
                        {
                            vPosJoint = sensorTransform.TransformPoint(vPosJoint);
                        }

                        if (userId != currentUserId)
                        {
                            currentUserId     = userId;
                            initialUserOffset = vPosJoint;
                        }

                        Vector3 vPosObject = relToInitialPos ? initialPosition + (vPosJoint - initialUserOffset) : vPosJoint;

                        if (debugText)
                        {
                            debugText.text = string.Format("{0} - ({1:F3}, {2:F3}, {3:F3})", trackedJoint,
                                                           vPosObject.x, vPosObject.y, vPosObject.z);
                        }

                        //if(moveTransform)
                        {
                            if (smoothFactor != 0f)
                            {
                                transform.position = Vector3.Lerp(transform.position, vPosObject, smoothFactor * Time.deltaTime);
                            }
                            else
                            {
                                transform.position = vPosObject;
                            }
                        }
                    }
                }
            }
        }
    // Update is called once per frame
    void Update()
    {
        km = KinectManager.Instance;
        string trackedJointsString = "Tracked Joints:";
        if (km != null) {
            if (km.IsUserDetected()) {
                uint userId = km.GetPlayer1ID();
                /*trackedJointsString += "\nchecking joints";
                if(km.IsJointTracked(userId, (int)rightHand))
                    trackedJointsString += "\nRight hand";
                if(km.IsJointTracked(userId, (int)rightWrist))
                    trackedJointsString += "\nRight wrist";
                if(km.IsJointTracked(userId, (int)centreHip))
                    trackedJointsString += "\nCentre Hip";
                if(km.IsJointTracked(userId, (int)leftShoulder))
                    trackedJointsString += "\nLeft shoulder";
                if(km.IsJointTracked(userId, (int)centreShoulder))
                    trackedJointsString += "\nCentre shoulder";
                if(km.IsJointTracked(userId, (int)rightShoulder))
                    trackedJointsString += "\nRight shoulder";
                trackedJointsString += "\ndone checking joints";*/

                if (km.IsJointTracked(userId, (int)rightHand) && km.IsJointTracked(userId, (int)rightShoulder))
                    wristVector = km.GetJointPosition(userId, (int)rightHand) - km.GetJointPosition(userId, (int)rightShoulder);
                if (km.IsJointTracked(userId, (int)rightShoulder) && km.IsJointTracked(userId, (int)leftShoulder))
                    shouldersVector = km.GetJointPosition(userId, (int)rightShoulder) - km.GetJointPosition(userId, (int)leftShoulder);
                if (km.IsJointTracked(userId, (int)centreShoulder) && km.IsJointTracked(userId, (int)centreHip))
                    backVector = km.GetJointPosition(userId, (int)centreShoulder) - km.GetJointPosition(userId, (int)centreHip);

                //GramSchmidt Orthonormal Space
                Vector3 e2 = backVector.normalized;
                Vector3 e1 = (shouldersVector - Vector3.Dot (shouldersVector,e2) * e2).normalized;

                wristVectorInPlane = new Vector2(Vector3.Dot(e1, wristVector), Vector3.Dot(e2, wristVector));

            }
        }
        trackedJointsText.text = trackedJointsString;
        CheckPointingTopRight();
    }
Пример #32
0
    private bool GetUserBodyHeight(KinectManager manager, float scaleFactor, ref float height)
    {
        height = 0f;

        if(manager && manager.IsJointTracked(currentUserId, (int)KinectInterop.JointType.HipLeft) &&
           manager.IsJointTracked(currentUserId, (int)KinectInterop.JointType.HipRight) &&
           manager.IsJointTracked(currentUserId, (int)KinectInterop.JointType.ShoulderLeft) &&
           manager.IsJointTracked(currentUserId, (int)KinectInterop.JointType.ShoulderRight))
        {
            //Vector3 posHipCenter = manager.GetJointPosition(currentUserId, (int)KinectInterop.JointType.SpineBase);
            Vector3 posHipLeft = manager.GetJointPosition(currentUserId, (int)KinectInterop.JointType.HipLeft);
            Vector3 posHipRight = manager.GetJointPosition(currentUserId, (int)KinectInterop.JointType.HipRight);
            Vector3 posHipCenter = (posHipLeft + posHipRight) / 2;

            Vector3 posShoulderLeft = manager.GetJointPosition(currentUserId, (int)KinectInterop.JointType.ShoulderLeft);
            Vector3 posShoulderRight = manager.GetJointPosition(currentUserId, (int)KinectInterop.JointType.ShoulderRight);
            Vector3 posShoulderCenter = (posShoulderLeft + posShoulderRight) / 2;

            height = (posShoulderCenter.y - posHipCenter.y) * scaleFactor;

            return true;
        }

        return false;
    }
Пример #33
0
    // gets the joint position in space
    private Vector3 GetJointPosition(KinectManager manager, int joint)
    {
        Vector3 vPosJoint = Vector3.zero;

        if(manager.IsJointTracked(currentUserId, joint))
        {
            if(foregroundCamera)
            {
                // get the background rectangle (use the portrait background, if available)
                Rect backgroundRect = foregroundCamera.pixelRect;
                PortraitBackground portraitBack = PortraitBackground.Instance;

                if(portraitBack && portraitBack.enabled)
                {
                    backgroundRect = portraitBack.GetBackgroundRect();
                }

                // get the color overlay position
                vPosJoint = manager.GetJointPosColorOverlay(currentUserId, joint, foregroundCamera, backgroundRect);
            }
            else
            //if(vPosJoint == Vector3.zero)
            {
                vPosJoint = manager.GetJointPosition(currentUserId, joint);
            }
        }

        return vPosJoint;
    }
Пример #34
0
    private bool GetUserBoneLength(KinectManager manager, KinectInterop.JointType baseJoint, KinectInterop.JointType endJoint, float scaleFactor, ref float length)
    {
        length = 0f;

        if(manager && manager.IsJointTracked(currentUserId, (int)baseJoint) &&
           manager.IsJointTracked(currentUserId, (int)endJoint))
        {
            Vector3 vPos1 = manager.GetJointPosition(currentUserId, (int)baseJoint);
            Vector3 vPos2 = manager.GetJointPosition(currentUserId, (int)endJoint);

            length = (vPos2 - vPos1).magnitude * scaleFactor;

            return true;
        }

        return false;
    }