/// <summary> Returns all repetitions of Quantity/Timing (OBR-27).</summary> public virtual TQ[] getQuantityTiming() { TQ[] ret = null; try { Type[] t = this.getField(27); ret = new TQ[t.Length]; for (int i = 0; i < ret.Length; i++) { ret[i] = (TQ)t[i]; } } catch (System.InvalidCastException) { throw new Exception(); } catch (NuGenHL7Exception) { throw new Exception(); } return(ret); }
static public TQ GetIKGoalTQ(Avatar avatar, float humanScale, AvatarIKGoal avatarIKGoal, TQ animatorBodyPositionRotation, TQ skeletonTQ) { int humanId = (int)HumanIDFromAvatarIKGoal(avatarIKGoal); if (humanId == (int)HumanBodyBones.LastBone) { throw new System.InvalidOperationException("Invalid human id."); } MethodInfo methodGetAxisLength = typeof(Avatar).GetMethod("GetAxisLength", BindingFlags.Instance | BindingFlags.NonPublic); if (methodGetAxisLength == null) { throw new System.InvalidOperationException("Cannot find GetAxisLength method."); } MethodInfo methodGetPostRotation = typeof(Avatar).GetMethod("GetPostRotation", BindingFlags.Instance | BindingFlags.NonPublic); if (methodGetPostRotation == null) { throw new System.InvalidOperationException("Cannot find GetPostRotation method."); } Quaternion postRotation = (Quaternion)methodGetPostRotation.Invoke(avatar, new object[] { humanId }); var goalTQ = new TQ(skeletonTQ.t, skeletonTQ.q * postRotation); if (avatarIKGoal == AvatarIKGoal.LeftFoot || avatarIKGoal == AvatarIKGoal.RightFoot) { // Here you could use animator.leftFeetBottomHeight or animator.rightFeetBottomHeight rather than GetAxisLenght // Both are equivalent but GetAxisLength is the generic way and work for all human bone float axislength = (float)methodGetAxisLength.Invoke(avatar, new object[] { humanId }); Vector3 footBottom = new Vector3(axislength, 0, 0); goalTQ.t += (goalTQ.q * footBottom); } // IK goal are in avatar body local space Quaternion invRootQ = Quaternion.Inverse(animatorBodyPositionRotation.q); goalTQ.t = invRootQ * (goalTQ.t - animatorBodyPositionRotation.t); goalTQ.q = invRootQ * goalTQ.q; goalTQ.t /= humanScale; return(goalTQ); }
//--------------------- PILS ---------------------------// //Bug: csv not generated when use button but key //public void onPressed() //{ // RecButtonController.pressed = !RecButtonController.pressed; // if (RecButtonController.pressed) // { // RecordStart(); // } // else // { // RecordEnd(); // } //} //--------------------- PILS ---------------------------// // Update is called once per frame private void LateUpdate() { if (!_recording) { return; } RecordedTime = Time.time - StartTime; if (TargetFPS != 0.0f) { var nextTime = (1.0f * (FrameIndex + 1)) / TargetFPS; if (nextTime > RecordedTime) { return; } if (FrameIndex % TargetFPS == 0) { print("Motion_FPS=" + 1 / (RecordedTime / FrameIndex)); } } else { if (Time.frameCount % Application.targetFrameRate == 0) { print("Motion_FPS=" + 1 / Time.deltaTime); } } //現在のフレームのHumanoidの姿勢を取得 _poseHandler.GetHumanPose(ref _currentPose); //posesに取得した姿勢を書き込む var serializedPose = new HumanoidPoses.SerializeHumanoidPose(); switch (_rootBoneSystem) { case MotionDataSettings.Rootbonesystem.Objectroot: serializedPose.BodyRootPosition = _animator.transform.localPosition; serializedPose.BodyRootRotation = _animator.transform.localRotation; break; case MotionDataSettings.Rootbonesystem.Hipbone: serializedPose.BodyRootPosition = _animator.GetBoneTransform(_targetRootBone).position; serializedPose.BodyRootRotation = _animator.GetBoneTransform(_targetRootBone).rotation; Debug.LogWarning(_animator.GetBoneTransform(_targetRootBone).position); break; default: throw new ArgumentOutOfRangeException(); } var bodyTQ = new TQ(_currentPose.bodyPosition, _currentPose.bodyRotation); var LeftFootTQ = new TQ(_animator.GetBoneTransform(IK_LeftFootBone).position, _animator.GetBoneTransform(IK_LeftFootBone).rotation); var RightFootTQ = new TQ(_animator.GetBoneTransform(IK_RightFootBone).position, _animator.GetBoneTransform(IK_RightFootBone).rotation); LeftFootTQ = AvatarUtility.GetIKGoalTQ(_animator.avatar, _animator.humanScale, AvatarIKGoal.LeftFoot, bodyTQ, LeftFootTQ); RightFootTQ = AvatarUtility.GetIKGoalTQ(_animator.avatar, _animator.humanScale, AvatarIKGoal.RightFoot, bodyTQ, RightFootTQ); serializedPose.BodyPosition = bodyTQ.t; serializedPose.BodyRotation = bodyTQ.q; serializedPose.LeftfootIK_Pos = LeftFootTQ.t; serializedPose.LeftfootIK_Rot = LeftFootTQ.q; serializedPose.RightfootIK_Pos = RightFootTQ.t; serializedPose.RightfootIK_Rot = RightFootTQ.q; serializedPose.FrameCount = FrameIndex; serializedPose.Muscles = new float[_currentPose.muscles.Length]; serializedPose.Time = RecordedTime; for (int i = 0; i < serializedPose.Muscles.Length; i++) { serializedPose.Muscles[i] = _currentPose.muscles[i]; } SetHumanBoneTransformToHumanoidPoses(_animator, ref serializedPose); Poses.Poses.Add(serializedPose); FrameIndex++; }