
Adding New Points on GLControl
Posted Thursday, 28 April, 2011 - 02:59 by adityatan inHi there:
I have a question regarding adding new points on GLControl.
Suppose I have an a running GLControl. After a user enter new points on another form, I would like to update my GLControl based on the new data. What is the best way to do this?
Below is a small fraction of my code:
private void glControl1_Load(object sender, EventArgs e) { bool loaded = d.Loaded; a = D.GetDataFromInputFile(); InitGL(); InitVars(); GL.ClearColor(Color.White); GL.Enable(EnableCap.DepthTest); for (int i = 0; i < a.GMS.Count(); i++) { PGASet.Add( new Vector3( Convert.ToSingle(a.GMS.ElementAt(i).PGA[0]), // PGA Convert.ToSingle(a.GMS.ElementAt(i).Coordinates[1] + 118.538), // Latitude Convert.ToSingle(a.GMS.ElementAt(i).Coordinates[0] - 34.0853))); // Longitude } if (loaded == true) // this is the updated points { for (int i = 0; i < d.XGridCounter; i++) { for (int j = 0; j < d.YGridCounter; j++) { for (int k = 0; k < d.ZGridCounter; k++) { numberOfNodes = numberOfNodes + 1; Nodes.Add( new Vector3( Convert.ToSingle(a.Grid.ElementAt(i).Coordinates[0]), Convert.ToSingle(a.Grid.ElementAt(j).Coordinates[1]), Convert.ToSingle(a.Grid.ElementAt(k).Coordinates[2]))); } } } }
private void glControl1_Paint(object sender, PaintEventArgs e) { //if (!loaded) return; bool loaded = d.Loaded; a = D.GetDataFromInputFile(); Vector3 lookatPoint = new Vector3((float)Math.Cos(facing), (float)Math.Sin(pitch / 2), (float)Math.Sin(facing)); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); cameraMatrix = Matrix4.LookAt(location, location + lookatPoint, up); GL.LoadMatrix(ref cameraMatrix); GL.Rotate(camera_rotationY, 0, 1, 0); GL.Rotate(camera_rotationZ, 0, 0, 1); paintPGAset(); paintAxes(); if (loaded == true) // this is the updated points { paintNodes(); paintGrid(); }
Thank you!
AT

