public void AddQuad(Vector3d v1, Vector3d v2, Vector3d v3, Vector3d v4, Color color, Dates date) { trianglePoints.Add(v1); trianglePoints.Add(v3); trianglePoints.Add(v2); trianglePoints.Add(v2); trianglePoints.Add(v3); trianglePoints.Add(v4); triangleColors.Add(color); triangleDates.Add(date); triangleColors.Add(color); triangleDates.Add(date); EmptyTriangleBuffer(); }
public void AddShape(List <Vector3d> shapePoints, Color color, Dates date) { shapes.Add(shapePoints); colors.Add(color); dates.Add(date); }
public void AddSubdividedTriangles(Vector3d v1, Vector3d v2, Vector3d v3, Color color, Dates date, int subdivisions) { subdivisions--; if (subdivisions < 0) { AddTriangle(v1, v2, v3, color, date); } else { Vector3d v12; Vector3d v23; Vector3d v31; v12 = Vector3d.MidPointByLength(v1, v2); v23 = Vector3d.MidPointByLength(v2, v3); v31 = Vector3d.MidPointByLength(v3, v1); // Add 1st AddSubdividedTriangles(v1, v12, v31, color, date, subdivisions); // Add 2nd AddSubdividedTriangles(v12, v23, v31, color, date, subdivisions); // Add 3rd AddSubdividedTriangles(v12, v2, v23, color, date, subdivisions); // Add 4th AddSubdividedTriangles(v23, v3, v31, color, date, subdivisions); } }
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); } List <string> shapes = UiTools.SplitString(parens, ","); foreach (string shape in shapes) { KmlLineList lineList = new KmlLineList(); lineList.Astronomical = astronomical; lineList.MeanRadius = meanRadius; lineList.ParseWkt(shape, mods, alt, date); AddPolygon(false, lineList, 1, Colors.White, lineColor, false, false, date); } }
private void AddPolygon(bool sky, KmlLineList geo, float lineWidth, Color polyColor, Color lineColor, bool extrude, bool fill, Dates date) { //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.GeoTo3dDoubleRad(geo.PointList[i].Lat, geo.PointList[i].Lng, 1 + (geo.PointList[i].Alt / meanRadius))); vertexListGround.Add(Coordinates.GeoTo3dDoubleRad(geo.PointList[i].Lat, geo.PointList[i].Lng, 1)); } for (int i = 0; i < (geo.PointList.Count - 1); i++) { if (sky) { //tdo reenable this //this.lineList2d.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, date); } else { if (extrude) { this.triangleList.AddQuad(vertexList[i], vertexList[i + 1], vertexListGround[i], vertexListGround[i + 1], polyColor, date); } if (lineWidth > 0) { if (extrude) { this.lineList.AddLine(vertexList[i], vertexList[i + 1], lineColor, date); } else { this.lineList2d.AddLine(vertexList[i], vertexList[i + 1], lineColor, date); } if (extrude) { this.lineList.AddLine(vertexListGround[i], vertexListGround[i + 1], lineColor, date); this.lineList.AddLine(vertexList[i], vertexListGround[i], lineColor, date); this.lineList.AddLine(vertexList[i + 1], vertexListGround[i + 1], lineColor, date); } } } } if (fill) { List <int> indexes = Tessellator.TesselateSimplePoly(vertexList); for (int i = 0; i < indexes.Count; i += 3) { this.triangleList.AddTriangle(vertexList[indexes[i]], vertexList[indexes[i + 1]], vertexList[indexes[i + 2]], polyColor, date); } } }
private void ParseGeometry(string gs, Color lineColor, Color polyColor, double alt, Dates date) { gs = gs.Trim().ToLowerCase(); int index = gs.IndexOf('('); if (index < 0) { return; } if (!gs.EndsWith(")")) { return; } string commandPart = gs.Substring(0, index).Trim(); string parens = gs.Substr(index); string[] parts = commandPart.Split(" "); string command = null; string mods = null; if (parts.Length > 0) { foreach (string item in parts) { if (string.IsNullOrEmpty(command)) { command = item; } else if (string.IsNullOrEmpty(mods)) { mods = item; } } } switch (command) { case "multipolygon": case "polygon": { ParsePolygon(parens, mods, lineColor, polyColor, alt, date); } break; case "multilinestring": { ParseLineString(parens, mods, lineColor, alt, false, date); } break; case "linestring": { ParseLineString(parens, mods, lineColor, alt, true, date); } break; case "geometrycollection": { parens = parens.Substring(1, parens.Length - 2); List <string> shapes = UiTools.SplitString(parens, ","); foreach (string shape in shapes) { ParseGeometry(shape, lineColor, polyColor, alt, date); } } break; default: break; } }
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); List <string> shapes = UiTools.SplitString(parens, ","); foreach (string shape in shapes) { KmlLineList 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? List <Vector3d> vertexList = new List <Vector3d>(); for (int i = 0; i < (geo.PointList.Count); i++) { vertexList.Add(Coordinates.GeoTo3dDoubleRad(geo.PointList[i].Lat, geo.PointList[i].Lng, 1 + (geo.PointList[i].Alt / meanRadius))); } for (int i = 0; i < (geo.PointList.Count - 1); i++) { if (sky) { //this.lineList2d.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, date); } else { if (lineWidth > 0) { this.lineList2d.AddLine(vertexList[i], vertexList[i + 1], lineColor, date); } } } if (fill) { List <int> indexes = Tessellator.TesselateSimplePoly(vertexList); for (int i = 0; i < indexes.Count; i += 3) { this.triangleList2d.AddSubdividedTriangles(vertexList[indexes[i]], vertexList[indexes[i + 1]], vertexList[indexes[i + 2]], polyColor, date, 2); } } }
public void AddLine(Vector3d v1, Vector3d v2, Color color, Dates date) { linePoints.Add(v1); linePoints.Add(v2); lineColors.Add(color); lineDates.Add(date); EmptyLineBuffer(); }
public void AddTriangle(Vector3d v1, Vector3d v2, Vector3d v3, Color color, Dates date) { trianglePoints.Add(v1); trianglePoints.Add(v2); trianglePoints.Add(v3); triangleColors.Add(color); triangleDates.Add(date); EmptyTriangleBuffer(); }
public void AddPoint(Vector3d v1, Color color, Dates date, float size) { points.Add(v1); colors.Add(color.Clone()); dates.Add(date); sizes.Add(size); EmptyPointBuffer(); }