public static Quaternion LocalRotation(ref MoCapBodyFrame frame, MoCapKinectBone bone, bool withCalibration = true) { if (!IsValidKinectBone(bone)) { throw new ArgumentException("Invalid Kinect bone!"); } var node = GetBoneHierarchyNode(bone); if (node.Parent == null) { return(frame.SkeletonTransforms[(int)bone].Rotation); } var parentBone = node.Parent.Current; while (!IsValidMecanimBone(Kinect2Mecanim(parentBone))) { parentBone = GetBoneHierarchyNode(parentBone).Parent.Current; } return (Quaternion.Inverse(frame.SkeletonTransforms[(int)parentBone].Rotation * (withCalibration ? Calibration.Calibration[(int)parentBone].Unit : Quaternion.Identity)) * (frame.SkeletonTransforms[(int)bone].Rotation * (withCalibration ? Calibration.Calibration[(int)bone].Unit : Quaternion.Identity))); }
public MoCapKinectBoneHierarchyNode this[MoCapKinectBone bone] { get { if (!MoCapBoneMapper.IsValidKinectBone(bone)) { throw new ArgumentException("Invalid Kinect bone!"); } if (Current == bone) { return(this); } foreach (var child in Children) { var value = child[bone]; if (value != null) { return(value); } } return(null); } }
public static MoCapMecanimBone Kinect2Mecanim(MoCapKinectBone bone) { if (!IsValidKinectBone(bone)) { return(MoCapMecanimBone.Unknown); } return(Kinect2MecanimMapping[(int)bone]); }
public static MoCapKinectBoneHierarchyNode GetBoneHierarchyNode(MoCapKinectBone bone) { if (!IsValidKinectBone(bone)) { throw new ArgumentException("Invalid Kinect bone!"); } return(KinectBoneHierarchyRoot[bone]); }
public MoCapKinectBoneHierarchyNode this[MoCapKinectBone bone] { get { if (!MoCapBoneMapper.IsValidKinectBone(bone)) throw new ArgumentException("Invalid Kinect bone!"); if (Current == bone) return this; foreach (var child in Children) { var value = child[bone]; if (value != null) return value; } return null; } }
public static bool IsValidKinectBone(MoCapKinectBone bone) { return(bone != MoCapKinectBone.Unknown && bone != MoCapKinectBone.Count); }
public static Quaternion LocalRotation(ref MoCapBodyFrame frame, MoCapKinectBone bone, bool withCalibration = true) { if (!IsValidKinectBone(bone)) throw new ArgumentException("Invalid Kinect bone!"); var node = GetBoneHierarchyNode(bone); if (node.Parent == null) return frame.SkeletonTransforms[(int) bone].Rotation; var parentBone = node.Parent.Current; while (!IsValidMecanimBone(Kinect2Mecanim(parentBone))) parentBone = GetBoneHierarchyNode(parentBone).Parent.Current; return Quaternion.Inverse(frame.SkeletonTransforms[(int) parentBone].Rotation* (withCalibration ? Calibration.Calibration[(int) parentBone].Unit : Quaternion.Identity))* (frame.SkeletonTransforms[(int) bone].Rotation* (withCalibration ? Calibration.Calibration[(int) bone].Unit : Quaternion.Identity)); }
public static MoCapMecanimBone Kinect2Mecanim(MoCapKinectBone bone) { if (!IsValidKinectBone(bone)) return MoCapMecanimBone.Unknown; return Kinect2MecanimMapping[(int) bone]; }
public static bool IsValidKinectBone(MoCapKinectBone bone) { return bone != MoCapKinectBone.Unknown && bone != MoCapKinectBone.Count; }
public static MoCapKinectBoneHierarchyNode GetBoneHierarchyNode(MoCapKinectBone bone) { if (!IsValidKinectBone(bone)) throw new ArgumentException("Invalid Kinect bone!"); return KinectBoneHierarchyRoot[bone]; }