예제 #1
0
 public void Save(string path, string name, CustomPose pose)
 {
     lock (locker)
     {
         GetSettingsCollection(path)?.Save(path, name, pose);
     }
 }
예제 #2
0
        public void Update(AnimationFlags flags, Vector3 height, Quaternion ankleAngle, Quaternion toeAngle, Quaternion legAngle, CustomPose customPose)
        {
            _generalSetting = StilettoContext._generalSettingsProvider.Value;

            // Reset position weight
            if (FullBodyBipedSolver != null)
            {
                if (_reset)
                {
                    _bodyPositionWeight      = FullBodyBipedSolver.bodyEffector.positionWeight;
                    _leftFootPositionWeight  = FullBodyBipedSolver.leftFootEffector.positionWeight;
                    _rightFootPositionWeight = FullBodyBipedSolver.rightFootEffector.positionWeight;
                }
                else
                {
                    FullBodyBipedSolver.bodyEffector.positionWeight      = _bodyPositionWeight;
                    FullBodyBipedSolver.rightFootEffector.positionWeight = _rightFootPositionWeight;
                    FullBodyBipedSolver.leftFootEffector.positionWeight  = _leftFootPositionWeight;
                }
            }

            if (flags.CUSTOM_POSE)
            {
                // Get Leg Heights
                var rightThighLength = Vector3.Distance(_lowWaist.position, _rightHighLeg.position);
                var leftThighLength  = Vector3.Distance(_lowWaist.position, _leftHighLeg.position);
                var rightLegLength   = Vector3.Distance(_rightHighLeg.position, _rightLowLeg.position);
                var leftLegLength    = Vector3.Distance(_leftHighLeg.position, _leftLowLeg.position);

                // Calculate Deltas
                var heelHeightDelta = GetHeelHeightDelta(height.y);
                var rightThighDelta = GetBodyLengthDelta(rightThighLength);
                var leftThighDelta  = GetBodyLengthDelta(leftThighLength);
                var rightLegDelta   = GetBodyLengthDelta(rightLegLength);
                var leftLegDelta    = GetBodyLengthDelta(leftLegLength);

                // Calcuate adjustment angles
                var waistAngle = customPose.WaistAngle * heelHeightDelta;

                var rightThighAngle = customPose.RightThighAngle * heelHeightDelta * rightThighDelta;
                var leftThighAngle  = customPose.LeftThighAngle * heelHeightDelta * leftThighDelta;

                var rightLowLegAngle = customPose.RightLegAngle * heelHeightDelta * rightLegDelta;
                var leftLowLegAngle  = customPose.LeftLegAngle * heelHeightDelta * leftLegDelta;

                var rightHighLegAngle = rightThighAngle + rightLowLegAngle;
                var leftHighLegAngle  = leftThighAngle + leftLowLegAngle;

                // Apply adjustments
                _lowWaist.localRotation *= Quaternion.Euler(-waistAngle, 0, 0);

                _rightThigh.localRotation *= Quaternion.Euler(-rightThighAngle, 0, 0);
                _leftThigh.localRotation  *= Quaternion.Euler(-leftThighAngle, 0, 0);

                _rightHighLeg.localRotation *= Quaternion.Euler(rightHighLegAngle, 0, 0);
                _leftHighLeg.localRotation  *= Quaternion.Euler(leftHighLegAngle, 0, 0);

                _rightLowLeg.localRotation *= Quaternion.Euler(-rightLowLegAngle, 0, 0);
                _leftLowLeg.localRotation  *= Quaternion.Euler(-leftLowLegAngle, 0, 0);

                _rightFoot.localRotation *= Quaternion.Euler(customPose.RightAnkleAngle, 0, 0);
                _leftFoot.localRotation  *= Quaternion.Euler(customPose.LeftAnkleAngle, 0, 0);

                _body.localPosition = Vector3.zero;
            }
            else if (flags.KNEE_BEND && FullBodyBipedEnabled)
            {
                var halfHeight = height * _generalSetting.KneeBend_HeelHeightMultiplier;

                FullBodyBipedSolver.bodyEffector.positionOffset -= halfHeight;
                FullBodyBipedSolver.bodyEffector.positionWeight  = 0f;

                FullBodyBipedSolver.rightFootEffector.positionOffset += halfHeight;
                FullBodyBipedSolver.rightFootEffector.positionWeight  = 0f;

                FullBodyBipedSolver.leftFootEffector.positionOffset += halfHeight;
                FullBodyBipedSolver.leftFootEffector.positionWeight  = 0f;

                _body.localPosition = Vector3.zero;
            }
            else
            {
                _body.localPosition = height;
            }

            _leftFoot.localRotation  *= ankleAngle;
            _rightFoot.localRotation *= ankleAngle;

            _leftToe.localRotation  *= toeAngle;
            _rightToe.localRotation *= toeAngle;

            _leftLowLeg.localRotation  *= legAngle;
            _rightLowLeg.localRotation *= legAngle;
        }