private void AddLines(bool sky, KmlLineList geo, float lineWidth, Color polyColor, Color lineColor, bool extrude) { //todo can we save this work for later? List<Vector3d> vertexList = new List<Vector3d>(); List<Vector3d> vertexListGround = new List<Vector3d>(); //todo list // We need to Wrap Around for complete polygone // we aldo need to do intereor //todo space? using RA/DEC for (int i = 0; i < (geo.PointList.Count); i++) { vertexList.Add(Coordinates.GeoTo3dDouble(geo.PointList[i].Lat, geo.PointList[i].Lng, 1 + (geo.PointList[i].Alt / geo.MeanRadius))); vertexListGround.Add(Coordinates.GeoTo3dDouble(geo.PointList[i].Lat, geo.PointList[i].Lng, 1)); } for (int i = 0; i < (geo.PointList.Count - 1); i++) { if (sky) { lines.AddLine(Coordinates.RADecTo3d(-(180.0 - geo.PointList[i].Lng) / 15 + 12, geo.PointList[i].Lat, 1), Coordinates.RADecTo3d(-(180.0 - geo.PointList[i + 1].Lng) / 15 + 12, geo.PointList[i + 1].Lat, 1), lineColor, new Dates()); } else { if (extrude) { triangles.AddQuad(vertexList[i], vertexList[i + 1], vertexListGround[i], vertexListGround[i + 1], polyColor, new Dates()); } if (lineWidth > 0) { lines.AddLine (vertexList[i], vertexList[i + 1], lineColor, new Dates()); if (extrude) { lines.AddLine(vertexListGround[i], vertexListGround[i + 1], lineColor, new Dates()); lines.AddLine(vertexList[i], vertexListGround[i], lineColor, new Dates()); lines.AddLine(vertexList[i + 1], vertexListGround[i + 1], lineColor, new Dates()); } } } } List<int> indexes = Glu.TesselateSimplePoly(vertexList); for (int i = 0; i < indexes.Count; i += 3) { triangles.AddTriangle(vertexList[indexes[i]], vertexList[indexes[i + 1]], vertexList[indexes[i + 2]], polyColor, new Dates()); } }
private void ParseLineString(string parens, string mods, Color lineColor, double alt, bool single, Dates date) { if (!parens.StartsWith("(") && parens.EndsWith(")")) { return; } if (!single) { // string the top level of parens parens = parens.Substring(1, parens.Length - 2); } var shapes = UiTools.SplitString(parens, ','); foreach (var shape in shapes) { var lineList = new KmlLineList(); lineList.Astronomical = astronomical; lineList.MeanRadius = meanRadius; lineList.ParseWkt(shape, mods, alt, date); AddPolygon(!bufferIsFlat && astronomical, lineList, 1, Color.White, lineColor, false, false, date); } }
private void ParsePolygon(string parens, string mods, Color lineColor, Color polyColor, double alt, Dates date) { if (!parens.StartsWith("(") && parens.EndsWith(")")) { return; } // string the top level of parens parens = parens.Substring(1, parens.Length - 2); var shapes = UiTools.SplitString(parens, ','); foreach (var shape in shapes) { var lineList = new KmlLineList(); lineList.Astronomical = astronomical; lineList.MeanRadius = meanRadius; lineList.ParseWkt(shape, mods, alt, date); if (alt == 0) { AddPolygonFlat(false, lineList, 1, polyColor, lineColor, true, true, date); } else { AddPolygon(false, lineList, 1, polyColor, lineColor, true, true, date); } } }
private void AddPolygonFlat(bool sky, KmlLineList geo, float lineWidth, Color polyColor, Color lineColor, bool extrude, bool fill, Dates date) { //todo can we save this work for later? var vertexList = new List<Vector3d>(); for (var i = 0; i < (geo.PointList.Count); i++) { vertexList.Add(Coordinates.GeoTo3dDouble(geo.PointList[i].Lat, geo.PointList[i].Lng, 1 + (geo.PointList[i].Alt / meanRadius))); } for (var i = 0; i < (geo.PointList.Count - 1); i++) { if (sky) { lineList2d.AddLine (Coordinates.RADecTo3d(-(180.0 - geo.PointList[i].Lng) / 15, geo.PointList[i].Lat, 1), Coordinates.RADecTo3d(-(180.0 - geo.PointList[i + 1].Lng) / 15, geo.PointList[i + 1].Lat, 1), lineColor, date); } else { if (lineWidth > 0) { lineList2d.AddLine(vertexList[i], vertexList[i + 1], lineColor, date); } } } if (fill) { var indexes = Glu.TesselateSimplePoly(vertexList); for (var i = 0; i < indexes.Count; i += 3) { triangleList2d.AddTriangle(vertexList[indexes[i]], vertexList[indexes[i + 1]], vertexList[indexes[i + 2]], polyColor, date, 2); } } }