ModelVisual3D GetSelectionBox(ContentBase content) { WireLines lines = GetWireBox(content.GetMesh().Bounds); lines.Transform = content.Model.Transform; return(lines); }
private Model3DGroup CreatePartModel() { if (string.IsNullOrEmpty(PartNumber)) { return(null); } _edges = new WireLines(); //_edges.Thickness = 1; // Create a model to hold the part geometry Model3DGroup model = new Model3DGroup(); // Create the Geometery for main mesh. MeshGeometry3D mesh = new MeshGeometry3D(); Material material = SetMaterial(PartColor); GeometryModel3D geometry = new GeometryModel3D(mesh, material) { BackMaterial = material }; model.Children.Add(geometry); GeneratePartMesh(PartNumber + LDrawHelper.PartsFileExtension, false, Matrix3D.Identity, model, PartColor); // Ldraw follows -Y so invert the part on the Y axis. RotateTransform3D invertY = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(1, 0, 0), 180)); model.Transform = invertY; _edges.Transform = invertY; //_children.Clear(); //_children.Add(this._edges //Children.Add(_edges); //if (model.CanFreeze) { // model.Freeze(); //} return(model); }
private void OnCompositionTargetRendering(object sender, EventArgs e) { if (this.ShowLinesVisual3D && this.linesVisual == null) { this.linesVisual = new LinesVisual3D { Color = Colors.Blue }; View1.Children.Add(this.linesVisual); } if (!this.ShowLinesVisual3D && this.linesVisual != null) { this.linesVisual.IsRendering = false; View1.Children.Remove(this.linesVisual); this.linesVisual = null; } if (this.ShowPointsVisual3D && this.pointsVisual == null) { this.pointsVisual = new PointsVisual3D { Color = Colors.Red, Size = 6 }; View1.Children.Add(this.pointsVisual); } if (!this.ShowPointsVisual3D && this.pointsVisual != null) { this.pointsVisual.IsRendering = false; View1.Children.Remove(this.pointsVisual); this.pointsVisual = null; } if (this.ShowScreenSpaceLines3D && this.screenSpaceLines == null) { this.screenSpaceLines = new ScreenSpaceLines3D { Color = Colors.Green }; View1.Children.Add(this.screenSpaceLines); } if (!this.ShowScreenSpaceLines3D && this.screenSpaceLines != null) { View1.Children.Remove(this.screenSpaceLines); this.screenSpaceLines = null; } if (this.ShowWireLines && this.wireLines == null) { this.wireLines = new WireLines { Color = Colors.Pink }; View1.Children.Add(this.wireLines); } if (!this.ShowWireLines && this.wireLines != null) { View1.Children.Remove(this.wireLines); this.wireLines = null; } if (this.Points == null || this.Points.Count != this.NumberOfPoints) { this.Points = new Point3DCollection(GeneratePoints(this.NumberOfPoints, this.watch.ElapsedMilliseconds * 0.001)); } if (this.linesVisual != null) { this.linesVisual.Points = this.Points; this.linesVisual.Transform = IsMirrored ? new ScaleTransform3D(-1, 1, 1) : new ScaleTransform3D(1, 1, 1); } if (this.pointsVisual != null) { this.pointsVisual.Points = this.Points; this.pointsVisual.Transform = IsMirrored ? new ScaleTransform3D(-1, 1, 1) : new ScaleTransform3D(1, 1, 1); } if (this.screenSpaceLines != null) { this.screenSpaceLines.Points = this.Points; this.screenSpaceLines.Transform = IsMirrored ? new ScaleTransform3D(-1, 1, 1) : new ScaleTransform3D(1, 1, 1); } if (this.wireLines != null) { this.wireLines.Lines = this.Points; this.wireLines.Transform = IsMirrored ? new ScaleTransform3D(-1, 1, 1) : new ScaleTransform3D(1, 1, 1); } }
void OnCompositionTargetRendering(object sender, EventArgs e) { if (ShowLinesVisual3D && lines == null) { lines = new LinesVisual3D { Color = Colors.Blue }; view1.Children.Add(lines); } if (!ShowLinesVisual3D && lines != null) { lines.IsRendering = false; view1.Children.Remove(lines); lines = null; } if (ShowPointsVisual3D && points == null) { points = new PointsVisual3D { Color = Colors.Red, Size = 6 }; view1.Children.Add(points); } if (!ShowPointsVisual3D && points != null) { points.IsRendering = false; view1.Children.Remove(points); points = null; } if (ShowScreenSpaceLines3D && screenSpaceLines == null) { screenSpaceLines = new ScreenSpaceLines3D { Color = Colors.Green }; view1.Children.Add(screenSpaceLines); } if (!ShowScreenSpaceLines3D && screenSpaceLines != null) { view1.Children.Remove(screenSpaceLines); screenSpaceLines = null; } if (ShowWireLines && wireLines == null) { wireLines = new WireLines { Color = Colors.Pink }; view1.Children.Add(wireLines); } if (!ShowWireLines && wireLines != null) { view1.Children.Remove(wireLines); wireLines = null; } if (Points == null || Points.Count != N || isAnimating) { Points = GeneratePoints(N, watch.ElapsedMilliseconds * 0.001); RaisePropertyChanged("Points"); } if (lines != null) { lines.Points = Points; } if (points != null) { points.Points = Points; } if (screenSpaceLines != null) { screenSpaceLines.Points = Points; } if (wireLines != null) { wireLines.Lines = Points; } }