Made a new layer calibration object
This commit is contained in:
parent
545de62b99
commit
b4fab6c435
2 changed files with 141 additions and 1 deletions
|
|
@ -125,7 +125,6 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
shape.LineTo(baseWidth, depth);
|
||||
shape.LineTo(0, depth);
|
||||
|
||||
var baseMesh = shape.Extrude(ChangeHeight);
|
||||
content.Children.Add(new Object3D()
|
||||
{
|
||||
Mesh = shape.Extrude(ChangeHeight),
|
||||
|
|
@ -142,6 +141,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
Mesh = cube,
|
||||
Color = Color.Yellow,
|
||||
Matrix = Matrix4X4.CreateScale(width, depth, 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
|
||||
});
|
||||
|
|
@ -161,4 +161,134 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
public class XyCalibrationFaceObject3D : Object3D
|
||||
{
|
||||
public XyCalibrationFaceObject3D()
|
||||
{
|
||||
Name = "Calibration Faces".Localize();
|
||||
}
|
||||
|
||||
public enum Layout { Horizontal, Vertical }
|
||||
public Layout Direction { get; set; } = Layout.Horizontal;
|
||||
|
||||
[DisplayName("Material")]
|
||||
public int CalibrationMaterialIndex { get; set; } = 1;
|
||||
public double ChangingHeight { get; set; } = .4;
|
||||
public double BaseHeight { get; set; } = .4;
|
||||
public double Offset { get; set; } = .5;
|
||||
public double NozzleWidth = .4;
|
||||
|
||||
public static async Task<XyCalibrationFaceObject3D> Create(int calibrationMaterialIndex = 1,
|
||||
double baseHeight = 1, double changingHeight = .2, double offset = .5, double nozzleWidth = .4)
|
||||
{
|
||||
var item = new XyCalibrationFaceObject3D()
|
||||
{
|
||||
CalibrationMaterialIndex = calibrationMaterialIndex,
|
||||
BaseHeight = baseHeight,
|
||||
ChangingHeight = changingHeight,
|
||||
Offset = offset,
|
||||
NozzleWidth = nozzleWidth
|
||||
};
|
||||
|
||||
await item.Rebuild();
|
||||
return item;
|
||||
}
|
||||
|
||||
public override async void OnInvalidate(InvalidateArgs invalidateType)
|
||||
{
|
||||
if (invalidateType.InvalidateType.HasFlag(InvalidateType.Properties)
|
||||
&& invalidateType.Source == this)
|
||||
{
|
||||
await Rebuild();
|
||||
}
|
||||
else
|
||||
{
|
||||
base.OnInvalidate(invalidateType);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
if (Direction == Layout.Vertical)
|
||||
{
|
||||
var origin = new Vector2(baseWidth, 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(baseWidth + depth, depth / 2); // a point on the left
|
||||
}
|
||||
shape.LineTo(baseWidth, depth);
|
||||
shape.LineTo(0, depth);
|
||||
|
||||
content.Children.Add(new Object3D()
|
||||
{
|
||||
Mesh = shape.Extrude(BaseHeight),
|
||||
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++)
|
||||
{
|
||||
for (int j = 0; j < 10; j++)
|
||||
{
|
||||
var calibrationMaterial = (j % 2 == 0);
|
||||
var cube = PlatonicSolids.CreateCube();
|
||||
var yOffset = calibrationMaterial ? position.Y : depth / 2;
|
||||
var offset = Matrix4X4.CreateTranslation(position.X, yOffset, BaseHeight + .5 * ChangingHeight + j * ChangingHeight);
|
||||
content.Children.Add(new Object3D()
|
||||
{
|
||||
Mesh = cube,
|
||||
Color = Color.Yellow,
|
||||
Matrix = Matrix4X4.CreateScale(width, depth, ChangingHeight) * offset,
|
||||
MaterialIndex = calibrationMaterial ? CalibrationMaterialIndex : 0
|
||||
});
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -56,6 +56,16 @@ namespace MatterHackers.MatterControl.Library
|
|||
() => "Cube".Localize(),
|
||||
async () => await CubeObject3D.Create())
|
||||
{ DateCreated = new System.DateTime(index++) },
|
||||
#if DEBUG
|
||||
new GeneratorItem(
|
||||
() => "Calibration Tab".Localize(),
|
||||
async () => await XyCalibrationTabObject3D.Create())
|
||||
{ DateCreated = new System.DateTime(index++) },
|
||||
new GeneratorItem(
|
||||
() => "Calibration Face".Localize(),
|
||||
async () => await XyCalibrationFaceObject3D.Create())
|
||||
{ DateCreated = new System.DateTime(index++) },
|
||||
#endif
|
||||
new GeneratorItem(
|
||||
() => "Pyramid".Localize(),
|
||||
async () => await PyramidObject3D.Create())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue