private Object3D GetTab(bool calibrateX) { var content = new Object3D(); var spaceBetween = NozzleWidth * TabScale; var shape = new VertexStorage(); shape.MoveTo(0, 0); // left + spaces + blocks + right var sampleCount = 7; var baseWidth = (2 * spaceBetween) + ((sampleCount - 1) * spaceBetween) + (sampleCount * TabWidth) + (2 * spaceBetween); shape.LineTo(baseWidth, 0); if (calibrateX) { var origin = new Vector2(baseWidth, TabDepth / 2); var delta = new Vector2(0, -TabDepth / 2); var count = 15; for (int i = 0; i < count; i++) { delta.Rotate(MathHelper.Tau / 2 / count); shape.LineTo(origin + delta); } } else { shape.LineTo(baseWidth + TabDepth, TabDepth / 2); // a point on the left } shape.LineTo(baseWidth, TabDepth); shape.LineTo(0, TabDepth); content.Children.Add(new Object3D() { Mesh = shape.Extrude(ChangeHeight), Color = Color.LightBlue }); var position = new Vector2(TabWidth / 2 + 2 * spaceBetween, TabDepth / 2 - Offset * 2); var step = new Vector2(spaceBetween + TabWidth, Offset); for (int i = 0; i < sampleCount; i++) { var cube = PlatonicSolids.CreateCube(); content.Children.Add(new Object3D() { Mesh = cube, Color = Color.Yellow, Matrix = Matrix4X4.CreateScale(TabWidth, TabDepth, ChangeHeight) // translate by 1.5 as it is a centered cube (.5) plus the base (1) = 1.5 * Matrix4X4.CreateTranslation(position.X, position.Y, ChangeHeight * 1.5), MaterialIndex = CalibrationMaterialIndex }); position += step; } if (calibrateX) { content.Matrix = Matrix4X4.CreateRotationZ(MathHelper.Tau / 4) * Matrix4X4.CreateTranslation(0, TabDepth, 0); } return(content); }
private Object3D GetTab(bool calibrateX) { var content = new Object3D(); var spaceBetween = NozzleWidth * tabScale; var shape = new VertexStorage(); shape.MoveTo(0, 0); // left + spaces + blocks + right var sampleCount = 7; var baseWidth = (2 * spaceBetween) + ((sampleCount - 1) * spaceBetween) + (sampleCount * TabWidth) + (2 * spaceBetween); shape.LineTo(baseWidth, 0); if (calibrateX) { var origin = new Vector2(baseWidth, TabDepth / 2); var delta = new Vector2(0, -TabDepth / 2); var count = 15; for (int i = 0; i < count; i++) { delta.Rotate(MathHelper.Tau / 2 / count); shape.LineTo(origin + delta); } } else { shape.LineTo(baseWidth + TabDepth, TabDepth / 2); // a point on the left } shape.LineTo(baseWidth, TabDepth); shape.LineTo(0, TabDepth); content.Children.Add(new Object3D() { Mesh = shape.Extrude(BaseHeight), Color = Color.LightBlue }); var position = new Vector2(TabWidth / 2 + 2 * spaceBetween, TabDepth / 2); var step = new Vector2(spaceBetween + TabWidth, 0); for (int i = 0; i < sampleCount; i++) { var offsetMultiple = i - 3; for (int j = 0; j < Layers; j++) { var calibrationMaterial = (j % 2 == 0); var cube = PlatonicSolids.CreateCube(); var item = new Object3D() { Mesh = cube, }; content.Children.Add(item); if (calibrationMaterial) { item.MaterialIndex = CalibrationMaterialIndex; item.Color = Color.Yellow; item.Matrix = Matrix4X4.CreateScale(TabWidth, TabDepth, ChangingHeight) * Matrix4X4.CreateTranslation(position.X, position.Y + Offset * offsetMultiple, BaseHeight + .5 * ChangingHeight + j * ChangingHeight); } else { item.Color = Color.LightBlue; item.Matrix = Matrix4X4.CreateScale(TabWidth + spaceBetween * 2, TabDepth, ChangingHeight) * Matrix4X4.CreateTranslation(position.X, position.Y, BaseHeight + .5 * ChangingHeight + j * ChangingHeight); } } position += step; } if (calibrateX) { content.Matrix = Matrix4X4.CreateRotationZ(MathHelper.Tau / 4) * Matrix4X4.CreateTranslation(0, TabDepth, 0); } return(content); }
public override Task Rebuild() { this.DebugDepth("Rebuild"); using (RebuildLock()) { using (new CenterAndHeightMantainer(this)) { this.Children.Modify((list) => { list.Clear(); }); var content = new Object3D(); var scale = 3.0; var width = NozzleWidth * scale * 3; var depth = NozzleWidth * scale * 5; var spaceBetween = NozzleWidth * scale; var shape = new VertexStorage(); shape.MoveTo(0, 0); // left + spaces + blocks + right var baseWidth = (2 * spaceBetween) + (4 * spaceBetween) + (5 * width) + (2 * spaceBetween); shape.LineTo(baseWidth, 0); shape.LineTo(baseWidth, depth); shape.LineTo(0, depth); if (Direction == Layout.Vertical) { var origin = new Vector2(0, depth / 2); var delta = new Vector2(0, depth / 2); var count = 15; for (int i = 0; i < count; i++) { delta.Rotate(MathHelper.Tau / 2 / count); shape.LineTo(origin + delta); } } else { shape.LineTo(-depth, depth / 2); // a point on the left } var baseMesh = shape.Extrude(ChangeHeight); content.Children.Add(new Object3D() { Mesh = shape.Extrude(ChangeHeight), Color = Color.LightBlue }); var position = new Vector2(width / 2 + 2 * spaceBetween, depth / 2 - Offset * 2); var step = new Vector2(spaceBetween + width, Offset); for (int i = 0; i < 5; i++) { var cube = PlatonicSolids.CreateCube(); content.Children.Add(new Object3D() { Mesh = cube, Color = Color.Yellow, Matrix = Matrix4X4.CreateScale(width, depth, ChangeHeight) * Matrix4X4.CreateTranslation(position.X, position.Y, ChangeHeight * 1.5), MaterialIndex = CalibrationMaterialIndex }); position += step; } if (Direction == Layout.Vertical) { content.Matrix = Matrix4X4.CreateRotationZ(MathHelper.Tau / 4); } this.Children.Add(content); } } Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh)); return(Task.CompletedTask); }