public IconsViewModel() { foreach (CommonShapeType value in Enum.GetValues(typeof(CommonShapeType))) { CommonShapes.Add(new IconWrapper { Name = value.ToString(), Geometry = CommonShapeFactory.GetShapeGeometry(value) }); } foreach (MdiShapeType value in Enum.GetValues(typeof(MdiShapeType))) { MdiShapes.Add(new IconWrapper { Name = value.ToString(), Geometry = MdiShapeFactory.GetShapeGeometry(value) }); } }
public void CreatePrintBed(Vector3 displayVolume, Vector2 bedCenter, BedShape bedShape) { if (MeshViewerWidget.BedCenter == bedCenter && MeshViewerWidget.bedShape == bedShape && MeshViewerWidget.displayVolume == displayVolume) { return; } MeshViewerWidget.BedCenter = bedCenter; MeshViewerWidget.bedShape = bedShape; MeshViewerWidget.displayVolume = displayVolume; Vector3 displayVolumeToBuild = Vector3.ComponentMax(displayVolume, new Vector3(1, 1, 1)); double sizeForMarking = Math.Max(displayVolumeToBuild.x, displayVolumeToBuild.y); double divisor = 10; int skip = 1; if (sizeForMarking > 1000) { divisor = 100; skip = 10; } else if (sizeForMarking > 300) { divisor = 50; skip = 5; } switch (bedShape) { case BedShape.Rectangular: if (displayVolumeToBuild.z > 0) { buildVolume = PlatonicSolids.CreateCube(displayVolumeToBuild); foreach (Vertex vertex in buildVolume.Vertices) { vertex.Position = vertex.Position + new Vector3(0, 0, displayVolumeToBuild.z / 2); } } CreateRectangularBedGridImage(displayVolumeToBuild, bedCenter, divisor, skip); printerBed = PlatonicSolids.CreateCube(displayVolumeToBuild.x, displayVolumeToBuild.y, 4); { Face face = printerBed.Faces[0]; CommonShapes.PlaceTextureOnFace(face, BedImage); } break; case BedShape.Circular: { if (displayVolumeToBuild.z > 0) { buildVolume = VertexSourceToMesh.Extrude(new Ellipse(new Vector2(), displayVolumeToBuild.x / 2, displayVolumeToBuild.y / 2), displayVolumeToBuild.z); foreach (Vertex vertex in buildVolume.Vertices) { vertex.Position = vertex.Position + new Vector3(0, 0, .2); } } CreateCircularBedGridImage((int)(displayVolumeToBuild.x / divisor), (int)(displayVolumeToBuild.y / divisor), skip); printerBed = VertexSourceToMesh.Extrude(new Ellipse(new Vector2(), displayVolumeToBuild.x / 2, displayVolumeToBuild.y / 2), 2); { foreach (Face face in printerBed.Faces) { if (face.normal.z > 0) { FaceTextureData faceData = FaceTextureData.Get(face); faceData.Textures.Add(BedImage); foreach (FaceEdge faceEdge in face.FaceEdges()) { FaceEdgeTextureUvData edgeUV = FaceEdgeTextureUvData.Get(faceEdge); edgeUV.TextureUV.Add(new Vector2((displayVolumeToBuild.x / 2 + faceEdge.firstVertex.Position.x) / displayVolumeToBuild.x, (displayVolumeToBuild.y / 2 + faceEdge.firstVertex.Position.y) / displayVolumeToBuild.y)); } } } } } break; default: throw new NotImplementedException(); } foreach (Vertex vertex in printerBed.Vertices) { vertex.Position = vertex.Position - new Vector3(-bedCenter, 2.2); } if (buildVolume != null) { foreach (Vertex vertex in buildVolume.Vertices) { vertex.Position = vertex.Position - new Vector3(-bedCenter, 2.2); } } Invalidate(); }