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; } } } }
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; } } } }
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 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; } } } }
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; } } }
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; } } }
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; } } } }
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; } } }
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); } } }
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; } } } }