Example #1
0
        static void OnPlacementComponentChangedCallback(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var ctrl            = sender as Transform;
            var newValue        = e.NewValue;
            var valueType       = newValue.GetType();
            var posXMultiVal    = new EditorCommon.PropertyMultiValue();
            var posYMultiVal    = new EditorCommon.PropertyMultiValue();
            var posZMultiVal    = new EditorCommon.PropertyMultiValue();
            var rotXMultiVal    = new EditorCommon.PropertyMultiValue();
            var rotYMultiVal    = new EditorCommon.PropertyMultiValue();
            var rotZMultiVal    = new EditorCommon.PropertyMultiValue();
            var scaleXMultiVal  = new EditorCommon.PropertyMultiValue();
            var scaleYMultiVal  = new EditorCommon.PropertyMultiValue();
            var scaleZMultiVal  = new EditorCommon.PropertyMultiValue();
            var inheritRotVal   = new EditorCommon.PropertyMultiValue();
            var inheritScaleVal = new EditorCommon.PropertyMultiValue();
            var delta           = 180 / System.Math.PI;

            if (valueType == typeof(EditorCommon.PropertyMultiValue))
            {
                var multiValue = newValue as EditorCommon.PropertyMultiValue;
                foreach (EngineNS.GamePlay.Component.GPlacementComponent placement in multiValue.Values)
                {
                    placement.PropertyChanged -= ctrl.Placement_PropertyChanged;
                    placement.PropertyChanged += ctrl.Placement_PropertyChanged;

                    posXMultiVal.Values.Add(placement.Location.X);
                    posYMultiVal.Values.Add(placement.Location.Y);
                    posZMultiVal.Values.Add(placement.Location.Z);

                    float yaw, pitch, roll;
                    placement.Rotation.GetYawPitchRoll(out yaw, out pitch, out roll);
                    rotXMultiVal.Values.Add(pitch * delta);
                    rotYMultiVal.Values.Add(yaw * delta);
                    rotZMultiVal.Values.Add(roll * delta);

                    scaleXMultiVal.Values.Add(placement.Scale.X);
                    scaleYMultiVal.Values.Add(placement.Scale.Y);
                    scaleZMultiVal.Values.Add(placement.Scale.Z);

                    inheritRotVal.Values.Add(placement.InheritRotation);
                    inheritScaleVal.Values.Add(placement.InheritScale);
                }
            }
            else// if(valueType == typeof(EngineNS.GamePlay.Component.GPlacementComponent))
            {
                var placement = newValue as EngineNS.GamePlay.Component.GPlacementComponent;
                placement.PropertyChanged -= ctrl.Placement_PropertyChanged;
                placement.PropertyChanged += ctrl.Placement_PropertyChanged;

                posXMultiVal.Values.Add(placement.Location.X);
                posYMultiVal.Values.Add(placement.Location.Y);
                posZMultiVal.Values.Add(placement.Location.Z);

                float yaw, pitch, roll;
                placement.Rotation.GetYawPitchRoll(out yaw, out pitch, out roll);
                rotXMultiVal.Values.Add(pitch * delta);
                rotYMultiVal.Values.Add(yaw * delta);
                rotZMultiVal.Values.Add(roll * delta);

                scaleXMultiVal.Values.Add(placement.Scale.X);
                scaleYMultiVal.Values.Add(placement.Scale.Y);
                scaleZMultiVal.Values.Add(placement.Scale.Z);

                inheritRotVal.Values.Add(placement.InheritRotation);
                inheritScaleVal.Values.Add(placement.InheritScale);
            }
            ctrl.mPositionX = posXMultiVal.GetValue();
            ctrl.OnPropertyChanged("PositionX");
            ctrl.mPositionY = posYMultiVal.GetValue();
            ctrl.OnPropertyChanged("PositionY");
            ctrl.mPositionZ = posZMultiVal.GetValue();
            ctrl.OnPropertyChanged("PositionZ");

            ctrl.mRotationX    = rotXMultiVal.GetValue();
            ctrl.mOldRotationX = ctrl.mRotationX;
            ctrl.OnPropertyChanged("RotationX");
            ctrl.mRotationY    = rotYMultiVal.GetValue();
            ctrl.mOldRotationY = ctrl.mRotationY;
            ctrl.OnPropertyChanged("RotationY");
            ctrl.mRotationZ    = rotZMultiVal.GetValue();
            ctrl.mOldRotationZ = ctrl.mRotationZ;
            ctrl.OnPropertyChanged("RotationZ");

            ctrl.mScaleX = scaleXMultiVal.GetValue();
            ctrl.OnPropertyChanged("ScaleX");
            ctrl.mScaleY = scaleYMultiVal.GetValue();
            ctrl.OnPropertyChanged("ScaleY");
            ctrl.mScaleZ = scaleZMultiVal.GetValue();
            ctrl.OnPropertyChanged("ScaleZ");

            ctrl.mInheritRotation = inheritRotVal.GetValue();
            ctrl.OnPropertyChanged("InheritRotation");

            ctrl.mInheritScale = inheritScaleVal.GetValue();
            ctrl.OnPropertyChanged("InheritScale");
        }
