//public static SimpleLineList11 sketch = null;
        static void InitTranslateUI()
        {
            TranslateUILines = new LineList();
            TranslateUILines.TimeSeries = false;
            TranslateUILines.DepthBuffered = false;
            TranslateUILines.ShowFarSide = true;

            TranslateUI = new TriangleList();
            TranslateUI.DepthBuffered = false;
            TranslateUI.TimeSeries = false;
            TranslateUI.WriteZbuffer = false;

            double twoPi = Math.PI * 2;
            double step = twoPi / 45;
            double rad = .05;

            // X

            for (double a = 0; a < twoPi; a += step)
            {
                Vector3d pnt1 = new Vector3d(1 - rad * 4, 0, 0);
                Vector3d pnt2 = new Vector3d(1 - rad * 4, Math.Cos(a) * rad, Math.Sin(a) * rad);
                Vector3d pnt3 = new Vector3d(1 - rad * 4, Math.Cos(a + step) * rad, Math.Sin(a + step) * rad);
                TranslateUI.AddTriangle(pnt1, pnt2, pnt3, System.Drawing.Color.Red, new Dates());
            }
            for (double a = 0; a < twoPi; a += step)
            {
                Vector3d pnt1 = new Vector3d(1, 0, 0);
                Vector3d pnt3 = new Vector3d(1 - rad * 4, Math.Cos(a) * rad, Math.Sin(a) * rad);
                Vector3d pnt2 = new Vector3d(1 - rad * 4, Math.Cos(a + step) * rad, Math.Sin(a + step) * rad);
                TranslateUI.AddTriangle(pnt1, pnt2, pnt3, System.Drawing.Color.FromArgb(255, Math.Max(0, (int)(Math.Sin(a) * 128)), Math.Max(0, (int)(Math.Sin(a) * 128))), new Dates());
            }

            TranslateUILines.AddLine(new Vector3d(0, 0, 0), new Vector3d(1, 0, 0), System.Drawing.Color.Red);

            // Y
            for (double a = 0; a < twoPi; a += step)
            {
                Vector3d pnt1 = new Vector3d(0, 1 - rad * 4, 0);
                Vector3d pnt3 = new Vector3d(Math.Cos(a) * rad, 1 - rad * 4, Math.Sin(a) * rad);
                Vector3d pnt2 = new Vector3d(Math.Cos(a + step) * rad, 1 - rad * 4, Math.Sin(a + step) * rad);
                TranslateUI.AddTriangle(pnt1, pnt2, pnt3, System.Drawing.Color.Green, new Dates());
            }

            for (double a = 0; a < twoPi; a += step)
            {
                Vector3d pnt1 = new Vector3d(0, 1, 0);
                Vector3d pnt2 = new Vector3d(Math.Cos(a) * rad, 1 - rad * 4, Math.Sin(a) * rad);
                Vector3d pnt3 = new Vector3d(Math.Cos(a + step) * rad, 1 - rad * 4, Math.Sin(a + step) * rad);
                TranslateUI.AddTriangle(pnt1, pnt2, pnt3, System.Drawing.Color.FromArgb(Math.Max(0, (int)(Math.Sin(a) * 128)), 255, Math.Max(0, (int)(Math.Sin(a) * 128))), new Dates());
            }

            TranslateUILines.AddLine(new Vector3d(0, 0, 0), new Vector3d(0, 1, 0), System.Drawing.Color.Green);

            // Z
            for (double a = 0; a < twoPi; a += step)
            {
                Vector3d pnt1 = new Vector3d(0, 0, 1 - rad * 4);
                Vector3d pnt2 = new Vector3d(Math.Cos(a) * rad, Math.Sin(a) * rad, 1 - rad * 4);
                Vector3d pnt3 = new Vector3d(Math.Cos(a + step) * rad, Math.Sin(a + step) * rad, 1 - rad * 4);
                TranslateUI.AddTriangle(pnt1, pnt2, pnt3, System.Drawing.Color.Blue, new Dates());
            }

            for (double a = 0; a < twoPi; a += step)
            {
                Vector3d pnt1 = new Vector3d(0, 0, 1);
                Vector3d pnt3 = new Vector3d(Math.Cos(a) * rad, Math.Sin(a) * rad, 1 - rad * 4);
                Vector3d pnt2 = new Vector3d(Math.Cos(a + step) * rad, Math.Sin(a + step) * rad, 1 - rad * 4);
                TranslateUI.AddTriangle(pnt1, pnt2, pnt3, System.Drawing.Color.FromArgb(Math.Max(0, (int)(Math.Sin(a) * 128)), Math.Max(0, (int)(Math.Sin(a) * 128)), 255), new Dates());
            }

            TranslateUILines.AddLine(new Vector3d(0, 0, 0), new Vector3d(0, 0, 1), System.Drawing.Color.Blue);
            InitRotateUI();
            InitScaleUI();
        }
