示例#1
0
        private void DrawCurve(RippleDeformer ripple)
        {
            using (new Handles.DrawingScope(Matrix4x4.TRS(ripple.Axis.position, ripple.Axis.rotation, ripple.Axis.lossyScale)))
            {
                var lineStart     = Vector3.up * -ripple.OuterRadius;
                var lineEnd       = Vector3.up * ripple.OuterRadius;
                var previousPoint = RipplePoint(ripple, lineStart, ripple.Mode == BoundsMode.Limited);
                DeformHandles.Line(Vector3.up * -ripple.OuterRadius, previousPoint, DeformHandles.LineMode.LightDotted);

                for (int i = 0; i <= CURVE_RES; i++)
                {
                    var point = Vector3.Lerp(lineStart, lineEnd, (float)i / CURVE_RES);

                    point = RipplePoint(ripple, point, ripple.Mode == BoundsMode.Limited);

                    DeformHandles.Line(previousPoint, point, DeformHandles.LineMode.Light);

                    previousPoint = point;
                }

                var outerPoint = RipplePoint(ripple, Vector3.up * ripple.OuterRadius, ripple.Mode == BoundsMode.Limited);
//				DeformHandles.Line (previousPoint, outerPoint, DeformHandles.LineMode.Light);
                DeformHandles.Line(lineEnd, outerPoint, DeformHandles.LineMode.LightDotted);
                DeformHandles.Line(lineStart, lineEnd, DeformHandles.LineMode.LightDotted);
            }
        }
示例#2
0
        private void DrawRadiusHandle(CylindrifyDeformer cylindrify)
        {
            var position = Vector3.up * cylindrify.Radius;

            var axis = cylindrify.Axis;

            using (new Handles.DrawingScope(Matrix4x4.TRS(axis.position, axis.rotation, axis.lossyScale)))
            {
                var size = HandleUtility.GetHandleSize(position) * DeformEditorSettings.ScreenspaceSliderHandleCapSize;

                DeformHandles.Circle(Vector3.zero, Vector3.forward, Vector3.up, cylindrify.Radius);

                DeformHandles.Line(position + Vector3.forward * size, position + Vector3.forward * size * 5f, DeformHandles.LineMode.Light);
                DeformHandles.Line(position - Vector3.forward * size, position - Vector3.forward * size * 5f, DeformHandles.LineMode.Light);

                using (var check = new EditorGUI.ChangeCheckScope())
                {
                    var newWorldPosition = DeformHandles.Slider(position, Vector3.up);
                    if (check.changed)
                    {
                        Undo.RecordObject(cylindrify, "Changed Radius");
                        cylindrify.Radius = cylindrify.Axis.position.y;
                    }
                }
            }
        }
