Exemple #1
0
            public override void Rotate(Option <Vector3> target, Vector2 offset, Vector2 influence)
            {
                Vector2 GetMorph(Vector3 t)
                {
                    var rotation = CalculateRotation(t, Transform(), offset) * influence;

                    var horizontal = (1f - YawRange.Ratio(YawRange.Clamp(rotation.x))) * 0.5f;
                    var vertical   = (1f + PitchRange.Ratio(PitchRange.Clamp(rotation.y))) * 0.5f;

                    return(new Vector2(horizontal, vertical));
                }

                var morph = target.Map(GetMorph).IfNone(new Vector2(0.5f, 0.5f));

                HorizontalControl.Position = morph.x;
                VerticalControl.Position   = morph.y;
            }
Exemple #2
0
            public override void Rotate(Option <Vector3> target, Vector2 offset, Vector2 influence)
            {
                var transform = Transform();

                //FIXME: A temporary workaround until godotengine/godot#33552 gets fixed.
                Skeleton.SetBoneGlobalPoseOverride(Bone, Godot.Transform.Identity, 0f, false);

                target.Iter(t =>
                {
                    var v = CalculateRotation(t, transform, offset) * influence;

                    var h = Basis.Identity.Rotated(Vector3.Up, YawRange.Clamp(v.x));
                    var r = h.Xform(Vector3.Right);

                    var global = Skeleton.GetBoneGlobalPose(Bone);

                    var rotation = h.Rotated(r, PitchRange.Clamp(v.y));
                    var rotated  = new Transform(rotation * global.basis, global.origin);

                    Skeleton.SetBoneGlobalPoseOverride(Bone, rotated, 1f, true);
                });
            }