public static void AddPointCloud(Dictionary <KeyValuePair <int, int>, double> PointCollection, out PointModel Points, out GridModel Grid, out AxisModel Axis, out HelixToolkit.Wpf.SharpDX.Camera Camera, bool cameraType = false) { Camera = null; Points = null; Grid = null; Axis = null; var points = new PointGeometry3D(); var col = new Color4Collection(); // color gradient var ptPos = new Vector3Collection(); // point positions var ptIdx = new IntCollection(); // point indexes if (PointCollection != null && PointCollection.Count() > 1) { //newdataFromTxt(path, positionX, positionY, positionZ); var maxX = PointCollection.Max(x => x.Key.Key); // X var minX = PointCollection.Min(x => x.Key.Key); // X var maxY = PointCollection.Max(x => x.Key.Value); // Y var minY = PointCollection.Min(x => x.Key.Value); // Y var maxZ = PointCollection.Max(x => x.Value); // Z var minZ = PointCollection.Min(x => x.Value); // Z var minYObj = PointCollection.First(x => x.Key.Value == minY); Trace.WriteLine($"{maxX} {minX} {maxY} {minY} {maxZ} {minZ}"); if (PointCollection.Count() <= 0) { return; } foreach (var point in PointCollection) { var positionToColour = point.Value; ptIdx.Add(ptPos.Count); ptPos.Add(new Vector3((float)point.Key.Key, ((float)point.Key.Value), (float)point.Value)); col.Add(new Color4(RedBlueScale((float)minZ, (float)maxZ, (float)positionToColour))); } Points = new PointModel { // indexes and color gradient PointsGeometry = new PointGeometry3D { Positions = ptPos, Indices = ptIdx, Colors = col }, PointsColor = Colors.White, PointsTransform = new TranslateTransform3D(-minX, -minY, -minZ) }; // floor plane grid LineBuilder gridLines = new LineBuilder(); VisualizationTools.CreateGrid(gridLines, maxX, minX, maxY, minY, minZ); Grid = new GridModel { GridGeometry = gridLines.ToLineGeometry3D(), GridColor = new Color4(153 / 255.0f, 204 / 255.0f, 255 / 255.0f, 0.3f).ToColor(), GridTransform = new TranslateTransform3D(0, 0, 0) }; // lines LineBuilder arrows = new LineBuilder(); VisualizationTools.CreateAxes(arrows, (float)maxX, (float)minX, (float)maxY, (float)minY, (float)maxZ, (float)minZ); Axis = new AxisModel { AxisGeometry = arrows.ToLineGeometry3D(), AxisColor = new Color4(0, 255 / 255.0f, 255 / 255.0f, 0.5f).ToColor(), AxisTransform = new TranslateTransform3D(0, 0, 0) }; if (cameraType == false) { Camera = new HelixToolkit.Wpf.SharpDX.PerspectiveCamera { Position = new Point3D(0, 0, Math.Abs(minZ * 100)), LookDirection = new Vector3D(((float)maxX - (float)minX) / 2, ((float)maxY - (float)minY) / 2, -Math.Abs(minZ * 100)),//z kamerą jest problem przy przybliżaniu prawdopodobnie przez ten LookDirection albo sposób poruszania kamerą UpDirection = new Vector3D(0, 1, 0), FarPlaneDistance = 5000000 }; } else { Camera = new HelixToolkit.Wpf.SharpDX.OrthographicCamera { Position = new Point3D(0, 0, Math.Abs(minZ * 100)), LookDirection = new Vector3D(((float)maxX - (float)minX) / 2, ((float)maxY - (float)minY) / 2, -Math.Abs(minZ * 100)),//z kamerą jest problem przy przybliżaniu prawdopodobnie przez ten LookDirection albo sposób poruszania kamerą UpDirection = new Vector3D(0, 1, 0), FarPlaneDistance = 5000000 }; } } }