示例#3
0
        private void DrawTopFactorHandles(TaperDeformer taper)
        {
            var topPosition = Vector3.forward * taper.Top;

            var topFactorXPosition = topPosition + Vector3.right * taper.TopFactor.x * 0.5f;
            var topFactorYPosition = topPosition + Vector3.up * taper.TopFactor.y * 0.5f;

            using (new Handles.DrawingScope(Matrix4x4.TRS(taper.Axis.position, taper.Axis.rotation, taper.Axis.lossyScale)))
            {
                DeformHandles.Line(topPosition, topFactorXPosition, DeformHandles.LineMode.LightDotted);
                DeformHandles.Line(topPosition, topFactorYPosition, DeformHandles.LineMode.LightDotted);

                using (var check = new EditorGUI.ChangeCheckScope())
                {
                    var newTopFactorXWorldPosition = DeformHandles.Slider(topFactorXPosition, Vector3.right);
                    if (check.changed)
                    {
                        Undo.RecordObject(taper, "Changed Top Factor");
                        taper.TopFactor = new Vector2(newTopFactorXWorldPosition.x * 2f, taper.TopFactor.y);
                    }
                }

                using (var check = new EditorGUI.ChangeCheckScope())
                {
                    var newTopFactorYWorldPosition = DeformHandles.Slider(topFactorYPosition, Vector3.up);
                    if (check.changed)
                    {
                        Undo.RecordObject(taper, "Changed Top Factor");
                        taper.TopFactor = new Vector2(taper.TopFactor.x, newTopFactorYWorldPosition.y * 2f);
                    }
                }
            }
        }
        private void DrawCurve(SineDeformer sine)
        {
            var forward = sine.Axis.forward;
            var size    = HandleUtility.GetHandleSize(sine.Axis.position) * 5f;
            var a       = sine.Axis.position - (forward * size);
            var b       = sine.Axis.position + (forward * size);

            var pointSet         = false;
            var lastPointOnCurve = Vector3.zero;

            for (int i = 0; i <= DeformHandles.DEF_CURVE_SEGMENTS; i++)
            {
                var pointOnLine     = sine.Axis.worldToLocalMatrix.MultiplyPoint3x4(Vector3.Lerp(a, b, i / (float)DeformHandles.DEF_CURVE_SEGMENTS));
                var newPointOnCurve = pointOnLine + Vector3.up * Mathf.Sin((pointOnLine.z * sine.Frequency + sine.GetTotalOffset()) * Mathf.PI * 2f);
                newPointOnCurve.y *= sine.Amplitude;
                newPointOnCurve.y *= Mathf.Exp(-sine.Falloff * Mathf.Abs(newPointOnCurve.z));
                newPointOnCurve    = sine.Axis.localToWorldMatrix.MultiplyPoint3x4(newPointOnCurve);
                if (pointSet)
                {
                    DeformHandles.Line(lastPointOnCurve, newPointOnCurve, DeformHandles.LineMode.Solid);
                }
                lastPointOnCurve = newPointOnCurve;
                pointSet         = true;
            }
        }
示例#5
0
        void DrawAngleHandle(TwirlDeformer twirl)
        {
            var radiusDistanceOffset = HandleUtility.GetHandleSize(twirl.Axis.position + twirl.Axis.right * twirl.Outer) * DeformEditorSettings.ScreenspaceSliderHandleCapSize * 2f;

            angleHandle.angle             = twirl.Angle;
            angleHandle.radius            = twirl.Outer + radiusDistanceOffset;
            angleHandle.fillColor         = Color.clear;
            angleHandle.angleHandleColor  = DeformEditorSettings.SolidHandleColor;
            angleHandle.radiusHandleColor = Color.clear;

            var matrix = Matrix4x4.TRS(twirl.transform.position, twirl.transform.rotation, twirl.transform.lossyScale);

            using (new Handles.DrawingScope(matrix))
            {
                DeformHandles.Circle(Vector3.zero, Vector3.forward, Vector3.right, angleHandle.radius);

                Handles.color = DeformEditorSettings.SolidHandleColor;

                using (var check = new EditorGUI.ChangeCheckScope())
                {
                    using (new Handles.DrawingScope(matrix * Matrix4x4.Rotate(Quaternion.LookRotation(Vector3.right, Vector3.forward))))
                    {
                        angleHandle.DrawHandle();
                        if (check.changed)
                        {
                            Undo.RecordObject(twirl, "Changed Angle");
                            twirl.Angle = angleHandle.angle;
                        }
                    }
                }
            }
        }
        private void DrawFactorHandle(SpherifyDeformer spherify)
        {
            if (spherify.Radius == 0f)
            {
                return;
            }

            var direction = Vector3.forward;
            var position  = direction * (spherify.Factor * spherify.Radius);

            using (new Handles.DrawingScope(Matrix4x4.TRS(spherify.Axis.position, spherify.Axis.rotation, spherify.Axis.lossyScale)))
            {
                DeformHandles.Line(Vector3.zero, position, DeformHandles.LineMode.Light);
                DeformHandles.Line(position, direction * spherify.Radius, DeformHandles.LineMode.LightDotted);

                using (var check = new EditorGUI.ChangeCheckScope())
                {
                    var newWorldPosition = DeformHandles.Slider(position, direction);
                    if (check.changed)
                    {
                        Undo.RecordObject(spherify, "Changed Factor");
                        var newFactor = newWorldPosition.z / spherify.Radius;
                        spherify.Factor = newFactor;
                    }
                }
            }
        }
