public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e) { var diameter = Diameter.Value(this); var startPercent = StartPercent.Value(this); var minSidesPerRotation = MinSidesPerRotation.Value(this); var sourceAabb = this.SourceContainer.GetAxisAlignedBoundingBox(); var distance = diameter / 2 + sourceAabb.YSize / 2; var center = sourceAabb.Center + new Vector3(0, BendDirection == BendDirections.Bend_Up ? distance : -distance, 0); center.X -= sourceAabb.XSize / 2 - (startPercent / 100.0) * sourceAabb.XSize; // render the top and bottom rings layer.World.RenderCylinderOutline(this.WorldMatrix(), center, diameter, sourceAabb.ZSize, 100, Color.Red, Color.Transparent); // render the split lines var radius = diameter / 2; var circumference = MathHelper.Tau * radius; var xxx = sourceAabb.XSize * (startPercent / 100.0); var startAngle = MathHelper.Tau * 3 / 4 - xxx / circumference * MathHelper.Tau; layer.World.RenderCylinderOutline(this.WorldMatrix(), center, diameter, sourceAabb.ZSize, (int)Math.Max(0, Math.Min(100, minSidesPerRotation)), Color.Transparent, Color.Red, phase: startAngle); // turn the lighting back on GL.Enable(EnableCap.Lighting); }
public void AddObject3DControls(Object3DControlsLayer object3DControlsLayer) { var getDiameters = new List <Func <double> >() { () => OuterDiameter.Value(this), () => InnerDiameter.Value(this) }; var setDiameters = new List <Action <double> >() { (diameter) => OuterDiameter = diameter, (diameter) => InnerDiameter = diameter }; object3DControlsLayer.Object3DControls.Add(new ScaleDiameterControl(object3DControlsLayer, null, null, getDiameters, setDiameters, 0, ObjectSpace.Placement.Center)); object3DControlsLayer.Object3DControls.Add(new ScaleDiameterControl(object3DControlsLayer, null, null, getDiameters, setDiameters, 1, ObjectSpace.Placement.Center, angleOffset: -MathHelper.Tau / 32)); object3DControlsLayer.AddControls(ControlTypes.MoveInZ); object3DControlsLayer.AddControls(ControlTypes.RotateXYZ); }
public void DrawEditor(Object3DControlsLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e) { if (layer.Scene.SelectedItem != null && layer.Scene.SelectedItem.DescendantsAndSelf().Where((i) => i == this).Any()) { var aabb = ItemToScale.GetAxisAlignedBoundingBox(); if (FitType == FitType.Box) { var center = aabb.Center; var worldMatrix = this.WorldMatrix(); var minXyz = center - new Vector3(Width / 2, Depth / 2, Height / 2); var maxXyz = center + new Vector3(Width / 2, Depth / 2, Height / 2); var bounds = new AxisAlignedBoundingBox(minXyz, maxXyz); // var leftW = Vector3Ex.Transform(, worldMatrix); var right = Vector3Ex.Transform(center + new Vector3(Width / 2, 0, 0), worldMatrix); // layer.World.Render3DLine(left, right, Agg.Color.Red); layer.World.RenderAabb(bounds, worldMatrix, Agg.Color.Red, 1, 1); } else { layer.World.RenderCylinderOutline(this.WorldMatrix(), aabb.Center, Diameter, Height, 30, Color.Red, 1, 1); } // turn the lighting back on GL.Enable(EnableCap.Lighting); } }
public void DrawEditor(Object3DControlsLayer object3DControlLayer, List <Object3DView> transparentMeshes, DrawEventArgs e) { var start = PositionsHaveBeenSet ? StartPosition : StartPosition.Transform(Matrix); var end = PositionsHaveBeenSet ? EndPosition : EndPosition.Transform(Matrix); object3DControlLayer.World.Render3DLine(start, end, Color.Black, true, width: GuiWidget.DeviceScale); }
public void DrawEditor(Object3DControlsLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e) { var aabb = this.WorldAxisAlignedBoundingBox(); layer.World.RenderCylinderOutline(Matrix4X4.Identity, aabb.Center, Diameter, aabb.ZSize, 90, Color.Red); // layer.World.RenderCylinderOutline(Matrix4X4.Identity, Vector3.Zero, Diameter, aabb.ZSize, 30, Color.Green); }
public void AddObject3DControls(Object3DControlsLayer object3DControlsLayer) { double getHeight() => Height.Value(this); void setHeight(double height) => Height = height; var getDiameters = new List <Func <double> >() { () => Diameter.Value(this) }; var setDiameters = new List <Action <double> >() { (diameter) => Diameter = diameter }; object3DControlsLayer.Object3DControls.Add(new ScaleDiameterControl(object3DControlsLayer, getHeight, setHeight, getDiameters, setDiameters, 0)); object3DControlsLayer.Object3DControls.Add(new ScaleHeightControl(object3DControlsLayer, null, null, null, null, getHeight, setHeight, getDiameters, setDiameters)); object3DControlsLayer.AddControls(ControlTypes.MoveInZ); object3DControlsLayer.AddControls(ControlTypes.RotateXYZ); }
public void DrawEditor(Object3DControlsLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e) { if (layer.Scene.SelectedItem != null && layer.Scene.SelectedItem.DescendantsAndSelf().Where((i) => i == this).Any()) { layer.World.RenderAxis(ScaleAbout, this.WorldMatrix(), 30, 1); } }
public void AddObject3DControls(Object3DControlsLayer object3DControlsLayer) { object3DControlsLayer.AddHeightControl(this, Width, Depth, Height); object3DControlsLayer.AddWidthDepthControls(this, Width, Depth, Height); object3DControlsLayer.AddControls(ControlTypes.MoveInZ); object3DControlsLayer.AddControls(ControlTypes.RotateXYZ); }
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e) { if (layer.Scene.SelectedItem != null && layer.Scene.SelectedItem.DescendantsAndSelf().Where((i) => i == this).Any()) { layer.World.RenderDirectionAxis(RotateAbout, this.WorldMatrix(), 30); } }
public void AddObject3DControls(Object3DControlsLayer object3DControlsLayer) { var controls = object3DControlsLayer.Object3DControls; object3DControlsLayer.AddWidthDepthControls(this, Width, Depth, null); object3DControlsLayer.AddControls(ControlTypes.MoveInZ); object3DControlsLayer.AddControls(ControlTypes.RotateXYZ); }
public void DrawEditor(Object3DControlsLayer object3DControlLayer, List <Object3DView> transparentMeshes, DrawEventArgs e) { var start = PositionsHaveBeenSet ? StartPosition : StartPosition.Transform(Matrix); var end = PositionsHaveBeenSet ? EndPosition : EndPosition.Transform(Matrix); // draw on top of anything that is already drawn object3DControlLayer.World.Render3DLine(start, end, Color.Black.WithAlpha(Constants.LineAlpha), false, width: GuiWidget.DeviceScale); // Restore DepthTest object3DControlLayer.World.Render3DLine(start, end, Color.Black, true, width: GuiWidget.DeviceScale); }
public void AddObject3DControls(Object3DControlsLayer object3DControlsLayer) { if (editorControls == null) { editorControls = new List <IObject3DControl> { // Start Position Object new TracedPositionObject3DControl(object3DControlsLayer, this, // get position function () => worldStartPosition, // set position function (position) => { if (!PositionsHaveBeenSet) { PositionsHaveBeenSet = true; } worldStartPosition = position; Distance = (worldStartPosition - worldEndPosition).Length; UiThread.RunOnIdle(() => Invalidate(InvalidateType.DisplayValues)); }, // edit complete function (undoPosition) => SetUndoData(undoPosition, worldEndPosition) ), // End Position Object new TracedPositionObject3DControl(object3DControlsLayer, this, // get position function () => worldEndPosition, // set position function (position) => { if (!PositionsHaveBeenSet) { PositionsHaveBeenSet = true; } worldEndPosition = position; Distance = (worldStartPosition - worldEndPosition).Length; UiThread.RunOnIdle(() => Invalidate(InvalidateType.DisplayValues)); }, // edit complete function (undoPosition) => SetUndoData(worldStartPosition, undoPosition) ), }; } object3DControlsLayer.Object3DControls.Modify((list) => { list.AddRange(editorControls); }); }
public void DrawEditor(Object3DControlsLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e) { var sourceAabb = this.SourceContainer.GetAxisAlignedBoundingBox(); var rotationCenter = SourceContainer.GetSmallestEnclosingCircleAlongZ().Center + RotationOffset; var center = new Vector3(rotationCenter.X, rotationCenter.Y, sourceAabb.Center.Z); // render the top and bottom rings layer.World.RenderCylinderOutline(this.WorldMatrix(), center, 1, sourceAabb.ZSize, 15, Color.Red, Color.Red, 5); // turn the lighting back on GL.Enable(EnableCap.Lighting); }
public void AddObject3DControls(Object3DControlsLayer object3DControlsLayer) { if (editorControls == null) { editorControls = new List <IObject3DControl> { new TracedPositionObject3DControl(object3DControlsLayer, this, () => { return(PositionsHaveBeenSet ? StartPosition : StartPosition.Transform(Matrix)); }, (position) => { if (!PositionsHaveBeenSet) { PositionsHaveBeenSet = true; EndPosition = EndPosition.Transform(this.Matrix); } StartPosition = position; Distance = (StartPosition - EndPosition).Length; UiThread.RunOnIdle(() => Invalidate(InvalidateType.DisplayValues)); }), new TracedPositionObject3DControl(object3DControlsLayer, this, () => { return(PositionsHaveBeenSet ? EndPosition : EndPosition.Transform(Matrix)); }, (position) => { if (!PositionsHaveBeenSet) { PositionsHaveBeenSet = true; StartPosition = StartPosition.Transform(this.Matrix); } EndPosition = position; Distance = (StartPosition - EndPosition).Length; UiThread.RunOnIdle(() => Invalidate(InvalidateType.DisplayValues)); }), }; } object3DControlsLayer.Object3DControls.Modify((list) => { list.AddRange(editorControls); }); }
public void DrawEditor(Object3DControlsLayer controlLayer, List <Object3DView> transparentMeshes, DrawEventArgs e) { if (!PositionsHaveBeenSet) { var aabb = this.Mesh.GetAxisAlignedBoundingBox(); LocalStartPosition = aabb.Center + new Vector3(-10, 5, 3); LocalEndPosition = aabb.Center + new Vector3(10, 5, 3); } var start = worldStartPosition; var end = worldEndPosition; var world = controlLayer.World; // draw on top of anything that is already drawn world.Render3DLine(start, end, Color.Black.WithAlpha(Constants.LineAlpha), false, GuiWidget.DeviceScale, true, true); // Restore DepthTest world.Render3DLine(start, end, Color.Black.WithAlpha(Constants.LineAlpha), true, GuiWidget.DeviceScale, true, true); var screenStart = world.GetScreenPosition(start); var screenEnd = world.GetScreenPosition(end); var center = (screenStart + screenEnd) / 2; if (PositionsHaveBeenSet) { CreateWidgetIfRequired(controlLayer); // always keep the displayed distance the actual world distance var worldStartPosition = LocalStartPosition.Transform(this.WorldMatrix()); var worldEndPosition = LocalEndPosition.Transform(this.WorldMatrix()); Distance = (worldStartPosition - worldEndPosition).Length; textWidget.Text = Distance.ToString("0.##"); containerWidget.Position = center - new Vector2(containerWidget.LocalBounds.Width / 2, containerWidget.LocalBounds.Height / 2); containerWidget.Visible = true; } }
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e) { if (layer.Scene.SelectedItem != null && layer.Scene.SelectedItem.DescendantsAndSelf().Where((i) => i == this).Any()) { // we want to measure the var currentMatrixInv = Matrix.Inverted; var aabb = this.GetAxisAlignedBoundingBox(currentMatrixInv); layer.World.RenderCylinderOutline(this.WorldMatrix(), new Vector3(rotationCenter, aabb.Center.Z), Diameter, aabb.ZSize, 30, Color.Red); } // turn the lighting back on GL.Enable(EnableCap.Lighting); }
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e) { var aabb = UntransformedChildren.GetAxisAlignedBoundingBox(); var center = aabb.Center; var worldMatrix = this.WorldMatrix(); var width = Width.Value(this); var depth = Depth.Value(this); var height = Height.Value(this); var minXyz = center - new Vector3(width / 2, depth / 2, height / 2); var maxXyz = center + new Vector3(width / 2, depth / 2, height / 2); var bounds = new AxisAlignedBoundingBox(minXyz, maxXyz); layer.World.RenderAabb(bounds, worldMatrix, Color.Red, 1, 1); }
public void AddObject3DControls(Object3DControlsLayer object3DControlsLayer) { object3DControlsLayer.Object3DControls.Add(new ScaleDiameterControl(object3DControlsLayer, null, null, new List <Func <double> >() { () => Diameter.Value(this) }, new List <Action <double> >() { (diameter) => Diameter = diameter }, 0)); object3DControlsLayer.AddControls(ControlTypes.MoveInZ); object3DControlsLayer.AddControls(ControlTypes.RotateXYZ); }
public void AddObject3DControls(Object3DControlsLayer object3DControlsLayer) { double getHeight() => Height.Value(this); void setHeight(double height) => Height = height; object3DControlsLayer.Object3DControls.Add(new ScaleHeightControl(object3DControlsLayer, null, null, null, null, getHeight, setHeight, null, null)); object3DControlsLayer.AddControls(ControlTypes.ScaleMatrixXY); object3DControlsLayer.AddControls(ControlTypes.MoveInZ); object3DControlsLayer.AddControls(ControlTypes.RotateXYZ); }
public void AddEditorTransparents(Object3DControlsLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e) { if (layer.Scene.SelectedItem != null && layer.Scene.SelectedItem == this) { var parentOfSubtractTargets = this.SourceContainer.DescendantsAndSelfMultipleChildrenFirstOrSelf(); var removeObjects = parentOfSubtractTargets.Children .Where(i => SelectedChildren.Contains(i.ID)) .SelectMany(c => c.VisibleMeshes()) .ToList(); foreach (var item in removeObjects) { var color = item.WorldColor(checkOutputType: true); transparentMeshes.Add(new Object3DView(item, color.WithAlpha(color.Alpha0To1 * .2))); } } }
public void DrawEditor(Object3DControlsLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e) { var child = this.Children.FirstOrDefault(); if (child is IPathObject pathObject) { // draw the line that is the rotation point var aabb = this.GetAxisAlignedBoundingBox(); var vertexSource = this.VertexSource.Transform(Matrix); var bounds = vertexSource.GetBounds(); var lineX = bounds.Left + AxisPosition; var start = new Vector3(lineX, aabb.MinXYZ.Y, aabb.MinXYZ.Z); var end = new Vector3(lineX, aabb.MaxXYZ.Y, aabb.MinXYZ.Z); layer.World.Render3DLine(start, end, Color.Red, true); layer.World.Render3DLine(start, end, Color.Red.WithAlpha(20), false); } }
public void AddObject3DControls(Object3DControlsLayer object3DControlsLayer) { double getHeight() => Height.Value(this); void setHeight(double height) => Height = height; var getDiameters = new List <Func <double> >() { () => Diameter.Value(this), () => DiameterTop.Value(this) }; var setDiameters = new List <Action <double> >() { (diameter) => Diameter = diameter, (diameter) => DiameterTop = diameter }; object3DControlsLayer.Object3DControls.Add(new ScaleDiameterControl(object3DControlsLayer, getHeight, setHeight, getDiameters, setDiameters, 0, controlVisible: () => true)); object3DControlsLayer.Object3DControls.Add(new ScaleDiameterControl(object3DControlsLayer, getHeight, setHeight, getDiameters, setDiameters, 1, ObjectSpace.Placement.Top, controlVisible: () => Advanced)); object3DControlsLayer.Object3DControls.Add(new ScaleHeightControl(object3DControlsLayer, null, null, null, null, getHeight, setHeight, getDiameters, setDiameters)); object3DControlsLayer.AddControls(ControlTypes.MoveInZ); object3DControlsLayer.AddControls(ControlTypes.RotateXYZ); }
public void DrawEditor(Object3DControlsLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e) { if (layer.Scene.SelectedItem != null && layer.Scene.SelectedItem == this) { var parentOfSubtractTargets = this.SourceContainer.DescendantsAndSelfMultipleChildrenFirstOrSelf(); var removeObjects = parentOfSubtractTargets.Children .Where(i => SelectedChildren.Contains(i.ID)) .SelectMany(c => c.VisibleMeshes()) .ToList(); foreach (var item in removeObjects) { transparentMeshes.Add(new Object3DView(item, new Color(item.WorldColor(this.SourceContainer), 80))); } var keepItems = parentOfSubtractTargets.Children .Where(i => !SelectedChildren.Contains(i.ID)) .ToList(); foreach (var keepItem in keepItems) { var drawItem = keepItem; var keepItemResult = this.Children.Where(i => i.OwnerID == keepItem.ID).FirstOrDefault(); drawItem = keepItemResult != null ? keepItemResult : drawItem; foreach (var item in drawItem.VisibleMeshes()) { GLHelper.Render(item.Mesh, item.WorldColor(), item.WorldMatrix(), RenderTypes.Outlines, item.WorldMatrix() * layer.World.ModelviewMatrix); } } } }
private void CreateWidgetIfRequired(Object3DControlsLayer controlLayer) { if (containerWidget == null || containerWidget.Parents <SystemWindow>().Count() == 0) { this.controlLayer = controlLayer; var theme = ApplicationController.Instance.MenuTheme; containerWidget = new GuiWidget() { HAnchor = HAnchor.Fit, VAnchor = VAnchor.Fit, Padding = 5, BackgroundColor = theme.BackgroundColor, BackgroundRadius = new RadiusCorners(3 * GuiWidget.DeviceScale), BorderColor = theme.PrimaryAccentColor, BackgroundOutlineWidth = 1, }; containerWidget.AddChild(textWidget = new TextWidget(Distance.ToString("0.##")) { TextColor = theme.TextColor, PointSize = 10, Selectable = true, AutoExpandBoundsToText = true, }); controlLayer.GuiSurface.AddChild(containerWidget); controlLayer.GuiSurface.AfterDraw += GuiSurface_AfterDraw; void NumberWidget_MouseDown(object sender, MouseEventArgs e2) { controlLayer.Scene.SelectedItem = this; } containerWidget.MouseDown += NumberWidget_MouseDown; } }
public void DrawEditor(Object3DControlsLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e) { var parentOfSourceItems = this.SourceContainer.DescendantsAndSelfMultipleChildrenFirstOrSelf(); var sourceItems = parentOfSourceItems.Children.ToList(); foreach (var paintItem in sourceItems) { var paintItemResults = this.Children.Where(i => i.OwnerID == paintItem.ID); var wasSelected = ComputedChildren.Contains(paintItem.ID); var currentlySelected = SelectedChildren.Contains(paintItem.ID); if (currentlySelected) { // if this is selected always paint a transparent source foreach (var item in paintItem.VisibleMeshes()) { transparentMeshes.Add(new Object3DView(item, new Color(item.WorldColor(this.SourceContainer), 80))); } // if it was also selected in before (the results are right) if (wasSelected) { // paint solid results if (paintItemResults != null) { foreach (var paintItemResult in paintItemResults) { foreach (var item in paintItemResult.VisibleMeshes()) { GLHelper.Render(item.Mesh, item.WorldColor(), item.WorldMatrix(), RenderTypes.Outlines, item.WorldMatrix() * layer.World.ModelviewMatrix); } } } } } else if (wasSelected) { // it is not selected now but was selected before (changed state) // pant the solid source foreach (var item in paintItem.VisibleMeshes()) { GLHelper.Render(item.Mesh, item.WorldColor(), item.WorldMatrix(), RenderTypes.Outlines, item.WorldMatrix() * layer.World.ModelviewMatrix); } } else // it is not selected now and was not before (same state) { // paint the results if (paintItemResults != null && paintItemResults.Count() > 0) { foreach (var paintItemResult in paintItemResults) { foreach (var item in paintItemResult.VisibleMeshes()) { GLHelper.Render(item.Mesh, item.WorldColor(), item.WorldMatrix(), RenderTypes.Outlines, item.WorldMatrix() * layer.World.ModelviewMatrix); } } } else // we don't have any results yet { foreach (var item in paintItem.VisibleMeshes()) { GLHelper.Render(item.Mesh, item.WorldColor(), item.WorldMatrix(), RenderTypes.Outlines, item.WorldMatrix() * layer.World.ModelviewMatrix); } } } } }
public void DrawEditor(Object3DControlsLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e) { this.DrawPath(); }
public void AddObject3DControls(Object3DControlsLayer object3DControlsLayer) { object3DControlsLayer.AddControls(ControlTypes.Standard2D); }
public void AddObject3DControls(Object3DControlsLayer object3DControlsLayer) { object3DControlsLayer.AddControls(ControlTypes.MoveInZ | ControlTypes.Shadow | ControlTypes.ScaleMatrixXY); }
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e) { this.DrawPath(); }
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e) { return; }