//Returns the center of a given rectangular shape public static Point3D FindCenter(Rect3D bounds) { return(new Point3D(bounds.X + bounds.SizeX / 2, bounds.Y + bounds.SizeY / 2, bounds.Z + bounds.SizeZ / 2)); }
public static XbimRect3D ToXbimRect3D(this Rect3D r3D) { return(new XbimRect3D(r3D.X, r3D.Y, r3D.Z, r3D.SizeX, r3D.SizeY, r3D.SizeZ)); }
/// <summary> /// Computes the center of 'box' /// </summary> /// <param name="box">The Rect3D we want the center of</param> /// <returns>The center point</returns> public static Point3D GetCenter(Rect3D box) { return(new Point3D(box.X + box.SizeX / 2, box.Y + box.SizeY / 2, box.Z + box.SizeZ / 2)); }
private void wPushsPull(object sender, KeyEventArgs e) { if (e.Key == Key.W || e.Key == Key.S) { //Get camera position, then use it to calculate the vector from camera to object current location Point3D camPoint = viewPort3d.Camera.Position; Vector3D camToCurrent = new Vector3D(currentPosition.X - camPoint.X, currentPosition.Y - camPoint.Y, currentPosition.Z - camPoint.Z); //Get length of the camToCurrent vector. This length will be extended or reduced depending on which key was pressed. double camToCurrentLength = camToCurrent.Length; double camToGoalLength; if (e.Key == Key.W) { camToGoalLength = camToCurrentLength + 10; } else { camToGoalLength = camToCurrentLength - 10; } var centerPoint = getCenter(); //Use the length of the goal vector to calculate the offset in each individual direction double xOffset; double yOffset; //Formula for new offset: sqrt((current_position*(goalVectorLength/currentVectorLength)^2) if (camToCurrent.X < 0) { xOffset = -(Math.Sqrt((camToCurrent.X * (camToGoalLength / camToCurrentLength)) * (camToCurrent.X * (camToGoalLength / camToCurrentLength)))); } else { xOffset = Math.Sqrt((camToCurrent.X * (camToGoalLength / camToCurrentLength)) * (camToCurrent.X * (camToGoalLength / camToCurrentLength))); } if (camToCurrent.Y < 0) { yOffset = -(Math.Sqrt((camToCurrent.Y * (camToGoalLength / camToCurrentLength)) * (camToCurrent.Y * (camToGoalLength / camToCurrentLength)))); } else { yOffset = Math.Sqrt((camToCurrent.Y * (camToGoalLength / camToCurrentLength)) * (camToCurrent.Y * (camToGoalLength / camToCurrentLength))); } //Use the length of each individual direction to calculate the goal position double goalXPos = camPoint.X + xOffset; double goalYPos = camPoint.Y + yOffset; //Create vector object using goal position and centerpoint for the translation Vector3D goalVector = new Vector3D(goalXPos - centerPoint.X, goalYPos - centerPoint.Y, 0); //Create transformation group - use to execute translation and also save previous rotation status Transform3DGroup trans3dgroup = new Transform3DGroup(); //Test to see if the transformation will put the object out of bounds. If so, don't do it. Rect3D rect = obj.Content.Bounds; if (((goalXPos - rect.X / 2 - 75) > 0) & ((goalYPos - rect.Y / 2 - 75) > 0) & ((goalXPos + rect.X / 2 - 75) < 200) & (goalYPos + rect.Y / 2 - 75) < 200) { TranslateTransform3D trans = new TranslateTransform3D(goalVector.X, goalVector.Y, 0); trans3dgroup.Children.Add(trans); currentPosition.X = goalXPos; currentPosition.Y = goalYPos; } else { TranslateTransform3D trans = new TranslateTransform3D(currentPosition.X - 75, currentPosition.Y - 75, 0); trans3dgroup.Children.Add(trans); } ScaleTransform3D scale = new ScaleTransform3D(scaleX, scaleY, scaleZ, currentPosition.X, currentPosition.Y, currentPosition.Z); RotateTransform3D rot = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 0, -1), degree), currentPosition); trans3dgroup.Children.Add(scale); trans3dgroup.Children.Add(rot); obj.Transform = trans3dgroup; myPCamera.LookDirection = new Vector3D(100 - myPCamera.Position.X, 100 - myPCamera.Position.Y, 0 - myPCamera.Position.Z); } }
private void RenderBoard(LagoVista.EaglePCB.Models.PCB board, LagoVista.EaglePCB.Models.PCBProject project, bool resetZoomAndView = true) { var linePoints = new Point3DCollection(); var modelGroup = new Model3DGroup(); var copperMaterial = MaterialHelper.CreateMaterial(Color.FromRgb(0xb8, 0x73, 0x33)); var redMaterial = MaterialHelper.CreateMaterial(Colors.Red); var greenMaterial = MaterialHelper.CreateMaterial(Colors.Green); var blueMaterial = MaterialHelper.CreateMaterial(Colors.Blue); var blackMaterial = MaterialHelper.CreateMaterial(Colors.Black); var grayMaterial = MaterialHelper.CreateMaterial(Colors.DarkGray); var scrapX = project == null ? 0 : project.ScrapSides; var scrapY = project == null ? 0 : project.ScrapTopBottom; var boardThickness = project == null ? 1.60 : project.StockThickness; if (_topWiresVisible) { foreach (var wireSection in board.TopWires.GroupBy(wre => wre.Width)) { var width = wireSection.First().Width; foreach (var wire in wireSection) { var topWireMeshBuilder = new MeshBuilder(false, false); var boxRect = new Rect3D(wire.Rect.X1 - (width / 2), wire.Rect.Y1, -0.1, width, wire.Rect.Length, 0.2); topWireMeshBuilder.AddBox(boxRect); topWireMeshBuilder.AddCylinder(new Point3D(wire.Rect.X1, wire.Rect.Y1, -0.1), new Point3D(wire.Rect.X1, wire.Rect.Y1, .1), width / 2, 50, true, true); var boxModel = new GeometryModel3D() { Geometry = topWireMeshBuilder.ToMesh(true), Material = copperMaterial }; boxModel.Transform = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 0, 1), wire.Rect.Angle), new Point3D(wire.Rect.X1, wire.Rect.Y1, 0)); modelGroup.Children.Add(boxModel); } } } if (_bottomWiresVisible) { foreach (var wireSection in board.BottomWires.GroupBy(wre => wre.Width)) { var width = wireSection.First().Width; foreach (var wire in wireSection) { var topWireMeshBuilder = new MeshBuilder(false, false); var boxRect = new Rect3D(wire.Rect.X1 - (width / 2), wire.Rect.Y1, -0.105, width, wire.Rect.Length, 0.2); topWireMeshBuilder.AddBox(boxRect); topWireMeshBuilder.AddCylinder(new Point3D(wire.Rect.X1, wire.Rect.Y1, -0.105), new Point3D(wire.Rect.X1, wire.Rect.Y1, .095), width / 2, 50, true, true); var boxModel = new GeometryModel3D() { Geometry = topWireMeshBuilder.ToMesh(true), Material = grayMaterial }; boxModel.Transform = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 0, 1), wire.Rect.Angle), new Point3D(wire.Rect.X1, wire.Rect.Y1, 0)); modelGroup.Children.Add(boxModel); } } } foreach (var element in board.Components) { foreach (var pad in element.SMDPads) { var padMeshBuilder = new MeshBuilder(false, false); padMeshBuilder.AddBox(new Rect3D(pad.OriginX - (pad.DX / 2), pad.OriginY - (pad.DY / 2), -0.1, (pad.DX), (pad.DY), 0.2)); var box = new GeometryModel3D() { Geometry = padMeshBuilder.ToMesh(true), Material = element.Layer == 1 ? copperMaterial : grayMaterial }; var transformGroup = new Transform3DGroup(); transformGroup.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 0, 1), element.RotateAngle))); transformGroup.Children.Add(new TranslateTransform3D(new Vector3D(element.X.Value, element.Y.Value, element.Layer == 1 ? 0 : 0.05))); box.Transform = transformGroup; modelGroup.Children.Add(box); } foreach (var pad in element.Pads) { var padCopperMeshBuilder = new MeshBuilder(false, false); padCopperMeshBuilder.AddCylinder(new Point3D(pad.X, pad.Y, 0), new Point3D(pad.X, pad.Y, 0.1), pad.DrillDiameter * 0.75); var padCopper = new GeometryModel3D() { Geometry = padCopperMeshBuilder.ToMesh(true), Material = copperMaterial }; modelGroup.Children.Add(padCopper); var padDrillMeshBuilder = new MeshBuilder(false, false); padDrillMeshBuilder.AddCylinder(new Point3D(pad.X, pad.Y, 0), new Point3D(pad.X, pad.Y, 0.101), pad.DrillDiameter / 2); var padDrill = new GeometryModel3D() { Geometry = padDrillMeshBuilder.ToMesh(true), Material = blackMaterial }; modelGroup.Children.Add(padDrill); } if (_pcbVisible) { var billBoard = new BillboardTextVisual3D() { Foreground = Brushes.White, Text = element.Name, Position = new Point3D(element.X.Value + scrapX, element.Y.Value + scrapY, 4), FontSize = 14 }; viewport.Children.Add(billBoard); } } foreach (var via in board.Vias) { var padCopperMeshBuilder = new MeshBuilder(false, false); padCopperMeshBuilder.AddCylinder(new Point3D(via.X, via.Y, 0), new Point3D(via.X, via.Y, 0.1), (via.DrillDiameter)); var padCopper = new GeometryModel3D() { Geometry = padCopperMeshBuilder.ToMesh(true), Material = copperMaterial }; modelGroup.Children.Add(padCopper); var padDrillMeshBuilder = new MeshBuilder(false, false); padDrillMeshBuilder.AddCylinder(new Point3D(via.X, via.Y, 0), new Point3D(via.X, via.Y, 0.11), via.DrillDiameter / 2); var padDrill = new GeometryModel3D() { Geometry = padDrillMeshBuilder.ToMesh(true), Material = blackMaterial }; modelGroup.Children.Add(padDrill); } if (_pcbVisible) { foreach (var circle in board.Holes) { var circleMeshBuilder = new MeshBuilder(false, false); circleMeshBuilder.AddCylinder(new Point3D(circle.X, circle.Y, 0), new Point3D(circle.X, circle.Y, 0.01), circle.Drill / 2); modelGroup.Children.Add(new GeometryModel3D() { Geometry = circleMeshBuilder.ToMesh(true), Material = blackMaterial }); } #region Hold your nose to discover why irregular boards don't render as expected... /* gonna cheat here in next chunk of code...need to make progress, assume all corners are * either square or round. If rounded, same radius...WILL revisit this at some point, KDW 2/24/2017 * FWIW - feel so dirty doing this, but need to move on :*( * very happy to accept a PR to fix this! Proper mechanism is to create a polygon and likely subdivide the curve into smaller polygon edges * more work than it's worth right now....sorry again :( */ //TODO: Render proper edge of board. var boardEdgeMeshBuilder = new MeshBuilder(false, false); var cornerWires = board.Layers.Where(layer => layer.Number == 20).FirstOrDefault().Wires.Where(wire => wire.Curve.HasValue == true); var radius = cornerWires.Any() ? Math.Abs(cornerWires.First().Rect.X1 - cornerWires.First().Rect.X2) : 0; if (radius == 0) { boardEdgeMeshBuilder.AddBox(new Point3D(board.Width / 2, board.Height / 2, -boardThickness / 2), board.Width, board.Height, boardThickness); } else { boardEdgeMeshBuilder.AddBox(new Point3D(board.Width / 2, board.Height / 2, -boardThickness / 2), board.Width - (radius * 2), board.Height - (radius * 2), boardThickness); boardEdgeMeshBuilder.AddBox(new Point3D(board.Width / 2, radius / 2, -boardThickness / 2), board.Width - (radius * 2), radius, boardThickness); boardEdgeMeshBuilder.AddBox(new Point3D(board.Width / 2, board.Height - radius / 2, -boardThickness / 2), board.Width - (radius * 2), radius, boardThickness); boardEdgeMeshBuilder.AddBox(new Point3D(radius / 2, board.Height / 2, -boardThickness / 2), radius, board.Height - (radius * 2), boardThickness); boardEdgeMeshBuilder.AddBox(new Point3D(board.Width - radius / 2, board.Height / 2, -boardThickness / 2), radius, board.Height - (radius * 2), boardThickness); boardEdgeMeshBuilder.AddCylinder(new Point3D(radius, radius, -boardThickness), new Point3D(radius, radius, 0), radius, 50, true, true); boardEdgeMeshBuilder.AddCylinder(new Point3D(radius, board.Height - radius, -boardThickness), new Point3D(radius, board.Height - radius, 0), radius, 50, true, true); boardEdgeMeshBuilder.AddCylinder(new Point3D(board.Width - radius, radius, -boardThickness), new Point3D(board.Width - radius, radius, 0), radius, 50, true, true); boardEdgeMeshBuilder.AddCylinder(new Point3D(board.Width - radius, board.Height - radius, -boardThickness), new Point3D(board.Width - radius, board.Height - radius, 0), radius, 50, true, true); } modelGroup.Children.Add(new GeometryModel3D() { Geometry = boardEdgeMeshBuilder.ToMesh(true), Material = greenMaterial }); #endregion } PCBLayer.Content = modelGroup; PCBLayer.Transform = new TranslateTransform3D(scrapX, scrapY, 0); if (project != null) { var stockGroup = new Model3DGroup(); var circleMeshBuilder = new MeshBuilder(false, false); var holdDownDrills = project.GetHoldDownDrills(board); foreach (var drl in holdDownDrills) { circleMeshBuilder.AddCylinder(new Point3D(drl.X, drl.Y, -boardThickness), new Point3D(drl.X, drl.Y, 0.01), project.HoldDownDiameter / 2); } stockGroup.Children.Add(new GeometryModel3D() { Geometry = circleMeshBuilder.ToMesh(true), Material = blackMaterial }); if (_stockVisible) { var stockMeshBuilder = new MeshBuilder(false, false); stockMeshBuilder.AddBox(new Point3D(project.StockWidth / 2, project.StockHeight / 2, -boardThickness / 2), project.StockWidth, project.StockHeight, boardThickness - 0.05); stockGroup.Children.Add(new GeometryModel3D() { Geometry = stockMeshBuilder.ToMesh(true), Material = copperMaterial }); } StockLayer.Content = stockGroup; } else { StockLayer.Content = null; } if (resetZoomAndView) { RefreshExtents(); } }
private Model3D CreateModel() { var plotModel = new Model3DGroup(); if (Points == null || Values == null) { return(plotModel); } double minX = Points.Min(p => p.X); double maxX = Points.Max(p => p.X); double minY = Points.Min(p => p.Y); double maxY = Points.Max(p => p.Y); double minZ = Points.Min(p => p.Z); double maxZ = Points.Max(p => p.Z); double minValue = Values.Min(); double maxValue = Values.Max(); var valueRange = maxValue - minValue; var scatterMeshBuilder = new MeshBuilder(true, true); var oldTCCount = 0; for (var i = 0; i < Points.Length; ++i) { scatterMeshBuilder.AddSphere(Points[i], SphereSize, 4, 4); var u = (Values[i] - minValue) / valueRange; var newTCCount = scatterMeshBuilder.TextureCoordinates.Count; for (var j = oldTCCount; j < newTCCount; ++j) { scatterMeshBuilder.TextureCoordinates[j] = new Point(u, u); } oldTCCount = newTCCount; } var scatterModel = new GeometryModel3D(scatterMeshBuilder.ToMesh(), MaterialHelper.CreateMaterial(SurfaceBrush, null, null, 1, 0)); scatterModel.BackMaterial = scatterModel.Material; // create bounding box with axes indications var axesMeshBuilder = new MeshBuilder(); for (double x = minX; x <= maxX; x += IntervalX) { GeometryModel3D label = TextCreator.CreateTextLabelModel3D(x.ToString(), Brushes.Black, true, FontSize, new Point3D(x, minY - FontSize * 2.5, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); plotModel.Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D("X-axis", Brushes.Black, true, FontSize, new Point3D((minX + maxX) * 0.5, minY - FontSize * 6, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); plotModel.Children.Add(label); } for (double y = minY; y <= maxY; y += IntervalY) { GeometryModel3D label = TextCreator.CreateTextLabelModel3D(y.ToString(), Brushes.Black, true, FontSize, new Point3D(minX - FontSize * 3, y, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); plotModel.Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Y-axis", Brushes.Black, true, FontSize, new Point3D(minX - FontSize * 10, (minY + maxY) * 0.5, minZ), new Vector3D(0, 1, 0), new Vector3D(-1, 0, 0)); plotModel.Children.Add(label); } double z0 = (int)(minZ / IntervalZ) * IntervalZ; for (double z = z0; z <= maxZ + double.Epsilon; z += IntervalZ) { GeometryModel3D label = TextCreator.CreateTextLabelModel3D(z.ToString(), Brushes.Black, true, FontSize, new Point3D(minX - FontSize * 3, maxY, z), new Vector3D(1, 0, 0), new Vector3D(0, 0, 1)); plotModel.Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Z-axis", Brushes.Black, true, FontSize, new Point3D(minX - FontSize * 10, maxY, (minZ + maxZ) * 0.5), new Vector3D(0, 0, 1), new Vector3D(1, 0, 0)); plotModel.Children.Add(label); } var bb = new Rect3D(minX, minY, minZ, maxX - minX, maxY - minY, maxZ - minZ); axesMeshBuilder.AddBoundingBox(bb, LineThickness); var axesModel = new GeometryModel3D(axesMeshBuilder.ToMesh(), Materials.Black); plotModel.Children.Add(scatterModel); plotModel.Children.Add(axesModel); return(plotModel); }
public Rect3D GetBoundary() { var rect3D = new Rect3D(Start.X, Start.Y, Start.Z, Math.Abs(End.X - Start.X), Math.Abs(End.Y - Start.Y), Math.Abs(End.Z - Start.Z)); return(rect3D); }
private void HighlightObject(ModelVisual3D newHighlightedObject, Rect3D highlightedObjectBounds) { if (newHighlightedObject == null) { _highlightedModelVisual3D = null; if (_highlightWireBoxVisual3D != null) { if (LinesVisual.Children.Contains(_highlightWireBoxVisual3D)) { LinesVisual.Children.Remove(_highlightWireBoxVisual3D); } _highlightWireBoxVisual3D = null; } } else if (newHighlightedObject == _selectedModelVisual3D) { // Do nothing - do not highlight selected object } else { if (_highlightWireBoxVisual3D == null) { _highlightWireBoxVisual3D = new CornerWireBoxVisual3D() { IsLineLengthPercent = false, LineLength = 5, LineThickness = 2, LineColor = SceneEditorContext.Current.HighlightedColor }; } if (highlightedObjectBounds.IsEmpty) { highlightedObjectBounds = ModelUtils.GetBounds(newHighlightedObject, newHighlightedObject.Transform, checkOnlyBounds: true); } double standardSelectionLineLength = 5; double minSize = Math.Min(highlightedObjectBounds.SizeX, Math.Min(highlightedObjectBounds.SizeY, highlightedObjectBounds.SizeZ)); if (minSize > standardSelectionLineLength * 3) { _highlightWireBoxVisual3D.LineLength = standardSelectionLineLength; } else { _highlightWireBoxVisual3D.LineLength = minSize / 3; } _highlightWireBoxVisual3D.CenterPosition = highlightedObjectBounds.GetCenterPosition(); _highlightWireBoxVisual3D.Size = highlightedObjectBounds.Size; if (!LinesVisual.Children.Contains(_highlightWireBoxVisual3D)) { LinesVisual.Children.Add(_highlightWireBoxVisual3D); } _highlightedModelVisual3D = newHighlightedObject; } }
private Model3D CreateModel() { var plotModel = new Model3DGroup(); int rows = Points.GetUpperBound(0) + 1; int columns = Points.GetUpperBound(1) + 1; double minX = double.MaxValue; double maxX = double.MinValue; double minY = double.MaxValue; double maxY = double.MinValue; double minZ = double.MaxValue; double maxZ = double.MinValue; double minColorValue = double.MaxValue; double maxColorValue = double.MinValue; for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { double x = Points[i, j].X; double y = Points[i, j].Y; double z = Points[i, j].Z; maxX = Math.Max(maxX, x); maxY = Math.Max(maxY, y); maxZ = Math.Max(maxZ, z); minX = Math.Min(minX, x); minY = Math.Min(minY, y); minZ = Math.Min(minZ, z); if (ColorValues != null) { maxColorValue = Math.Max(maxColorValue, ColorValues[i, j]); minColorValue = Math.Min(minColorValue, ColorValues[i, j]); } } } // make color value 0 at texture coordinate 0.5 if (Math.Abs(minColorValue) < Math.Abs(maxColorValue)) { minColorValue = -maxColorValue; } else { maxColorValue = -minColorValue; } // set the texture coordinates by z-value or ColorValue var texcoords = new Point[rows, columns]; for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { double u = (Points[i, j].Z - minZ) / (maxZ - minZ); if (ColorValues != null) { u = (ColorValues[i, j] - minColorValue) / (maxColorValue - minColorValue); } texcoords[i, j] = new Point(u, u); } } var surfaceMeshBuilder = new MeshBuilder(); surfaceMeshBuilder.AddRectangularMesh(Points, texcoords); var surfaceModel = new GeometryModel3D(surfaceMeshBuilder.ToMesh(), MaterialHelper.CreateMaterial(SurfaceBrush, null, null, 1, 0)); surfaceModel.BackMaterial = surfaceModel.Material; var axesMeshBuilder = new MeshBuilder(); for (double x = minX; x <= maxX; x += IntervalX) { double j = (x - minX) / (maxX - minX) * (columns - 1); var path = new List <Point3D> { new Point3D(x, minY, minZ) }; for (int i = 0; i < rows; i++) { path.Add(BilinearInterpolation(Points, i, j)); } path.Add(new Point3D(x, maxY, minZ)); axesMeshBuilder.AddTube(path, LineThickness, 9, false); GeometryModel3D label = TextCreator.CreateTextLabelModel3D(x.ToString(), Brushes.Black, true, FontSize, new Point3D(x, minY - FontSize * 2.5, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); plotModel.Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D("X-axis", Brushes.Black, true, FontSize, new Point3D((minX + maxX) * 0.5, minY - FontSize * 6, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); plotModel.Children.Add(label); } for (double y = minY; y <= maxY; y += IntervalY) { double i = (y - minY) / (maxY - minY) * (rows - 1); var path = new List <Point3D> { new Point3D(minX, y, minZ) }; for (int j = 0; j < columns; j++) { path.Add(BilinearInterpolation(Points, i, j)); } path.Add(new Point3D(maxX, y, minZ)); axesMeshBuilder.AddTube(path, LineThickness, 9, false); GeometryModel3D label = TextCreator.CreateTextLabelModel3D(y.ToString(), Brushes.Black, true, FontSize, new Point3D(minX - FontSize * 3, y, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); plotModel.Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Y-axis", Brushes.Black, true, FontSize, new Point3D(minX - FontSize * 10, (minY + maxY) * 0.5, minZ), new Vector3D(0, 1, 0), new Vector3D(-1, 0, 0)); plotModel.Children.Add(label); } double z0 = (int)(minZ / IntervalZ) * IntervalZ; for (double z = z0; z <= maxZ + double.Epsilon; z += IntervalZ) { GeometryModel3D label = TextCreator.CreateTextLabelModel3D(z.ToString(), Brushes.Black, true, FontSize, new Point3D(minX - FontSize * 3, maxY, z), new Vector3D(1, 0, 0), new Vector3D(0, 0, 1)); plotModel.Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Z-axis", Brushes.Black, true, FontSize, new Point3D(minX - FontSize * 10, maxY, (minZ + maxZ) * 0.5), new Vector3D(0, 0, 1), new Vector3D(1, 0, 0)); plotModel.Children.Add(label); } var bb = new Rect3D(minX, minY, minZ, maxX - minX, maxY - minY, 0 * (maxZ - minZ)); axesMeshBuilder.AddBoundingBox(bb, LineThickness); var axesModel = new GeometryModel3D(axesMeshBuilder.ToMesh(), Materials.Black); plotModel.Children.Add(surfaceModel); plotModel.Children.Add(axesModel); return(plotModel); }
// ------------------------------------------ void Awake() { MGUILayer = LayerMaskDefine.GUI; MIsHitUIObject = false; MGUICamera = GameObject.Find("UICamera").GetComponent <Camera>(); DontDestroyOnLoad(MGUICamera); DontDestroyOnLoad(MGUICamera.transform.parent); // Calculate EZGUI 3D Bound Vector3 screenCenter = MGUICamera.transform.position; screenWidth = Screen.width; screenHeight = Screen.height; string t_machineType = ""; // if(t_machineType.StartsWith("iPhone4") // || t_machineType.StartsWith("iPhone5") // || t_machineType.StartsWith("iPhone6") // || t_machineType.StartsWith("iPhone7") // || t_machineType.StartsWith("iPad") // || t_machineType.StartsWith("iPod5") // || t_machineType.StartsWith("iPod6") // || t_machineType.StartsWith("iPod7")){ Debug.Log("Device is " + t_machineType + " Screen.width:" + Screen.width + " Screen.height:" + Screen.height); // auto resize MGUICamera.orthographicSize = screenHeight * 0.5f; widthRatio = screenWidth / GUIManager.DEFAULT_SCREEN_WIDTH; heightRatio = screenHeight / GUIManager.DEFAULT_SCREEN_HEIGHT; //calculate the minimum ratio by lsj if (widthRatio <= heightRatio) { windowFormHRatio = windowFormWRatio = widthRatio; } else { windowFormHRatio = windowFormWRatio = heightRatio; } // comment by lsj // widthRatioInv = 1 / widthRatio; // heightRatioInv = 1 / heightRatio; // comment by lsj // if (height < 2 * MGUICamera.orthographicSize) // { // height = 2 * MGUICamera.orthographicSize; // } Vector3 topLeft = screenCenter; topLeft.x -= 0.5f * screenWidth; topLeft.y += 0.5f * screenHeight; Vector3 topRight = screenCenter; topRight.x += 0.5f * screenWidth; topRight.y += 0.5f * screenHeight; Vector3 bottomLeft = screenCenter; bottomLeft.x -= 0.5f * screenWidth; bottomLeft.y -= 0.5f * screenHeight; M3DScreenRect = new Rect3D(topLeft, topRight, bottomLeft); _mModalWindow = null; _mTopWindow = null; _mGUIWindows = new List <GUIWindow>(); _mCreateGUIQueue = new Queue <IEnumerator>(); // read the culling mask //mMainCameraCullMask = Camera.main.cullingMask; }
private void SelectObject(ModelVisual3D newSelectedObject, Rect3D selectedObjectBounds) { if (newSelectedObject == null) { _selectedModelVisual3D = null; _selectedObjectScaleTransform = null; _selectedObjectTranslateTransform3D = null; if (_selectionWireBoxVisual3D != null) { if (LinesVisual.Children.Contains(_selectionWireBoxVisual3D)) { LinesVisual.Children.Remove(_selectionWireBoxVisual3D); } _selectionWireBoxVisual3D = null; } OverlayCanvas.ClearScreenPositions(); } else { if (_selectionWireBoxVisual3D == null) { _selectionWireBoxVisual3D = new CornerWireBoxVisual3D() { IsLineLengthPercent = false, LineLength = 5, LineThickness = 2, LineColor = SceneEditorContext.Current.SelectedColor }; } if (selectedObjectBounds.IsEmpty) { selectedObjectBounds = ModelUtils.GetBounds(newSelectedObject, newSelectedObject.Transform, checkOnlyBounds: true); } double standardSelectionLineLength = 5; double minSize = Math.Min(selectedObjectBounds.SizeX, Math.Min(selectedObjectBounds.SizeY, selectedObjectBounds.SizeZ)); if (minSize > standardSelectionLineLength * 3) { _selectionWireBoxVisual3D.LineLength = standardSelectionLineLength; } else { _selectionWireBoxVisual3D.LineLength = minSize / 3; } _selectionWireBoxVisual3D.CenterPosition = selectedObjectBounds.GetCenterPosition(); _selectionWireBoxVisual3D.Size = selectedObjectBounds.Size; if (!LinesVisual.Children.Contains(_selectionWireBoxVisual3D)) { LinesVisual.Children.Add(_selectionWireBoxVisual3D); } _selectedModelVisual3D = newSelectedObject; _selectedObjectTranslateTransform3D = GetFirstTranslateTransform3D(_selectedModelVisual3D.Transform); _selectedObjectScaleTransform = GetFirstScaleTransform3D(_selectedModelVisual3D.Transform); } }
public MainWindow() { InitializeComponent(); // Define 3D mesh object MeshGeometry3D mesh = new MeshGeometry3D(); // Experiment with changing this value to create either a smooth or hard-edged mesh Boolean smooth = false; // EDIT THE SQLCONNECTION STRING HERE using (SqlConnection conn = new SqlConnection("server=localhost\\SQL2012EXPRESS;Trusted_Connection=yes;database=ProSpatial")) { // Define the stored procedure that returns the 3D triangulated mesh SqlCommand comm = new SqlCommand(); comm.CommandText = "GeometryTriangulate3d"; comm.CommandType = CommandType.StoredProcedure; comm.Connection = conn; // Pass in the MultiPoint to be triangulated SqlGeometry WolfPoint = SqlGeometry.STMPointFromText(new SqlChars("MULTIPOINT ((532101.12 5121560.53 432.31), (532100.44 5121557.35 432.62), (532100.22 5121547.64 434.28), (532100.97 5121550.66 432.14), (532101.61 5121553.86 432.65), (532102.27 5121557.03 432.63), (532102.94 5121560.21 432.46), (532105.43 5121562.63 432.28), (532104.77 5121559.46 432.56), (532104.1 5121556.28 432.74), (532103.46 5121553.09 432.48), (532102.78 5121549.93 432.88), (532100.26 5121530.64 440.67), (532100.93 5121533.78 440.38), (532101.61 5121536.89 439.81), (532104.45 5121549.21 434.75), (532105.21 5121552.24 432.51), (532105.86 5121555.43 432.76), (532106.52 5121558.61 432.68), (532107.19 5121561.78 432.54), (532109.57 5121563.62 432.76), (532108.91 5121560.43 432.71), (532108.25 5121557.26 432.83), (532107.61 5121554.06 432.57), (532106.91 5121550.96 433.79), (532106.16 5121547.94 436.09), (532104.03 5121538.75 440.38), (532103.36 5121535.63 440.83), (532102.71 5121532.48 440.92), (532102.04 5121529.37 441.38), (532100.7 5121523.17 442.5), (532100.08 5121512.23 444.65), (532100.75 5121515.32 444.14), (532102.75 5121524.64 442.98), (532104.09 5121530.86 442.11), (532104.77 5121533.98 441.63), (532105.44 5121537.1 441.18), (532106.1 5121540.26 441.18), (532108.28 5121549.4 436.04), (532109.75 5121555.55 432.71), (532110.4 5121558.74 432.87), (532111.07 5121561.91 432.71), (532113.22 5121562.6 432.81), (532112.56 5121559.42 432.95), (532111.91 5121556.26 432.91), (532111.2 5121553.18 434.37), (532110.47 5121550.12 436.13), (532109.75 5121547.07 437.8), (532109.02 5121544.04 439.73), (532108.31 5121540.97 441.08), (532107.63 5121537.88 441.97), (532106.97 5121534.75 442.21), (532106.32 5121531.61 442.26), (532105.65 5121528.51 442.82), (532104.99 5121525.41 443.24), (532104.34 5121522.29 443.45), (532103.02 5121516.1 444.23), (532102.37 5121513.01 444.53), (532101.71 5121509.92 444.83), (532101.06 5121506.82 445.14), (532100.38 5121503.78 446.08), (532101.27 5121500.05 446.49), (532101.93 5121503.14 446.26), (532102.61 5121506.18 445.36), (532103.26 5121509.3 445.25), (532103.93 5121512.39 444.67), (532104.59 5121515.52 444.64), (532105.24 5121518.64 444.5), (532105.92 5121521.73 443.82), (532107.26 5121527.97 443.08), (532107.92 5121531.09 442.73), (532108.58 5121534.23 442.62), (532109.26 5121537.35 442.15), (532109.94 5121540.47 441.52), (532110.64 5121543.56 440.4), (532112.84 5121552.73 435.15), (532113.59 5121555.77 433.01), (532114.25 5121558.96 433.04), (532114.91 5121562.14 432.94), (532124.74 5121597.75 425.41), (532117.17 5121563.01 432.99), (532116.52 5121559.85 433.05), (532115.86 5121556.68 433.07), (532112.96 5121544.46 440.13), (532110.91 5121535.18 442.63), (532109.58 5121528.96 443.58), (532108.93 5121525.84 443.73), (532108.27 5121522.73 444), (532107.61 5121519.63 444.39), (532106.95 5121516.54 444.83), (532106.3 5121513.45 445.07), (532105.66 5121510.33 445.09), (532105.01 5121507.23 445.4), (532104.34 5121504.17 446.05), (532103.67 5121501.12 446.89), (532105.56 5121502.68 446.69), (532106.24 5121505.73 445.9), (532107.57 5121511.91 444.92), (532108.22 5121515.04 444.84), (532108.89 5121518.16 444.57), (532109.54 5121521.3 444.52), (532110.21 5121524.4 443.98), (532110.88 5121527.52 443.62), (532111.54 5121530.65 443.36), (532113.57 5121540.02 441.72), (532114.27 5121543.13 440.87), (532117.89 5121558.53 433.08), (532118.55 5121561.72 433.11), (532126.87 5121599.81 425.42), (532121.32 5121564.99 433.08), (532120.66 5121561.8 433.16), (532120.01 5121558.61 433.02), (532119.27 5121555.55 435.04), (532118.57 5121552.45 436.2), (532116.42 5121543.23 440.71), (532113.06 5121527.69 443.92), (532112.4 5121524.56 444.12), (532111.73 5121521.48 444.86), (532111.08 5121518.33 444.84), (532110.43 5121515.21 445.06), (532109.78 5121512.08 445.15), (532109.12 5121509 445.62), (532108.46 5121505.91 446.19), (532107.79 5121502.85 446.89), (532109.95 5121505.55 446.52), (532110.62 5121508.63 445.89), (532111.3 5121511.7 445.17), (532111.95 5121514.85 445.23), (532112.61 5121517.98 444.97), (532113.27 5121521.1 444.67), (532114.6 5121527.33 444.02), (532117.99 5121542.9 441.1), (532118.67 5121546.03 440.46), (532121.6 5121558.29 433.5), (532122.27 5121561.47 433.23), (532122.93 5121564.64 433.17), (532129.86 5121596.33 426.45), (532131.65 5121595.62 426.88), (532124.81 5121563.98 433.3), (532124.15 5121560.79 433.29), (532120.59 5121545.39 440.53), (532119.91 5121542.27 441.3), (532119.23 5121539.18 442.12), (532117.89 5121532.95 443.17), (532117.2 5121529.87 444.24), (532116.55 5121526.75 444.42), (532115.89 5121523.63 444.79), (532115.25 5121520.48 444.75), (532114.59 5121517.35 444.98), (532113.95 5121514.23 445.04), (532113.3 5121511.12 445.23), (532111.95 5121504.99 446.97), (532111.28 5121501.93 447.66), (532112.35 5121500.03 448.15), (532113.03 5121503.1 447.36), (532113.71 5121506.16 446.53), (532114.39 5121509.23 445.79), (532115.05 5121512.33 445.35), (532115.71 5121515.46 445.09), (532116.37 5121518.6 445.05), (532117.03 5121521.72 444.73), (532117.68 5121524.85 444.65), (532118.35 5121527.96 444.15), (532119.02 5121531.08 443.76), (532119.72 5121534.16 442.67), (532121.74 5121543.55 441.27), (532122.45 5121546.63 439.92), (532126.03 5121562.13 433.32), (532126.69 5121565.3 433.25), (532134.89 5121593.95 428.19), (532128.75 5121565.43 433.37), (532128.1 5121562.25 433.33), (532124.56 5121546.76 439.7), (532122.52 5121537.44 442.06), (532121.86 5121534.31 442.43), (532121.17 5121531.23 443.37), (532120.51 5121528.12 443.89), (532119.84 5121525 444.42), (532119.18 5121521.88 444.82), (532117.87 5121515.64 445.29), (532117.22 5121512.52 445.37), (532116.57 5121509.42 445.72), (532115.9 5121506.35 446.49), (532115.22 5121503.28 447.25), (532114.56 5121500.23 447.85), (532116.58 5121502.45 447.42), (532117.26 5121505.5 446.59), (532117.93 5121508.58 445.9), (532118.59 5121511.69 445.65), (532119.25 5121514.82 445.39), (532119.92 5121517.94 445), (532120.57 5121521.08 444.94), (532121.24 5121524.19 444.49), (532121.91 5121527.32 444.11), (532122.59 5121530.43 443.47), (532123.27 5121533.54 442.83), (532125.33 5121542.86 440.47), (532126.71 5121549.08 438.66), (532129.58 5121561.49 433.3), (532130.23 5121564.69 433.45), (532130.89 5121567.87 433.4), (532138.11 5121592.18 429.87), (532132.68 5121566.72 433.55), (532132.03 5121563.53 433.47), (532129.2 5121551.06 438.36), (532128.52 5121547.92 438.88), (532127.84 5121544.79 439.74), (532127.15 5121541.67 440.47), (532126.46 5121538.56 441.44), (532125.09 5121532.35 443.11), (532124.42 5121529.24 443.66), (532123.75 5121526.13 444.29), (532123.09 5121523 444.59), (532122.44 5121519.87 444.87), (532121.78 5121516.76 445.26), (532121.12 5121513.63 445.41), (532120.47 5121510.52 445.68), (532119.81 5121507.41 446.07), (532119.15 5121504.33 446.69), (532118.47 5121501.27 447.47), (532119.74 5121500.14 447.54), (532120.4 5121503.23 447.1), (532121.08 5121506.29 446.35), (532121.74 5121509.37 445.91), (532122.39 5121512.48 445.74), (532123.05 5121515.57 445.26), (532123.7 5121518.69 445.1), (532124.37 5121521.78 444.61), (532125.03 5121524.89 444.29), (532125.69 5121528 443.91), (532127.73 5121537.3 441.84), (532129.12 5121543.47 439.72), (532129.79 5121546.61 439.35), (532130.49 5121549.71 438.29), (532131.16 5121552.84 437.92), (532133.32 5121562.08 433.32), (532133.97 5121565.27 433.59), (532134.63 5121568.45 433.54), (532139.37 5121590.59 430.54), (532141.55 5121599.99 426.3), (532142.85 5121597.12 427.12), (532142.12 5121593.96 428.47), (532136.63 5121568.59 433.68), (532135.97 5121565.4 433.67), (532135.33 5121562.2 433.51), (532133.85 5121556.05 437.39), (532133.18 5121552.89 437.7), (532132.51 5121549.75 438.16), (532131.83 5121546.62 438.84), (532131.15 5121543.49 439.6), (532130.45 5121540.39 440.74), (532129.76 5121537.29 441.67), (532128.39 5121531.09 443.43), (532127.72 5121527.98 444.02), (532127.06 5121524.87 444.51), (532125.73 5121518.62 445.23), (532124.4 5121512.42 446.32), (532123.77 5121509.25 445.96), (532123.12 5121506.13 446.17), (532122.45 5121503.06 446.9), (532123.4 5121500.22 447.15), (532124.05 5121503.3 446.74), (532124.72 5121506.36 446.05), (532125.37 5121509.47 445.96), (532126 5121512.63 446.29), (532126.69 5121515.69 445.38), (532127.34 5121518.8 445.13), (532128 5121521.93 444.95), (532128.66 5121525.04 444.69), (532130.02 5121531.24 443.2), (532131.38 5121537.43 441.71), (532132.08 5121540.53 440.68), (532132.78 5121543.62 439.53), (532133.47 5121546.72 438.69), (532134.14 5121549.85 438.29), (532134.82 5121552.98 437.68), (532135.49 5121556.12 437.27), (532136.96 5121562.27 433.72), (532137.61 5121565.45 433.75), (532138.27 5121568.63 433.74), (532138.91 5121571.83 434.09), (532142.32 5121587.67 431.57), (532143.03 5121590.81 430.49), (532143.77 5121593.93 428.76), (532144.48 5121597.09 427.68), (532146.62 5121598.48 426.98), (532143.73 5121585.88 432.47), (532143.07 5121582.68 432.44), (532140.4 5121569.98 433.83), (532139.74 5121566.78 433.85), (532139.1 5121563.59 433.59), (532136.95 5121554.29 438.06), (532136.3 5121551.12 438.06), (532135.63 5121548 438.65), (532134.95 5121544.87 439.3), (532134.26 5121541.76 440.27), (532133.57 5121538.66 441.24), (532132.89 5121535.55 442.07), (532132.2 5121532.48 443.12), (532131.53 5121529.37 443.71), (532130.85 5121526.28 444.46), (532130.18 5121523.18 445.1), (532129.54 5121520.04 445.08), (532128.89 5121516.92 445.31), (532128.23 5121513.82 445.82), (532127.57 5121510.72 446.25), (532126.92 5121507.62 446.53), (532126.29 5121504.48 446.25), (532125.63 5121501.4 446.84), (532127.44 5121502.25 446.76), (532128.09 5121505.37 446.66), (532128.73 5121508.49 446.71), (532129.39 5121511.58 446.31), (532130.07 5121514.65 445.52), (532130.73 5121517.77 445.22), (532132.05 5121524 444.6), (532132.73 5121527.11 444.07), (532133.41 5121530.19 443.24), (532134.07 5121533.32 442.94), (532134.77 5121536.39 441.77), (532135.47 5121539.47 440.72), (532136.15 5121542.57 439.96), (532136.83 5121545.7 439.31), (532137.51 5121548.83 438.8), (532138.18 5121551.97 438.41), (532138.85 5121555.1 437.97), (532141.02 5121564.4 433.54), (532141.66 5121567.6 433.93), (532142.32 5121570.79 433.95), (532142.98 5121574 434.05), (532143.64 5121577.18 434.04), (532144.32 5121580.34 433.5), (532145 5121583.52 433.09), (532145.66 5121586.72 433.05), (532147.11 5121593 430.35), (532147.85 5121596.15 428.83), (532149.5 5121595.95 429.06), (532148.76 5121592.8 430.8), (532148 5121589.67 432.75), (532146.63 5121583.29 433.9), (532145.97 5121580.08 433.95), (532145.31 5121576.88 434.01), (532144.66 5121573.68 434.07), (532144 5121570.48 434.03), (532143.35 5121567.27 433.93), (532142.71 5121564.06 433.7), (532139.88 5121551.58 438.66), (532139.21 5121548.43 438.97), (532138.54 5121545.28 439.44), (532137.84 5121542.18 440.62), (532137.17 5121539.03 441.01), (532136.49 5121535.92 441.85), (532135.82 5121532.8 442.44), (532135.14 5121529.69 443.23), (532134.46 5121526.59 444.04), (532133.79 5121523.48 444.57), (532133.13 5121520.36 445.04), (532132.46 5121517.28 445.74), (532131.81 5121514.14 445.82), (532131.13 5121511.07 446.69), (532130.48 5121507.95 446.87), (532129.85 5121504.83 446.77), (532129.21 5121501.7 446.71), (532130.74 5121501.15 446.67), (532131.37 5121504.3 447.02), (532132.02 5121507.42 446.96), (532132.68 5121510.52 446.64), (532133.34 5121513.63 446.37), (532134 5121516.72 445.91), (532134.67 5121519.83 445.48), (532136.02 5121526.01 444.16), (532136.69 5121529.12 443.68), (532137.36 5121532.25 443.24), (532138.07 5121535.33 441.94), (532138.75 5121538.45 441.31), (532140.12 5121544.69 439.98), (532140.8 5121547.83 439.41), (532144.25 5121563.52 435.74), (532144.98 5121566.61 434.02), (532145.64 5121569.81 434.05), (532146.3 5121573.02 434.18), (532146.96 5121576.22 434.21), (532147.63 5121579.4 433.93), (532148.28 5121582.62 434.19), (532149.66 5121588.98 433.01), (532150.39 5121592.12 431.57), (532151.13 5121595.26 429.86), (532153.3 5121597.1 429.45), (532152.56 5121593.96 431.07), (532149.79 5121581.27 434.04), (532149.13 5121578.08 434.23), (532148.47 5121574.89 434.25), (532147.82 5121571.69 434.21), (532147.17 5121568.49 434.1), (532146.54 5121565.28 433.7), (532145.77 5121562.23 436.18), (532142.35 5121546.58 440.09), (532141.67 5121543.44 440.72), (532141.01 5121540.31 441.11), (532140.34 5121537.17 441.5), (532138.97 5121530.98 443.3), (532138.31 5121527.86 443.71), (532137.61 5121524.8 445.04), (532136.97 5121521.66 445.05), (532136.31 5121518.54 445.42), (532135.62 5121515.48 446.43), (532134.32 5121509.26 446.86), (532133.68 5121506.15 447.08), (532133.03 5121503.05 447.22), (532134.24 5121501.07 447.35), (532134.89 5121504.19 447.3), (532135.55 5121507.3 446.98), (532136.2 5121510.43 446.93), (532137.53 5121516.64 446.05), (532138.19 5121519.77 445.83), (532138.87 5121522.85 444.92), (532139.54 5121525.99 444.65), (532140.23 5121529.08 443.64), (532140.92 5121532.16 442.66), (532141.6 5121535.27 442.11), (532142.27 5121538.42 441.66), (532142.95 5121541.55 441.02), (532143.63 5121544.68 440.45), (532144.31 5121547.82 440.01), (532144.98 5121550.98 439.59), (532147.82 5121563.43 434.86), (532148.52 5121566.58 433.99), (532149.17 5121569.78 434.14), (532149.82 5121572.98 434.25), (532150.48 5121576.19 434.29), (532151.15 5121579.39 434.21), (532151.82 5121582.58 434), (532154.48 5121586.38 433.63), (532153.81 5121583.2 433.95), (532153.15 5121580.02 434.13), (532152.48 5121576.83 434.31), (532151.83 5121573.63 434.3), (532151.18 5121570.43 434.24), (532149.86 5121564.06 434.45), (532147.66 5121554.83 439.94), (532146.99 5121551.69 440.42), (532146.34 5121548.52 440.43), (532145.68 5121545.36 440.67), (532145.02 5121542.21 441.02), (532144.35 5121539.09 441.57), (532143.69 5121535.96 441.94), (532143.01 5121532.84 442.59), (532142.34 5121529.73 443.25), (532141.63 5121526.69 444.77), (532140.97 5121523.57 445.19), (532140.29 5121520.48 445.99), (532139.64 5121517.35 446.17), (532137.69 5121508 446.72), (532137.03 5121504.9 447.28), (532136.38 5121501.8 447.53), (532137.79 5121501.01 447.56), (532138.45 5121504.13 447.34), (532139.11 5121507.22 446.91), (532139.78 5121510.31 446.35), (532141.06 5121516.6 446.52), (532141.74 5121519.71 445.96), (532142.42 5121522.81 445.22), (532143.08 5121525.93 444.81), (532144.49 5121532.09 442.51), (532145.15 5121535.24 442.15), (532145.82 5121538.38 441.8), (532146.49 5121541.52 441.39), (532147.17 5121544.66 440.82), (532147.84 5121547.83 440.56), (532151.35 5121563.46 435.57), (532152.09 5121566.55 433.6), (532152.72 5121569.78 434.25), (532153.38 5121572.99 434.27), (532154.04 5121576.18 434.27), (532154.71 5121579.38 434.17), (532155.38 5121582.58 434.01), (532156.05 5121585.78 433.84), (532158.31 5121587.38 433.69), (532157.65 5121584.2 433.9), (532156.98 5121581.02 434.09), (532156.32 5121577.82 434.24), (532155.67 5121574.64 434.3), (532155.01 5121571.45 434.34), (532154.36 5121568.25 434.3), (532153.66 5121565.11 435.24), (532152.96 5121562.01 436.51), (532151.5 5121555.85 440.04), (532150.13 5121549.6 441.53), (532149.49 5121546.43 441.54), (532148.83 5121543.28 441.73), (532148.18 5121540.12 441.77), (532147.52 5121536.99 442.16), (532146.85 5121533.87 442.75), (532146.18 5121530.75 443.23), (532145.51 5121527.64 443.84), (532144.83 5121524.56 444.7), (532144.14 5121521.5 445.89), (532143.49 5121518.37 445.93), (532142.81 5121515.32 446.97), (532142.18 5121512.16 446.67), (532141.55 5121509 446.39), (532140.88 5121505.92 447.13), (532140.23 5121502.81 447.4), (532141.4 5121500.87 447.46), (532142.06 5121503.98 447.22), (532142.71 5121507.1 446.93), (532143.4 5121510.17 446.06), (532144.02 5121513.36 446.76), (532144.68 5121516.49 446.44), (532145.34 5121519.61 446.17), (532146.01 5121522.72 445.64), (532146.72 5121525.79 444.46), (532148.08 5121532.02 443.14), (532149.42 5121538.3 442.29), (532150.1 5121541.45 441.79), (532150.76 5121544.61 441.63), (532152.78 5121554.07 440.49), (532154.21 5121560.29 437.95), (532156.35 5121569.68 434.38), (532157.01 5121572.88 434.37), (532157.67 5121576.08 434.3), (532158.34 5121579.27 434.12), (532159.01 5121582.47 433.97), (532159.68 5121585.66 433.73), (532160.36 5121588.86 433.52), (532162.24 5121589.12 433.4), (532161.57 5121585.94 433.71), (532160.91 5121582.75 433.87), (532160.25 5121579.56 434.06), (532159.58 5121576.37 434.33), (532158.92 5121573.19 434.45), (532158.26 5121570 434.51), (532157.59 5121566.84 435.04), (532156.86 5121563.73 436.59), (532156.13 5121560.64 438.36), (532154.05 5121551.26 441.15), (532152.72 5121544.98 441.94), (532152.05 5121541.84 442.33), (532151.39 5121538.68 442.61), (532150.74 5121535.52 442.64), (532150.06 5121532.41 443.37), (532149.39 5121529.28 443.89), (532148.72 5121526.15 444.51), (532148.03 5121523.09 445.61), (532147.37 5121519.96 445.93), (532146.71 5121516.84 446.26), (532146.06 5121513.7 446.36), (532145.43 5121510.55 446.15), (532144.76 5121507.47 446.91), (532144.11 5121504.36 447.16), (532143.46 5121501.24 447.23), (532144.94 5121500.51 446.95), (532145.58 5121503.65 447.04), (532146.23 5121506.78 446.94), (532147.56 5121513 446.04), (532148.2 5121516.16 446.3), (532148.87 5121519.27 445.8), (532150.24 5121525.47 444.37), (532150.9 5121528.6 444.1), (532151.58 5121531.73 443.48), (532152.24 5121534.87 443.17), (532152.91 5121538.02 442.93), (532153.58 5121541.16 442.44), (532154.25 5121544.32 442.22), (532154.92 5121547.49 441.93), (532155.58 5121550.65 441.8), (532157.69 5121560.04 438.74), (532158.43 5121563.13 436.97), (532159.15 5121566.24 435.6), (532159.86 5121569.38 434.5), (532160.52 5121572.59 434.54), (532161.19 5121575.79 434.42), (532161.87 5121578.96 433.95), (532162.55 5121582.16 433.67), (532163.21 5121585.36 433.61), (532163.88 5121588.55 433.36), (532166.09 5121589.94 433.21), (532165.43 5121586.74 433.39), (532164.77 5121583.54 433.35), (532163.41 5121577.19 434.39), (532162.75 5121574 434.57), (532162.1 5121570.81 434.58), (532161.44 5121567.61 434.63), (532160.7 5121564.52 436.42), (532159.97 5121561.42 438.07), (532157.18 5121548.95 442.22), (532156.53 5121545.78 442.29), (532155.87 5121542.61 442.45), (532155.2 5121539.49 443.06), (532153.88 5121533.19 443.55), (532153.22 5121530.04 443.79), (532152.56 5121526.91 444.11), (532151.88 5121523.8 444.81), (532151.22 5121520.68 445.22), (532150.55 5121517.57 445.78), (532149.91 5121514.43 445.81), (532149.24 5121511.32 446.39), (532148.58 5121508.23 446.86), (532147.93 5121505.09 446.91), (532147.3 5121501.94 446.66), (532148.57 5121500.36 445.96), (532149.18 5121503.54 446.63), (532149.83 5121506.7 446.85), (532150.48 5121509.84 446.77), (532151.15 5121512.93 446.08), (532151.84 5121515.99 445.11), (532152.5 5121519.14 445.04), (532153.16 5121522.29 444.76), (532153.83 5121525.41 444.32), (532154.49 5121528.55 444.1), (532155.82 5121534.83 443.61), (532156.48 5121537.98 443.38), (532157.82 5121544.25 442.68), (532158.47 5121547.42 442.66), (532159.14 5121550.57 442.38), (532161.25 5121559.92 439.13), (532162.72 5121566.12 435.87), (532163.45 5121569.22 434.31), (532164.09 5121572.43 434.65), (532164.76 5121575.62 434.56), (532167.46 5121588.34 433.14), (532168.14 5121591.53 432.87), (532170.36 5121592.64 432.57), (532169.69 5121589.44 432.86), (532166.98 5121576.69 434.65), (532166.32 5121573.49 434.7), (532165.66 5121570.3 434.71), (532164.98 5121567.14 435.23), (532162.8 5121557.82 440.08), (532162.08 5121554.71 441.48), (532160.72 5121548.43 442.85), (532160.06 5121545.27 443.03), (532159.41 5121542.1 443.11), (532158.74 5121538.96 443.61), (532158.08 5121535.79 443.78), (532156.76 5121529.47 444.1), (532156.1 5121526.33 444.39), (532155.45 5121523.17 444.48), (532154.8 5121520.02 444.62), (532154.14 5121516.88 444.8), (532153.45 5121513.81 445.9), (532152.77 5121510.72 446.68), (532152.12 5121507.59 446.84), (532151.49 5121504.41 446.52), (532150.88 5121501.23 445.88), (532152.69 5121502.71 445.63), (532153.3 5121505.92 446.63), (532153.94 5121509.07 446.76), (532154.6 5121512.21 446.56), (532155.3 5121515.27 445.35), (532155.98 5121518.35 444.52), (532156.63 5121521.5 444.6), (532157.28 5121524.68 444.65), (532157.95 5121527.82 444.25), (532158.61 5121530.96 444.1), (532159.28 5121534.1 443.79), (532159.93 5121537.28 443.79), (532160.6 5121540.44 443.55), (532161.28 5121543.57 442.89), (532161.93 5121546.74 443.02), (532162.59 5121549.92 442.95), (532164 5121556.15 440.88), (532166.92 5121568.57 434.53), (532167.57 5121571.78 434.78), (532168.23 5121574.97 434.74), (532170.98 5121587.68 432.55), (532171.64 5121590.89 432.58), (532172.32 5121594.09 432.3), (532174.79 5121596.02 431.87), (532174.12 5121592.81 432.19), (532173.46 5121589.59 432.12), (532170.71 5121576.86 434.72), (532170.05 5121573.67 434.84), (532169.39 5121570.47 434.83), (532164.43 5121548.6 443.35), (532163.78 5121545.42 443.23), (532163.13 5121542.26 443.39), (532162.45 5121539.12 444), (532161.8 5121535.95 443.98), (532161.15 5121532.8 444.13), (532160.49 5121529.63 444.21), (532159.85 5121526.46 444.13), (532159.19 5121523.33 444.45), (532158.54 5121520.19 444.6), (532157.88 5121517.05 444.88), (532157.18 5121513.98 446.1), (532156.51 5121510.88 446.68), (532155.87 5121507.73 446.65), (532155.26 5121504.53 445.83), (532154.62 5121501.39 445.79), (532156.29 5121502.53 445.31), (532156.91 5121505.7 445.83), (532157.52 5121508.89 446.69), (532158.18 5121512.03 446.57), (532158.86 5121515.13 445.85), (532159.55 5121518.19 444.76), (532160.21 5121521.32 444.57), (532160.88 5121524.45 444.12), (532161.53 5121527.62 444.18), (532162.18 5121530.78 444.21), (532162.83 5121533.93 444.17), (532163.47 5121537.11 444.45), (532164.15 5121540.23 443.82), (532164.82 5121543.39 443.6), (532165.47 5121546.56 443.7), (532170.47 5121568.34 434.66), (532171.12 5121571.55 434.91), (532171.79 5121574.74 434.83), (532175.23 5121590.64 432.02), (532175.89 5121593.85 431.97), (532176.58 5121597.05 431.62), (532178.35 5121595.56 431.56), (532177.68 5121592.36 431.76), (532176.98 5121589.18 432.55), (532174.25 5121576.44 434.78), (532173.59 5121573.25 434.93), (532172.94 5121570.04 434.78), (532171.5 5121563.79 437.6), (532170.75 5121560.73 439.83), (532167.3 5121545.08 444.1), (532166.66 5121541.9 443.97), (532165.99 5121538.75 444.29), (532165.33 5121535.6 444.54), (532164.69 5121532.42 444.37), (532164.05 5121529.26 444.27), (532163.41 5121526.09 444.13), (532162.75 5121522.97 444.52), (532162.09 5121519.85 444.85), (532161.42 5121516.75 445.59), (532160.74 5121513.66 446.4), (532160.08 5121510.53 446.61), (532159.45 5121507.37 446.35), (532158.86 5121504.12 445.02), (532158.2 5121501.02 445.45), (532159.78 5121501.64 445.9), (532160.46 5121504.72 445.29), (532161.06 5121507.92 446.3), (532161.7 5121511.08 446.59), (532162.35 5121514.2 446.42), (532163.03 5121517.29 445.64), (532163.72 5121520.37 444.81), (532164.38 5121523.49 444.48), (532165.03 5121526.64 444.52), (532165.66 5121529.82 444.92), (532166.33 5121532.96 444.56), (532166.98 5121536.11 444.59), (532167.64 5121539.27 444.53), (532168.99 5121545.71 444.04), (532172.44 5121561.21 439.77), (532173.19 5121564.29 437.83), (532174.65 5121570.53 434.83), (532175.3 5121573.73 434.97), (532175.96 5121576.91 434.85), (532179.43 5121592.8 431.59), (532180.1 5121596.01 431.37), (532180.78 5121599.2 431.03), (532182.69 5121598.36 430.85), (532182.02 5121595.15 431.17), (532177.89 5121576.04 434.91), (532177.23 5121572.85 435.07), (532176.58 5121569.64 434.87), (532175.1 5121563.45 438.56), (532170.92 5121544.69 444.61), (532170.27 5121541.53 444.65), (532169.61 5121538.37 444.83), (532168.96 5121535.2 444.85), (532168.31 5121532.04 444.82), (532167.65 5121528.9 445.19), (532167.02 5121525.72 444.81), (532166.38 5121522.56 444.75), (532165.72 5121519.44 445.15), (532165.04 5121516.35 445.97), (532164.37 5121513.25 446.47), (532163.73 5121510.11 446.49), (532163.11 5121506.93 445.93), (532162.46 5121503.81 446.16), (532161.83 5121500.66 445.92), (532163.55 5121501.92 445.81), (532164.19 5121505.06 445.86), (532164.83 5121508.22 446.15), (532165.46 5121511.38 446.48), (532166.11 5121514.5 446.39), (532166.79 5121517.59 445.74), (532167.46 5121520.7 445.26), (532168.12 5121523.83 444.93), (532168.77 5121526.99 445.08), (532169.41 5121530.16 445.18), (532170.07 5121533.31 445.14), (532170.74 5121536.45 444.74), (532171.38 5121539.62 444.87), (532172.04 5121542.78 444.93), (532176.94 5121564.65 438.04), (532177.71 5121567.72 435.79), (532178.4 5121570.88 435), (532179.06 5121574.08 435.07), (532179.73 5121577.29 434.97), (532183.9 5121596.36 430.85), (532184.59 5121599.57 430.5), (532186.24 5121597.29 430.48), (532183.42 5121584.58 434.28), (532182.07 5121578.2 435.06), (532181.41 5121575 435.11), (532180.75 5121571.79 435.12), (532180.07 5121568.63 435.68), (532174.42 5121543.67 444.96), (532173.78 5121540.5 444.88), (532173.12 5121537.35 445.01), (532172.45 5121534.2 445.48), (532171.82 5121531.03 445.23), (532171.17 5121527.86 445.14), (532170.53 5121524.71 445.1), (532169.88 5121521.56 445.2), (532169.21 5121518.44 445.66), (532168.54 5121515.34 446.32), (532167.89 5121512.21 446.47), (532167.25 5121509.05 446.27), (532166.62 5121505.89 445.95), (532165.97 5121502.76 446.12), (532167.16 5121501.28 445.98), (532167.82 5121504.42 445.95), (532168.46 5121507.58 446.1), (532169.09 5121510.74 446.43), (532169.74 5121513.87 446.36), (532170.41 5121516.98 445.9), (532171.08 5121520.1 445.45), (532171.75 5121523.23 445.13), (532172.39 5121526.41 445.32), (532173.03 5121529.58 445.53), (532173.68 5121532.74 445.66), (532174.35 5121535.87 445.19), (532175.01 5121539.03 445.07), (532175.67 5121542.18 444.84), (532176.33 5121545.34 444.69), (532182.03 5121570.32 435.16), (532182.7 5121573.52 435.15), (532183.36 5121576.72 435.06), (532184.7 5121583.11 434.72), (532188.24 5121599 430.15), (532190.23 5121597.93 429.92), (532188.1 5121588.41 433.12), (532186.7 5121582.07 434.89), (532186.03 5121578.89 435.24), (532185.38 5121575.69 435.16), (532184.72 5121572.5 435.18), (532184.06 5121569.3 435.29), (532179.1 5121547.49 443.88), (532177.75 5121541.21 444.91), (532177.09 5121538.05 445.17), (532176.44 5121534.9 445.33), (532175.78 5121531.76 445.58), (532175.13 5121528.6 445.48), (532174.49 5121525.44 445.45), (532173.85 5121522.28 445.35), (532173.19 5121519.14 445.61), (532172.52 5121516.04 446.13), (532171.87 5121512.91 446.32), (532171.23 5121509.78 446.34), (532170.6 5121506.64 446.18), (532169.95 5121503.51 446.21), (532169.31 5121500.38 446.17), (532170.93 5121501.29 446.4), (532171.58 5121504.43 446.36), (532172.24 5121507.57 446.23), (532172.89 5121510.73 446.28), (532173.54 5121513.88 446.26), (532174.2 5121517.01 445.94), (532174.87 5121520.15 445.72), (532175.54 5121523.27 445.1), (532176.18 5121526.46 445.57), (532176.83 5121529.63 445.54), (532177.48 5121532.81 445.63), (532178.15 5121535.96 445.33), (532178.81 5121539.13 445.25), (532179.48 5121542.29 444.84), (532180.16 5121545.44 444.46), (532180.85 5121548.58 443.75), (532185.86 5121570.52 435.2), (532186.52 5121573.73 435.26), (532187.19 5121576.93 435.2), (532189.97 5121589.68 432.56), (532192.12 5121599.24 429.55), (532191.66 5121587.49 433.16), (532190.27 5121581.15 434.86), (532189.59 5121577.98 435.29), (532188.94 5121574.78 435.27), (532188.28 5121571.58 435.29), (532183.34 5121549.7 443.22), (532182.66 5121546.57 443.9), (532181.31 5121540.3 445.05), (532180 5121534 445.48), (532179.33 5121530.88 446.02), (532178.05 5121524.54 445.65), (532177.4 5121521.4 445.72), (532176.75 5121518.26 445.87), (532176.1 5121515.13 446.12), (532175.45 5121512 446.24), (532174.81 5121508.85 446.12), (532174.16 5121505.73 446.26), (532173.51 5121502.61 446.46), (532174.77 5121501.39 446.47), (532175.41 5121504.53 446.61), (532176.08 5121507.64 446.18), (532176.73 5121510.78 446.17), (532177.38 5121513.93 446.22), (532178.05 5121517.06 445.87), (532178.7 5121520.22 445.9), (532179.34 5121523.38 446), (532182 5121535.99 445.2), (532182.66 5121539.14 444.95), (532184.01 5121545.45 444.21), (532189.7 5121570.49 435.24), (532190.36 5121573.69 435.33), (532191.02 5121576.9 435.31), (532193.11 5121586.44 433.27), (532196.97 5121594.52 430.81), (532196.25 5121591.37 432.16), (532195.6 5121588.16 432.04), (532194.89 5121585 433.12), (532192.81 5121575.51 435.37), (532192.16 5121572.31 435.33), (532191.51 5121569.13 435.38), (532187.94 5121553.57 441.94), (532186.56 5121547.33 443.71), (532185.88 5121544.21 444.45), (532185.21 5121541.09 444.98), (532184.56 5121537.93 445.1), (532183.89 5121534.78 445.38), (532183.22 5121531.67 446.04), (532181.28 5121522.2 445.97), (532180.65 5121519.04 445.67), (532179.99 5121515.92 446.02), (532179.35 5121512.78 446.06), (532178.7 5121509.64 446.16), (532178.05 5121506.51 446.23), (532177.4 5121503.39 446.46), (532176.76 5121500.27 446.49), (532178.44 5121500.92 446.39), (532179.09 5121504.07 446.43), (532179.75 5121507.21 446.29), (532180.41 5121510.34 446.05), (532181.06 5121513.5 446.04), (532181.73 5121516.65 445.82), (532182.38 5121519.8 445.75), (532183.02 5121523 446.21), (532184.33 5121529.34 446.21), (532185 5121532.47 445.77), (532185.68 5121535.62 445.37), (532186.35 5121538.78 444.96), (532187.7 5121545.09 444.27), (532188.4 5121548.22 443.24), (532189.1 5121551.35 442.31), (532190.51 5121557.62 440.46), (532191.25 5121560.73 438.72), (532193.39 5121570.16 435.36), (532194.05 5121573.38 435.45), (532194.72 5121576.59 435.41), (532196.83 5121586.09 432.82), (532198.21 5121592.48 431.8), (532198.92 5121595.66 430.94), (532198.37 5121583.5 433.44), (532196.95 5121577.19 435.58), (532196.3 5121573.99 435.54), (532195.65 5121570.79 435.42), (532194.99 5121567.6 435.42), (532193.53 5121561.39 438.74), (532192.85 5121558.22 439.27), (532192.14 5121555.1 440.45), (532191.4 5121552.02 442.24), (532190.72 5121548.89 442.97), (532190.01 5121545.78 444.13), (532188.69 5121539.48 444.72), (532188.03 5121536.33 444.94), (532187.35 5121533.2 445.64), (532186.69 5121530.05 445.74), (532184.75 5121520.57 445.81), (532184.11 5121517.41 445.62), (532183.45 5121514.29 445.89), (532182.81 5121511.13 445.75), (532182.15 5121508.01 446.25), (532181.48 5121504.91 446.72), (532180.85 5121501.75 446.47), (532182.04 5121500.11 446.86), (532182.67 5121503.3 447.35), (532183.34 5121506.42 446.85), (532184.02 5121509.53 446.27), (532184.69 5121512.65 445.8), (532185.35 5121515.81 445.7), (532186.01 5121518.97 445.56), (532187.96 5121528.5 445.96), (532188.63 5121531.66 445.7), (532189.3 5121534.8 445.27), (532189.99 5121537.92 444.53), (532190.66 5121541.08 444.22), (532191.34 5121544.24 443.89), (532192.03 5121547.39 443.23), (532192.75 5121550.51 441.9), (532193.45 5121553.64 440.89), (532194.17 5121556.77 439.69), (532194.85 5121559.94 439.29), (532196.31 5121566.18 436.33), (532197.02 5121569.35 435.44), (532197.68 5121572.56 435.51), (532198.34 5121575.77 435.5), (532199.91 5121572.69 435.59), (532199.26 5121569.48 435.53), (532198.6 5121566.31 435.72), (532197.14 5121560.09 438.8), (532196.45 5121556.94 439.65), (532193.01 5121541.25 443.37), (532192.32 5121538.13 444.28), (532191.64 5121535.01 444.91), (532188.36 5121519.28 445.86), (532187.72 5121516.11 445.57), (532187.07 5121512.97 445.69), (532186.4 5121509.86 446.19), (532185.73 5121506.75 446.76), (532185.08 5121503.62 446.89), (532184.43 5121500.48 446.94), (532185.99 5121500.82 446.83), (532186.62 5121503.97 447.11), (532187.28 5121507.08 446.81), (532187.96 5121510.18 446.12), (532188.64 5121513.28 445.57), (532189.29 5121516.42 445.43), (532189.93 5121519.61 445.85), (532192.56 5121532.2 445.36), (532193.94 5121538.43 443.78), (532194.61 5121541.59 443.47), (532195.98 5121547.86 442.2), (532196.68 5121550.98 441.28), (532197.41 5121554.09 439.7), (532198.08 5121557.27 439.48), (532198.78 5121560.41 438.62), (532199.87 5121554.98 439.73), (532198.48 5121548.7 441.49), (532196.42 5121539.27 443.58), (532195.74 5121536.14 444.26), (532195.06 5121533.01 444.94), (532191.81 5121517.18 444.96), (532191.13 5121514.07 445.51), (532190.49 5121510.9 445.36), (532189.78 5121507.86 446.94), (532189.12 5121504.73 447.29), (532188.49 5121501.56 446.86), (532189.74 5121500.23 446.82), (532190.38 5121503.39 447), (532191.03 5121506.56 447.2), (532191.73 5121509.61 445.95), (532192.41 5121512.71 445.36), (532193.06 5121515.85 445.24), (532193.7 5121519.03 445.5), (532197.02 5121534.76 444.51), (532197.71 5121537.86 443.56), (532198.39 5121541 443.13), (532199.07 5121544.12 442.49), (532199.77 5121547.25 441.62), (532199.88 5121537.4 443.28), (532199.19 5121534.28 444.17), (532195.89 5121518.52 445.33), (532195.25 5121515.35 445.13), (532194.6 5121512.2 445.24), (532193.92 5121509.09 445.91), (532193.22 5121506.04 447.22), (532192.56 5121502.9 447.35), (532193.82 5121501.64 446.99), (532195.14 5121507.88 446.49), (532195.86 5121510.89 444.91), (532196.5 5121514.04 445.17), (532197.17 5121517.14 444.63), (532199.43 5121516.94 444.53), (532198.76 5121513.83 445.05), (532198.13 5121510.64 444.74), (532197.41 5121507.59 446.2), (532196.08 5121501.38 447.26), (532197.97 5121503.1 447.2), (532198.64 5121506.22 446.86), (532199.36 5121509.24 445.27))"), 26910); SqlParameter Points = new SqlParameter("@MultiPoint", WolfPoint); Points.UdtTypeName = "geometry"; comm.Parameters.Add(Points); try { // Open the connection conn.Open(); // Execute the procedure SqlDataReader dataReader = comm.ExecuteReader(); // Loop through the results while (dataReader.Read()) { // First column in the results contains geometry triangles SqlGeometry tri = SqlGeometry.Deserialize(dataReader.GetSqlBytes(0)); // Loop through each vertex of this triangle for (int n = 1; n <= 3; n++) { SqlGeometry point = tri.STPointN(n); double X = (double)point.STX; double Y = (double)point.STY; double Z = point.HasZ ? (double)point.Z : 0; if (smooth) { /** * Option A - Smooth mesh * Use this code to add only distinct vertices to the mesh */ Point3D p3d = new Point3D(X, Z, -Y); int idx = mesh.Positions.IndexOf(p3d); // This point hasn't been added yet, so add it to the Positions array if (idx == -1) { mesh.Positions.Add(p3d); mesh.TextureCoordinates.Add(new Point(X, -Y)); mesh.TriangleIndices.Add(mesh.Positions.Count - 1); } // The point already exists, so just added a reference to it to the triangle indices array else { mesh.TriangleIndices.Add(idx); } } else { /** * Option B - Hard edge mesh * Use this code to add all vertices to the mesh, which will duplicate any shared vertices */ mesh.Positions.Add(new Point3D(X, Z, -Y)); mesh.TextureCoordinates.Add(new Point(X, -Y)); } } } // All points added to the mesh, so close the reader dataReader.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } // Display some info about the mesh info.Text = "Vertices:" + mesh.Positions.Count + " Faces: " + (smooth ? mesh.TriangleIndices.Count / 3 : mesh.Positions.Count / 3); // Define a simple material with which to render the geometry Material mat = new DiffuseMaterial(Brushes.SlateGray); /* * // Or, add a texture map to the model * ImageBrush imgBrush = new ImageBrush(); * imgBrush.ImageSource = new BitmapImage(new Uri(@"http://www.example.com/texture.jpg", UriKind.Absolute)); * Material mat = new DiffuseMaterial(imgBrush); */ // Create a new 3d Model using the mesh and material geomModel = new GeometryModel3D(mesh, mat); // Add a transform so we can rotate/transform/scale the model geomModel.Transform = new Transform3DGroup(); // Add the model to the scene group.Children.Add(geomModel); // Calculate the camera position Rect3D r = group.Children[1].Bounds; // Look at the midpoint of the model lookAt = new Point3D(r.X + (r.SizeX / 2), r.Y + (r.SizeY / 2), r.Z + (r.SizeZ / 2)); // Locate the camera in middle front and slightly above the model this.camera.Position = new Point3D(r.X + (r.SizeX / 2) - 10, r.Y + (r.SizeY * 2) + 20, r.Z + (r.SizeZ * 1.2) + 5); // Work out the vector from the camera to the point of focus this.camera.LookDirection = new Vector3D(lookAt.X - this.camera.Position.X, lookAt.Y - this.camera.Position.Y, lookAt.Z - this.camera.Position.Z); // Add a transform so we can rotate/transform the camera this.camera.Transform = new MatrixTransform3D(); }
public override void CalcHitBBox() { HitBBox = new Rect3D(P.X, P.X, P.Y, P.Y, P.Z, P.Z); }
/// <summary> /// Transforms the bounding box to the smallest axis aligned bounding box /// that contains all the points in the original bounding box /// </summary> /// <param name="rect">Bounding box</param> /// <returns>The transformed bounding box</returns> public override Rect3D TransformBounds(Rect3D rect) { throw new NotImplementedException(); }
public Lot(string category, int level, Rect3D bounds) { Category = category; Level = level; Bounds = bounds; }
private void InitializeModelScene(Scene scene, Rect3D rect3D, OpenGLControl sceneControl, ArcBallEffect arcBallEffect) { float centerX = rect3D.X + rect3D.Size.x / 2.0f; float centerY = rect3D.Y + rect3D.Size.y / 2.0f; float centerZ = rect3D.Z + rect3D.Size.z / 2.0f; //scene.CreateInContext(scenContor); Vertex center = new Vertex(centerX, centerY, centerZ); Vertex position = center + new Vertex(0.0f, 0.0f, 1.0f) * (rect3D.Size.z * 2); Vertex PositionNear = center + new Vertex(0.0f, 0.0f, 1.0f) * (rect3D.Size.z * 0.52f); //arcBallEffect. var lookAtCamera = new LookAtCamera() { Position = position, Target = center, UpVector = new Vertex(0f, 1f, 0f), FieldOfView = 60, AspectRatio = 1.0f, Near = (PositionNear - center).Z, Far = float.MaxValue }; scene.CurrentCamera = lookAtCamera; Vertex lightPosition = center; Light light1 = new Light() { Name = "Light 1", On = true, Position = lightPosition, GLCode = OpenGL.GL_LIGHT0 }; /* * Light light2 = new Light() * { * Name = "Light 2", * On = true, * Position = center + new Vertex(1.0f,0.0f,0.0f)* rect3D.Size.x, * GLCode = OpenGL.GL_LIGHT1 * }; * * Light light3 = new Light() * { * Name = "Light 3", * On = true, * Position = center + new Vertex(0.0f,1.0f,0.0f)*rect3D.Size.y, * GLCode = OpenGL.GL_LIGHT2 * }; */ var folder = new Folder() { Name = "Lights" }; //folder.AddChild(light1); //folder.AddChild(light2); //folder.AddChild(light3); scene.SceneContainer.AddChild(folder); // Create a set of scene attributes. OpenGLAttributesEffect sceneAttributes = new OpenGLAttributesEffect() { Name = "Scene Attributes" }; // Specify the scene attributes. sceneAttributes.EnableAttributes.EnableDepthTest = true; sceneAttributes.EnableAttributes.EnableNormalize = true; //sceneAttributes.EnableAttributes.EnableLighting = true; sceneAttributes.EnableAttributes.EnableTexture2D = true; sceneAttributes.EnableAttributes.EnableBlend = true; sceneAttributes.ColorBufferAttributes.BlendingSourceFactor = BlendingSourceFactor.SourceAlpha; sceneAttributes.ColorBufferAttributes.BlendingDestinationFactor = BlendingDestinationFactor.OneMinusSourceAlpha; sceneAttributes.LightingAttributes.TwoSided = true; scene.SceneContainer.AddEffect(sceneAttributes); sceneControl.OpenGL.SetDimensions(sceneControl.Width, sceneControl.Height); scene.Resize(sceneControl.Width, sceneControl.Height); }
protected override void OnUpdateModel() { BoiteEnglobante = P_Model.Bounds; base.OnUpdateModel(); }
public static Point3D GetCenter(Point3DCollection Points) { Rect3D bounds = Extents(Points); return(new Point3D(bounds.X + (bounds.SizeX / 2), bounds.Y + (bounds.SizeY / 2), bounds.Z + (bounds.SizeZ / 2))); }
public static Camera CreateEnclosingPerspectiveCamera(double horizontalFieldOfView, double aspectRatio, Rect3D bounds, double scaleRatio) { double num1 = horizontalFieldOfView * Math.PI / 180.0; double num2 = Math.Atan(Math.Tan(num1 / 2.0) / aspectRatio) * 2.0; Vector3D vector3D; if (bounds.IsEmpty) { vector3D = new Vector3D(0.0, 0.0, 0.0); bounds = new Rect3D(-1.0, -1.0, -1.0, 2.0, 2.0, 2.0); } else { vector3D = new Vector3D(bounds.X + bounds.SizeX / 2.0, bounds.Y + bounds.SizeY / 2.0, bounds.Z + bounds.SizeZ / 2.0); } PerspectiveCamera perspectiveCamera = new PerspectiveCamera(); perspectiveCamera.FieldOfView = horizontalFieldOfView; perspectiveCamera.UpDirection = new Vector3D(0.0, 1.0, 0.0); double num3 = bounds.SizeX / 2.0; double num4 = bounds.SizeY / 2.0; double num5 = Math.Max(num3 / scaleRatio / Math.Tan(num1 / 2.0), num4 / scaleRatio / Math.Tan(num2 / 2.0)); perspectiveCamera.Position = new Point3D(vector3D.X, vector3D.Y, bounds.Z + bounds.SizeZ + num5); perspectiveCamera.LookDirection = new Point3D(vector3D.X, vector3D.Y, vector3D.Z) - perspectiveCamera.Position; perspectiveCamera.NearPlaneDistance = 0.1; perspectiveCamera.FarPlaneDistance = Math.Max(100.0, 3.0 * num5); return((Camera)perspectiveCamera); }
public HitQuadTree(List <HitObject> hitObjects, Rect3D bounds) { HitObjects = hitObjects; CreateNextLevel(bounds, 0, 0); }
/// <summary> /// Rectを作成します。 /// </summary> public static Rect MakeRectXY(Rect3D r) { return(new Rect(r.X, r.Y, r.SizeX, r.SizeY)); }
private void CreateNextLevel(Rect3D bounds, int level, int levelEmpty) { if (HitObjects.Count <= 4) { //!! magic return; } IsLeaf = false; Center.X = (bounds.Left + bounds.Right) * 0.5f; Center.Y = (bounds.Top + bounds.Bottom) * 0.5f; Center.Z = (bounds.ZLow + bounds.ZHigh) * 0.5f; for (var i = 0; i < 4; i++) { Children[i] = new HitQuadTree(); } List <HitObject> vRemain = new List <HitObject>(); // hit objects which did not go to a quadrant // TODO check if casting in C++ results in null if not the cast type _unique = HitObjects[0].E ? HitObjects[0].Obj : null; // sort items into appropriate child nodes foreach (var hitObject in HitObjects) { int oct; if ((hitObject.E ? hitObject.Obj : null) != _unique) { // are all objects in current node unique/belong to the same primitive? _unique = null; } if (hitObject.HitBBox.Right < Center.X) { oct = 0; } else if (hitObject.HitBBox.Left > Center.X) { oct = 1; } else { oct = 128; } if (hitObject.HitBBox.Bottom < Center.Y) { oct |= 0; } else if (hitObject.HitBBox.Top > Center.Y) { oct |= 2; } else { oct |= 128; } if ((oct & 128) == 0) { Children[oct].HitObjects.Add(hitObject); } else { vRemain.Add(hitObject); } } // m_vho originally.Swap(vRemain); - but vRemain isn't used below. HitObjects = vRemain; // check if at least two nodes feature objects, otherwise don't bother subdividing further var countEmpty = HitObjects.Count == 0 ? 1 : 0; for (var i = 0; i < 4; ++i) { if (Children[i].HitObjects.Count == 0) { ++countEmpty; } } if (countEmpty >= 4) { ++levelEmpty; } else { levelEmpty = 0; } if (Center.X - bounds.Left > 0.0001 //!! magic && levelEmpty <= 8 && // If 8 levels were all just subdividing the same objects without luck, exit & Free the nodes again (but at least empty space was cut off) level + 1 < 128 / 3) { for (var i = 0; i < 4; ++i) { var childBounds = new Rect3D { Left = (i & 1) != 0 ? Center.X : bounds.Left, Top = (i & 2) != 0 ? Center.Y : bounds.Top, ZLow = bounds.ZLow, Right = (i & 1) != 0 ? bounds.Right : Center.X, Bottom = (i & 2) != 0 ? bounds.Bottom : Center.Y, ZHigh = bounds.ZHigh }; Children[i].CreateNextLevel(childBounds, level + 1, levelEmpty); } } }
private void AdjustCamera(Camera camera, Model3DGroup scene) { ProjectionCamera pc = camera as ProjectionCamera; if (pc == null) { // Can't adjust MatrixCamera return; } if (double.IsNaN(pc.NearPlaneDistance) || double.IsNaN(pc.FarPlaneDistance) || double.IsPositiveInfinity(pc.NearPlaneDistance) || double.IsNegativeInfinity(pc.FarPlaneDistance) || pc.NearPlaneDistance > pc.FarPlaneDistance) { // Don't render, and don't use NaN. pc.NearPlaneDistance = double.MaxValue; pc.FarPlaneDistance = double.MaxValue; return; } bool adjustNearPlane = double.IsNegativeInfinity(pc.NearPlaneDistance); bool adjustFarPlane = double.IsPositiveInfinity(pc.FarPlaneDistance); if (!adjustNearPlane && !adjustFarPlane) { // Camera is fine. Leave it alone. return; } Matrix3D view = MatrixUtils.ViewMatrix(this.camera); Rect3D sceneBounds = ModelBounder.CalculateBounds(scene, view); if (sceneBounds.IsEmpty) { // It doesn't really matter what these are since there's nothing in the scene. // But I do like to avoid infinity... pc.NearPlaneDistance = double.MaxValue; pc.FarPlaneDistance = double.MaxValue; } else { // sceneBounds is aligned to the axes defined by the camera's view matrix, // but it's facing the wrong way! // // +-----------+ // |sceneBounds| // o---|-----------|---> look direction (-z axis) // | | // +-----------+ // ^ ^ // Z+sizeZ Z // // o is the camera position (also origin; z == 0) // This works regardless of the camera's position relative to the sceneBounds double np = pc.NearPlaneDistance; double fp = pc.FarPlaneDistance; double zBufferEpsilon = Math.Pow(2, -10); // Add a little padding to the scene bounds double sceneNearClip = -(sceneBounds.Z + sceneBounds.SizeZ + zBufferEpsilon); double sceneFarClip = -(sceneBounds.Z - zBufferEpsilon); // Shrink the user specified clipping planes to the tightest fit around // the scene without modifying what is visible. // Do not expand user's clipping plane values (unless we need a little more zBuffer tolerance)! if (adjustFarPlane) { pc.FarPlaneDistance = sceneFarClip; } if (adjustNearPlane) { pc.NearPlaneDistance = sceneNearClip; } if (pc.NearPlaneDistance > pc.FarPlaneDistance) { // Don't render. pc.NearPlaneDistance = double.MaxValue; pc.FarPlaneDistance = double.MaxValue; return; } if (pc is PerspectiveCamera && pc.NearPlaneDistance <= 0) { // We don't currently handle this case correctly. Just don't crash. pc.NearPlaneDistance = 0.125; } AdjustCameraTolerance(pc, adjustNearPlane, adjustFarPlane); } }
public void Readjust(Rect3D bounds) { Readjust(new Point3D(bounds.X, bounds.Y, bounds.Z)); Readjust(new Point3D(bounds.X + bounds.SizeX, bounds.Y + bounds.SizeY, bounds.Z + bounds.SizeZ)); }
/// <summary> /// Zooms to fit the specified bounding rectangle. /// </summary> /// <param name="camera"> /// The camera to change. /// </param> /// <param name="viewport"> /// The viewport. /// </param> /// <param name="bounds"> /// The bounding rectangle. /// </param> /// <param name="animationTime"> /// The animation time. /// </param> public static void ZoomExtents(this ProjectionCamera camera, Viewport3D viewport, Rect3D bounds, double animationTime = 0) { var diagonal = new Vector3D(bounds.SizeX, bounds.SizeY, bounds.SizeZ); var center = bounds.Location + (diagonal * 0.5); double radius = diagonal.Length * 0.5; ZoomExtents(camera, viewport, center, radius, animationTime); }
// This function returns true if the probe line intersects the bbox volume (not // just the surface of the box). Does LINE and RAY intersection tests. // // Based on Woo's method presented in Gems I, p. 395. See also "Real-Time // Rendering", Haines, sec 10.4.2. // // origin/direction define the non-oriented line or ray // box is the volume to intersect // // origin, direction, and box are passed by ref for perf. They are NOT MODIFIED // // Ported from dxg\d3dx9\mesh\intersect.cpp (12/04/03) internal static bool ComputeLineBoxIntersection(ref Point3D origin, ref Vector3D direction, ref Rect3D box, bool isRay) { // Reject empty bounding boxes. if (box.IsEmpty) { return(false); } bool inside = true; bool[] middle = new bool[3]; // True if ray origin in middle for coord i. double[] plane = new double[3]; // Candidate BBox Planes int i; // General Loop Counter // Find all candidate planes; select the plane nearest to the ray origin // for each coordinate. double[] rgfMin = new double[] { box.X, box.Y, box.Z }; double[] rgfMax = new double[] { box.X + box.SizeX, box.Y + box.SizeY, box.Z + box.SizeZ }; double[] rgfRayPos = new double[] { origin.X, origin.Y, origin.Z }; double[] rgfRayDir = new double[] { direction.X, direction.Y, direction.Z }; for (i = 0; i < 3; ++i) { if (rgfRayPos[i] < rgfMin[i]) { middle[i] = false; plane[i] = rgfMin[i]; inside = false; } else if (rgfRayPos[i] > rgfMax[i]) { middle[i] = false; plane[i] = rgfMax[i]; inside = false; } else { middle[i] = true; } } // If the ray origin is inside the box, then it must intersect the volume // of the bounding box. if (inside) { return(true); } double rayt; if (isRay) { // If we never end up finding the furthest plane, the box will be // rejected since rayt is negative rayt = -1; } else { // Can't use -1 in the line case because rayt^2 is 1 and we // would miss valid ts in the furthest plane search rayt = 0; } int maxPlane = 0; for (i = 0; i < 3; ++i) { if (!middle[i] && (rgfRayDir[i] != 0)) { double t = (plane[i] - rgfRayPos[i]) / rgfRayDir[i]; if (isRay) { if (t > rayt) { rayt = t; maxPlane = i; } } else { // In the original ray algorithm this test to find the furthest plane from the // origin was t > rayt which only considered planes in the positive direction. // I changed it to compare squared values so that we look for the farthest // plane in either direction. // Note that if the line intersects the box then all of the planes considered // in this loop must be on the same side of the origin (because we are finding // the intersection of the line with the space formed by the intersection of // the half-spaces formed by the planes -- which incidentally point away from // the origin.) if (t * t > rayt * rayt) { rayt = t; maxPlane = i; } } } } // If the box is behind the ray, or if the box is beyond the extent of the // ray, then return no-intersect. if (isRay && rayt < 0) { return(false); } // The intersection candidate point is within acceptible range; test each // coordinate here to ensure that it actually hits the box. for (i = 0; i < 3; ++i) { if (i != maxPlane) { double c = rgfRayPos[i] + (rayt * rgfRayDir[i]); if ((c < rgfMin[i]) || (rgfMax[i] < c)) { return(false); } } } return(true); }
public BindableSize3DModel(Rect3D size) { _size = size.IsEmpty ? new Size3D() : new Size3D(size.SizeX, size.SizeY, size.SizeZ); }
private void UpdateScene() { _originalModelVisual3D = null; _originalModel3D = null; _originalMesh3D = null; _model3DFor2DSlice = null; RootModelVisual3D.Children.Clear(); WireframeModels1.OriginalModel = null; WireframeModels2.OriginalModel = null; if (Model1RadioButton.IsChecked ?? false) { // Use ObjModelVisual3D to load robotarm.obj and then read its Content to get Model3D var objModelVisual3D = new ObjModelVisual3D() { Source = new Uri("pack://application:,,,/Ab3d.PowerToys.Samples;component/Resources/ObjFiles/robotarm.obj", UriKind.Absolute), SizeX = 100, Position = new Point3D(0, 0, 0), PositionType = ObjModelVisual3D.VisualPositionType.BottomCenter }; _originalModel3D = objModelVisual3D.Content; _modelBounds = _originalModel3D.Bounds; } else if (Model2RadioButton.IsChecked ?? false) { _originalMesh3D = new Ab3d.Meshes.SphereMesh3D(new Point3D(0, 0, 0), 50, 20).Geometry; _modelBounds = _originalMesh3D.Bounds; } else if (Model3RadioButton.IsChecked ?? false) { _originalModelVisual3D = new ModelVisual3D(); _originalModelVisual3D.Children.Add(new Ab3d.Visuals.PyramidVisual3D() { BottomCenterPosition = new Point3D(-280, -60, 0), Size = new Size3D(120, 120, 120), Material = new DiffuseMaterial(Brushes.Green) }); _originalModelVisual3D.Children.Add(new Ab3d.Visuals.BoxVisual3D() { CenterPosition = new Point3D(-100, 0, 0), Size = new Size3D(120, 120, 60), Material = new DiffuseMaterial(Brushes.Green) }); _originalModelVisual3D.Children.Add(new Ab3d.Visuals.TubeVisual3D() { BottomCenterPosition = new Point3D(80, -60, 0), InnerRadius = 40, OuterRadius = 60, Height = 120, Material = new DiffuseMaterial(Brushes.Green) }); _originalModelVisual3D.Children.Add(new Ab3d.Visuals.SphereVisual3D() { CenterPosition = new Point3D(240, 0, 0), Radius = 60, Material = new DiffuseMaterial(Brushes.Green) }); _modelBounds = new Rect3D(); foreach (var visual3D in _originalModelVisual3D.Children.OfType <ModelVisual3D>()) { _modelBounds.Union(visual3D.Content.Bounds); } } _rootModelSize = Math.Sqrt(_modelBounds.SizeX * _modelBounds.SizeX + _modelBounds.SizeY * _modelBounds.SizeY + _modelBounds.SizeZ * _modelBounds.SizeZ); Camera1.Distance = 2 * _rootModelSize; }
public void ShowData(List <SphereData> originalData, Rect3D displayedDataBounds, Rect xyDataRange) { // Now use original data to create our data view objects // All data will be displayed in a 3D box defined below: //var displayedDataBounds = new Rect3D(AxesBox.CenterPosition.X - AxesBox.Size.X * 0.5, // AxesBox.CenterPosition.Y - AxesBox.Size.Y * 0.5, // AxesBox.CenterPosition.Z - AxesBox.Size.Z * 0.5, // AxesBox.Size.X, // AxesBox.Size.Y, // AxesBox.Size.Z); _allSpheresData = new List <SphereDataView>(originalData.Count); foreach (var originalSphereData in originalData) { // Set color of the sphere based on its y position // We choose the color from the gradient defined in EnsureGradientColorsArray double relativeY = (originalSphereData.Location.Y - xyDataRange.Y) / xyDataRange.Height; int colorArrayIndex = (int)(relativeY * (_gradientColorsArray.Length - 1)); Color color = _gradientColorsArray[colorArrayIndex]; var sphereDataView = SphereDataView.Create(originalSphereData, displayedDataBounds, originalData.Count, xyDataRange, color); sphereDataView.IsSelectedChanged += delegate(object sender, EventArgs args) { var changedPositionDataView = (SphereDataView)sender; if (changedPositionDataView.IsSelected) { DataListBox.SelectedItems.Add(changedPositionDataView); } else { DataListBox.SelectedItems.Remove(changedPositionDataView); } UpdateSelectedSpheresData(); }; _allSpheresData.Add(sphereDataView); } // Bind positions data to ListBox DataListBox.ItemsSource = _allSpheresData; // Create curve through all positions // This is done by first creating all points that define the curve (10 points between each position that define the curve) List <Point3D> allPositions = new List <Point3D>(); foreach (var positionData in _allSpheresData) { allPositions.Add(positionData.Position); } BezierCurve bezierCurve = Ab3d.Utilities.BezierCurve.CreateFromCurvePositions(allPositions); Point3DCollection curvePoints = bezierCurve.CreateBezierCurve(positionsPerSegment: 10); // How many points between each defined position in the curve // Create 3D Polyline from curvePoints Model3D curveModel = Ab3d.Models.Line3DFactory.CreatePolyLine3D(curvePoints, thickness: 2, color: Colors.Blue, isClosed: false, startLineCap: LineCap.Flat, endLineCap: LineCap.Flat, parentViewport3D: MainViewport); CurveModelVisual.Content = curveModel; // Now create 3D sphere objects for each position SpheresModelVisual.Children.Clear(); // Each sphere will also need MouseEnter, MouseLeave and MouseClick event handlers // We use EventManager3D for that var eventManager3D = new Ab3d.Utilities.EventManager3D(MainViewport); // Add 3D sphere for each position foreach (var positionData in _allSpheresData) { SpheresModelVisual.Children.Add(positionData.ModelVisual3D); // Sphere Visual3D is created in SphereDataView object // Add event handlers (sphere Visual3D will be the source of the events) var visualEventSource3D = new VisualEventSource3D(positionData.ModelVisual3D); visualEventSource3D.MouseEnter += delegate(object sender, Mouse3DEventArgs e) { if (_isSelecting) { return; } // Use hand cursor Mouse.OverrideCursor = Cursors.Hand; // Find selected position data var selectedPositionData = _allSpheresData.FirstOrDefault(p => p.ModelVisual3D == e.HitObject); SelectData(selectedPositionData, e.CurrentMousePosition); }; visualEventSource3D.MouseLeave += delegate(object sender, Mouse3DEventArgs e) { if (_isSelecting) { return; } Mouse.OverrideCursor = null; DataToolTipBorder.Visibility = Visibility.Collapsed; DataToolTipBorder.DataContext = null; SelectedSphereLinesVisual.Children.Clear(); }; visualEventSource3D.MouseClick += delegate(object sender, MouseButton3DEventArgs e) { // Select / deselect on mouse click var clickedPositionData = _allSpheresData.FirstOrDefault(p => p.ModelVisual3D == e.HitObject); if (clickedPositionData != null) { positionData.IsSelected = !clickedPositionData.IsSelected; } }; // Register the event source eventManager3D.RegisterEventSource3D(visualEventSource3D); } }
private Model3D CreateModel() { var viewport = this.GetViewport3D(); var plotModel = new Model3DGroup(); var Children = plotModel.Children; plotModel.Children = null; int rows = Points.GetUpperBound(0) + 1; int columns = Points.GetUpperBound(1) + 1; double minX = double.MaxValue; double maxX = double.MinValue; double minY = double.MaxValue; double maxY = double.MinValue; double minZ = double.MaxValue; double maxZ = double.MinValue; double minColorValue = double.MaxValue; double maxColorValue = double.MinValue; for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { double x = Points[i, j].X; double y = Points[i, j].Y; double z = Points[i, j].Z; if (x == 0 && y == 0 && z == 0) { continue; } maxX = Math.Max(maxX, x); maxY = Math.Max(maxY, y); maxZ = Math.Max(maxZ, z); minX = Math.Min(minX, x); minY = Math.Min(minY, y); minZ = Math.Min(minZ, z); if (ColorValues != null) { maxColorValue = Math.Max(maxColorValue, ColorValues[i, j]); minColorValue = Math.Min(minColorValue, ColorValues[i, j]); } } } IntervalX = (maxX - minX) / 6.0; IntervalY = (maxY - minY) / 6.0; IntervalZ = (maxZ - minZ) / 1.0; FontSize = 0.03; var FontScale = 1; LineThickness = 0.005; // make color value 0 at texture coordinate 0.5 if (Math.Abs(minColorValue) < Math.Abs(maxColorValue)) { minColorValue = -maxColorValue; } else { maxColorValue = -minColorValue; } // set the texture coordinates by z-value or ColorValue var texcoords = new Point[rows, columns]; for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { double u = (Points[i, j].Z - minZ) / (maxZ - minZ); if (ColorValues != null) { u = (ColorValues[i, j] - minColorValue) / (maxColorValue - minColorValue); } texcoords[i, j] = new Point(u, u); } } if (rows == 1 || columns == 1) { var surfaceMeshBuilder = new MeshBuilder(); var pointList = new List <Point3D>(); var texturePoints = new List <double>(); var diameters = new List <double>(); for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { pointList.Add(Points[i, j]); texturePoints.Add(texcoords[i, j].X); diameters.Add(LineThickness * 2.0); } } surfaceMeshBuilder.AddTube(pointList, texturePoints.ToArray(), diameters.ToArray(), 9, false, true, true); var mesh = surfaceMeshBuilder.ToMesh(); var surfaceModel = new GeometryModel3D(mesh, MaterialHelper.CreateMaterial(SurfaceBrush, null, null, 1, 0)); surfaceModel.BackMaterial = surfaceModel.Material; Children.Add(surfaceModel); } else { var vertexZMapping = new Dictionary <Vertex, double>(); var vertices = new List <Vertex>(); for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { if (Points[i, j].X == 0.0 && Points[i, j].Y == 0.0 && Points[i, j].Z == 0.0) { continue; } var vertex = new Vertex(Points[i, j].X, Points[i, j].Y); vertices.Add(vertex); vertexZMapping[vertex] = Points[i, j].Z; } } var mesh = DelaunayTriangulation <Vertex, Cell> .Create(vertices, 1e-10); foreach (var cell in mesh.Cells) { // 3D-ify it. var min = cell.Vertices.Min(vertex => vertexZMapping[vertex]); var max = cell.Vertices.Max(vertex => vertexZMapping[vertex]); var minPercentile = (min - minZ) / (maxZ - minZ); var maxPercentile = (max - minZ) / (maxZ - minZ); var minR = Math.Round(255.0 * (1 - 0.3 * minPercentile)); var minG = Math.Round(255.0 * (minPercentile)); var minB = Math.Round(255.0 * (Math.Abs(0.5 - minPercentile) * 2)); var maxR = Math.Round(255.0 * (1 - 0.3 * maxPercentile)); var maxG = Math.Round(255.0 * (maxPercentile)); var maxB = Math.Round(255.0 * (Math.Abs(0.5 - maxPercentile) * 2)); var minColor = Color.FromArgb((byte)255, (byte)minR, (byte)minG, (byte)minB); var maxColor = Color.FromArgb((byte)255, (byte)maxR, (byte)maxG, (byte)maxB); Children.Add(cell.Visual.CreateModel(new Point3DCollection(cell.Vertices.Select(vertex => { var vertexPoint = vertex.ToPoint(); return(new Point3D(vertexPoint.X, vertexPoint.Y, vertexZMapping[vertex])); })), minColor, maxColor)); } } //2 Stat //x=stat=x*total //y=stat2=y*total //3 Stat //x=stat1=x*total //y_1=stat2=(-x*total-y*total)/2 //y_2=stat3=y*total+(-x*total-y*total)/2 var axesMeshBuilder = new MeshBuilder(); for (double x = minX; x <= maxX; x += IntervalX) { double j = (x - minX) / (maxX - minX) * (columns - 1); var path = new List <Point3D> { new Point3D(x, minY, minZ) }; path.Add(new Point3D(x, maxY, minZ)); axesMeshBuilder.AddTube(path, LineThickness, 9, false, true, true); var labelString = (x * ResultsData.ShrinkingFactor).ToString("F4"); if (StatCount == 2 || StatCount == 3) { labelString = (x * Total).ToString("F0"); } GeometryModel3D label = TextCreator.CreateTextLabelModel3D(labelString, Brushes.Black, true, FontSize, new Point3D(x, minY - FontSize * 6, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); label.Transform = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 0, 1), -90.0), new Point3D(label.Bounds.SizeX / 2 + label.Bounds.Location.X, label.Bounds.SizeY / 2 + label.Bounds.Location.Y, 0.0)); Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D(XAxisName, Brushes.Black, true, FontSize, new Point3D((minX + maxX) * 0.5, minY - FontSize * 12, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); Children.Add(label); } for (double y = minY; y <= maxY; y += IntervalY) { double i = (y - minY) / (maxY - minY) * (rows - 1); var path = new List <Point3D> { new Point3D(minX, y, minZ) }; path.Add(new Point3D(maxX, y, minZ)); axesMeshBuilder.AddTube(path, LineThickness, 9, false, true, true); var labelString = (y * ResultsData.ShrinkingFactor).ToString("F4"); if (StatCount == 2) { labelString = (y * Total).ToString("F0"); } GeometryModel3D label = TextCreator.CreateTextLabelModel3D(labelString, Brushes.Black, true, FontSize, new Point3D(minX - FontSize * 4, y, minZ), new Vector3D(1, 0, 0), new Vector3D(0, 1, 0)); Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D(YAxisName, Brushes.Black, true, FontSize, new Point3D(minX - FontSize * 10, (minY + maxY) * 0.5, minZ), new Vector3D(0, 1, 0), new Vector3D(-1, 0, 0)); label.Transform = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 0, 1), 180.0), new Point3D(label.Bounds.SizeX / 2 + label.Bounds.Location.X, label.Bounds.SizeY / 2 + label.Bounds.Location.Y, 0.0)); Children.Add(label); } //double z0 = (int)(minZ / IntervalZ) * IntervalZ; var zTrans = IntervalZ / 3; for (double z = minZ; z <= maxZ + double.Epsilon; z += IntervalZ) { GeometryModel3D label = TextCreator.CreateTextLabelModel3D(z.ToString("F4"), Brushes.Black, true, FontSize / FontScale, new Point3D(minX - FontSize * 4, maxY + .015, z), new Vector3D(1, 0, 0), new Vector3D(0, 0, 1)); label.Transform = new TranslateTransform3D(new Vector3D(0, 0, zTrans)); Children.Add(label); } { GeometryModel3D label = TextCreator.CreateTextLabelModel3D(ZAxisName, Brushes.Black, true, FontSize / FontScale, new Point3D(minX - FontSize * 10, maxY + .015, (minZ + maxZ) * 0.5), new Vector3D(0, 0, 1), new Vector3D(1, 0, 0)); label.Transform = new TranslateTransform3D(new Vector3D(0, 0, IntervalZ)); Children.Add(label); } var bb = new Rect3D(minX, minY, minZ, maxX - minX, maxY - minY, 0 * (maxZ - minZ)); axesMeshBuilder.AddBoundingBox(bb, LineThickness); var axesModel = new GeometryModel3D(axesMeshBuilder.ToMesh(), Materials.Black); Children.Add(axesModel); plotModel.Children = Children; return(plotModel); }