public Vector3 GetJointPosition(HumanJointType jointType) { //HumanJointTypeUtil.OppositeSideJoint(jointType); int jointTypeIndex = (int)jointType; JointType kinectJointType = ((JointType)jointTypeIndex); //Vector3 originalPos = GetJointPosition(kinectJointType); //return Vector3.Scale(new Vector3(-1, 1, 1), originalPos); return(GetJointPosition(kinectJointType)); }
public virtual bool TryGetMappedJointPosition(HumanJointType jointType, out Vector3 mappedJointPosition) { try { mappedJointPosition = GetMappedJointPosition(jointType); return(true); } catch (Exception ex) { mappedJointPosition = Vector3.zero; Debug.LogWarningFormat("Unable to retrieve position for {0}: {1}", jointType.ToString(), ex.Message); } return(false); }
public static HumanJointType OppositeSideJoint(HumanJointType joint) { string jointName = joint.ToString(); if (jointName.Contains("Right")) { string oppositeJointName = jointName.Replace("Right", "Left"); return((HumanJointType)System.Enum.Parse(typeof(HumanJointType), oppositeJointName)); } else if (jointName.Contains("Left")) { string oppositeJointName = jointName.Replace("Left", "Right"); return((HumanJointType)System.Enum.Parse(typeof(HumanJointType), oppositeJointName)); } return(joint); }
public Vector3 GetMappedJointPosition(HumanJointType jointType) { switch (jointType) { case HumanJointType.Head: return(this.HeadPosition); case HumanJointType.Neck: return(this.NeckPosition); case HumanJointType.SpineShoulder: return(this.SpineShoulderPosition); case HumanJointType.SpineMid: return(this.SpineMidPosition); case HumanJointType.SpineBase: return(this.SpineBasePosition); case HumanJointType.ShoulderLeft: return(this.LeftArmShoulderPosition); case HumanJointType.ElbowLeft: return(this.LeftArmElbowPosition); case HumanJointType.WristLeft: return(this.LeftArmWristPosition); case HumanJointType.HandLeft: return(this.LeftArmHandPosition); case HumanJointType.HandTipLeft: return(this.LeftArmHandTipPosition); case HumanJointType.ThumbLeft: return(this.LeftArmHandThumbPosition); case HumanJointType.ShoulderRight: return(this.RightArmShoulderPosition); case HumanJointType.ElbowRight: return(this.RightArmElbowPosition); case HumanJointType.WristRight: return(this.RightArmWristPosition); case HumanJointType.HandRight: return(this.RightArmHandPosition); case HumanJointType.HandTipRight: return(this.RightArmHandTipPosition); case HumanJointType.ThumbRight: return(this.RightArmHandThumbPosition); case HumanJointType.HipLeft: return(this.LeftLegHipPosition); case HumanJointType.KneeLeft: return(this.LeftLegKneePosition); case HumanJointType.AnkleLeft: return(this.LeftLegAnklePosition); case HumanJointType.FootLeft: return(this.LeftLegFootPosition); case HumanJointType.HipRight: return(this.RightLegHipPosition); case HumanJointType.KneeRight: return(this.RightLegKneePosition); case HumanJointType.AnkleRight: return(this.RightLegAnklePosition); case HumanJointType.FootRight: return(this.RightLegFootPosition); default: throw new Exception("Unrecognized joint type"); break; } }