public override void OnEnable() { serializedObject.Update(); base.OnEnable(); BodyExpressionAction.EnsureBodyPoseMatchingRig(); m_ToleranceProperty = serializedObject.FindProperty(k_BodyPoseMatchTolerancePropName); m_ToleranceAngleDegrees = Mathf.Acos(m_ToleranceProperty.floatValue) * Mathf.Rad2Deg; serializedObject.ApplyModifiedProperties(); }
static BodyPoseData GenerateBodyPoseDataFromAvatar(Animator objToGetDataFrom, string poseName) { var anim = objToGetDataFrom; var humanPoseHandler = new HumanPoseHandler(anim.avatar, objToGetDataFrom.transform); var humanPose = new HumanPose { bodyPosition = new Vector3(0, 0, 0), bodyRotation = Quaternion.identity }; humanPoseHandler.GetHumanPose(ref humanPose); var relevantMuscles = new List <bool>(); for (var i = 0; i < humanPose.muscles.Length; i++) { relevantMuscles.Add(true); } for (var i = 0; i < k_NonRelevantMuscleIndices.Length; i++) { relevantMuscles[k_NonRelevantMuscleIndices[i]] = false; } var bodyPoseData = ScriptableObject.CreateInstance <BodyPoseData>(); var bonesOrientations = BodyExpressionAction.GenerateBoneOrientations(anim); var relevantBonesForPoseMatch = new bool[bonesOrientations.Length]; for (var i = 0; i < relevantBonesForPoseMatch.Length; i++) { relevantBonesForPoseMatch[i] = true; } bodyPoseData.Init(poseName, PruneMuscleValues(humanPose.muscles), relevantMuscles.ToArray(), bonesOrientations, relevantBonesForPoseMatch); return(bodyPoseData); }
void UpdateBodyPoseDataForPreviewAvatar() { var anim = m_PreviewBodyPose.GetComponent <Animator>(); HumanPoseHandler humanPoseHandler = new HumanPoseHandler(anim.avatar, m_PreviewBodyPose.transform); HumanPose humanPose = new HumanPose(); humanPoseHandler.GetHumanPose(ref humanPose); for (var i = 0; i < humanPose.muscles.Length; i++) { humanPose.muscles[i] = m_MuscleDataPropToTweak.GetArrayElementAtIndex(i).floatValue; } humanPoseHandler.SetHumanPose(ref humanPose); Vector3[] updatedBoneOrientations = BodyExpressionAction.GenerateBoneOrientations(anim); for (var i = 0; i < updatedBoneOrientations.Length; i++) { m_BonesOrientationsPropToTweak.GetArrayElementAtIndex(i).vector3Value = updatedBoneOrientations[i]; } m_SerializedObjToTweak.ApplyModifiedProperties(); }