Beispiel #2
0
        private void AddFeatureToDisplay(KmlFeature feature, bool sky)
        {
            KmlDocument doc = feature as KmlDocument;

            if (doc != null)
            {
                sky = doc.sky;
            }
            if (!(feature is KmlNetworkLink))
            {
                if (feature.visibility == false)
                {
                    return;
                }
                else if (feature is KmlPlacemark)
                {
                    KmlPlacemark placemark = (KmlPlacemark)feature;
                    KmlStyle     style     = placemark.Style.GetStyle(placemark.Selected);
                    Color        lineColor = Color.White;
                    if (style != null)
                    {
                        lineColor = style.LineStyle.Color;
                    }
                    if (placemark.geometry is KmlPoint)
                    {
                        placemark.Point = (KmlPoint)placemark.geometry;
                        AddPlacemark(placemark);
                    }
                    else if (placemark.geometry is KmlMultiGeometry)
                    {
                        KmlMultiGeometry geo = (KmlMultiGeometry)placemark.geometry;
                        AddMultiGeometry(sky, placemark, (float)style.LineStyle.Width, style.PolyStyle.Color, lineColor, geo);
                    }
                    else if (placemark.geometry is KmlPolygon)
                    {
                        KmlPolygon geo = (KmlPolygon)placemark.geometry;
                        if (geo.OuterBoundary != null)
                        {
                            AddLines(sky, geo.OuterBoundary as KmlLineList, (float)style.LineStyle.Width, style.PolyStyle.Color, lineColor, geo.extrude);
                            // to do 3d work and subtract inner rings
                        }
                    }
                    else if (placemark.geometry is KmlLineString)
                    {
                        KmlLineString geo = (KmlLineString)placemark.geometry;

                        List <Vector3d> vertexList = new List <Vector3d>();
                        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)));
                        }
                        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
                            {
                                lines.AddLine(vertexList[i], vertexList[i + 1], lineColor, new Dates());
                            }
                        }
                    }
                }
                if (feature is KmlGroundOverlay && feature.visibility)
                {
                    AddGroundOverlay(feature as KmlGroundOverlay);
                }

                if (feature is KmlScreenOverlay && feature.visibility)
                {
                    AddScreenOverlay(feature as KmlScreenOverlay);
                }
            }
            if (feature.visibility)
            {
                if (feature is KmlContainer)
                {
                    KmlContainer container = (KmlContainer)feature;
                    if (container.children != null)
                    {
                        foreach (KmlFeature child in container.children)
                        {
                            AddFeatureToDisplay(child, sky);
                        }
                    }
                }
                else
                {
                    if (feature is KmlNetworkLink)
                    {
                        KmlNetworkLink netLink = (KmlNetworkLink)feature;
                        if (netLink.LinkRoot != null)
                        {
                            foreach (KmlFeature child in netLink.LinkRoot.children)
                            {
                                AddFeatureToDisplay(child, sky);
                            }
                        }
                    }
                }
            }
        }