// DotColour = transparent, use the map colour associated with each entry. Else use this colour for all public List <IData3DSet> BuildSystems(bool DrawLines, bool DrawDots, Color DotColour, List <HistoryEntry> syslists) { // we use the expanded capability of Line and Point to holds colours for each element instead of the previous sorting system // This means less submissions to GL. if (syslists.Any()) { if (DrawLines) { var datasetl = Data3DSetClass <LineData> .Create("visitedstarslines", Color.Transparent, 2.0f); Vector3d?lastpos = null; foreach (HistoryEntry sp in syslists) { if (sp.System.HasCoordinate) { if (lastpos.HasValue) { Color c = Color.FromArgb(255, Color.FromArgb(sp.MapColour)); // convert to colour, ensure alpha is 255 (some time in the past this value could have been screwed up) if (c.GetBrightness() < 0.05) // and ensure it shows { c = Color.Red; } datasetl.Add(new LineData(sp.System.x, sp.System.y, sp.System.z, lastpos.Value.X, lastpos.Value.Y, lastpos.Value.Z, c)); } lastpos = new Vector3d(sp.System.x, sp.System.y, sp.System.z); } } _datasets.Add(datasetl); } if (DrawDots) { var datasetp = Data3DSetClass <PointData> .Create("visitedstarsdots", DotColour, 2.0f); foreach (HistoryEntry vs in syslists) { if (vs.System.HasCoordinate) { Color c = Color.FromArgb(255, Color.FromArgb(vs.MapColour)); // convert to colour, ensure alpha is 255 (some time in the past this value could have been screwed up) if (c.GetBrightness() < 0.05) // and ensure it shows { c = Color.Red; } datasetp.Add(new PointData(vs.System.x, vs.System.y, vs.System.z, c)); } } _datasets.Add(datasetp); } } return(_datasets); }
public List <IData3DSet> AddCoarseGridLines() { var datasetGridLOD1 = Data3DSetClass <LineData> .Create("gridLOD1", MapColours.CoarseGridLines, 0.6f); for (float x = MinGridPos.X; x <= MaxGridPos.X; x += gridunitSize) { datasetGridLOD1.Add(new LineData(x, 0, MinGridPos.Y, x, 0, MaxGridPos.Y)); } for (float z = MinGridPos.Y; z <= MaxGridPos.Y; z += gridunitSize) { datasetGridLOD1.Add(new LineData(MinGridPos.X, 0, z, MaxGridPos.X, 0, z)); } _datasets.Add(datasetGridLOD1); var datasetGridLOD2 = Data3DSetClass <LineData> .Create("gridLOD2", MapColours.CoarseGridLines, 0.6f); for (float x = MinGridPos.X; x <= MaxGridPos.X; x += gridunitSize * 10) { datasetGridLOD2.Add(new LineData(x, 0, MinGridPos.Y, x, 0, MaxGridPos.Y)); } for (float z = MinGridPos.Y; z <= MaxGridPos.Y; z += gridunitSize * 10) { datasetGridLOD2.Add(new LineData(MinGridPos.X, 0, z, MaxGridPos.X, 0, z)); } _datasets.Add(datasetGridLOD2); return(_datasets); }
public List <IData3DSet> AddNotedBookmarks(Bitmap map, Bitmap maptarget, float widthly, float heightly, Vector3 rotation, List <HistoryEntry> syslists) { var datasetbks = Data3DSetClass <TexturedQuadData> .Create("bkmrs", Color.White, 1f); long bookmarknoted = TargetClass.GetTargetNotedSystem(); if (syslists != null) { foreach (HistoryEntry vs in syslists) { SystemNoteClass notecs = SystemNoteClass.GetNoteOnSystem(vs.System.name, vs.System.id_edsm); if (notecs != null) // if we have a note.. { string note = notecs.Note.Trim(); if (note.Length > 0) { PointData pd = new PointData(vs.System.x, vs.System.y, vs.System.z); Bitmap touse = (notecs.id == bookmarknoted) ? maptarget : map; TexturedQuadData newtexture = TexturedQuadData.FromBitmap(touse, pd, rotation, widthly, heightly, 0, heightly / 2); newtexture.Tag = vs; newtexture.Tag2 = 1; // note mark datasetbks.Add(newtexture); } } } } _datasets.Add(datasetbks); return(_datasets); }
public List <IData3DSet> AddMapImages(FGEImage [] list) { if (list.Length > 0) { var datasetMapImg = Data3DSetClass <TexturedQuadData> .Create("mapimage", Color.White, 1.0f); for (int i = 0; i < list.Length; i++) { FGEImage img = list[i]; if (_cachedTextures.ContainsKey(img.FileName)) { datasetMapImg.Add(_cachedTextures[img.FileName]); } else { Bitmap bmp = (Bitmap)Bitmap.FromFile(img.FilePath); Vector3d centre = new Vector3d((img.TopLeft.X + img.BottomRight.X) / 2, 0, (img.TopRight.Y + img.BottomLeft.Y) / 2); float width = img.TopRight.X - img.BottomLeft.X; float height = img.TopLeft.Y - img.BottomRight.Y; // its rectangular.. so does not really matter which left/right/top/bot you use var texture = TexturedQuadData.FromBitmap(bmp, centre, TexturedQuadData.NoRotation, width, height); _cachedTextures[img.FileName] = texture; datasetMapImg.Add(texture); } } _datasets.Add(datasetMapImg); } return(_datasets); }
public List <IData3DSet> AddGalMapObjectsToDataset(Bitmap target, float widthly, float heightly, Vector3 rotation, bool namethem) { var datasetbks = Data3DSetClass <TexturedQuadData> .Create("galobj", Color.White, 1f); if (EDDiscoveryForm.galacticMapping != null) { long gmotarget = TargetClass.GetTargetGMO(); foreach (GalacticMapObject gmo in EDDiscoveryForm.galacticMapping.galacticMapObjects) { PointData pd = (gmo.points.Count > 0) ? gmo.points[0] : null; // lets be paranoid Bitmap touse = gmo.galMapType.Image; // under our control, so must have it if (touse != null && pd != null && gmo.galMapType.Enabled) // if it has an image (may not) and has a co-ord, may not.. { Debug.Assert(touse != null); TexturedQuadData newtexture = TexturedQuadData.FromBitmap(touse, pd, rotation, widthly, heightly); newtexture.Tag = gmo; newtexture.Tag2 = 0; datasetbks.Add(newtexture); if (namethem) { Bitmap map = null; if (_cachedBitmaps.ContainsKey(gmo.name)) // cache them, they take a long time to compute.. { map = _cachedBitmaps[gmo.name]; } else { map = DrawString(gmo.name, Color.Orange, gmostarfont); _cachedBitmaps.Add(gmo.name, map); } TexturedQuadData ntext = TexturedQuadData.FromBitmap(map, pd, rotation, (widthly / 10 * gmo.name.Length), (heightly / 3), 0, heightly * gmonameoff); ntext.Tag = gmo; ntext.Tag2 = 1; datasetbks.Add(ntext); } if (gmo.id == gmotarget) { TexturedQuadData ntag = TexturedQuadData.FromBitmap(target, pd, rotation, widthly, heightly, 0, heightly * gmotargetoff); ntag.Tag = gmo; ntag.Tag2 = 2; datasetbks.Add(ntag); } } } } _datasets.Add(datasetbks); return(_datasets); }
public void UpdateStandardSystems(DateTime maxtime) { var ds = from dataset in _datasets where dataset.Name.Equals("stars") select dataset; Data3DSetClass <PointData> datasetS = (Data3DSetClass <PointData>)ds.First(); _datasets.Remove(datasetS); datasetS = Data3DSetClass <PointData> .Create("stars", Color.White, 1.0f); if (AllSystems && StarList != null) { bool addstations = !Stations; //var datasetS = Data3DSetClass<PointData>.Create("stars", Color.White, 1.0f); foreach (ISystem si in StarList) { if (addstations || (si.population == 0 && si.CreateDate < maxtime)) { AddSystem(si, datasetS); } } _datasets.Add(datasetS); } }
public List <IData3DSet> AddNotedBookmarks(Bitmap map, Bitmap maptarget, float widthly, float heightly, Vector3 rotation, List <VisitedSystemsClass> VisitedSystems) { var datasetbks = Data3DSetClass <TexturedQuadData> .Create("bkmrs", Color.White, 1f); long bookmarknoted = TargetClass.GetTargetNotedSystem(); if (VisitedSystems != null) { foreach (VisitedSystemsClass vs in VisitedSystems) { SystemNoteClass notecs = SystemNoteClass.GetSystemNoteClass(vs.Name); if (notecs != null) // if we have a note.. { string note = notecs.Note.Trim(); if (note.Length > 0) { PointData pd = new PointData((vs.HasTravelCoordinates) ? vs.X : vs.curSystem.x, (vs.HasTravelCoordinates) ? vs.Y : vs.curSystem.y, (vs.HasTravelCoordinates) ? vs.Z : vs.curSystem.z); Bitmap touse = (notecs.id == bookmarknoted) ? maptarget : map; TexturedQuadData newtexture = TexturedQuadData.FromBitmap(touse, pd, rotation, widthly, heightly, 0, heightly / 2); newtexture.Tag = vs; newtexture.Tag2 = 1; // note mark datasetbks.Add(newtexture); } } } } _datasets.Add(datasetbks); return(_datasets); }
// Planned change: Centered system will be marked but won't be "center" of the galaxy // dataset anymore. The origin will stay at Sol. public void AddCenterPointToDataset() { var dataset = Data3DSetClass <PointData> .Create("Center", Color.Yellow, 5.0f); //GL.Enable(EnableCap.ProgramPointSize); dataset.Add(new PointData(CenterSystem.x, CenterSystem.y, CenterSystem.z)); _datasets.Add(dataset); }
public void AddPOIsToDataset() { var dataset = Data3DSetClass <PointData> .Create("Interest", Color.Purple, 10.0f); AddSystem("sol", dataset); AddSystem("sagittarius a*", dataset); //AddSystem("polaris", dataset); _datasets.Add(dataset); }
public void AddSelectedSystemToDataset() { if (SelectedSystem != null) { var dataset = Data3DSetClass <PointData> .Create("Selected", Color.Orange, 5.0f); //GL.Enable(EnableCap.ProgramPointSize); dataset.Add(new PointData(SelectedSystem.x, SelectedSystem.y, SelectedSystem.z)); _datasets.Add(dataset); } }
public void AddMapImages() { if (UseImage && Images != null && Images.Length != 0) { var datasetMapImg = Data3DSetClass <TexturedQuadData> .Create("mapimage", Color.White, 1.0f); foreach (var img in Images) { datasetMapImg.Add(TexturedQuadData.FromFGEImage(img)); } _datasets.Add(datasetMapImg); } }
public void AddVisitedSystemsInformation() { if (VisitedSystems != null && VisitedSystems.Any()) { ISystem lastknownps = LastKnownSystemPosition(); // For some reason I am unable to fathom this errors during the session after DBUpgrade8 // colours just resolves to an object reference not set error, but after a restart it works fine // Not going to waste any more time, a one time restart is hardly the worst workaround in the world... IEnumerable <IGrouping <int, SystemPosition> > colours = from SystemPosition sysPos in VisitedSystems where sysPos.vs != null group sysPos by sysPos.vs.MapColour; if (colours != null) { foreach (IGrouping <int, SystemPosition> colour in colours) { if (DrawLines) { var datasetl = Data3DSetClass <LineData> .Create("visitedstars" + colour.Key.ToString(), Color.FromArgb(colour.Key), 2.0f); foreach (SystemPosition sp in colour) { if (sp.curSystem != null && sp.curSystem.HasCoordinate && sp.lastKnownSystem != null && sp.lastKnownSystem.HasCoordinate) { datasetl.Add(new LineData(sp.curSystem.x, sp.curSystem.y, sp.curSystem.z, sp.lastKnownSystem.x, sp.lastKnownSystem.y, sp.lastKnownSystem.z)); } } _datasets.Add(datasetl); } else { var datasetvs = Data3DSetClass <PointData> .Create("visitedstars" + colour.Key.ToString(), Color.FromArgb(colour.Key), 2.0f); foreach (SystemPosition sp in colour) { ISystem star = SystemData.GetSystem(sp.Name); if (star != null && star.HasCoordinate) { AddSystem(star, datasetvs); } } _datasets.Add(datasetvs); } } } } }
private void AddRoutePlannerInfoToDataset(List <SystemClass> PlannedRoute) { if (PlannedRoute != null && PlannedRoute.Any()) { var routeLines = Data3DSetClass <LineData> .Create("PlannedRoute", MapColours.PlannedRoute, 25.0f); ISystem prevSystem = PlannedRoute.First(); foreach (ISystem point in PlannedRoute.Skip(1)) { routeLines.Add(new LineData(prevSystem.x, prevSystem.y, prevSystem.z, point.x, point.y, point.z)); prevSystem = point; } _datasets.Add(routeLines); } }
public void AddRoutePlannerInfoToDataset() { if (PlannedRoute != null && PlannedRoute.Any()) { var routeLines = Data3DSetClass <LineData> .Create("PlannedRoute", Color.DarkOrange, 25.0f); ISystem prevSystem = PlannedRoute.First(); foreach (ISystem point in PlannedRoute.Skip(1)) { routeLines.Add(new LineData(prevSystem.x, prevSystem.y, prevSystem.z, point.x, point.y, point.z)); prevSystem = point; } _datasets.Add(routeLines); } }
public void AddStations() { if (Stations) { var datasetS = Data3DSetClass <PointData> .Create("stations", Color.RoyalBlue, 1.0f); foreach (ISystem si in StarList) { if (si.population > 0) { AddSystem(si, datasetS); } } _datasets.Add(datasetS); } }
public List <IData3DSet> BuildRouteTri(List <SystemClass> PlannedRoute) { if (PlannedRoute != null && PlannedRoute.Any()) { var routeLines = Data3DSetClass <LineData> .Create("PlannedRoute", MapColours.PlannedRoute, 25.0f); ISystem prevSystem = PlannedRoute.First(); foreach (ISystem point in PlannedRoute.Skip(1)) { routeLines.Add(new LineData(prevSystem.x, prevSystem.y, prevSystem.z, point.x, point.y, point.z)); prevSystem = point; } _datasets.Add(routeLines); } return(_datasets); }
public void AddStandardSystems() { if (AllSystems && StarList != null) { bool addstations = !Stations; var datasetS = Data3DSetClass <PointData> .Create("stars", Color.White, 1.0f); foreach (ISystem si in StarList) { if (addstations || si.population == 0) { AddSystem(si, datasetS); } } _datasets.Add(datasetS); } }
public List <IData3DSet> AddFineGridLines() { int smallUnitSize = gridunitSize / 10; var smalldatasetGrid = Data3DSetClass <LineData> .Create("gridLOD0", MapColours.FineGridLines, 0.6f); for (float x = MinGridPos.X; x <= MaxGridPos.X; x += smallUnitSize) { smalldatasetGrid.Add(new LineData(x, 0, MinGridPos.Y, x, 0, MaxGridPos.Y)); } for (float z = MinGridPos.Y; z <= MaxGridPos.Y; z += smallUnitSize) { smalldatasetGrid.Add(new LineData(MinGridPos.X, 0, z, MaxGridPos.X, 0, z)); } _datasets.Add(smalldatasetGrid); return(_datasets); }
public List <IData3DSet> AddStarBookmarks(Bitmap mapstar, Bitmap mapregion, Bitmap maptarget, float widthly, float heightly, Vector3 rotation) { var datasetbks = Data3DSetClass <TexturedQuadData> .Create("bkmrs", Color.White, 1f); long bookmarktarget = TargetClass.GetTargetBookmark(); foreach (BookmarkClass bc in BookmarkClass.bookmarks) { Bitmap touse = (bc.id == bookmarktarget) ? maptarget : ((bc.isRegion) ? mapregion : mapstar); TexturedQuadData newtexture = TexturedQuadData.FromBitmap(touse, new PointData(bc.x, bc.y, bc.z), rotation, widthly, heightly, 0, heightly / 2); newtexture.Tag = bc; newtexture.Tag2 = 0; // bookmark datasetbks.Add(newtexture); } _datasets.Add(datasetbks); return(_datasets); }
public List <IData3DSet> BuildSelected(ISystem centersystem, ISystem selectedsystem, GalacticMapObject selectedgmo, float widthly, float heightly, Vector3 rotation) { Bitmap selmark = (Bitmap)EDDiscovery.Properties.Resources.selectedmarker; if (centersystem != null) { var dataset = Data3DSetClass <PointData> .Create("Center", MapColours.CentredSystem, 5.0f); dataset.Add(new PointData(centersystem.x, centersystem.y, centersystem.z)); _datasets.Add(dataset); } if (selectedsystem != null) { var datasetbks = Data3DSetClass <TexturedQuadData> .Create("selstar", Color.White, 1f); TexturedQuadData newtexture = TexturedQuadData.FromBitmap(selmark, new PointData(selectedsystem.x, selectedsystem.y, selectedsystem.z), rotation, widthly, heightly / 2, 0, heightly / 4 + heightly / 16); newtexture.Tag = 0; datasetbks.Add(newtexture); _datasets.Add(datasetbks); } if (selectedgmo != null) { PointData pd = (selectedgmo.points.Count > 0) ? selectedgmo.points[0] : null; // lets be paranoid if (pd != null) { var datasetbks = Data3DSetClass <TexturedQuadData> .Create("selgmo", Color.White, 1f); long gmotarget = TargetClass.GetTargetGMO(); float hoff = (gmotarget == selectedgmo.id) ? (heightly * gmoseltarget) : (heightly * gmoselonly); TexturedQuadData newtexture = TexturedQuadData.FromBitmap(selmark, pd, rotation, widthly, heightly / 2, 0, hoff); newtexture.Tag = 1; datasetbks.Add(newtexture); _datasets.Add(datasetbks); } } return(_datasets); }
public void UpdateGridCoordZoom(ref List <IData3DSet> _datasets, double zoom) { double LOD2fade = Math.Max(Math.Min((0.2 / zoom - 1.0) / 2.0, 1.0), 0.0); var gridLOD2 = _datasets.SingleOrDefault(s => s.Name == "text bitmap LOD2"); if (gridLOD2 != null) { //Console.WriteLine("LOD2 fade" + LOD2fade); var newgrid = Data3DSetClass <TexturedQuadData> .Create("text bitmap LOD2", Color.FromArgb((int)(255 * LOD2fade), Color.White), 1.0f); foreach (var tex in ((Data3DSetClass <TexturedQuadData>)gridLOD2).Primatives) { newgrid.Add(tex); } _datasets.Remove(gridLOD2); _datasets.Add(newgrid); } }
public void AddTrilaterationInfoToDataset() { if (ReferenceSystems != null && ReferenceSystems.Any()) { var referenceLines = Data3DSetClass <LineData> .Create("CurrentReference", Color.Green, 5.0f); foreach (var refSystem in ReferenceSystems) { referenceLines.Add(new LineData(CenterSystem.x, CenterSystem.y, CenterSystem.z, refSystem.x, refSystem.y, refSystem.z)); } _datasets.Add(referenceLines); var lineSet = Data3DSetClass <LineData> .Create("SuggestedReference", Color.DarkOrange, 5.0f); Stopwatch sw = new Stopwatch(); sw.Start(); SuggestedReferences references = new SuggestedReferences(CenterSystem.x, CenterSystem.y, CenterSystem.z); for (int ii = 0; ii < 16; ii++) { var rsys = references.GetCandidate(); if (rsys == null) { break; } var system = rsys.System; references.AddReferenceStar(system); if (ReferenceSystems != null && ReferenceSystems.Any(s => s.name == system.name)) { continue; } System.Diagnostics.Trace.WriteLine(string.Format("{0} Dist: {1} x:{2} y:{3} z:{4}", system.name, rsys.Distance.ToString("0.00"), system.x, system.y, system.z)); lineSet.Add(new LineData(CenterSystem.x, CenterSystem.y, CenterSystem.z, system.x, system.y, system.z)); } sw.Stop(); System.Diagnostics.Trace.WriteLine("Reference stars time " + sw.Elapsed.TotalSeconds.ToString("0.000s")); _datasets.Add(lineSet); } }
public void AddGridLines() { int unitSize = 1000; if (GridLines) { bool addstations = !Stations; var datasetGrid = Data3DSetClass <LineData> .Create("grid", (Color)System.Drawing.ColorTranslator.FromHtml("#296A6C"), 0.6f); for (float x = MinGridPos.X; x <= MaxGridPos.X; x += unitSize) { datasetGrid.Add(new LineData(x, 0, MinGridPos.Y, x, 0, MaxGridPos.Y)); } for (float z = MinGridPos.Y; z <= MaxGridPos.Y; z += unitSize) { datasetGrid.Add(new LineData(MinGridPos.X, 0, z, MaxGridPos.X, 0, z)); } _datasets.Add(datasetGrid); } }
private void AddVisitedSystemsInformation(bool DrawLines, List <VisitedSystemsClass> VisitedSystems) { if (VisitedSystems != null && VisitedSystems.Any() && DrawLines) { VisitedSystemsClass.SetLastKnownSystemPosition(VisitedSystems); IEnumerable <IGrouping <int, VisitedSystemsClass> > colours = from VisitedSystemsClass sysPos in VisitedSystems group sysPos by sysPos.MapColour; if (colours != null) { foreach (IGrouping <int, VisitedSystemsClass> colour in colours) { var datasetl = Data3DSetClass <LineData> .Create("visitedstars" + colour.Key.ToString(), Color.FromArgb(colour.Key), 2.0f); foreach (VisitedSystemsClass sp in colour) { if (sp.curSystem != null && sp.curSystem.HasCoordinate && sp.lastKnownSystem != null && sp.lastKnownSystem.HasCoordinate) { datasetl.Add(new LineData(sp.curSystem.x, sp.curSystem.y, sp.curSystem.z, sp.lastKnownSystem.x, sp.lastKnownSystem.y, sp.lastKnownSystem.z)); } } _datasets.Add(datasetl); var datasetvs = Data3DSetClass <PointData> .Create("visitedstars" + colour.Key.ToString(), Color.Orange, 2.0f); foreach (VisitedSystemsClass sp in colour) { if (sp.curSystem != null && sp.curSystem.HasCoordinate) { datasetvs.Add(new PointData(sp.curSystem.x, sp.curSystem.y, sp.curSystem.z)); } } _datasets.Add(datasetvs); } } } }
public void UpdateGridZoom(ref List <IData3DSet> _datasets, double zoom) { double LOD1fade = Math.Max(Math.Min((zoom / 0.1 - 1.0) / 5.0, 1.0), 0.5); var gridLOD1 = _datasets.SingleOrDefault(s => s.Name == "gridLOD1"); if (gridLOD1 != null) { var colour = MapColours.CoarseGridLines; //Console.WriteLine("LOD1 fade"+ LOD1fade); colour = Color.FromArgb((int)(colour.R * LOD1fade), (int)(colour.G * LOD1fade), (int)(colour.B * LOD1fade)); var newgrid = Data3DSetClass <LineData> .Create("gridLOD1", colour, 0.6f); foreach (var line in ((Data3DSetClass <LineData>)gridLOD1).Primatives) { newgrid.Add(line); } int index = _datasets.IndexOf(gridLOD1); _datasets.Remove(gridLOD1); ((IDisposable)gridLOD1).Dispose(); _datasets.Insert(index, newgrid); } }
public List <IData3DSet> AddGridCoords() { string fontname = "MS Sans Serif"; { Font fnt = new Font(fontname, 20F); int bitmapwidth, bitmapheight; Bitmap text_bmp = new Bitmap(300, 30); using (Graphics g = Graphics.FromImage(text_bmp)) { SizeF sz = g.MeasureString("-99999,-99999", fnt); bitmapwidth = (int)sz.Width + 4; bitmapheight = (int)sz.Height + 4; } var datasetMapImgLOD1 = Data3DSetClass <TexturedQuadData> .Create("text bitmap LOD1", Color.White, 1.0f); var datasetMapImgLOD2 = Data3DSetClass <TexturedQuadData> .Create("text bitmap LOD2", Color.FromArgb(128, Color.White), 1.0f); int textheightly = 50; int textwidthly = textheightly * bitmapwidth / bitmapheight; int gridwideLOD1 = (int)Math.Floor((MaxGridPos.X - MinGridPos.X) / gridunitSize + 1); int gridhighLOD1 = (int)Math.Floor((MaxGridPos.Y - MinGridPos.Y) / gridunitSize + 1); int gridwideLOD2 = (int)Math.Floor((MaxGridPos.X - MinGridPos.X) / (gridunitSize * 10) + 1); int gridhighLOD2 = (int)Math.Floor((MaxGridPos.Y - MinGridPos.Y) / (gridunitSize * 10) + 1); int texwide = 1024 / bitmapwidth; int texhigh = 1024 / bitmapheight; int numtexLOD1 = (int)Math.Ceiling((gridwideLOD1 * gridhighLOD1) * 1.0 / (texwide * texhigh)); int numtexLOD2 = (int)Math.Ceiling((gridwideLOD2 * gridhighLOD2) * 1.0 / (texwide * texhigh)); List <TexturedQuadData> basetexturesLOD1 = Enumerable.Range(0, numtexLOD1).Select(i => new TexturedQuadData(null, null, new Bitmap(1024, 1024))).ToList(); List <TexturedQuadData> basetexturesLOD2 = Enumerable.Range(0, numtexLOD2).Select(i => new TexturedQuadData(null, null, new Bitmap(1024, 1024))).ToList(); for (float x = MinGridPos.X; x < MaxGridPos.X; x += gridunitSize) { for (float z = MinGridPos.Y; z <= MaxGridPos.Y; z += gridunitSize) { int num = (int)(Math.Floor((x - MinGridPos.X) / gridunitSize) * gridwideLOD1 + Math.Floor((z - MinGridPos.Y) / gridunitSize)); int tex_x = (num % texwide) * bitmapwidth; int tex_y = ((num / texwide) % texhigh) * bitmapheight; int tex_n = num / (texwide * texhigh); //Console.WriteLine("num {0} tex_x {1} tex_y {2} txt_n {3}", num, tex_x, tex_y, tex_n); DrawGridBitmap(basetexturesLOD1[tex_n].Texture, x, z, fnt, tex_x, tex_y); datasetMapImgLOD1.Add(basetexturesLOD1[tex_n].Horz( x, z, x + textwidthly, z + textheightly, tex_x, tex_y, tex_x + bitmapwidth, tex_y + bitmapheight )); } } for (float x = MinGridPos.X; x < MaxGridPos.X; x += gridunitSize * 10) { for (float z = MinGridPos.Y; z <= MaxGridPos.Y; z += gridunitSize * 10) { int num = (int)(Math.Floor((x - MinGridPos.X) / (gridunitSize * 10)) * gridwideLOD2 + Math.Floor((z - MinGridPos.Y) / (gridunitSize * 10))); int tex_x = (num % texwide) * bitmapwidth; int tex_y = ((num / texwide) % texhigh) * bitmapheight; int tex_n = num / (texwide * texhigh); DrawGridBitmap(basetexturesLOD2[tex_n].Texture, x, z, fnt, tex_x, tex_y); datasetMapImgLOD2.Add(basetexturesLOD2[tex_n].Horz( x, z, x + textwidthly * 10, z + textheightly * 10, tex_x, tex_y, tex_x + bitmapwidth, tex_y + bitmapheight )); } } _datasets.Add(datasetMapImgLOD1); _datasets.Add(datasetMapImgLOD2); } return(_datasets); }
public List <IData3DSet> AddGalMapRegionsToDataset(bool colourregions) { var polydataset = new PolygonCollection("regpolys", Color.White, 1f, OpenTK.Graphics.OpenGL.PrimitiveType.Triangles); // ORDER AND NUMBER v.Important var outlinedataset = new PolygonCollection("reglines", Color.White, 1f, OpenTK.Graphics.OpenGL.PrimitiveType.LineLoop); // DrawStars picks them out in a particular order var datasetbks = Data3DSetClass <TexturedQuadData> .Create("regtext", Color.White, 1f); if (EDDiscoveryForm.galacticMapping != null) { long gmotarget = TargetClass.GetTargetGMO(); int cindex = 0; foreach (GalacticMapObject gmo in EDDiscoveryForm.galacticMapping.galacticMapObjects) { if (gmo.galMapType.Enabled && gmo.galMapType.Group == GalMapType.GalMapGroup.Regions) { string name = gmo.name; Color[] array = new Color[] { Color.Red, Color.Green, Color.Blue, Color.Brown, Color.Crimson, Color.Coral, Color.Aqua, Color.Yellow, Color.Violet, Color.Sienna, Color.Silver, Color.Salmon, Color.Pink, Color.AntiqueWhite, Color.Beige, Color.DarkCyan, Color.DarkGray, Color.ForestGreen, Color.LightSkyBlue, Color.Lime, Color.Maroon, Color.Olive, Color.SteelBlue }; Color c = array[cindex++ % array.Length]; List <Vector2> polygonxz = new List <Vector2>(); // needs it in x/z and in vector2's foreach (Vector3 pd in gmo.points) { polygonxz.Add(new Vector2((float)pd.X, (float)pd.Z)); // can be concave and wound the wrong way.. } Vector2 size, avg; Vector2 centre = PolygonTriangulator.Centre(polygonxz, out size, out avg); // default geographic centre (min x/z + max x/z/2) used in case poly triangulate fails (unlikely) List <List <Vector2> > polys = PolygonTriangulator.Triangulate(polygonxz, false); // cut into convex polygons first - because we want the biggest possible area for naming purposes //Console.WriteLine("Region {0} decomposed to {1} ", name, polys.Count); Vector2 bestpos = centre; Vector2 bestsize = new Vector2(250, 250 / 5); if (polys.Count > 0) // just in case.. { centre = PolygonTriangulator.Centroids(polys); // weighted mean of the centroids //Bitmap map3 = DrawString(String.Format("O{0}", cindex - 1), Color.White, gmostarfont); TexturedQuadData ntext3 = TexturedQuadData.FromBitmap(map3, new PointData(centre.X, 0, centre.Y), TexturedQuadData.NoRotation, 2000, 500); datasetbks.Add(ntext3); float mindist = float.MaxValue; foreach (List <Vector2> points in polys) // now for every poly { if (colourregions) { Color regcol = Color.FromArgb(64, c.R, c.G, c.B); if (points.Count == 3) // already a triangle.. { polydataset.Add(new Polygon(points, 1, regcol)); //outlinedataset.Add(new Polygon(points, 1, Color.FromArgb(255, 255, 255, 0))); //DEBUG } else { List <List <Vector2> > polytri = PolygonTriangulator.Triangulate(points, true); // cut into triangles not polygons foreach (List <Vector2> pt in polytri) { polydataset.Add(new Polygon(pt, 1, regcol)); // outlinedataset.Add(new Polygon(pt, 1, Color.FromArgb(255, 255, 255, 0))); // DEBUG } } } //float area; Vector2 polycentrepos = PolygonTriangulator.Centroid(points,out area); Bitmap map2 = DrawString(String.Format("X") , Color.White, gmostarfont); TexturedQuadData ntext2 = TexturedQuadData.FromBitmap(map2, new PointData(polycentrepos.X, 0, polycentrepos.Y), TexturedQuadData.NoRotation, 1000, 200); datasetbks.Add(ntext2); PolygonTriangulator.FitInsideConvexPoly(points, centre, new Vector2(3000, 3000 / 5), new Vector2(200, 200), ref mindist, ref bestpos, ref bestsize, bestsize.X / 2); } } Bitmap map = DrawString(gmo.name, Color.White, gmostarfont); PointData bitmappos = new PointData(bestpos.X, 0, bestpos.Y); TexturedQuadData ntext = TexturedQuadData.FromBitmap(map, bitmappos, TexturedQuadData.NoRotation, bestsize.X, bestsize.Y); datasetbks.Add(ntext); outlinedataset.Add(new Polygon(polygonxz, 1, Color.FromArgb(255, 128, 128, 128))); } } } _datasets.Add(polydataset); _datasets.Add(outlinedataset); _datasets.Add(datasetbks); return(_datasets); }