private void SharpEdgeCheckBoxChanged(object sender, RoutedEventArgs routedEventArgs) { if (!this.IsLoaded) { return; } var checkBox = (CheckBox)sender; int index = (int)checkBox.Tag; _sections[index] = new LatheSection(_sections[index].Offset, _sections[index].Radius, checkBox.IsChecked ?? false); UpdateSectionCheckBox(checkBox, _sections[index]); UpdateLatheMesh(); }
public void AddMousePosition(Point relativeMousePosition) { var newLatheSection = new LatheSection(relativeMousePosition.Y, relativeMousePosition.X, true); _sections.Add(newLatheSection); var checkBox = new CheckBox(); UpdateSectionCheckBox(checkBox, newLatheSection); checkBox.IsChecked = true; checkBox.Tag = _sections.Count - 1; checkBox.Unchecked += SharpEdgeCheckBoxChanged; checkBox.Checked += SharpEdgeCheckBoxChanged; SectionsStackPanel.Children.Add(checkBox); AddNewSections(); }
private void UpdateSectionCheckBox(CheckBox checkBox, LatheSection section) { checkBox.Content = string.Format(System.Globalization.CultureInfo.InvariantCulture, "Offset = {0:0.00}; Radius = {1:0.00}; IsSharpEdge = {2}", section.Offset, section.Radius, section.IsSharpEdge); }
private Model3DGroup CreateScene() { var material = this.FindResource("ObjectsMaterial") as Material; var rootModel3DGroup = new Model3DGroup(); var geometryModel3D = Ab3d.Models.Model3DFactory.CreateBox(centerPosition: new Point3D(30, 10, 30), size: new Size3D(20, 20, 20), material: material); rootModel3DGroup.Children.Add(geometryModel3D); geometryModel3D = Ab3d.Models.Model3DFactory.CreateBox(centerPosition: new Point3D(30, 10, 60), size: new Size3D(20, 20, 20), material: material, xCellsCount: 3, yCellsCount: 3, zCellsCount: 3); rootModel3DGroup.Children.Add(geometryModel3D); geometryModel3D = Ab3d.Models.Model3DFactory.CreateSphere(centerPosition: new Point3D(0, 10, 0), radius: 10, segments: 10, material: material); rootModel3DGroup.Children.Add(geometryModel3D); geometryModel3D = Ab3d.Models.Model3DFactory.CreatePyramid(bottomCenterPosition: new Point3D(0, 0, 30), size: new Size3D(20, 20, 20), material: material); rootModel3DGroup.Children.Add(geometryModel3D); geometryModel3D = Ab3d.Models.Model3DFactory.CreateCone(bottomCenterPosition: new Point3D(-30, 0, -30), bottomRadius: 10, topRadius: 0, height: 20, material: material, segments: 30, isSmooth: true); // When Cone is smooth, the side polygon lines will not be created rootModel3DGroup.Children.Add(geometryModel3D); geometryModel3D = Ab3d.Models.Model3DFactory.CreateCone(bottomCenterPosition: new Point3D(0, 0, -30), bottomRadius: 10, topRadius: 5, height: 20, material: material, segments: 30, isSmooth: true); rootModel3DGroup.Children.Add(geometryModel3D); geometryModel3D = Ab3d.Models.Model3DFactory.CreateCone(bottomCenterPosition: new Point3D(30, 0, -30), bottomRadius: 10, topRadius: 5, height: 20, material: material, segments: 6, isSmooth: false); rootModel3DGroup.Children.Add(geometryModel3D); geometryModel3D = Ab3d.Models.Model3DFactory.CreateCylinder(bottomCenterPosition: new Point3D(30, 0, 0), radius: 10, height: 20, material: material, segments: 30, isSmooth: true); rootModel3DGroup.Children.Add(geometryModel3D); geometryModel3D = Ab3d.Models.Model3DFactory.CreateCylinder(bottomCenterPosition: new Point3D(60, 0, 0), radius: 10, height: 20, material: material, segments: 6, isSmooth: false); rootModel3DGroup.Children.Add(geometryModel3D); geometryModel3D = Ab3d.Models.Model3DFactory.CreateTrapezoid(bottomCenterPosition: new Point3D(60, 0, -30), bottomSize: new Size(20, 15), topSize: new Size(10, 5), height: 20, material: material); rootModel3DGroup.Children.Add(geometryModel3D); geometryModel3D = Ab3d.Models.Model3DFactory.CreatePlane(centerPosition: new Point3D(-30, 0, 60), planeNormal: new Vector3D(0, 1, 0), planeHeightDirection: new Vector3D(0, 0, -1), size: new Size(20, 20), material: material, width_cells_count: 1, length_cells_count: 1); geometryModel3D.BackMaterial = geometryModel3D.Material; rootModel3DGroup.Children.Add(geometryModel3D); geometryModel3D = Ab3d.Models.Model3DFactory.CreatePlane(centerPosition: new Point3D(0, 0, 60), planeNormal: new Vector3D(0, 1, 0), planeHeightDirection: new Vector3D(0, 0, -1), size: new Size(20, 20), material: material, width_cells_count: 3, length_cells_count: 3); geometryModel3D.BackMaterial = geometryModel3D.Material; rootModel3DGroup.Children.Add(geometryModel3D); var multiMaterialBox = Ab3d.Models.Model3DFactory.CreateMultiMaterialBox(centerPosition: new Point3D(60, 10, 30), size: new Size3D(20, 20, 20), topMaterial: new DiffuseMaterial(Brushes.Blue), bottomMaterial: material, leftMaterial: material, rightMaterial: material, frontMaterial: material, backMaterial: material, isBackMaterialSet: false); rootModel3DGroup.Children.Add(multiMaterialBox); multiMaterialBox = Ab3d.Models.Model3DFactory.CreateMultiMaterialBox(centerPosition: new Point3D(60, 10, 60), size: new Size3D(20, 20, 20), xCellsCount: 3, yCellsCount: 3, zCellsCount: 3, topMaterial: new DiffuseMaterial(Brushes.Blue), bottomMaterial: material, leftMaterial: material, rightMaterial: material, frontMaterial: material, backMaterial: material, isBackMaterialSet: false); rootModel3DGroup.Children.Add(multiMaterialBox); var circleMesh3D = new Ab3d.Meshes.CircleMesh3D(new Point3D(-30, 0, 30), new Vector3D(0, 1, 0), new Vector3D(0, 0, -1), 10, 10); var model3D = new GeometryModel3D(circleMesh3D.Geometry, material); model3D.BackMaterial = material; rootModel3DGroup.Children.Add(model3D); var tubeMesh3D = new Ab3d.Meshes.TubeMesh3D(new Point3D(60, 0, 90), new Vector3D(0, 1, 0), 10, 8, 6, 4, 20, 10); model3D = new GeometryModel3D(tubeMesh3D.Geometry, material); model3D.BackMaterial = material; rootModel3DGroup.Children.Add(model3D); tubeMesh3D = new Ab3d.Meshes.TubeMesh3D(new Point3D(30, 0, 90), new Vector3D(0, 1, 0), 10, 8, 8, 6, 0, 10); // Tube with height == 0 is a special case model3D = new GeometryModel3D(tubeMesh3D.Geometry, material); model3D.BackMaterial = material; rootModel3DGroup.Children.Add(model3D); //var arrowMesh3D = new Ab3d.Meshes.ArrowMesh3D(new Point3D(-30, 0, 0), new Point3D(-30, 20, 0), 3, 6, 60, 30, false); //model3D = new GeometryModel3D(arrowMesh3D.Geometry, material); //rootModel3DGroup.Children.Add(model3D); var sections = new LatheSection[6]; sections[0] = new LatheSection(offset: 0, radius: 5, isSharpEdge: true); sections[1] = new LatheSection(0.3, 10, false); sections[2] = new LatheSection(0.4, 12, true); sections[3] = new LatheSection(0.6, 9, false); sections[4] = new LatheSection(0.8, 6, false); sections[5] = new LatheSection(1, 5, true); var latheMesh3D = new LatheMesh3D(new Point3D(-30, 20, 0), new Point3D(-30, 0, 0), sections, 10, isStartPositionClosed: true, isEndPositionClosed: true, generateTextureCoordinates: false); model3D = new GeometryModel3D(latheMesh3D.Geometry, material); model3D.BackMaterial = new DiffuseMaterial(Brushes.Red); rootModel3DGroup.Children.Add(model3D); return(rootModel3DGroup); }