2,537
社区成员
发帖
与我相关
我的任务
分享
if(KinectManager.Instance.IsUserDetected())
{
//User is detected.
long userId = KinectManager.Instance.GetPrimaryUserID();//Get user's ID.
int JointType=(int)KinectInterop.JointType.HandRight;//Righthand is the detected joint.
if(KinectManager.Instance.IsJointTracked(userId,JointType))
{
Vector3 rightHandPos = KinectManager.Instance.GetJointPosition(userId,JointType);
Vector3 rightHandScreenPos = Camera.main.WorldToScreenPoint(rightHandPos);
print("rHPx= "+rightHandPos.x+" rHPy= "+rightHandPos.y+" rHPz= "+rightHandPos.z);
print("rHSx= "+rightHandScreenPos.x+" rHSy= "+rightHandScreenPos.y+" rHSz= "+rightHandScreenPos.z);
Vector2 rightHandSenPos = new Vector2( rightHandScreenPos.x, rightHandScreenPos.y);
Vector2 rightHandUguiPos;
if(RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)canvas.transform, rightHandSenPos, null, out rightHandUguiPos))
{
//Right hand is in the rectangle of canvas.
RectTransform rightRectTf = rightHand.transform as RectTransform ;
rightRectTf.anchoredPosition = rightHandUguiPos ;
}
}
}