From 8bbf482210cae1fd04a3c1ef74e135ab7a99f066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ha=C3=AF=7E?= Date: Tue, 15 Mar 2022 15:30:04 +0100 Subject: [PATCH] Add AacFlState.PoseSpaceEntered(...), PoseSpaceExited, PoseSpaceEnteredPercent, and PoseSpaceExitedPercent: - Add AadFlState.PoseSpaceEntered(...) with 0-duration default overload. - Add AadFlState.PoseSpaceExited(...) with 0-duration default overload. - Add AadFlState.PoseSpaceEnteredPercent(...) - Add AadFlState.PoseSpaceExitedPercent(...) --- Framework/Editor/V0/AacFlStates.cs | 48 +++++++++++++++++++++++++++++- README.md | 16 ++++++---- 2 files changed, 58 insertions(+), 6 deletions(-) diff --git a/Framework/Editor/V0/AacFlStates.cs b/Framework/Editor/V0/AacFlStates.cs index 0754e37..56fa50b 100644 --- a/Framework/Editor/V0/AacFlStates.cs +++ b/Framework/Editor/V0/AacFlStates.cs @@ -214,6 +214,7 @@ namespace AnimatorAsCode.V0 private VRCAvatarParameterDriver _driver; private VRCAnimatorTrackingControl _tracking; private VRCAnimatorLocomotionControl _locomotionControl; + private VRCAnimatorTemporaryPoseSpace _temporaryPoseSpace; public AacFlState(AnimatorState state, AnimatorStateMachine machine, IAacDefaultsProvider defaultsProvider) { @@ -528,6 +529,46 @@ namespace AnimatorAsCode.V0 return this; } + public AacFlState PoseSpaceEntered(float delaySeconds = 0f) + { + CreateTemporaryPoseSpaceBehaviorIfNotExists(); + _temporaryPoseSpace.enterPoseSpace = true; + _temporaryPoseSpace.fixedDelay = true; + _temporaryPoseSpace.delayTime = delaySeconds; + + return this; + } + + public AacFlState PoseSpaceExited(float delaySeconds = 0f) + { + CreateTemporaryPoseSpaceBehaviorIfNotExists(); + _temporaryPoseSpace.enterPoseSpace = false; + _temporaryPoseSpace.fixedDelay = true; + _temporaryPoseSpace.delayTime = delaySeconds; + + return this; + } + + public AacFlState PoseSpaceEnteredPercent(float delayNormalized) + { + CreateTemporaryPoseSpaceBehaviorIfNotExists(); + _temporaryPoseSpace.enterPoseSpace = true; + _temporaryPoseSpace.fixedDelay = false; + _temporaryPoseSpace.delayTime = delayNormalized; + + return this; + } + + public AacFlState PoseSpaceExitedPercent(float delayNormalized) + { + CreateTemporaryPoseSpaceBehaviorIfNotExists(); + _temporaryPoseSpace.enterPoseSpace = false; + _temporaryPoseSpace.fixedDelay = false; + _temporaryPoseSpace.delayTime = delayNormalized; + + return this; + } + public AacFlState MotionTime(AacFlFloatParameter floatParam) { State.timeParameterActive = true; @@ -597,13 +638,18 @@ namespace AnimatorAsCode.V0 _tracking = State.AddStateMachineBehaviour(); } - private void CreateLocomotionBehaviorIfNotExists() { if (_locomotionControl != null) return; _locomotionControl = State.AddStateMachineBehaviour(); } + private void CreateTemporaryPoseSpaceBehaviorIfNotExists() + { + if (_temporaryPoseSpace != null) return; + _temporaryPoseSpace = State.AddStateMachineBehaviour(); + } + public enum TrackingElement { Head, diff --git a/README.md b/README.md index 963c04d..7bca0f0 100644 --- a/README.md +++ b/README.md @@ -704,11 +704,17 @@ foreach (var cancelWhenNotAllowed in new[] {auto, reverse, manual, custom, done} - `AacFlState TrackingSets(TrackingElement element, VRC_AnimatorTrackingControl.TrackingType trackingType)` /// Use an Animator Tracking Control to set the element to be the value of `trackingType`. Create an Animator Tracking Control state behaviour if it does not exist. - `AacFlState LocomotionEnabled()` /// Enable locomotion. Create an Animator Locomotion Control if it does not exist. - `AacFlState LocomotionDisabled()` /// Disable locomotion. Create an Animator Locomotion Control if it does not exist. -- `public AacFlState PlayableEnables(VRC_PlayableLayerControl.BlendableLayer blendable)` /// Use a Playable Layer Control to set the playable layer weight to 1, enabling it immediately. Create an Playable Layer Control no matter what. -- `public AacFlState PlayableDisables(VRC_PlayableLayerControl.BlendableLayer blendable)` /// Use a Playable Layer Control to set the playable layer weight to 0, disabling it immediately. Create an Playable Layer Control no matter what. -- `public AacFlState PlayableEnables(VRC_PlayableLayerControl.BlendableLayer blendable, float blendDurationSeconds)` /// Use a Playable Layer Control to set the playable layer weight to 1, blending it over a duration, enabling it. Create an Playable Layer Control no matter what. -- `public AacFlState PlayableDisables(VRC_PlayableLayerControl.BlendableLayer blendable, float blendDurationSeconds)` /// Use a Playable Layer Control to set the playable layer weight to 0, blending it over a duration, disabling it. Create an Playable Layer Control no matter what. -- `public AacFlState PlayableSets(VRC_PlayableLayerControl.BlendableLayer blendable, float blendDurationSeconds, float weight)` /// Use a Playable Layer Control to set the playable layer weight to a specified value, blending it over a duration. Create an Playable Layer Control no matter what. +- `AacFlState PlayableEnables(VRC_PlayableLayerControl.BlendableLayer blendable)` /// Use a Playable Layer Control to set the playable layer weight to 1, enabling it immediately. Create an Playable Layer Control no matter what. +- `AacFlState PlayableDisables(VRC_PlayableLayerControl.BlendableLayer blendable)` /// Use a Playable Layer Control to set the playable layer weight to 0, disabling it immediately. Create an Playable Layer Control no matter what. +- `AacFlState PlayableEnables(VRC_PlayableLayerControl.BlendableLayer blendable, float blendDurationSeconds)` /// Use a Playable Layer Control to set the playable layer weight to 1, blending it over a duration, enabling it. Create an Playable Layer Control no matter what. +- `AacFlState PlayableDisables(VRC_PlayableLayerControl.BlendableLayer blendable, float blendDurationSeconds)` /// Use a Playable Layer Control to set the playable layer weight to 0, blending it over a duration, disabling it. Create an Playable Layer Control no matter what. +- `AacFlState PlayableSets(VRC_PlayableLayerControl.BlendableLayer blendable, float blendDurationSeconds, float weight)` /// Use a Playable Layer Control to set the playable layer weight to a specified value, blending it over a duration. Create an Playable Layer Control no matter what. +- `AacFlState PoseSpaceEntered()` /// Use a Temporary Pose Space to change the viewpoint immediately. Create a Temporary Pose Space if it does not exist. +- `AacFlState PoseSpaceExited()` /// Use a Temporary Pose Space to reset the viewpoint immediately. Create a Temporary Pose Space if it does not exist. +- `AacFlState PoseSpaceEntered(float delaySeconds)` /// Use a Temporary Pose Space to change the viewpoint after a delay. Create a Temporary Pose Space if it does not exist. +- `AacFlState PoseSpaceExited(float delaySeconds)` /// Use a Temporary Pose Space to reset the viewpoint after a delay. Create a Temporary Pose Space if it does not exist. +- `AacFlState PoseSpaceEnteredPercent(float delayNormalized)` /// Use a Temporary Pose Space to change the viewpoint after a normalized amount of the current state. Create a Temporary Pose Space if it does not exist. +- `AacFlState PoseSpaceExitedPercent(float delayNormalized)` /// Use a Temporary Pose Space to reset the viewpoint after a normalized amount of the current state. Create a Temporary Pose Space if it does not exist. # Clip (AacFlClip)