private void OnGizmoAttemptHandleDragBegin(Gizmo gizmo, int handleId) { if (handleId == HandleId) { if (_dragChannel == GizmoDragChannel.Offset) { GizmoDblAxisOffsetDrag3D.WorkData workData = new GizmoDblAxisOffsetDrag3D.WorkData(); workData.Axis0 = Right; workData.Axis1 = Up; workData.DragOrigin = Position; workData.SnapStep0 = Settings.OffsetSnapStepRight; workData.SnapStep1 = Settings.OffsetSnapStepUp; _dblAxisOffsetDrag.SetWorkData(workData); } else if (_dragChannel == GizmoDragChannel.Rotation) { GizmoSglAxisRotationDrag3D.WorkData workData = new GizmoSglAxisRotationDrag3D.WorkData(); workData.Axis = Normal; workData.RotationPlanePos = Position; workData.SnapMode = Settings.RotationSnapMode; workData.SnapStep = Settings.RotationSnapStep; _rotationDrag.SetWorkData(workData); Vector3 arcStart = Plane.ProjectPoint(Gizmo.HoverInfo.HoverPoint); _rotationArc.SetArcData(Normal, Position, arcStart, GetRealCircleRadius(GetZoomFactor(Gizmo.FocusCamera))); } else if (_dragChannel == GizmoDragChannel.Scale) { GizmoDblAxisScaleDrag3D.WorkData workData = new GizmoDblAxisScaleDrag3D.WorkData(); workData.Axis0 = Right; workData.Axis1 = Up; workData.DragOrigin = Position; workData.AxisIndex0 = _scaleDragAxisIndexRight; workData.AxisIndex1 = _scaleDragAxisIndexUp; workData.SnapStep = Settings.ProportionalScaleSnapStep; _scaleDrag.SetWorkData(workData); } } }
private void OnGizmoAttemptHandleDragBegin(Gizmo gizmo, int handleId) { if (handleId == Handle.Id || handleId == _cap3D.HandleId) { if (_dragChannel == GizmoDragChannel.Offset) { // We need to tell the session about the data that it needs in order to do its work GizmoSglAxisOffsetDrag3D.WorkData workData = new GizmoSglAxisOffsetDrag3D.WorkData(); workData.Axis = Direction; // The offset session will offset along the slider direction workData.DragOrigin = StartPosition; // The point on the drag plane is the slider's start point workData.SnapStep = Settings.OffsetSnapStep; // Use the snap step stored in the slider settings _offsetDrag.SetWorkData(workData); // Set the work data } else if (_dragChannel == GizmoDragChannel.Rotation) { // We need to tell the session about the data that it needs in order to do its work GizmoSglAxisRotationDrag3D.WorkData workData = new GizmoSglAxisRotationDrag3D.WorkData(); workData.Axis = DragRotationAxis; // The rotation session will rotate around the drag rotation axis workData.RotationPlanePos = StartPosition; // The point on the rotation plane is the slider's start point workData.SnapStep = Settings.RotationSnapStep; // Use the snap step stored in the slider settings workData.SnapMode = Settings.RotationSnapMode; // Use the snap mode stored in the slider settings _rotationDrag.SetWorkData(workData); // Set the work data // Configure the rotation arc plane _rotationArc.SetArcData(DragRotationAxis, StartPosition, StartPosition + Direction, GetRealLength(GetZoomFactor(Gizmo.FocusCamera))); } else if (_dragChannel == GizmoDragChannel.Scale) { // We need to tell the session about the data that it needs in order to do its work GizmoSglAxisScaleDrag3D.WorkData workData = new GizmoSglAxisScaleDrag3D.WorkData(); workData.Axis = Direction; // The scale session will scale along the slider direction workData.DragOrigin = StartPosition; // The point on the drag plane is the slider's start point workData.SnapStep = Settings.ScaleSnapStep; // Use the snap step stored in the slider settings workData.AxisIndex = ScaleDragAxisIndex; // We want the slider to store the scale ouput in the component with the specified index. workData.BaseSize = GetRealLength(GetZoomFactor(Gizmo.FocusCamera)); // The session needs to know the size of the entity which will be scaled in order to properly // calculate a scale drag value. We use the real length of the slider for this. _scaleDrag.SetWorkData(workData); // Set the work data } } }
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.DragOrigin = ScaleDragOrigin; workData.SnapStep = Settings.ScaleSnapStep; workData.EntityScale = 1.0f; _scaleDrag.SetWorkData(workData); } } }
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 == HandleId) { if (_dragChannel == GizmoDragChannel.Offset) { GizmoDblAxisOffsetDrag3D.WorkData workData = new GizmoDblAxisOffsetDrag3D.WorkData(); workData.Axis0 = Right; workData.Axis1 = Up; workData.DragOrigin = Position; workData.SnapStep0 = Settings.OffsetSnapStepRight; workData.SnapStep1 = Settings.OffsetSnapStepUp; _dblAxisOffsetDrag.SetWorkData(workData); } else if (_dragChannel == GizmoDragChannel.Rotation) { GizmoSglAxisRotationDrag3D.WorkData workData = new GizmoSglAxisRotationDrag3D.WorkData(); workData.Axis = Normal; workData.RotationPlanePos = Position; workData.SnapMode = Settings.RotationSnapMode; workData.SnapStep = Settings.RotationSnapStep; _rotationDrag.SetWorkData(workData); Vector3 arcStart = Plane.ProjectPoint(Gizmo.HoverInfo.HoverPoint); _rotationArc.SetArcData(Normal, Position, arcStart, GetRealCircleRadius(GetZoomFactor(Gizmo.FocusCamera))); } else if (_dragChannel == GizmoDragChannel.Scale) { float zoomFactor = GetZoomFactor(Gizmo.FocusCamera); GizmoDblAxisScaleDrag3D.WorkData workData = new GizmoDblAxisScaleDrag3D.WorkData(); workData.Axis0 = Right; workData.Axis1 = Up; workData.DragOrigin = Position; workData.AxisIndex0 = _scaleDragAxisIndexRight; workData.AxisIndex1 = _scaleDragAxisIndexUp; workData.ScaleMode = Settings.ScaleMode; if (workData.ScaleMode == GizmoDblAxisScaleMode.Independent) { workData.IndSnapStep0 = Settings.ScaleSnapStepRight; workData.IndSnapStep1 = Settings.ScaleSnapStepUp; if (LookAndFeel.PlaneType == GizmoPlane3DType.Quad) { workData.IndBaseSize0 = GetRealQuadWidth(zoomFactor) * 0.5f; workData.IndBaseSize1 = GetRealQuadHeight(zoomFactor) * 0.5f; } else if (LookAndFeel.PlaneType == GizmoPlane3DType.RATriangle) { workData.IndBaseSize0 = GetRealRATriXLength(zoomFactor); workData.IndBaseSize1 = GetRealRATriYLength(zoomFactor); } } else { if (LookAndFeel.PlaneType == GizmoPlane3DType.Quad) { workData.PropBaseSize = TriangleMath.CalcRATriangleHypotenuse(GetRealQuadSize(zoomFactor) * 0.5f); } else if (LookAndFeel.PlaneType == GizmoPlane3DType.RATriangle) { workData.PropBaseSize = TriangleMath.CalcRATriangleAltitude(GetRealRATriSize(zoomFactor)); } workData.PropSnapStep = Settings.ProportionalScaleSnapStep; workData.PropAxis = ((Right + Up) * 0.5f).normalized; } _scaleDrag.SetWorkData(workData); } } }