示例#7
0
        private void DrawFactorHandle(CylindrifyDeformer cylindrify)
        {
            if (cylindrify.Radius == 0f)
            {
                return;
            }

            var position = Vector3.up * cylindrify.Factor * cylindrify.Radius;

            var axis = cylindrify.Axis;

            using (new Handles.DrawingScope(Matrix4x4.TRS(axis.position, axis.rotation, axis.lossyScale)))
            {
                DeformHandles.Line(position, Vector3.zero, DeformHandles.LineMode.Light);
                DeformHandles.Line(position, Vector3.up * cylindrify.Radius, DeformHandles.LineMode.LightDotted);

                using (var check = new EditorGUI.ChangeCheckScope())
                {
                    var newWorldPosition = DeformHandles.Slider(position, Vector3.up);
                    if (check.changed)
                    {
                        Undo.RecordObject(cylindrify, "Changed Radius");
                        cylindrify.Factor = newWorldPosition.y;
                    }
                }
            }
        }
示例#8
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;
                }
            }
        }
        public override void OnSceneGUI()
        {
            base.OnSceneGUI();

            var lathe = target as LatheDisplaceDeformer;

            DeformHandles.Curve(lathe.Curve, lathe.Axis, lathe.Factor * 0.5f, lathe.Offset, lathe.Bias * 0.5f);
        }
示例#10
0
        public override void OnSceneGUI()
        {
            base.OnSceneGUI();

            var curveScale = target as CurveScaleDeformer;

            DeformHandles.Curve(curveScale.Curve, curveScale.Axis, curveScale.Factor * 0.5f, curveScale.Offset, curveScale.Bias * 0.5f);
        }
示例#11
0
        private void DrawAxisGuide(RadialSkewDeformer skew)
        {
            var direction = skew.Axis.up;

            var top    = skew.Axis.position + direction * HandleUtility.GetHandleSize(skew.Axis.position) * 2f;
            var bottom = skew.Axis.position - direction * HandleUtility.GetHandleSize(skew.Axis.position) * 2f;

            DeformHandles.Line(top, bottom, DeformHandles.LineMode.LightDotted);
        }
示例#12
0
        private void OnSceneGUI()
        {
            if (foldoutDebug)
            {
                var deformable = target as Deformable;

                DeformHandles.Bounds(deformable.GetMesh().bounds, deformable.transform.localToWorldMatrix, DeformHandles.LineMode.LightDotted);
            }
        }
示例#13
0
        protected override void OnEnable()
        {
            base.OnEnable();

            properties = new Properties(serializedObject);

            boundsHandle.HandleCapFunction     = DeformHandles.HandleCapFunction;
            boundsHandle.DrawGuidelineCallback = (a, b) => DeformHandles.Line(a, b, DeformHandles.LineMode.LightDotted);
        }
        public override void OnSceneGUI()
        {
            base.OnSceneGUI();

            var curveScale = target as CurveScaleDeformer;

            var handleScale = new Vector3(1f, 1f, curveScale.Axis.lossyScale.z);

            DeformHandles.Curve(curveScale.Curve, curveScale.Axis.position, curveScale.Axis.rotation, handleScale, curveScale.Factor * 0.5f, curveScale.Offset, curveScale.Bias * 0.5f);
        }
示例#15
0
 protected virtual void OnSceneGUI()
 {
     if (foldoutDebug)
     {
         var deformable = target as Deformable;
         if (deformable != null)
         {
             DeformHandles.Bounds(deformable.GetCurrentMesh().bounds, deformable.transform.localToWorldMatrix, DeformHandles.LineMode.LightDotted);
         }
     }
 }
        private void DrawGuides(SineDeformer sine)
        {
            var direction = sine.Axis.forward;
            var size      = HandleUtility.GetHandleSize(sine.Axis.position) * 5f;
            var baseA     = sine.Axis.position - direction * size;
            var baseB     = sine.Axis.position + direction * size;

            DeformHandles.Line(baseA, baseB, DeformHandles.LineMode.LightDotted);
            DeformHandles.Line(baseA + sine.Axis.up * sine.Amplitude, baseB + sine.Axis.up * sine.Amplitude, DeformHandles.LineMode.LightDotted);
            DeformHandles.Line(baseA - sine.Axis.up * sine.Amplitude, baseB - sine.Axis.up * sine.Amplitude, DeformHandles.LineMode.LightDotted);
        }
        public override void OnSceneGUI()
        {
            base.OnSceneGUI();

            var curveDisplace = target as CurveDisplaceDeformer;

            if (curveDisplace.Curve == null || curveDisplace.Curve.length < 1)
            {
                return;
            }
            DeformHandles.Curve(curveDisplace.Curve, curveDisplace.Axis, curveDisplace.Factor, curveDisplace.Offset, 0f);
        }
