public bool GestureCompleted(uint userId, int userIndex, KinectGestures.Gestures gesture, KinectWrapper.SkeletonJoint joint, Vector3 screenPos) { string sGestureText = gesture + " detected"; if (GestureInfo != null) { GestureInfo.GetComponent <GUIText>().text = sGestureText; } if (gesture == KinectGestures.Gestures.SwipeLeft) { swipeLeft = true; } else if (gesture == KinectGestures.Gestures.SwipeRight) { swipeRight = true; } else if (gesture == KinectGestures.Gestures.SwipeUp) { swipeUp = true; } else if (gesture == KinectGestures.Gestures.SwipeDown) { swipeDown = true; } return(true); }
public void GestureInProgress(uint userId, int userIndex, KinectGestures.Gestures gesture, float progress, KinectWrapper.SkeletonJoint joint, Vector3 screenPos) { //GestureInfo.guiText.text = string.Format("{0} Progress: {1:F1}%", gesture, (progress * 100)); if (gesture == KinectGestures.Gestures.Click && progress > 0.3f) { string sGestureText = string.Format("{0} {1:F1}% complete", gesture, progress * 100); if (GestureInfo != null) { GestureInfo.GetComponent <GUIText>().text = sGestureText; } progressDisplayed = true; } else if ((gesture == KinectGestures.Gestures.ZoomOut || gesture == KinectGestures.Gestures.ZoomIn) && progress > 0.5f) { string sGestureText = string.Format("{0} detected, zoom={1:F1}%", gesture, screenPos.z * 100); if (GestureInfo != null) { GestureInfo.GetComponent <GUIText>().text = sGestureText; } progressDisplayed = true; } else if (gesture == KinectGestures.Gestures.Wheel && progress > 0.5f) { string sGestureText = string.Format("{0} detected, angle={1:F1} deg", gesture, screenPos.z); if (GestureInfo != null) { GestureInfo.GetComponent <GUIText>().text = sGestureText; } progressDisplayed = true; } }
public bool GestureCompleted(uint userId, int userIndex, KinectGestures.Gestures gesture, KinectWrapper.SkeletonJoint joint, Vector3 screenPos) { string sGestureText = gesture + " detected"; if (GestureInfo != null) { GestureInfo.guiText.text = sGestureText; } if (gesture == KinectGestures.Gestures.SwipeLeft) { swipeLeft = true; } else if (gesture == KinectGestures.Gestures.SwipeRight) { swipeRight = true; } else if (gesture == KinectGestures.Gestures.SwipeUp) { swipeUp = true; } else if (gesture == KinectGestures.Gestures.SwipeDown) { swipeDown = true; } else if (gesture == KinectGestures.Gestures.RaiseRightHand) { Application.LoadLevel("Level1Selection"); } return(true); }
public bool GestureCompleted(uint userId, int userIndex, KinectGestures.Gestures gesture, KinectWrapper.SkeletonJoint joint, Vector3 screenPos) { DisplayText(gesture + " detected"); progressDisplayed = false; return(true); }
public bool GestureCancelled(uint userId, int userIndex, KinectGestures.Gestures gesture, KinectWrapper.SkeletonJoint joint) { if (progressDisplayed) { DisplayText(String.Empty); progressDisplayed = false; } return(true); }
// Invoked when a gesture is cancelled. public bool GestureCancelled(uint userId, KinectWrapper.Gestures gesture, KinectWrapper.SkeletonJoint joint) { if (progressDisplayed) { // clear the progress info if (GestureInfo != null) { GestureInfo.guiText.text = String.Empty; } progressDisplayed = false; } return(true); }
public void GestureInProgress(uint userId, int userIndex, KinectGestures.Gestures gesture, float progress, KinectWrapper.SkeletonJoint joint, Vector3 screenPos) { //GestureInfo.guiText.text = string.Format("{0} Progress: {1:F1}%", gesture, (progress * 100)); if (gesture == KinectGestures.Gestures.Click && progress > 0.3f) { //string sGestureText = string.Format ("{1:F2} detected, zoom={2:F2}%", screenPos.x, screenPos.y); if (GestureInfo != null) { //GestureInfo.guiText.text = sGestureText; progressDisplayed = true; } } }
// Apply the rotations tracked by kinect to the joints. void TransformBone(uint userId, KinectWrapper.SkeletonJoint joint, bool isMirrored) { int boneIndex = GetJointIndex(joint, isMirrored); if (boneIndex < 0) { return; } Transform boneTransform = bones[boneIndex]; if (boneTransform == null) { return; } // Grab the bone we're moving. int iJoint = (int)joint; if (iJoint < 0) { return; } // Get Kinect joint orientation Quaternion jointRotation = KinectManager.Instance.GetJointOrientation(userId, iJoint, !isMirrored); if (jointRotation == Quaternion.identity) { return; } // Apply the new rotation. Quaternion newRotation = jointRotation * initialRotations[boneIndex]; //If an offset node is specified, combine the transform with its //orientation to essentially make the skeleton relative to the node if (offsetNode != null) { // Grab the total rotation by adding the Euler and offset's Euler. Vector3 totalRotation = newRotation.eulerAngles + offsetNode.transform.rotation.eulerAngles; // Grab our new rotation. newRotation = Quaternion.Euler(totalRotation); } // Smoothly transition to our new rotation. boneTransform.rotation = Quaternion.Slerp(boneTransform.rotation, newRotation, Time.deltaTime * SmoothFactor); }
public bool GestureCancelled(uint userId, int userIndex, KinectGestures.Gestures gesture, KinectWrapper.SkeletonJoint joint) { if (progressDisplayed) { // clear the progress info if (GestureInfo != null) { GestureInfo.GetComponent <GUIText>().text = String.Empty; } progressDisplayed = false; } return(true); }
// Invoked when a gesture is complete. // Return true, if the gesture must be detected again, false otherwise public bool GestureComplete(uint userId, KinectWrapper.Gestures gesture, KinectWrapper.SkeletonJoint joint, Vector3 screenPos) { string sGestureText = gesture + " detected"; Debug.Log(sGestureText); if (sGestureText == "SwipeLeft detected") { //GameObject.Find("CubeCloud").animation.Play("CubeCloudTurnLeft"); GameObject.Find("CubeCloud").GetComponent <CubeCloudGenerator>().turnLeft = true; } else if (sGestureText == "SwipeRight detected") { GameObject.Find("CubeCloud").animation.Play("CubeCloudTurnRight"); } else if (sGestureText == "RaiseRightHand detected") { GameObject.Find("CubeCloud").GetComponent <CubeCloudGenerator>().turnLeft = false; } if (gesture == KinectWrapper.Gestures.Click) { sGestureText += string.Format(" at ({0:F1}, {1:F1})", screenPos.x, screenPos.y); handArea = GameObject.Find("RightHandArea"); if (handArea.transform.childCount != 0) { Debug.Log("NOT EMPTY!!!!!!"); handArea.transform.GetChild(0).gameObject.renderer.material = temp; changeableObject = handArea.transform.GetChild(0).gameObject; } else { Debug.Log("EMPTY!!"); } } if (GestureInfo != null) { GestureInfo.guiText.text = sGestureText; } progressDisplayed = false; return(true); }
// Returns the correct bone index, depending on the mirroring int GetJointIndex(KinectWrapper.SkeletonJoint joint, bool isMirrored) { if (isMirrored) { switch (joint) { case KinectWrapper.SkeletonJoint.LEFT_SHOULDER: return((int)KinectWrapper.SkeletonJoint.RIGHT_SHOULDER); case KinectWrapper.SkeletonJoint.LEFT_ELBOW: return((int)KinectWrapper.SkeletonJoint.RIGHT_ELBOW); case KinectWrapper.SkeletonJoint.LEFT_HAND: return((int)KinectWrapper.SkeletonJoint.RIGHT_HAND); case KinectWrapper.SkeletonJoint.RIGHT_SHOULDER: return((int)KinectWrapper.SkeletonJoint.LEFT_SHOULDER); case KinectWrapper.SkeletonJoint.RIGHT_ELBOW: return((int)KinectWrapper.SkeletonJoint.LEFT_ELBOW); case KinectWrapper.SkeletonJoint.RIGHT_HAND: return((int)KinectWrapper.SkeletonJoint.LEFT_HAND); case KinectWrapper.SkeletonJoint.LEFT_HIP: return((int)KinectWrapper.SkeletonJoint.RIGHT_HIP); case KinectWrapper.SkeletonJoint.LEFT_KNEE: return((int)KinectWrapper.SkeletonJoint.RIGHT_KNEE); case KinectWrapper.SkeletonJoint.LEFT_FOOT: return((int)KinectWrapper.SkeletonJoint.RIGHT_FOOT); case KinectWrapper.SkeletonJoint.RIGHT_HIP: return((int)KinectWrapper.SkeletonJoint.LEFT_HIP); case KinectWrapper.SkeletonJoint.RIGHT_KNEE: return((int)KinectWrapper.SkeletonJoint.LEFT_KNEE); case KinectWrapper.SkeletonJoint.RIGHT_FOOT: return((int)KinectWrapper.SkeletonJoint.LEFT_FOOT); } } return((int)joint); }
// Invoked when a gesture is complete. // Return true, if the gesture must be detected again, false otherwise public bool GestureComplete(uint userId, KinectWrapper.Gestures gesture, KinectWrapper.SkeletonJoint joint, Vector3 screenPos) { string sGestureText = gesture + " detected"; if (gesture == KinectWrapper.Gestures.Click) { sGestureText += string.Format(" at ({0:F1}, {1:F1})", screenPos.x, screenPos.y); } if (GestureInfo != null) { GestureInfo.GetComponent <GUIText>().text = sGestureText; } return(true); }
// Invoked when a gesture is complete. // Return true, if the gesture must be detected again, false otherwise public bool GestureComplete(uint userId, KinectWrapper.Gestures gesture, KinectWrapper.SkeletonJoint joint, Vector3 screenPos) { string sGestureText = gesture + " detected"; if (gesture == KinectWrapper.Gestures.Click) { sGestureText += string.Format(" at ({0:F1}, {1:F1})", screenPos.x, screenPos.y); } if (GestureInfo != null) { GestureInfo.guiText.text = sGestureText; } progressDisplayed = false; return(true); }
// Invoked when a gesture is in progress // The gesture must be added first, with KinectManager.Instance.DetectGesture() public void GestureInProgress(uint userId, KinectWrapper.Gestures gesture, float progress, KinectWrapper.SkeletonJoint joint, Vector3 screenPos) { //GestureInfo.guiText.text = string.Format("{0} Progress: {1:F1}%", gesture, (progress * 100)); if ((gesture == KinectWrapper.Gestures.RightHandCursor || gesture == KinectWrapper.Gestures.LeftHandCursor) && progress > 0.5f) { // if(HandCursor != null) // { // HandCursor.transform.position = Vector3.Lerp(HandCursor.transform.position, screenPos, 3 * Time.deltaTime); // } // // string sGestureText = string.Format("{0} - ({1:F1}, {2:F1} {3:F1})", gesture, screenPos.x, screenPos.y, progress * 100); // Debug.Log(sGestureText); } else if (gesture == KinectWrapper.Gestures.Click && progress > 0.3f) { string sGestureText = string.Format("{0} {1:F1}% complete", gesture, progress * 100); if (GestureInfo != null) { GestureInfo.guiText.text = sGestureText; } progressDisplayed = true; } else if ((gesture == KinectWrapper.Gestures.ZoomOut || gesture == KinectWrapper.Gestures.ZoomIn) && progress > 0.5f) { string sGestureText = string.Format("{0} detected, zoom={1:F1}%", gesture, screenPos.z * 100); if (GestureInfo != null) { GestureInfo.guiText.text = sGestureText; } progressDisplayed = true; } else if (gesture == KinectWrapper.Gestures.Wheel && progress > 0.5f) { string sGestureText = string.Format("{0} detected, angle={1:F1} deg", gesture, screenPos.z); if (GestureInfo != null) { GestureInfo.guiText.text = sGestureText; } progressDisplayed = true; } }
// Apply the rotations tracked by kinect to the joints. void TransformBone(uint userId, KinectWrapper.SkeletonJoint joint, int boneIndex, bool flip) { Transform boneTransform = bones[boneIndex]; if (boneTransform == null || kinectManager == null) { return; } int iJoint = (int)joint; if (iJoint < 0) { return; } // Get Kinect joint orientation Quaternion jointRotation = kinectManager.GetJointOrientation(userId, iJoint, flip); if (jointRotation == Quaternion.identity) { return; } // 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; } }
public bool GestureCompleted(uint userId, int userIndex, KinectGestures.Gestures gesture, KinectWrapper.SkeletonJoint joint, Vector3 screenPos) { string sGestureText = gesture + " detected"; if (gesture == KinectGestures.Gestures.Click) { Changed(screenPos.x, screenPos.y); sGestureText += string.Format(" at ({0:F1}, {1:F1})", screenPos.x, screenPos.y); } else if (gesture == KinectGestures.Gestures.RaiseRightHand) { Application.LoadLevel("Level1"); } if (GestureInfo != null) { GestureInfo.guiText.text = sGestureText; } progressDisplayed = false; return(true); }
public void GestureInProgress(uint userId, int userIndex, KinectGestures.Gestures gesture, float progress, KinectWrapper.SkeletonJoint joint, Vector3 screenPos) { //GestureInfo.guiText.text = string.Format("{0} Progress: {1:F1}%", gesture, (progress * 100)); if (gesture == KinectGestures.Gestures.Click && progress > 0.3f) { changeCubeScript.ChangeProgress(progress, screenPos.x, screenPos.y); string sGestureText = string.Format("{1:F2} detected, zoom={2:F2}%", screenPos.x, screenPos.y); if (GestureInfo != null) { GestureInfo.guiText.text = sGestureText; } progressDisplayed = true; } else if ((gesture == KinectGestures.Gestures.ZoomOut || gesture == KinectGestures.Gestures.ZoomIn) && progress > 0.5f) { string sGestureText = string.Format("{1:F2} detected, zoom={2:F2}%", screenPos.x, screenPos.y); if (GestureInfo != null) { GestureInfo.guiText.text = sGestureText; } progressDisplayed = true; } else if (gesture == KinectGestures.Gestures.Wheel && progress > 0.5f) { string sGestureText = string.Format("{0} detected, angle={1:F1} deg", gesture, screenPos.z); if (GestureInfo != null) { GestureInfo.guiText.text = sGestureText; } progressDisplayed = true; } }
// Apply the rotations tracked by kinect to the joints. void TransformBoneDir(uint userId, KinectWrapper.SkeletonJoint joint, int boneIndex, bool flip) { Transform boneTransform = bones[boneIndex]; if (boneTransform == null || kinectManager == null) { return; } // Get initial bone direction Vector3 initialDir = initialDirections[boneIndex]; if (initialDir == Vector3.zero) { return; } int iJoint = (int)joint; // if(iJoint < 0) // return; // Get Kinect joint orientation Vector3 jointDir = Vector3.zero; if (boneIndex == 16) // Hip_center { initialDir = hipsUp; // target is a vector from hip_center to average of hips left and right jointDir = ((kinectManager.GetJointPosition(userId, (int)KinectWrapper.NuiSkeletonPositionIndex.HipLeft) + kinectManager.GetJointPosition(userId, (int)KinectWrapper.NuiSkeletonPositionIndex.HipRight)) / 2.0f) - kinectManager.GetJointPosition(userId, (int)KinectWrapper.NuiSkeletonPositionIndex.HipCenter); jointDir.z = -jointDir.z; if (!flip) { jointDir.x = -jointDir.x; } } else if (boneIndex == 5 || boneIndex == 11) // Collar_left or Collar_right (shoulders) { // target is a vector from shoulder_center to bone jointDir = kinectManager.GetDirectionBetweenJoints(userId, (int)KinectWrapper.NuiSkeletonPositionIndex.ShoulderCenter, iJoint, !flip, true); } else { jointDir = kinectManager.GetDirectionBetweenJoints(userId, iJoint - 1, iJoint, !flip, true); } if (jointDir == Vector3.zero) { return; } Vector3 upDir = Vector3.zero; Vector3 rightDir = Vector3.zero; if (joint == KinectWrapper.SkeletonJoint.SPINE) { // // the spine in the Kinect data is ~40 degrees back from the hip // jointDir = Quaternion.Euler(40, 0, 0) * jointDir; if (Hips && LeftThigh && RightThigh) { upDir = ((LeftThigh.position + RightThigh.position) / 2.0f) - Hips.transform.position; rightDir = RightThigh.transform.position - LeftThigh.transform.position; } } boneTransform.localRotation = initialLocalRotations[boneIndex]; // transform it into bone-local space jointDir = transform.TransformDirection(jointDir); jointDir = boneTransform.InverseTransformDirection(jointDir); //create a rotation that rotates dir into target Quaternion quat = Quaternion.FromToRotation(initialDir, jointDir); //if bone is the hip override, add in the rotation along the hips if (boneIndex == 16) { //rotate the hips so they face forward (determined by the hips) initialDir = hipsRight; jointDir = kinectManager.GetDirectionBetweenJoints(userId, (int)KinectWrapper.NuiSkeletonPositionIndex.HipLeft, (int)KinectWrapper.NuiSkeletonPositionIndex.HipRight, false, flip); if (jointDir != Vector3.zero) { jointDir = transform.TransformDirection(jointDir); jointDir = boneTransform.InverseTransformDirection(jointDir); jointDir -= Vector3.Project(jointDir, initialDirections[boneIndex]); quat *= Quaternion.FromToRotation(initialDir, jointDir); } } //if bone is the spine, add in the rotation along the spine else if (joint == KinectWrapper.SkeletonJoint.SPINE) { //rotate the chest so that it faces forward (determined by the shoulders) initialDir = chestRight; jointDir = kinectManager.GetDirectionBetweenJoints(userId, (int)KinectWrapper.NuiSkeletonPositionIndex.ShoulderLeft, (int)KinectWrapper.NuiSkeletonPositionIndex.ShoulderRight, false, flip); if (jointDir != Vector3.zero) { jointDir = transform.TransformDirection(jointDir); jointDir = boneTransform.InverseTransformDirection(jointDir); jointDir -= Vector3.Project(jointDir, initialDirections[boneIndex]); quat *= Quaternion.FromToRotation(initialDir, jointDir); } } boneTransform.localRotation *= quat; // if(joint == KinectWrapper.SkeletonJoint.SPINE && upDir != Vector3.zero && rightDir != Vector3.zero) // { // RestoreBone(bones[1], hipsUp, upDir); // RestoreBone(bones[1], hipsRight, rightDir); // } }
public void GestureInProgress(uint userId, int userIndex, KinectGestures.Gestures gesture, float progress, KinectWrapper.SkeletonJoint joint, Vector3 screenPos) { // criar procedimentos para verificar se um gesto está sendo executado sem ter finalizado. // throw new System.NotImplementedException(); }
//Metodo que é chamado assim que o usuario termina de executar um dos gestos public bool GestureCompleted(uint userId, int userIndex, KinectGestures.Gestures gesture, KinectWrapper.SkeletonJoint joint, Vector3 screenPos) { string sGestureText = gesture + " detected"; Debug.Log(sGestureText); if (gesture == KinectGestures.Gestures.SwipeLeft) { swipeLeft = true; } else if (gesture == KinectGestures.Gestures.SwipeRight) { swipeRight = true; } else if (gesture == KinectGestures.Gestures.SwipeUp) { swipeUp = true; } else if (gesture == KinectGestures.Gestures.SwipeDown) { swipeDown = true; } return(true); }
public bool GestureCancelled(uint userId, int userIndex, KinectGestures.Gestures gesture, KinectWrapper.SkeletonJoint joint) { // throw new System.NotImplementedException(); return(true); }
public bool GestureCancelled(uint userId, int userIndex, KinectGestures.Gestures gesture, KinectWrapper.SkeletonJoint joint) { // don't do anything here, just reset the gesture state return(true); }
public bool GestureCompleted(uint userId, int userIndex, KinectGestures.Gestures gesture, KinectWrapper.SkeletonJoint joint, Vector3 screenPos) { string sGestureText = gesture + ""; if (GestureInfo != null) { GestureInfo.GetComponent <GUIText>().text = sGestureText + " detected"; } if (GestureInfo2 != null) { if (sGestureText.Equals("SwipeLeft")) { sGestureText = "FlyLeft"; } else if (sGestureText.Equals("SwipeRight")) { sGestureText = "FlyRight"; } GestureInfo2.text = "Gesture : " + sGestureText; } if (gesture == KinectGestures.Gestures.SwipeLeft) { swipeLeft = true; } else if (gesture == KinectGestures.Gestures.SwipeRight) { swipeRight = true; } else if (gesture == KinectGestures.Gestures.SwipeUp) { swipeUp = true; } else if (gesture == KinectGestures.Gestures.SwipeDown) { swipeDown = true; } else if (gesture == KinectGestures.Gestures.FlyLeft) { flyLeft = true; } else if (gesture == KinectGestures.Gestures.FlyRight) { flyRight = true; } else if (gesture == KinectGestures.Gestures.FlyMiddle) { flyMiddle = true; } else if (gesture == KinectGestures.Gestures.Flap) { Flap = true; } else if (gesture == KinectGestures.Gestures.Squat) { Squat = true; } else if (gesture == KinectGestures.Gestures.RaiseLeftHand) { raiseLeftHand = true; } else if (gesture == KinectGestures.Gestures.RaiseRightHand) { raiseRightHand = true; } return(true); }
public void GestureInProgress(uint userId, int userIndex, KinectGestures.Gestures gesture, float progress, KinectWrapper.SkeletonJoint joint, Vector3 screenPos) { // don't do anything here }
public void GestureInProgress(uint userId, int userIndex, KinectGestures.Gestures gesture, float progress, KinectWrapper.SkeletonJoint joint, Vector3 screenPos) { if (progress > 0.3f) { DisplayText(string.Format("{0} {1:F1}% complete", gesture, progress * 100)); progressDisplayed = true; } }