Esempio n. 1
0
        private void DrawBoundsHandles(RadialSkewDeformer skew)
        {
            var direction = skew.Axis.up;

            var topHandleWorldPosition    = skew.Axis.position + direction * skew.Top;
            var bottomHandleWorldPosition = skew.Axis.position + direction * skew.Bottom;

            DeformHandles.Line(topHandleWorldPosition, bottomHandleWorldPosition, DeformHandles.LineMode.LightDotted);

            using (var check = new EditorGUI.ChangeCheckScope())
            {
                var newTopWorldPosition = DeformHandles.Slider(topHandleWorldPosition, direction);
                if (check.changed)
                {
                    Undo.RecordObject(skew, "Changed Top");
                    var newTop = DeformHandlesUtility.DistanceAlongAxis(skew.Axis, skew.Axis.position, newTopWorldPosition, Axis.Y);
                    skew.Top = newTop;
                }
            }

            using (var check = new EditorGUI.ChangeCheckScope())
            {
                var newBottomWorldPosition = DeformHandles.Slider(bottomHandleWorldPosition, direction);
                if (check.changed)
                {
                    Undo.RecordObject(skew, "Changed Bottom");
                    var newBottom = DeformHandlesUtility.DistanceAlongAxis(skew.Axis, skew.Axis.position, newBottomWorldPosition, Axis.Y);
                    skew.Bottom = newBottom;
                }
            }
        }
        private void DrawMagnitudeHandle(SineDeformer sine)
        {
            var direction = sine.Axis.up;
            var magnitudeHandleWorldPosition = sine.Axis.position + direction * sine.Amplitude * sine.Axis.lossyScale.y;

            using (var check = new EditorGUI.ChangeCheckScope())
            {
                var newMagnitudeWorldPosition = DeformHandles.Slider(magnitudeHandleWorldPosition, direction);
                if (check.changed)
                {
                    Undo.RecordObject(sine, "Changed Magnitude");
                    var newMagnitude = DeformHandlesUtility.DistanceAlongAxis(sine.Axis, sine.Axis.position, newMagnitudeWorldPosition, Axis.Y) / sine.Axis.lossyScale.y;
                    sine.Amplitude = newMagnitude;
                }
            }
        }
        private void DrawFrequencyHandle(SineDeformer sine)
        {
            var direction = sine.Axis.forward;
            var frequencyHandleWorldPosition = sine.Axis.position + direction * (1f / sine.Frequency * sine.Axis.lossyScale.z);

            using (var check = new EditorGUI.ChangeCheckScope())
            {
                var newFrequencyWorldPosition = DeformHandles.Slider(frequencyHandleWorldPosition, direction);
                if (check.changed)
                {
                    Undo.RecordObject(sine, "Changed Frequency");
                    var newFrequency = sine.Axis.lossyScale.z / DeformHandlesUtility.DistanceAlongAxis(sine.Axis, sine.Axis.position, newFrequencyWorldPosition, Axis.Z);
                    sine.Frequency = newFrequency;
                }
            }
        }
Esempio n. 4
0
        private void DrawFactorHandle(RadialSkewDeformer skew)
        {
            var direction           = skew.Axis.forward;
            var handleWorldPosition = skew.Axis.position + direction * skew.Factor;

            DeformHandles.Line(skew.Axis.position, handleWorldPosition, DeformHandles.LineMode.LightDotted);

            using (var check = new EditorGUI.ChangeCheckScope())
            {
                var newWorldPosition = DeformHandles.Slider(handleWorldPosition, direction);
                if (check.changed)
                {
                    Undo.RecordObject(skew, "Changed Factor");
                    var newFactor = DeformHandlesUtility.DistanceAlongAxis(skew.Axis, skew.Axis.position, newWorldPosition, Axis.Z);
                    skew.Factor = newFactor;
                }
            }
        }
Esempio n. 5
0
        private void DrawFactorHandle(BulgeDeformer bulge)
        {
            var direction = bulge.Axis.up;

            var center        = bulge.Axis.position + (bulge.Axis.forward * ((bulge.Top + bulge.Bottom) * 0.5f));
            var worldPosition = center + direction * ((bulge.Factor + 1f) * 0.5f);

            DeformHandles.Line(center, worldPosition, DeformHandles.LineMode.LightDotted);

            using (var check = new EditorGUI.ChangeCheckScope())
            {
                var newWorldPosition = DeformHandles.Slider(worldPosition, direction);
                if (check.changed)
                {
                    var newFactor = DeformHandlesUtility.DistanceAlongAxis(bulge.Axis, bulge.Axis.position, newWorldPosition, Axis.Y) * 2f - 1f;
                    Undo.RecordObject(bulge, "Changed Factor");
                    bulge.Factor = newFactor;
                }
            }
        }