예제 #1
0
        public static ScaledTransformPatch GenerateLocalTransformPatch(MWScaledTransform _old, Transform _new)
        {
            if (_old == null && _new != null)
            {
                return(new ScaledTransformPatch()
                {
                    Position = GeneratePatch(null, _new.localPosition),
                    Rotation = GeneratePatch(null, _new.localRotation),
                    Scale = GeneratePatch(null, _new.localScale)
                });
            }
            else if (_new == null)
            {
                return(null);
            }

            ScaledTransformPatch transform = new ScaledTransformPatch()
            {
                Position = GeneratePatch(_old.Position, _new.localPosition),
                Rotation = GeneratePatch(_old.Rotation, _new.localRotation),
                Scale    = GeneratePatch(_old.Scale, _new.localScale)
            };

            return(transform.IsPatched() ? transform : null);
        }
예제 #2
0
        public static ScaledTransformPatch GenerateLocalTransformPatch(MWScaledTransform _old, Spatial _new)
        {
            if (_old == null && _new != null)
            {
                return(new ScaledTransformPatch()
                {
                    Position = GeneratePatch(null, _new.Transform.origin),
                    Rotation = GeneratePatch(null, new Quat(_new.Transform.basis)),
                    Scale = GeneratePatch(null, _new.Scale)
                });
            }
            else if (_new == null)
            {
                return(null);
            }

            ScaledTransformPatch transform = new ScaledTransformPatch()
            {
                Position = GeneratePatch(_old.Position, _new.Transform.origin),
                Rotation = GeneratePatch(_old.Rotation, new Quat(_new.Transform.basis)),
                Scale    = GeneratePatch(_old.Scale, _new.Scale)
            };

            return(transform.IsPatched() ? transform : null);
        }
예제 #3
0
        public static void ApplyLocalPatch(this Transform _this, MWScaledTransform current, ScaledTransformPatch patch)
        {
            if (patch.Position != null)
            {
                _this.localPosition = _this.localPosition.GetPatchApplied(current.Position.ApplyPatch(patch.Position));
            }

            if (patch.Rotation != null)
            {
                _this.localRotation = _this.localRotation.GetPatchApplied(current.Rotation.ApplyPatch(patch.Rotation));
            }

            if (patch.Scale != null)
            {
                _this.localScale = _this.localScale.GetPatchApplied(current.Scale.ApplyPatch(patch.Scale));
            }
        }
        public static void ToLocalTransform(this MWScaledTransform _this, Transform transform)
        {
            if (_this.Position == null)
            {
                _this.Position = new MWVector3();
            }

            if (_this.Rotation == null)
            {
                _this.Rotation = new MWQuaternion();
            }

            if (_this.Scale == null)
            {
                _this.Scale = new MWVector3();
            }

            _this.Position.FromUnityVector3(transform.localPosition);
            _this.Rotation.FromUnityQuaternion(transform.localRotation);
            _this.Scale.FromUnityVector3(transform.localScale);
        }
예제 #5
0
        public static void ToLocalTransform(this MWScaledTransform _this, Spatial spatial)
        {
            if (_this.Position == null)
            {
                _this.Position = new MWVector3();
            }

            if (_this.Rotation == null)
            {
                _this.Rotation = new MWQuaternion();
            }

            if (_this.Scale == null)
            {
                _this.Scale = new MWVector3();
            }

            _this.Position.FromGodotVector3(spatial.Transform.origin);
            _this.Position.Z *= -1;
            _this.Rotation.FromGodotQuaternion(new Quat(spatial.Rotation));
            _this.Scale.FromGodotVector3(spatial.Scale);
        }