public void Add(LineString lineString) { lineString.Visible = IsRenderableVisible(lineString.ParentRenderable); m_lineStrings.Add(lineString); LastUpdate = System.DateTime.Now; m_oBounds.Union(lineString.GetGeographicBoundingBox()); }
private void drawLineString(LineString lineString, Graphics g, GeographicBoundingBox dstBB, Size imageSize) { using(Pen p = new Pen(lineString.Color, lineString.LineWidth)) { g.DrawLines(p, getScreenPoints(lineString.Coordinates, 0, lineString.Coordinates.Length, dstBB, imageSize)); } }
private void UpdateTexturedVertices() { if(m_altitudeMode == AltitudeMode.ClampedToGround) { if(m_lineString != null) { m_lineString.Remove = true; m_lineString = null; } m_lineString = new LineString(); m_lineString.Coordinates = Points; m_lineString.Color = LineColor; m_lineString.LineWidth = LineWidth; m_lineString.ParentRenderable = this; this.World.ProjectedVectorRenderer.Add(m_lineString); if(m_wallVertices != null) m_wallVertices = null; return; } if(m_extrude || m_altitudeMode == AltitudeMode.RelativeToGround) { m_wallVertices = new CustomVertex.PositionColoredTextured[m_numPoints * 2]; } float textureCoordIncrement = 1.0f / (float)(m_numPoints - 1); m_verticalExaggeration = World.Settings.VerticalExaggeration; int vertexColor = m_polygonColor.ToArgb(); m_topVertices = new CustomVertex.PositionColored[m_numPoints]; for(int i = 0; i < m_numPoints; i++) { double terrainHeight = 0; if(m_altitudeMode == AltitudeMode.RelativeToGround) { if(World.TerrainAccessor != null) { terrainHeight = World.TerrainAccessor.GetElevationAt( m_points[i].Y, m_points[i].X, (100.0 / DrawArgs.Camera.ViewRange.Degrees) ); } } Vector3 xyzVertex = MathEngine.SphericalToCartesian( m_points[i].Y, m_points[i].X, m_verticalExaggeration * (m_distanceAboveSurface + terrainHeight + m_points[i].Z) + World.EquatorialRadius ); m_topVertices[i].X = xyzVertex.X; m_topVertices[i].Y = xyzVertex.Y; m_topVertices[i].Z = xyzVertex.Z; m_topVertices[i].Color = m_lineColor.ToArgb(); if(m_extrude || m_altitudeMode == AltitudeMode.RelativeToGround) { m_wallVertices[2 * i].X = xyzVertex.X; m_wallVertices[2 * i].Y = xyzVertex.Y; m_wallVertices[2 * i].Z = xyzVertex.Z; m_wallVertices[2 * i].Color = vertexColor; m_wallVertices[2 * i].Tu = i * textureCoordIncrement; m_wallVertices[2 * i].Tv = 1.0f; xyzVertex = MathEngine.SphericalToCartesian( m_points[i].Y, m_points[i].X, m_verticalExaggeration * (m_distanceAboveSurface + terrainHeight) + World.EquatorialRadius ); m_wallVertices[2 * i + 1].X = xyzVertex.X; m_wallVertices[2 * i + 1].Y = xyzVertex.Y; m_wallVertices[2 * i + 1].Z = xyzVertex.Z; m_wallVertices[2 * i + 1].Color = vertexColor; m_wallVertices[2 * i + 1].Tu = i * textureCoordIncrement; m_wallVertices[2 * i + 1].Tv = 0.0f; } } }
public void Add(LineString lineString) { lineString.Visible = IsRenderableVisible(lineString.ParentRenderable); m_lineStrings.Add(lineString); LastUpdate = System.DateTime.Now; }
private static RenderableObject Construct(String strRelativeDirectory, KMLObject oSource, World oWorld, GeographicBoundingBox oBounds, ProjectedVectorRenderer oPVR, Icons oIcons) { if (oSource is KMLContainer) { KMLContainer oCastSource = oSource as KMLContainer; KMLRenderableObjectList result = new KMLRenderableObjectList(oCastSource.Name); if (oPVR == null) { oPVR = new ProjectedVectorRenderer("Polygons and LineStrings", oWorld); result.Add(oPVR); } if (oIcons == null) { oIcons = new Icons("Icons"); result.Add(oIcons); } for (int count = 0; count < oCastSource.Count; count++) { if (oCastSource[count].Visibility == true) { RenderableObject oLayer = Construct(strRelativeDirectory, oCastSource[count], oWorld, oBounds, oPVR, oIcons); if (oLayer != null) { result.Add(oLayer); } } } return result; } else if (oSource is KMLPlacemark) { KMLPlacemark oCastSource = oSource as KMLPlacemark; return Construct(strRelativeDirectory, oCastSource.Geometry, oWorld, oBounds, oPVR, oIcons); } else if (oSource is KMLMultiGeometry) { KMLMultiGeometry oCastSource = oSource as KMLMultiGeometry; KMLRenderableObjectList result = new KMLRenderableObjectList("MultiGeometry"); for (int count = 0; count < oCastSource.Count; count++) { RenderableObject oLayer = Construct(strRelativeDirectory, oCastSource[count], oWorld, oBounds, oPVR, oIcons); if (oLayer != null) { result.Add(oLayer); } } return result; } else if (oSource is KMLPoint) { KMLPoint oCastSource = oSource as KMLPoint; KMLIcon result = new KMLIcon(oCastSource.Owner.Name, oCastSource.Coordinates.Latitude, oCastSource.Coordinates.Longitude, oCastSource.Coordinates.Altitude); result.DrawGroundStick = oCastSource.Extrude; result.Rotation = WorldWind.Angle.FromDegrees(oCastSource.Style.NormalStyle.IconStyle.Heading); result.IsRotated = oCastSource.Style.NormalStyle.IconStyle.Heading != 0.0f; result.NormalColor = oCastSource.Style.NormalStyle.LabelStyle.Color; result.HotColor = oCastSource.Style.HighlightStyle.LabelStyle.Color; oIcons.Add(result); oBounds.Union(oCastSource.Coordinates.Longitude, oCastSource.Coordinates.Latitude, oCastSource.Coordinates.Altitude); return null; } else if (oSource is KMLPolygon) { KMLPolygon oCastSource = oSource as KMLPolygon; Polygon oTool = new Polygon(); oTool.outerBoundary = new WorldWind.LinearRing(GetPoints(oCastSource.OuterBoundary)); oTool.innerBoundaries = GetInnerBoundaries(oCastSource); oTool.PolgonColor = oCastSource.Style.NormalStyle.PolyStyle.Color; oTool.Fill = oCastSource.Style.NormalStyle.PolyStyle.Fill; oTool.LineWidth = oCastSource.Style.NormalStyle.LineStyle.Width; oTool.Outline = oCastSource.Style.NormalStyle.PolyStyle.Outline; oTool.OutlineColor = oCastSource.Style.NormalStyle.LineStyle.Color; oPVR.Add(oTool); oBounds.Union(oTool.GetGeographicBoundingBox()); return null; } else if (oSource is KMLLineString) { KMLLineString oCastSource = oSource as KMLLineString; LineString oTool = new LineString(); oTool.Coordinates = GetPoints(oCastSource); oTool.Color = oCastSource.Style.NormalStyle.LineStyle.Color; oTool.LineWidth = oCastSource.Style.NormalStyle.LineStyle.Width; oPVR.Add(oTool); oBounds.Union(oTool.GetGeographicBoundingBox()); return null; } else if (oSource is KMLGroundOverlay) { KMLGroundOverlay oCastSource = oSource as KMLGroundOverlay; KMLGroundOverlayRenderable result = new KMLGroundOverlayRenderable(oCastSource, strRelativeDirectory); oBounds.Union(new GeographicBoundingBox(oCastSource.LatLonBox.North, oCastSource.LatLonBox.South, oCastSource.LatLonBox.West, oCastSource.LatLonBox.East)); return result; } else { return null; } }
private void UpdateTexturedVertices() { if (m_altitudeMode == AltitudeMode.ClampedToGround) { if (m_lineString != null) { m_lineString.Remove = true; m_lineString = null; } m_lineString = new LineString(); m_lineString.Coordinates = Points; m_lineString.Color = LineColor; m_lineString.LineWidth = LineWidth; m_lineString.ParentRenderable = this; this.World.ProjectedVectorRenderer.Add(m_lineString); if (m_wallVertices != null) { m_wallVertices = null; } return; } if (m_extrude || m_altitudeMode == AltitudeMode.RelativeToGround) { m_wallVertices = new CustomVertex.PositionColoredTextured[m_numPoints * 2]; } float textureCoordIncrement = 1.0f / (float)(m_numPoints - 1); m_verticalExaggeration = World.Settings.VerticalExaggeration; int vertexColor = m_polygonColor.ToArgb(); m_topVertices = new CustomVertex.PositionColored[m_numPoints]; for (int i = 0; i < m_numPoints; i++) { double terrainHeight = 0; if (m_altitudeMode == AltitudeMode.RelativeToGround) { if (World.TerrainAccessor != null) { terrainHeight = World.TerrainAccessor.GetElevationAt( m_points[i].Y, m_points[i].X, (100.0 / DrawArgs.Camera.ViewRange.Degrees) ); } } Vector3 xyzVertex = MathEngine.SphericalToCartesian( m_points[i].Y, m_points[i].X, m_verticalExaggeration * (m_distanceAboveSurface + terrainHeight + m_points[i].Z) + World.EquatorialRadius ); m_topVertices[i].X = xyzVertex.X; m_topVertices[i].Y = xyzVertex.Y; m_topVertices[i].Z = xyzVertex.Z; m_topVertices[i].Color = m_lineColor.ToArgb(); if (m_extrude || m_altitudeMode == AltitudeMode.RelativeToGround) { m_wallVertices[2 * i].X = xyzVertex.X; m_wallVertices[2 * i].Y = xyzVertex.Y; m_wallVertices[2 * i].Z = xyzVertex.Z; m_wallVertices[2 * i].Color = vertexColor; m_wallVertices[2 * i].Tu = i * textureCoordIncrement; m_wallVertices[2 * i].Tv = 1.0f; xyzVertex = MathEngine.SphericalToCartesian( m_points[i].Y, m_points[i].X, m_verticalExaggeration * (m_distanceAboveSurface + terrainHeight) + World.EquatorialRadius ); m_wallVertices[2 * i + 1].X = xyzVertex.X; m_wallVertices[2 * i + 1].Y = xyzVertex.Y; m_wallVertices[2 * i + 1].Z = xyzVertex.Z; m_wallVertices[2 * i + 1].Color = vertexColor; m_wallVertices[2 * i + 1].Tu = i * textureCoordIncrement; m_wallVertices[2 * i + 1].Tv = 0.0f; } } }