public bool AlignFirstModelFromRegistratioMatrix(Matrix4d myMatrix) { //Vector3d v = new Vector3d(); if (this.GLrender.RenderableObjects.Count > 0) { RenderableObject o = this.GLrender.RenderableObjects[0]; PointCloud pc1 = o.PointCloud; myMatrix.TransformPointCloud(pc1); } else { System.Windows.Forms.MessageBox.Show("Please load two Point Clouds first"); return(false); } return(true); }
public bool SaveSelectedModel() { if (this.GLrender.RenderableObjects.Count > 0) { RenderableObject o = null; o = this.GLrender.RenderableObjects[this.GLrender.SelectedModelIndex]; if (o != null) { PointCloud pc = o.PointCloud; pc.ToObjFile(pc.FileNameLong); } } else { System.Windows.Forms.MessageBox.Show("please switch to 3D Tab if scanning is in progress - (nothing to save) "); return(false); } return(true); }
public Matrix4d CalculateRegistrationMatrix(PointCloud pcOriginal) { Vector3d v = new Vector3d(); Matrix4d myMatrix = Matrix4d.Identity; if (this.GLrender.RenderableObjects.Count > 1) { RenderableObject o = this.GLrender.RenderableObjects[0]; PointCloud pc1 = o.PointCloud; myMatrix = SVD.FindTransformationMatrix(v.ArrayVector3ToList(pcOriginal.Vectors), v.ArrayVector3ToList(pc1.Vectors), ICP_VersionUsed.Scaling_Umeyama); //myMatrix = SVD.FindTransformationMatrix_WithoutCentroids(v.ArrayVector3ToList(pc1.Vectors), v.ArrayVector3ToList(pc2.Vectors), ICP_VersionUsed.Scaling_Umeyama); } else { System.Windows.Forms.MessageBox.Show("Please load two Point Clouds first"); } return(myMatrix); }
private void toolStripChangeColor_Click(object sender, EventArgs e) { if (comboModels.SelectedIndex >= 0) { ColorDialog colDiag = new ColorDialog(); // Sets the initial color select to the current text color. // Update the text box color if the user clicks OK if (colDiag.ShowDialog() == DialogResult.OK) { RenderableObject pcr = this.OGLControl.GLrender.RenderableObjects[this.OGLControl.GLrender.SelectedModelIndex]; PointCloud pc = pcr.PointCloud; pc.SetColor(new Vector3(colDiag.Color.R / 255f, colDiag.Color.G / 255f, colDiag.Color.B / 255f)); this.OGLControl.Refresh(); } } else { System.Windows.Forms.MessageBox.Show("Please load a 3D object first"); } }
public void Draw() { try { if (isDrawing) { return; } isDrawing = true; fpsCalc.newFrame(); UpdateFramesPerSecond(); GL.Clear(ClearBufferMask.DepthBufferBit | ClearBufferMask.ColorBufferBit); GL.ClearColor(GLSettings.BackColor); GL.Enable(EnableCap.DepthTest); for (int i = 0; i < this.RenderableObjects.Count; i++) { RenderableObject o = this.RenderableObjects[i]; if (AlignCameraToObject || (!cameraIsAlignedToObject && i == 0)) { AlignCameraToObject = false; //System.Diagnostics.Debug.WriteLine("----Align camera to object - on first draw"); //o.PointCloudGL.ResetCentroid(true); Camera.ZNear = Convert.ToSingle(o.PointCloud.BoundingBoxMaxFloat); //Convert.ToSingle(o.PointCloud.BoundingBoxMinFloat ); Camera.PerspectiveUpdate(); this.Camera.Position = new Vector3(0f, 0f, o.PointCloud.BoundingBoxMaxFloat + 5 * this.Camera.ZNear); //Camera.SetDirection(new Vector3d(0, 0, 0)); Vector3 axis = Vector3.UnitY; //this.Camera.Rotate(Convert.ToSingle(Math.PI), axis); cameraIsAlignedToObject = true; } o.MVP = this.Camera.MVP; o.Scale = 1; o.Render(this.PrimitiveTypes, PoygonModes); } if (GLSettings.ShowAxes) { axes.MVP = this.Camera.MVP; axes.Render(PrimitiveType.Lines, PolygonMode.Line); } if (GLSettings.ShowGrid) { grid.MVP = this.Camera.MVP; grid.Render(PrimitiveType.Lines, PolygonMode.Line); } if (GLSettings.ShowCameraFOV) { cameraFOV.MVP = this.Camera.MVP; cameraFOV.Render(PrimitiveType.Lines, PolygonMode.Line); } //this.DrawAxesLabels(); try { this.GLControlInstance.SwapBuffers(); } catch (Exception err) { System.Diagnostics.Debug.WriteLine("GL Draw Error : " + err.Message); ErrorCode code = GL.GetError(); if (code.ToString() != "NoError") { System.Diagnostics.Debug.WriteLine("GL Draw Error : " + code.ToString()); } } } catch { System.Diagnostics.Debug.WriteLine("GL Draw Error : "); } isDrawing = false; }
private void RotateModel(int iObject, float xAngle, float yAngle) { RenderableObject o = this.RenderableObjects[iObject]; o.PointCloud.RotateDegrees(xAngle, yAngle, 0f); }
private void ScaleModel(int iObject, float scale) { RenderableObject o = this.RenderableObjects[iObject]; o.PointCloud.Scale(scale); }