// operate on display - Called in a thread.. public void GetSystemsInView(ref SortedDictionary <float, InViewInfo> list, TransFormInfo ti, int forcecol = 0) { if (array1displayed) { GetSystemsInView(ref array1, ref carray1, array1vertices, ref list, ti, forcecol); } else { GetSystemsInView(ref array2, ref carray2, array2vertices, ref list, ti, forcecol); } }
public Vector3?FindPoint(int x, int y, ref double cursysdistz, TransFormInfo ti) // UI call .. operate on display { Debug.Assert(Application.MessageLoop); if (array1displayed) { return(FindPoint(ref array1, array1vertices, x, y, ref cursysdistz, ti)); } else { return(FindPoint(ref array2, array2vertices, x, y, ref cursysdistz, ti)); } }
// operate on display - can be called BY A THREAD public void GetSystemsInView(ref Vector3[] vert, ref int[] cols, int total, ref SortedDictionary <float, InViewInfo> list, TransFormInfo ti, int forcecol) { int margin = -150; float sqdist = 0F; double w2 = (double)ti.dwidth / 2.0; double h2 = (double)ti.dheight / 2.0; lock (lockdisplaydata) // must lock it.. { for (int i = 0; i < total; i++) { Vector3 v = vert[i]; Vector4d syspos = new Vector4d(v.X, v.Y, v.Z, 1.0); Vector4d sysloc = Vector4d.Transform(syspos, ti.resmat); if (sysloc.Z > ti.znear) { Vector2d syssloc = new Vector2d(((sysloc.X / sysloc.W) + 1.0) * w2, ((sysloc.Y / sysloc.W) + 1.0) * h2); if ((syssloc.X >= margin && syssloc.X <= ti.dwidth - margin) && (syssloc.Y >= margin && syssloc.Y <= ti.dheight - margin)) { sqdist = ((float)v.X - ti.campos.X) * ((float)v.X - ti.campos.X) + ((float)v.Y - ti.campos.Y) * ((float)v.Y - ti.campos.Y) + ((float)v.Z - ti.campos.Z) * ((float)v.Z - ti.campos.Z); if (sqdist <= ti.sqlylimit) { list.Add(sqdist, new InViewInfo(new Vector3(v.X, v.Y, v.Z), (forcecol != 0) ? forcecol : cols[i])); } } } } } }
// operate on display public Vector3?FindPoint(ref Vector3[] vert, int total, int x, int y, ref double cursysdistz, TransFormInfo ti) { Vector3?ret = null; double w2 = (double)ti.dwidth / 2.0; double h2 = (double)ti.dheight / 2.0; for (int i = 0; i < total; i++) { Vector3 v = vert[i]; Vector4d syspos = new Vector4d(v.X, v.Y, v.Z, 1.0); Vector4d sysloc = Vector4d.Transform(syspos, ti.resmat); if (sysloc.Z > ti.znear) { Vector2d syssloc = new Vector2d(((sysloc.X / sysloc.W) + 1.0) * w2 - x, ((sysloc.Y / sysloc.W) + 1.0) * h2 - y); double sysdistsq = syssloc.X * syssloc.X + syssloc.Y * syssloc.Y; if (sysdistsq < 7.0 * 7.0) { double sysdist = Math.Sqrt(sysdistsq); if ((sysdist + Math.Abs(sysloc.Z * ti.zoom)) < cursysdistz) { cursysdistz = sysdist + Math.Abs(sysloc.Z * ti.zoom); ret = new Vector3(v.X, v.Y, v.Z); } } } } return(ret); }
// operate on display public Vector3?FindPoint(ref Vector3[] vert, int total, int x, int y, ref float cursysdistz, TransFormInfo ti) { Vector3?ret = null; float w2 = (float)ti.dwidth / 2.0F; float h2 = (float)ti.dheight / 2.0F; for (int i = 0; i < total; i++) { Vector3 v = vert[i]; Vector4 syspos = new Vector4(v.X, v.Y, v.Z, 1.0F); Vector4 sysloc = Vector4.Transform(syspos, ti.resmat); if (sysloc.Z > ti.znear) { Vector2 syssloc = new Vector2(((sysloc.X / sysloc.W) + 1.0F) * w2 - x, ((sysloc.Y / sysloc.W) + 1.0F) * h2 - y); float sysdistsq = syssloc.X * syssloc.X + syssloc.Y * syssloc.Y; if (sysdistsq < 7.0 * 7.0) { float sysdist = (float)Math.Sqrt(sysdistsq); if ((sysdist + Math.Abs(sysloc.Z * ti.zoom)) < cursysdistz) { cursysdistz = sysdist + (float)Math.Abs(sysloc.Z * ti.zoom); ret = new Vector3(v.X, v.Y, v.Z); } } } } return(ret); }