示例#18
0
        public override void OnSceneGUI()
        {
            base.OnSceneGUI();

            var ripple = target as RippleDeformer;

            DrawMagnitudeHandle(ripple);

            if (ripple.Mode == BoundsMode.Limited)
            {
                boundsHandle.HandleColor           = DeformEditorSettings.SolidHandleColor;
                boundsHandle.ScreenspaceHandleSize = DeformEditorSettings.ScreenspaceSliderHandleCapSize;
                if (boundsHandle.DrawHandle(ripple.OuterRadius, ripple.InnerRadius, ripple.Axis, Vector3.up))
                {
                    Undo.RecordObject(ripple, "Changed Bounds");
                    ripple.OuterRadius = boundsHandle.Top;
                    ripple.InnerRadius = boundsHandle.Bottom;
                }
            }

            DrawCurve(ripple);

            using (new Handles.DrawingScope(Matrix4x4.TRS(ripple.Axis.position, ripple.Axis.rotation, ripple.Axis.lossyScale)))
            {
                DeformHandles.Line
                (
                    Vector3.up * ripple.InnerRadius,
                    RipplePoint(ripple, Vector3.up * ripple.InnerRadius, ripple.Mode == BoundsMode.Limited),
                    DeformHandles.LineMode.LightDotted
                );

                var limited = ripple.Mode == BoundsMode.Limited;

                var innerCirlePosition = new Vector3
                {
                    x = 0f,
                    y = 0f,
                    z = RipplePoint(ripple, Vector3.up * ripple.InnerRadius, limited).z
                };

                var outerCirlePosition = new Vector3
                {
                    x = 0f,
                    y = 0f,
                    z = RipplePoint(ripple, Vector3.up * ripple.OuterRadius, limited).z
                };

                DeformHandles.Circle(innerCirlePosition, Vector3.forward, Vector3.right, ripple.InnerRadius);
                DeformHandles.Circle(outerCirlePosition, Vector3.forward, Vector3.right, ripple.OuterRadius);
            }

            EditorApplication.QueuePlayerLoopUpdate();
        }
示例#19
0
 private void DrawRadiusHandle(SpherifyDeformer spherify)
 {
     using (new Handles.DrawingScope(Matrix4x4.TRS(spherify.Axis.position, spherify.Axis.rotation, spherify.Axis.lossyScale)))
     {
         using (var check = new EditorGUI.ChangeCheckScope())
         {
             var newRadius = DeformHandles.Radius(Quaternion.identity, Vector3.zero, spherify.Radius);
             if (check.changed)
             {
                 Undo.RecordObject(spherify, "Changed Radius");
                 spherify.Radius = newRadius;
             }
         }
     }
 }
        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;
                }
            }
        }
示例#22
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;
                }
            }
        }
示例#23
0
        private void DrawFactorHandle(SkewDeformer skew)
        {
            var center         = Vector3.up * ((skew.Top + skew.Bottom) * 0.5f);
            var handlePosition = center + Vector3.forward * skew.Factor;

            using (new Handles.DrawingScope(Matrix4x4.TRS(skew.Axis.position, skew.Axis.rotation, skew.Axis.lossyScale)))
            {
                DeformHandles.Line(center, handlePosition, DeformHandles.LineMode.LightDotted);

                using (var check = new EditorGUI.ChangeCheckScope())
                {
                    var newWorldPosition = DeformHandles.Slider(handlePosition, Vector3.forward);
                    if (check.changed)
                    {
                        Undo.RecordObject(skew, "Changed Factor");
                        skew.Factor = newWorldPosition.z;
                    }
                }
            }
        }
