/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { // left hand stays above left elbow Vector3 handLeft = skeleton.getRawWorldPosition(JointType.HandLeft); Vector3 shoulderCenter = skeleton.getRawWorldPosition(JointType.SpineShoulder); Vector3 elbowLeft = skeleton.getRawWorldPosition(JointType.ElbowLeft); if (handLeft.y > elbowLeft.y) { // left hand in front of left elbow if (handLeft.z > elbowLeft.z) { // left elbow in front of left shoulder Vector3 shoulderLeft = skeleton.getRawWorldPosition(JointType.ShoulderLeft); if (elbowLeft.z > shoulderLeft.z) { //Debug.Log("Segment2 Success"); return(GesturePartResult.Succeed); } return(GesturePartResult.Pausing); } return(GesturePartResult.Pausing); } return(GesturePartResult.Fail); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { // right hand below right shoulder Vector3 handRight = skeleton.getRawWorldPosition(JointType.HandRight); Vector3 shoulderCenter = skeleton.getRawWorldPosition(JointType.SpineShoulder); Vector3 elbowRight = skeleton.getRawWorldPosition(JointType.ElbowRight); if (handRight.y > shoulderCenter.y) { // right hand in front right elbow if (handRight.z > elbowRight.z) { // right elbow in front of right shouder Vector3 shoulderRight = skeleton.getRawWorldPosition(JointType.ShoulderRight); if (elbowRight.z > shoulderRight.z) { //Debug.Log("Segment2 Success"); return(GesturePartResult.Succeed); } return(GesturePartResult.Pausing); } return(GesturePartResult.Pausing); } return(GesturePartResult.Fail); }
/// <summary> /// Updates all gestures. /// </summary> /// <param name="data">The skeleton data.</param> public void UpdateAllGestures(BasicAvatarModel data) { foreach (Gesture gesture in this.gestures) { gesture.UpdateGesture(data); } }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { // left and right hand in front of left and right shoulder Vector3 handLeft = skeleton.getRawWorldPosition(JointType.HandLeft); Vector3 shoulderCenter = skeleton.getRawWorldPosition(JointType.SpineShoulder); Vector3 handRight = skeleton.getRawWorldPosition(JointType.HandRight); Vector3 elbowLeft = skeleton.getRawWorldPosition(JointType.ElbowLeft); Vector3 elbowRight = skeleton.getRawWorldPosition(JointType.ElbowRight); Vector3 shoulderRight = skeleton.getRawWorldPosition(JointType.ShoulderRight); Vector3 shoulderLeft = skeleton.getRawWorldPosition(JointType.ShoulderLeft); if (handLeft.x > shoulderLeft.x && handRight.x < shoulderRight.x) { // left and right hand below shoulder height but above hip height Vector3 head = skeleton.getRawWorldPosition(JointType.Head); Vector3 hipCenter = skeleton.getRawWorldPosition(JointType.SpineBase); Vector3 spineMid = skeleton.getRawWorldPosition(JointType.SpineMid); if ((handLeft.y < head.y && handLeft.y > spineMid.y) && (handRight.y < head.y && handRight.y > spineMid.y)) { Debug.Log("Segment1 Success"); return(GesturePartResult.Succeed); } return(GesturePartResult.Fail); } return(GesturePartResult.Fail); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { // right hand in front of right shoulder Vector3 handLeft = skeleton.getRawWorldPosition(JointType.HandLeft); Vector3 shoulderCenter = skeleton.getRawWorldPosition(JointType.SpineShoulder); Vector3 handRight = skeleton.getRawWorldPosition(JointType.HandRight); Vector3 elbowLeft = skeleton.getRawWorldPosition(JointType.ElbowLeft); Vector3 hip = skeleton.getRawWorldPosition(JointType.SpineBase); if (handLeft.z > elbowLeft.z && handRight.y < hip.y) { // right hand below shoulder height but above hip height Vector3 head = skeleton.getRawWorldPosition(JointType.Head); if (handLeft.y < head.y && handLeft.y > hip.y) { // //right hand left of center hip if (handLeft.x > hip.x) { //Debug.Log("SwipeRight3 Success"); return(GesturePartResult.Succeed); } return(GesturePartResult.Pausing); } return(GesturePartResult.Fail); } return(GesturePartResult.Fail); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { // right hand in front of right shoulder Vector3 handLeft = skeleton.getRawWorldPosition(JointType.HandLeft); Vector3 shoulderCenter = skeleton.getRawWorldPosition(JointType.SpineShoulder); Vector3 handRight = skeleton.getRawWorldPosition(JointType.HandRight); Vector3 elbowRight = skeleton.getRawWorldPosition(JointType.ElbowRight); if (handRight.z > elbowRight.z && handLeft.y < shoulderCenter.y) { // right hand below shoulder height but above hip height Vector3 head = skeleton.getRawWorldPosition(JointType.Head); Vector3 shoulderRight = skeleton.getRawWorldPosition(JointType.ShoulderRight); if (handRight.y < head.y && handRight.y >= shoulderCenter.y - 0.2f) { // right hand right of right shoulder if (handRight.x - 0.4f > shoulderRight.x) { //Debug.Log("Segment1 Success"); return(GesturePartResult.Succeed); } return(GesturePartResult.Pausing); } return(GesturePartResult.Fail); } return(GesturePartResult.Fail); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { // left hand under shoulder and right hand in front of body Vector3 handLeft = skeleton.getRawWorldPosition(JointType.HandLeft); Vector3 shoulderCenter = skeleton.getRawWorldPosition(JointType.SpineShoulder); Vector3 handRight = skeleton.getRawWorldPosition(JointType.HandRight); if (handLeft.y < shoulderCenter.y && handRight.z > shoulderCenter.z) { // right hand above hip center and below head and left of right elbow and right of hip center Vector3 head = skeleton.getRawWorldPosition(JointType.Head); Vector3 elbowRight = skeleton.getRawWorldPosition(JointType.ElbowRight); Vector3 hipCenter = skeleton.getRawWorldPosition(JointType.SpineBase); if (handRight.y < head.y && handRight.y > hipCenter.y && handRight.x < elbowRight.x && handRight.x > hipCenter.x) { return(GesturePartResult.Succeed); } return(GesturePartResult.Pausing); } return(GesturePartResult.Fail); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { //get necessary joint positions Vector3 leftHand = skeleton.getRawWorldPosition(JointType.HandLeft); Vector3 rightHand = skeleton.getRawWorldPosition(JointType.HandRight); Vector3 shoulder = skeleton.getRawWorldPosition(JointType.SpineShoulder); Vector3 hip = skeleton.getRawWorldPosition(JointType.SpineBase); Vector3 leftShoulder = skeleton.getRawWorldPosition(JointType.ShoulderLeft); Vector3 rightShoulder = skeleton.getRawWorldPosition(JointType.ShoulderRight); if (leftHand.x <= leftShoulder.x && rightHand.x >= rightShoulder.x) { if (leftHand.y < shoulder.y && rightHand.y < shoulder.y) { if (leftHand.y >= hip.y && rightHand.y >= hip.y) { //Debug.Log("PunchDown seg2"); return(GesturePartResult.Succeed); } //return GesturePartResult.Pausing; } return(GesturePartResult.Pausing); } return(GesturePartResult.Fail); }
// Use this for initialization void Awake() { if (_instance != null) { Destroy(gameObject); } else { _instance = this; _moCapAvatar = GetComponent <KinectPointManAvatarModel>(); DontDestroyOnLoad(this.gameObject); } }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { Vector3 handLeft = skeleton.getRawWorldPosition(JointType.HandLeft); Vector3 handRight = skeleton.getRawWorldPosition(JointType.HandRight); Vector3 head = skeleton.getRawWorldPosition(JointType.Head); // left and right hand above head if (handLeft.y >= head.y && handRight.y >= head.y) { //Debug.Log("Segment1 Success"); return(GesturePartResult.Succeed); } return(GesturePartResult.Pausing); }
/// <summary> /// Updates the gesture. /// </summary> /// <param name="data">The skeleton data.</param> public void UpdateGesture(BasicAvatarModel data) { if (this.paused) { if (this.frameCount == this.pausedFrameCount) { this.paused = false; } this.frameCount++; } GesturePartResult result = this.gestureParts[this.currentGesturePart].CheckGesture(data); if (result == GesturePartResult.Succeed) { // There are still segments of our gesture if (this.currentGesturePart + 1 < this.gestureParts.Length) { // increase the currentGesturePart to check for the next part of the gesture the next time this method is called this.currentGesturePart++; this.frameCount = 0; // reset the frame counter this.pausedFrameCount = 10; // make a short break of 10 frames this.paused = true; } else // Found last segment of the gesture { if (this.GestureRecognizedInGesture != null) // make sure our event is associated with a method { // fire the event // The method to be called is defined in GestureController.cs this.GestureRecognizedInGesture(this, new GestureEventArgs(this.name, data.getTrackingID())); this.Reset(); } } } else if (result == GesturePartResult.Fail || this.frameCount == 50) { this.currentGesturePart = 0; this.frameCount = 0; this.pausedFrameCount = 5; this.paused = true; } else { this.frameCount++; this.pausedFrameCount = 5; this.paused = true; } }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { Vector3 handLeft = skeleton.getRawWorldPosition(JointType.HandLeft); Vector3 handRight = skeleton.getRawWorldPosition(JointType.HandRight); Vector3 spineMid = skeleton.getRawWorldPosition(JointType.SpineBase); // left and right hand bewlow spineMid if (handLeft.y < spineMid.y && handRight.y < spineMid.y) { Debug.Log("Segment2 Success"); return(GesturePartResult.Succeed); } return(GesturePartResult.Pausing); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { //get necessary joint positions Vector3 rightHand = skeleton.getRawWorldPosition(JointType.HandRight); Vector3 hip = skeleton.getRawWorldPosition(JointType.SpineBase); //position detection if (rightHand.y <= hip.y) { //Debug.Log("Cirlce seg3"); return(GesturePartResult.Succeed); //ggf. add hand.z betw. shoulders } return(GesturePartResult.Pausing); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { //get necessary joint positions Vector3 elbowRight = skeleton.getRawWorldPosition(JointType.ElbowRight); Vector3 shoulderRight = skeleton.getRawWorldPosition(JointType.ShoulderRight); //position detection if (elbowRight.z <= shoulderRight.z) { return(GesturePartResult.Succeed); Debug.Log("PushFwrd seg1"); } return(GesturePartResult.Fail); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { //get necessary joint positions Vector3 leftHand = skeleton.getRawWorldPosition(JointType.HandLeft); Vector3 rightHand = skeleton.getRawWorldPosition(JointType.HandRight); Vector3 hip = skeleton.getRawWorldPosition(JointType.SpineBase); //position detection if (leftHand.y < hip.y && rightHand.y < hip.y) { //Debug.Log("PullUp seg1"); return(GesturePartResult.Succeed); } return(GesturePartResult.Pausing); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { //get necessary joint positions Vector3 rightHand = skeleton.getRawWorldPosition(JointType.HandRight); Vector3 leftShoulder = skeleton.getRawWorldPosition(JointType.ShoulderLeft); Vector3 head = skeleton.getRawWorldPosition(JointType.Head); Vector3 hip = skeleton.getRawWorldPosition(JointType.SpineBase); if (rightHand.y < head.y && rightHand.y > hip.y) { if (rightHand.x < leftShoulder.x) { //Debug.Log("Circle seg4"); return(GesturePartResult.Succeed); } } return(GesturePartResult.Pausing); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { //get necessary joint positions Vector3 leftFoot = skeleton.getRawWorldPosition(JointType.FootLeft); Vector3 rightAnkel = skeleton.getRawWorldPosition(JointType.AnkleRight); Vector3 leftShoulder = skeleton.getRawWorldPosition(JointType.ShoulderLeft); Vector3 rightShoulder = skeleton.getRawWorldPosition(JointType.ShoulderRight); //position detection if (leftShoulder.z < rightShoulder.z) { if (leftFoot.y < rightAnkel.y) { //Debug.Log("TurnLeft seg2"); return(GesturePartResult.Succeed); } } return(GesturePartResult.Pausing); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { //get necessary joint positions Vector3 leftHand = skeleton.getRawWorldPosition(JointType.HandLeft); Vector3 rightHand = skeleton.getRawWorldPosition(JointType.HandRight); Vector3 leftShoulder = skeleton.getRawWorldPosition(JointType.ShoulderLeft); Vector3 rightShoulder = skeleton.getRawWorldPosition(JointType.ShoulderRight); Vector3 shoulderMid = skeleton.getRawWorldPosition(JointType.SpineShoulder); //position detection if (leftHand.y <= shoulderMid.y && rightHand.y <= shoulderMid.y) { if (leftHand.x < leftShoulder.x && rightHand.x > rightShoulder.x) { Debug.Log("Cross seg2"); return(GesturePartResult.Succeed); } } return(GesturePartResult.Pausing); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { //get necessary joint positions Vector3 leftHand = skeleton.getRawWorldPosition(JointType.HandLeft); Vector3 rightHand = skeleton.getRawWorldPosition(JointType.HandRight); Vector3 leftElbow = skeleton.getRawWorldPosition(JointType.ElbowLeft); Vector3 rightElbow = skeleton.getRawWorldPosition(JointType.ElbowRight); //position detection if (leftHand.y < leftElbow.y && rightHand.y < rightElbow.y) { //Debug.Log("HandL: "+leftHand.z+" ShoulderR: "+ rightShoulder.z); if (leftHand.x > rightElbow.x && rightHand.x < leftElbow.x) { Debug.Log("Cross seg1"); return(GesturePartResult.Succeed); } } return(GesturePartResult.Pausing); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { // hand above elbow Vector3 handLeft = skeleton.getRawWorldPosition(JointType.HandLeft); Vector3 elbowLeft = skeleton.getRawWorldPosition(JointType.ElbowLeft); if (handLeft.y > elbowLeft.y) { // hand left of elbow if (handLeft.x < elbowLeft.x) { return(GesturePartResult.Succeed); } // hand has not dropped but is not quite where we expect it to be, pausing till next frame return(GesturePartResult.Pausing); } // hand dropped - no gesture fails return(GesturePartResult.Fail); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { //get necessary joint positions Vector3 leftHand = skeleton.getRawWorldPosition(JointType.HandLeft); Vector3 rightHand = skeleton.getRawWorldPosition(JointType.HandRight); Vector3 leftShoulder = skeleton.getRawWorldPosition(JointType.ShoulderLeft); Vector3 rightShoulder = skeleton.getRawWorldPosition(JointType.ShoulderRight); Vector3 shoulder = skeleton.getRawWorldPosition(JointType.SpineShoulder); Vector3 hip = skeleton.getRawWorldPosition(JointType.SpineBase); //position detection if (leftHand.y < shoulder.y && rightHand.y < shoulder.y && leftHand.y > hip.y && rightHand.y > hip.y) { //Debug.Log("HandL: "+leftHand.z+" ShoulderR: "+ rightShoulder.z); if (leftHand.x > leftShoulder.x && rightHand.x < rightShoulder.x && leftHand.x < rightShoulder.x && rightHand.x > leftShoulder.x) { //Debug.Log("Clap seg1"); return(GesturePartResult.Succeed); } } return(GesturePartResult.Pausing); }
/// <summary> /// Checks the gesture. /// </summary> /// <param name="skeleton">The skeleton.</param> /// <returns>GesturePartResult based on if the gesture part has been completed</returns> public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { //get necessary joint positions Vector3 elbowRight = skeleton.getRawWorldPosition(JointType.ElbowRight); Vector3 shoulderRight = skeleton.getRawWorldPosition(JointType.ShoulderRight); Vector3 handRight = skeleton.getRawWorldPosition(JointType.HandRight); if (elbowRight.z > shoulderRight.z) { if (handRight.y <= shoulderRight.y) { return(GesturePartResult.Succeed); Debug.Log("PushFwrd succeed"); } return(GesturePartResult.Pausing); Debug.Log("PushFwrd pausing"); } return(GesturePartResult.Fail); Debug.Log("PushFwrd failed"); }
public GesturePartResult CheckGesture(BasicAvatarModel skeleton) { // right hand between spinemid and head Vector3 rightHand = skeleton.getRawWorldPosition(JointType.HandRight); Vector3 spineMid = skeleton.getRawWorldPosition(JointType.SpineMid); Vector3 head = skeleton.getRawWorldPosition(JointType.Head); if (rightHand.y > spineMid.y && rightHand.y < head.y) { //right hand left from spine if (rightHand.x < spineMid.x) { //right elbow under spinemid Vector3 rightElbow = skeleton.getRawWorldPosition(JointType.ElbowRight); if (rightElbow.y < spineMid.y) { return(GesturePartResult.Succeed); } return(GesturePartResult.Pausing); } return(GesturePartResult.Fail); } return(GesturePartResult.Fail); }