コード例 #1
0
    /* Displaying current frames hand joints */
    private void TrackJoints(PXCMHandData handOutput)
    {
        if (hasLaunched)
        {
            return;
        }

        //Get hand by time of appearence
        if (handOutput.QueryHandData(PXCMHandData.AccessOrderType.ACCESS_ORDER_BY_TIME, 0, out handData) == pxcmStatus.PXCM_STATUS_NO_ERROR)
        {
            if (handData.IsCalibrated() == false)
            {
                calibText.text = "Please wait Calibrating hand.";
                return;
            }
            calibText.text = "Hand Calibrated!";

            handData.QueryTrackedJoint(PXCMHandData.JointType.JOINT_THUMB_TIP, out ThumbJointData);
            handData.QueryTrackedJoint(PXCMHandData.JointType.JOINT_INDEX_TIP, out IndexJointData);

            /* get joint distance */
            thumb_pos = new Vector3(ThumbJointData.positionWorld.x, ThumbJointData.positionWorld.y, ThumbJointData.positionWorld.z);
            index_pos = new Vector3(IndexJointData.positionWorld.x, IndexJointData.positionWorld.y, IndexJointData.positionWorld.z);

            pinch_dist = Vector3.Distance(index_pos, thumb_pos);

            /* Update game based on pinch result*/
            HandlePinchResult(pinch_dist);
        }
    }