示例#24
0
        private void DrawMagnitudeHandle(RippleDeformer ripple)
        {
            var direction = Vector3.forward;
            var position  = direction * ripple.Amplitude;

            using (var check = new EditorGUI.ChangeCheckScope())
            {
                using (new Handles.DrawingScope(Matrix4x4.TRS(ripple.Axis.position, ripple.Axis.rotation, ripple.Axis.lossyScale)))
                {
                    var newPosition = DeformHandles.Slider(position, direction);
                    if (check.changed)
                    {
                        Undo.RecordObject(ripple, "Changed Magnitude");
                        ripple.Amplitude = newPosition.z;
                    }

                    DeformHandles.Line(Vector3.zero, newPosition, DeformHandles.LineMode.LightDotted);
                }
            }
        }
示例#25
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;
                }
            }
        }
示例#26
0
        private void DrawLattice(LatticeDeformer lattice, DeformHandles.LineMode lineMode)
        {
            var resolution    = lattice.Resolution;
            var controlPoints = lattice.ControlPoints;

            for (int z = 0; z < resolution.z - 1; z++)
            {
                for (int y = 0; y < resolution.y - 1; y++)
                {
                    for (int x = 0; x < resolution.x - 1; x++)
                    {
                        int index000 = lattice.GetIndex(x, y, z);
                        int index100 = lattice.GetIndex(x + 1, y, z);
                        int index010 = lattice.GetIndex(x, y + 1, z);
                        int index110 = lattice.GetIndex(x + 1, y + 1, z);
                        int index001 = lattice.GetIndex(x, y, z + 1);
                        int index101 = lattice.GetIndex(x + 1, y, z + 1);
                        int index011 = lattice.GetIndex(x, y + 1, z + 1);
                        int index111 = lattice.GetIndex(x + 1, y + 1, z + 1);

                        DeformHandles.Line(controlPoints[index000], controlPoints[index100], lineMode);
                        DeformHandles.Line(controlPoints[index010], controlPoints[index110], lineMode);
                        DeformHandles.Line(controlPoints[index001], controlPoints[index101], lineMode);
                        DeformHandles.Line(controlPoints[index011], controlPoints[index111], lineMode);

                        DeformHandles.Line(controlPoints[index000], controlPoints[index010], lineMode);
                        DeformHandles.Line(controlPoints[index100], controlPoints[index110], lineMode);
                        DeformHandles.Line(controlPoints[index001], controlPoints[index011], lineMode);
                        DeformHandles.Line(controlPoints[index101], controlPoints[index111], lineMode);

                        DeformHandles.Line(controlPoints[index000], controlPoints[index001], lineMode);
                        DeformHandles.Line(controlPoints[index100], controlPoints[index101], lineMode);
                        DeformHandles.Line(controlPoints[index010], controlPoints[index011], lineMode);
                        DeformHandles.Line(controlPoints[index110], controlPoints[index111], lineMode);
                    }
                }
            }
        }
示例#27
0
        private void DrawRadiusHandle(MeltDeformer melt)
        {
            var scaledRadius = melt.Radius;

            var bottomPosition = Vector3.forward * melt.Bottom;

            using (new Handles.DrawingScope(Matrix4x4.TRS(melt.Axis.position, melt.Axis.rotation, melt.Axis.lossyScale)))
            {
                DeformHandles.Circle(bottomPosition, Vector3.forward, Vector3.right, scaledRadius);

                var radiusWorldPosition = (Vector3.forward * melt.Bottom) + Vector3.up * scaledRadius;

                using (var check = new EditorGUI.ChangeCheckScope())
                {
                    var newRadiusWorldPosition = DeformHandles.Slider(radiusWorldPosition, Vector3.up);
                    if (check.changed)
                    {
                        Undo.RecordObject(melt, "Changed Radius");
                        melt.Radius = newRadiusWorldPosition.y;
                    }
                }
            }
        }