private void DrawSnappingMarks(DrawGlContentEventArgs drawEventArgs, double mouseAngle, double alphaValue, Matrix4X4 rotationCenterTransform, double distanceFromCenter, int numSnapPoints, int markToSnapTo) { var graphics2DOpenGL = new Graphics2DOpenGL(GuiWidget.DeviceScale); double snappingRadians = MathHelper.Tau / numSnapPoints; for (int i = 0; i < numSnapPoints; i++) { double startAngle = i * snappingRadians + mouseAngle; var snapShape = new VertexStorage(); var scale = GuiWidget.DeviceScale; snapShape.MoveTo(-10 * scale, 0); snapShape.LineTo(5 * scale, 7 * scale); snapShape.LineTo(5 * scale, -7 * scale); snapShape.ClosePolygon(); var transformed = new VertexSourceApplyTransform(snapShape, Affine.NewTranslation(distanceFromCenter, 0) * Affine.NewRotation(startAngle)); // new Ellipse(startPosition.x, startPosition.y, dotRadius, dotRadius); var color = theme.TextColor; if (i == markToSnapTo) { color = theme.PrimaryAccentColor; } graphics2DOpenGL.RenderTransformedPath(rotationCenterTransform, transformed, new Color(color, (int)(254 * alphaValue)), drawEventArgs.ZBuffered); } }
public override void Draw(DrawGlContentEventArgs e) { bool shouldDrawScaleControls = true; var selectedItem = RootSelection; if (Object3DControlContext.SelectedObject3DControl != null && Object3DControlContext.SelectedObject3DControl as ScaleMatrixTopControl == null) { shouldDrawScaleControls = false; } if (selectedItem != null) { if (shouldDrawScaleControls) { // don't draw if any other control is dragging if (MouseIsOver || MouseDownOnControl) { GLHelper.Render(topScaleMesh, theme.PrimaryAccentColor.WithAlpha(e.Alpha0to255), TotalTransform, RenderTypes.Shaded); } else { GLHelper.Render(topScaleMesh, theme.TextColor.WithAlpha(e.Alpha0to255), TotalTransform, RenderTypes.Shaded); } } if (e != null) { // evaluate the position of the up line to draw Vector3 topPosition = GetTopPosition(selectedItem); var bottomPosition = topPosition; var originalSelectedBounds = selectedItem.GetAxisAlignedBoundingBox(); bottomPosition.Z = originalSelectedBounds.MinXYZ.Z; // render with z-buffer full black Frustum clippingFrustum = Object3DControlContext.World.GetClippingFrustum(); if (e.ZBuffered) { Object3DControlContext.World.Render3DLine(clippingFrustum, bottomPosition, topPosition, theme.TextColor, width: GuiWidget.DeviceScale); } else { // render on top of everything very lightly Object3DControlContext.World.Render3DLine(clippingFrustum, bottomPosition, topPosition, theme.TextColor.WithAlpha(Constants.LineAlpha), false, GuiWidget.DeviceScale); } } } if (hitPlane != null) { // Object3DControlContext.World.RenderPlane(hitPlane.Plane, Color.Red, true, 50, 3); // Object3DControlContext.World.RenderPlane(initialHitPosition, hitPlane.Plane.Normal, Color.Red, true, 50, 3); } base.Draw(e); }
public void Draw(DrawGlContentEventArgs e) { var color = Color.Black; if (mouseOver) { color = theme.PrimaryAccentColor; } GLHelper.Render(shape, color, ShapeMatrix(), RenderTypes.Shaded); }
public override void Draw(DrawGlContentEventArgs e) { bool shouldDrawScaleControls = controlVisible == null ? true : controlVisible(); if (Object3DControlContext.SelectedObject3DControl != null && Object3DControlContext.SelectedObject3DControl as ScaleDiameterControl == null) { shouldDrawScaleControls = false; } var selectedItem = RootSelection; if (selectedItem != null) { // Ensures that functions in this scope run against the original instance reference rather than the // current value, thus avoiding null reference errors that would occur otherwise if (shouldDrawScaleControls) { // don't draw if any other control is dragging var color = theme.PrimaryAccentColor.WithAlpha(e.Alpha0to255); if (MouseIsOver || MouseDownOnControl) { GLHelper.Render(grabControlMesh, color, TotalTransform, RenderTypes.Shaded); } else { color = theme.TextColor; GLHelper.Render(grabControlMesh, color.WithAlpha(e.Alpha0to255), TotalTransform, RenderTypes.Shaded); } Vector3 newBottomCenter = ObjectSpace.GetCenterPosition(selectedItem, placement); var rotation = Matrix4X4.CreateRotation(new Quaternion(selectedItem.Matrix)); var translation = Matrix4X4.CreateTranslation(newBottomCenter); Object3DControlContext.World.RenderRing(rotation * translation, Vector3.Zero, getDiameters[diameterIndex](), 60, color.WithAlpha(e.Alpha0to255), 2, 0, e.ZBuffered); } if (hitPlane != null) { //Object3DControlContext.World.RenderPlane(hitPlane.Plane, Color.Red, true, 50, 3); //Object3DControlContext.World.RenderPlane(initialHitPosition, hitPlane.Plane.Normal, Color.Red, true, 50, 3); } if (shouldDrawScaleControls && (MouseIsOver || MouseDownOnControl)) { DrawMeasureLines(e); } } base.Draw(e); }
public override void Draw(DrawGlContentEventArgs e) { bool shouldDrawScaleControls = true; var selectedItem = RootSelection; if (Object3DControlContext.SelectedObject3DControl != null && Object3DControlContext.SelectedObject3DControl as ScaleHeightControl == null) { shouldDrawScaleControls = false; } if (selectedItem != null) { if (shouldDrawScaleControls) { // don't draw if any other control is dragging if (MouseIsOver) { GLHelper.Render(topScaleMesh, theme.PrimaryAccentColor, TotalTransform, RenderTypes.Shaded); } else { GLHelper.Render(topScaleMesh, theme.TextColor, TotalTransform, RenderTypes.Shaded); } } if (e != null) { // evaluate the position of the up line to draw Vector3 topPosition = GetTopPosition(selectedItem); var bottomPosition = GetBottomPosition(selectedItem); // render with z-buffer full black Frustum clippingFrustum = Object3DControlContext.World.GetClippingFrustum(); if (e.ZBuffered) { Object3DControlContext.World.Render3DLine(clippingFrustum, bottomPosition, topPosition, theme.TextColor, width: GuiWidget.DeviceScale); } else { // render on top of everything very lightly Object3DControlContext.World.Render3DLine(clippingFrustum, bottomPosition, topPosition, theme.TextColor.WithAlpha(Constants.LineAlpha), false, GuiWidget.DeviceScale); } } } base.Draw(e); }
public override void Draw(DrawGlContentEventArgs e) { var selectedItem = RootSelection; if (selectedItem != null && Object3DControlContext.Scene.ShowSelectionShadow) { // draw the bounds on the bed AxisAlignedBoundingBox selectedBounds = selectedItem.GetAxisAlignedBoundingBox(); var withScale = Matrix4X4.CreateScale(selectedBounds.XSize, selectedBounds.YSize, 1) * TotalTransform; GLHelper.Render(GetNormalShadowMesh(), shadowColor, withScale, RenderTypes.Shaded); } base.Draw(e); }
public void Draw(DrawGlContentEventArgs e) { var color = Color.Black; if (mouseOver) { color = theme.PrimaryAccentColor; } GLHelper.Render(shape, color.WithAlpha(e.Alpha0to255), ShapeMatrix(), RenderTypes.Shaded); if (HitPlane != null) { //Object3DControlContext.World.RenderPlane(hitPlane.Plane, Color.Red, true, 30, 3); //Object3DControlContext.World.RenderPlane(initialHitPosition, hitPlane.Plane.Normal, Color.Red, true, 30, 3); } }
public override void Draw(DrawGlContentEventArgs e) { bool shouldDrawScaleControls = true; if (Object3DControlContext.SelectedObject3DControl != null && Object3DControlContext.SelectedObject3DControl as ScaleWidthDepthEdgeControl == null) { shouldDrawScaleControls = false; } var selectedItem = RootSelection; if (selectedItem != null) { // Ensures that functions in this scope run against the original instance reference rather than the // current value, thus avoiding null reference errors that would occur otherwise if (shouldDrawScaleControls) { // don't draw if any other control is dragging if (MouseIsOver || MouseDownOnControl) { GLHelper.Render(minXminYMesh, theme.PrimaryAccentColor.WithAlpha(e.Alpha0to255), TotalTransform, RenderTypes.Shaded); } else { GLHelper.Render(minXminYMesh, theme.TextColor.Blend(theme.BackgroundColor, .35).WithAlpha(e.Alpha0to255), TotalTransform, RenderTypes.Shaded); } } if (hitPlane != null) { //Object3DControlContext.World.RenderPlane(hitPlane.Plane, Color.Red, true, 50, 3); //Object3DControlContext.World.RenderPlane(initialHitPosition, hitPlane.Plane.Normal, Color.Red, true, 50, 3); } if (MouseIsOver || MouseDownOnControl) { DrawMeasureLines(e); } } base.Draw(e); }
private void DrawMeasureLines(DrawGlContentEventArgs e) { var selectedItem = RootSelection; if (selectedItem != null) { var limitsLines = GetMeasureLine(selectedItem); var color = theme.TextColor.WithAlpha(e.Alpha0to255); if (!e.ZBuffered) { theme.TextColor.WithAlpha(Constants.LineAlpha); } Frustum clippingFrustum = Object3DControlContext.World.GetClippingFrustum(); Object3DControlContext.World.Render3DLine(clippingFrustum, limitsLines.start0, limitsLines.end0, color, e.ZBuffered, GuiWidget.DeviceScale); Object3DControlContext.World.Render3DLine(clippingFrustum, limitsLines.start1, limitsLines.end1, color, e.ZBuffered, GuiWidget.DeviceScale); var start = (limitsLines.start0 + limitsLines.end0) / 2; var end = (limitsLines.start1 + limitsLines.end1) / 2; Object3DControlContext.World.Render3DLine(clippingFrustum, start, end, color, e.ZBuffered, GuiWidget.DeviceScale * 1.2, true, true); } }
public override void DrawGlContent(DrawGlContentEventArgs e) { bool shouldDrawScaleControls = true; if (InteractionContext.SelectedInteractionVolume != null && InteractionContext.SelectedInteractionVolume as ScaleCornerControl == null) { shouldDrawScaleControls = false; } var selectedItem = RootSelection; if (selectedItem != null && InteractionContext.Scene.ShowSelectionShadow) { // Ensures that functions in this scope run against the original instance reference rather than the // current value, thus avoiding null reference errors that would occur otherwise if (shouldDrawScaleControls) { // don't draw if any other control is dragging if (MouseOver) { GLHelper.Render(minXminYMesh, Color.Red, TotalTransform, RenderTypes.Shaded); } else { GLHelper.Render(minXminYMesh, Color.Black, TotalTransform, RenderTypes.Shaded); } } if (e != null) { Vector3 startPosition = GetCornerPosition(selectedItem, quadrantIndex); Vector3 endPosition = GetCornerPosition(selectedItem, (quadrantIndex + 1) % 4); Frustum clippingFrustum = GLHelper.GetClippingFrustum(InteractionContext.World); if (clippingFrustum.ClipLine(ref startPosition, ref endPosition)) { if (e.ZBuffered) { InteractionContext.World.Render3DLine(clippingFrustum, startPosition, endPosition, Color.Black); } else { // render on top of everything very lightly InteractionContext.World.Render3DLine(clippingFrustum, startPosition, endPosition, new Color(Color.Black, 20), false); } } //Vector3 startScreenSpace = InteractionContext.World.GetScreenSpace(startPosition); //e.graphics2D.Circle(startScreenSpace.x, startScreenSpace.y, 5, Color.Red); //Vector2 startScreenPosition = InteractionContext.World.GetScreenPosition(startPosition); //e.graphics2D.Circle(startScreenPosition.x, startScreenPosition.y, 5, Color.Red); } } base.DrawGlContent(e); }