Example #2
0
        private void Placement_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (mIsManual)
            {
                return;
            }
            var newValue        = PlacementComponent;
            var valueType       = newValue.GetType();
            var posXMultiVal    = new EditorCommon.PropertyMultiValue();
            var posYMultiVal    = new EditorCommon.PropertyMultiValue();
            var posZMultiVal    = new EditorCommon.PropertyMultiValue();
            var rotXMultiVal    = new EditorCommon.PropertyMultiValue();
            var rotYMultiVal    = new EditorCommon.PropertyMultiValue();
            var rotZMultiVal    = new EditorCommon.PropertyMultiValue();
            var scaleXMultiVal  = new EditorCommon.PropertyMultiValue();
            var scaleYMultiVal  = new EditorCommon.PropertyMultiValue();
            var scaleZMultiVal  = new EditorCommon.PropertyMultiValue();
            var inheritRotVal   = new EditorCommon.PropertyMultiValue();
            var inheritScaleVal = new EditorCommon.PropertyMultiValue();
            var delta           = 180 / System.Math.PI;

            if (valueType == typeof(EditorCommon.PropertyMultiValue))
            {
                var multiValue = newValue as EditorCommon.PropertyMultiValue;
                foreach (EngineNS.GamePlay.Component.GPlacementComponent placement in multiValue.Values)
                {
                    posXMultiVal.Values.Add(placement.Location.X);
                    posYMultiVal.Values.Add(placement.Location.Y);
                    posZMultiVal.Values.Add(placement.Location.Z);

                    float yaw, pitch, roll;
                    placement.Rotation.GetYawPitchRoll(out yaw, out pitch, out roll);
                    rotXMultiVal.Values.Add(pitch * delta);
                    rotYMultiVal.Values.Add(yaw * delta);
                    rotZMultiVal.Values.Add(roll * delta);

                    scaleXMultiVal.Values.Add(placement.Scale.X);
                    scaleYMultiVal.Values.Add(placement.Scale.Y);
                    scaleZMultiVal.Values.Add(placement.Scale.Z);

                    inheritRotVal.Values.Add(placement.InheritRotation);
                    inheritScaleVal.Values.Add(placement.InheritScale);
                }
            }
            else// if (valueType == typeof(EngineNS.GamePlay.Component.GPlacementComponent))
            {
                var placement = newValue as EngineNS.GamePlay.Component.GPlacementComponent;

                posXMultiVal.Values.Add(placement.Location.X);
                posYMultiVal.Values.Add(placement.Location.Y);
                posZMultiVal.Values.Add(placement.Location.Z);

                float yaw, pitch, roll;
                placement.Rotation.GetYawPitchRoll(out yaw, out pitch, out roll);
                rotXMultiVal.Values.Add(pitch * delta);
                rotYMultiVal.Values.Add(yaw * delta);
                rotZMultiVal.Values.Add(roll * delta);

                scaleXMultiVal.Values.Add(placement.Scale.X);
                scaleYMultiVal.Values.Add(placement.Scale.Y);
                scaleZMultiVal.Values.Add(placement.Scale.Z);

                inheritRotVal.Values.Add(placement.InheritRotation);
                inheritScaleVal.Values.Add(placement.InheritScale);
            }
            mPositionX = posXMultiVal.GetValue();
            OnPropertyChanged("PositionX");
            mPositionY = posYMultiVal.GetValue();
            OnPropertyChanged("PositionY");
            mPositionZ = posZMultiVal.GetValue();
            OnPropertyChanged("PositionZ");

            var RotationAngle = GameActors as WPG.Themes.TypeEditors.TransformGradient.IRotationAngle;

            if (RotationAngle != null)
            {
                //RotationAngle.YawPitchRoll = new EngineNS.Vector3(System.Convert.ToSingle(mRotationX), System.Convert.ToSingle(mRotationY), System.Convert.ToSingle(mRotationZ));
                mRotationX    = RotationAngle.YawPitchRoll.X;
                mOldRotationX = mRotationX;
                OnPropertyChanged("RotationX");
                mRotationY    = RotationAngle.YawPitchRoll.Y;
                mOldRotationY = mRotationY;
                OnPropertyChanged("RotationY");
                mRotationZ    = RotationAngle.YawPitchRoll.Z;
                mOldRotationZ = mRotationZ;
                OnPropertyChanged("RotationZ");
            }
            else
            {
                mRotationX    = rotXMultiVal.GetValue();
                mOldRotationX = mRotationX;
                OnPropertyChanged("RotationX");
                mRotationY    = rotYMultiVal.GetValue();
                mOldRotationY = mRotationY;
                OnPropertyChanged("RotationY");
                mRotationZ    = rotZMultiVal.GetValue();
                mOldRotationZ = mRotationZ;
                OnPropertyChanged("RotationZ");
            }


            mScaleX = scaleXMultiVal.GetValue();
            OnPropertyChanged("ScaleX");
            mScaleY = scaleYMultiVal.GetValue();
            OnPropertyChanged("ScaleY");
            mScaleZ = scaleZMultiVal.GetValue();
            OnPropertyChanged("ScaleZ");

            mInheritRotation = inheritRotVal.GetValue();
            OnPropertyChanged("InheritRotation");

            mInheritScale = inheritScaleVal.GetValue();
            OnPropertyChanged("InheritScale");
        }