private void OnGizmoAttemptHandleDragBegin(Gizmo gizmo, int handleId) { if (handleId == HandleId) { if (_dragChannel == GizmoDragChannel.Offset) { GizmoDblAxisOffsetDrag3D.WorkData workData = new GizmoDblAxisOffsetDrag3D.WorkData(); workData.Axis0 = Vector2Ex.ConvertDirTo3D(_transform.Right2D, OffsetDragOrigin, Gizmo.FocusCamera).normalized; workData.Axis1 = Vector2Ex.ConvertDirTo3D(_transform.Up2D, OffsetDragOrigin, Gizmo.FocusCamera).normalized; workData.DragOrigin = OffsetDragOrigin; workData.SnapStep0 = Settings.OffsetSnapStepRight; workData.SnapStep1 = Settings.OffsetSnapStepUp; _offsetDrag.SetWorkData(workData); } else if (_dragChannel == GizmoDragChannel.Rotation) { GizmoSglAxisRotationDrag3D.WorkData workData = new GizmoSglAxisRotationDrag3D.WorkData(); workData.Axis = Gizmo.FocusCamera.transform.forward; workData.SnapMode = Settings.RotationSnapMode; workData.SnapStep = Settings.RotationSnapStep; if (LookAndFeel.PlaneType != GizmoPlane2DType.Polygon) { workData.RotationPlanePos = Gizmo.FocusCamera.ScreenToWorldPoint(new Vector3(Position.x, Position.y, Gizmo.FocusCamera.nearClipPlane)); } if (LookAndFeel.PlaneType == GizmoPlane2DType.Circle) { _rotationArc.SetArcData(Position, Gizmo.HoverInfo.HoverPoint, GetRealCircleRadius()); _rotationArc.Type = GizmoRotationArc2D.ArcType.Standard; } else if (LookAndFeel.PlaneType == GizmoPlane2DType.Polygon) { Vector3 polyCenter = PolyCenter; workData.RotationPlanePos = Gizmo.FocusCamera.ScreenToWorldPoint(new Vector3(polyCenter.x, polyCenter.y, Gizmo.FocusCamera.nearClipPlane)); _rotationArc.SetArcData(PolyCenter, Gizmo.HoverInfo.HoverPoint, 1.0f); _rotationArc.Type = GizmoRotationArc2D.ArcType.PolyProjected; _rotationArc.ProjectionPoly = _polygon; _rotationArc.NumProjectedPoints = 100; } _rotationDrag.SetWorkData(workData); } else if (_dragChannel == GizmoDragChannel.Scale) { _scaleAxisRight = Vector2Ex.ConvertDirTo3D(Position, GetRealExtentPoint(Shape2DExtentPoint.Right), ScaleDragOrigin, Gizmo.FocusCamera); _scaleAxisUp = Vector2Ex.ConvertDirTo3D(Position, GetRealExtentPoint(Shape2DExtentPoint.Top), ScaleDragOrigin, Gizmo.FocusCamera); GizmoDblAxisScaleDrag3D.WorkData workData = new GizmoDblAxisScaleDrag3D.WorkData(); workData.Axis0 = _scaleAxisRight.normalized; workData.Axis1 = _scaleAxisUp.normalized; workData.AxisIndex0 = _scaleDragAxisIndexRight; workData.AxisIndex1 = _scaleDragAxisIndexUp; workData.DragOrigin = ScaleDragOrigin; workData.SnapStep = Settings.ProportionalScaleSnapStep; _scaleDrag.SetWorkData(workData); } } }
private void OnGizmoAttemptHandleDragBegin(Gizmo gizmo, int handleId) { if (handleId == Handle.Id || handleId == _cap2D.HandleId) { if (_dragChannel == GizmoDragChannel.Offset) { GizmoSglAxisOffsetDrag3D.WorkData workData = new GizmoSglAxisOffsetDrag3D.WorkData(); workData.Axis = Vector2Ex.ConvertDirTo3D(StartPosition, GetRealEndPosition(), OffsetDragOrigin, Gizmo.FocusCamera).normalized; workData.DragOrigin = OffsetDragOrigin; workData.SnapStep = Settings.OffsetSnapStep; _offsetDrag.SetWorkData(workData); } else if (_dragChannel == GizmoDragChannel.Rotation) { GizmoSglAxisRotationDrag3D.WorkData workData = new GizmoSglAxisRotationDrag3D.WorkData(); workData.Axis = Gizmo.FocusCamera.transform.forward; workData.SnapMode = Settings.RotationSnapMode; workData.SnapStep = Settings.RotationSnapStep; workData.RotationPlanePos = Gizmo.FocusCamera.ScreenToWorldPoint(new Vector3(_transform.Position2D.x, _transform.Position2D.y, Gizmo.FocusCamera.nearClipPlane)); _rotationArc.SetArcData(StartPosition, GetRealEndPosition(), GetRealLength()); _rotationDrag.SetWorkData(workData); } else if (_dragChannel == GizmoDragChannel.Scale) { _scaleAxis = Vector2Ex.ConvertDirTo3D(StartPosition, GetRealEndPosition(), ScaleDragOrigin, Gizmo.FocusCamera); GizmoSglAxisScaleDrag3D.WorkData workData = new GizmoSglAxisScaleDrag3D.WorkData(); workData.Axis = _scaleAxis.normalized; workData.AxisIndex = _scaleDragAxisIndex; workData.BaseSize = _scaleAxis.magnitude; workData.DragOrigin = ScaleDragOrigin; workData.SnapStep = Settings.ScaleSnapStep; _scaleDrag.SetWorkData(workData); } } }