예제 #1
0
        public void Render(Earth3d window)
        {
            //todo11 reanble this
            if (texture == null)
            {
                Bitmap bmp = null;
                bmp = GetChartImageBitmap(window);
                bmp.Dispose();
            }


            Sprite2d.Draw2D(window.RenderContext11, texture, new SizeF(texture.Width, texture.Height), new PointF(0, 0), 0, new PointF(Left + texture.Width / 2, Top + texture.Height / 2), Color.White);


            if (!String.IsNullOrEmpty(HoverText))
            {
                Rectangle recttext = new Rectangle((int)(hoverPoint.X + 15), (int)(hoverPoint.Y - 8), 0, 0);
            }


            return;
        }
예제 #2
0
        public void DrawScreenOverlays(RenderContext11 renderContext)
        {
            foreach (KmlScreenOverlay overlay in ScreenOverlays)
            {
                Texture11 texture = overlay.Icon.Texture;

                if (texture != null)
                {
                    PointF center = new PointF();
                    PointF screen = new PointF();

                    SizeF size = new SizeF();

                    if (overlay.RotationSpot.UnitsX == KmlPixelUnits.Fraction)
                    {
                        center.X = overlay.RotationSpot.X * texture.Width;
                    }


                    if (overlay.RotationSpot.UnitsY == KmlPixelUnits.Fraction)
                    {
                        center.Y = overlay.RotationSpot.Y * texture.Height;
                    }

                    Rectangle clientRect = Earth3d.MainWindow.ClearClientArea;

                    Size clientSize = clientRect.Size;

                    if (overlay.ScreenSpot.UnitsX == KmlPixelUnits.Fraction)
                    {
                        screen.X = overlay.ScreenSpot.X * clientSize.Width;
                    }
                    else if (overlay.Size.UnitsX == KmlPixelUnits.Pixels)
                    {
                        screen.X = overlay.ScreenSpot.X;
                    }

                    if (overlay.ScreenSpot.UnitsY == KmlPixelUnits.Fraction)
                    {
                        screen.Y = overlay.ScreenSpot.Y * clientSize.Height;
                    }
                    else if (overlay.Size.UnitsY == KmlPixelUnits.Pixels)
                    {
                        screen.Y = overlay.ScreenSpot.Y;
                    }

                    if (overlay.Size.UnitsX == KmlPixelUnits.Fraction)
                    {
                        if (overlay.Size.X == -1)
                        {
                            size.Width = texture.Width;
                        }
                        else
                        {
                            size.Width = overlay.Size.X * clientSize.Width;
                        }
                    }
                    else if (overlay.Size.UnitsX == KmlPixelUnits.Pixels)
                    {
                        if (overlay.Size.X == -1)
                        {
                            size.Width = texture.Width;
                        }
                        else
                        {
                            size.Width = overlay.Size.X;
                        }
                    }

                    if (overlay.Size.UnitsY == KmlPixelUnits.Fraction)
                    {
                        size.Height = overlay.Size.Y * clientSize.Height;
                    }
                    else if (overlay.Size.UnitsY == KmlPixelUnits.Pixels)
                    {
                        if (overlay.Size.Y == -1)
                        {
                            size.Height = texture.Height;
                        }
                        else
                        {
                            size.Height = overlay.Size.Y;
                        }
                    }
                    screen.Y = clientRect.Bottom - screen.Y - size.Height + center.Y;
                    screen.X = clientRect.Left + screen.X + center.X;


                    Sprite2d.Draw2D(renderContext, texture, size, center, (float)overlay.Rotation, screen, overlay.color);
                    //sprite.Draw2D(texture, Rectangle.Empty, size, center, (float)overlay.Rotation, screen, Color.White);
                }
            }
        }
예제 #3
0
        public void DrawPlaceMarks()
        {
            // todo11 port this Maybe instancing later?
            Matrix   projection = Earth3d.MainWindow.RenderContext11.Projection.Matrix11;
            Matrix   view       = Earth3d.MainWindow.RenderContext11.View.Matrix11;
            Matrix   world      = Earth3d.MainWindow.RenderContext11.World.Matrix11;
            Matrix3d worldD     = Earth3d.MainWindow.RenderContext11.World;
            Matrix   wvp        = (world * view * projection);

            try
            {
                Vector3 center = new Vector3(0f, 0f, 0);

                foreach (KmlPlacemark placemark in Placemarks)
                {
                    if (placemark.ShouldDisplay())
                    {
                        SharpDX.Direct3D11.Viewport vp = Earth3d.MainWindow.RenderContext11.ViewPort;
                        double   alt     = placemark.Point.altitude + EGM96Geoid.Height(placemark.Point.latitude, placemark.Point.longitude);
                        Vector3d point3d = Coordinates.GeoTo3dDouble(placemark.Point.latitude, placemark.Point.longitude, 1 + (alt / Earth3d.MainWindow.RenderContext11.NominalRadius));
                        Vector3  point   = Vector3.Project(point3d.Vector311, vp.TopLeftX, vp.TopLeftY, vp.Width, vp.Height, 0, 1, wvp);
                        // point.Z = 1;
                        KmlStyle  style   = placemark.Style.GetStyle(placemark.Selected);
                        Texture11 texture = style.IconStyle.Icon.Texture;

                        if (String.IsNullOrEmpty(style.IconStyle.Icon.Href))
                        {
                            texture = Star;
                        }

                        double sizeFactor = 1;

                        if (placemark.Selected)
                        {
                            double ticks          = HiResTimer.TickCount;
                            double elapsedSeconds = ((double)(ticks - TicksAtLastSelect)) / HiResTimer.Frequency;
                            sizeFactor = 1 + .3 * (Math.Sin(elapsedSeconds * 15) * Math.Max(0, (1 - elapsedSeconds)));
                        }

                        point3d.TransformCoordinate(worldD);
                        Vector3d dist     = Earth3d.MainWindow.RenderContext11.CameraPosition - point3d;
                        double   distance = dist.Length() * Earth3d.MainWindow.RenderContext11.NominalRadius;
                        dist.Normalize();
                        double dot = Vector3d.Dot(point3d, dist);
                        // if (dot > -.2)
                        {
                            double baseSize = Math.Min(40, 25 * ((2 * Math.Atan(.5 * (5884764 / distance))) / .7853)) * sizeFactor;
                            float  size     = (float)baseSize * style.IconStyle.Scale;
                            //todo fix this with real centers and offset by KML data
                            placemark.hitTestRect = new Rectangle((int)(point.X - (size / 2)), (int)(point.Y - (size / 2)), (int)(size + .5), (int)(size + .5));
                            if (texture != null)
                            {
                                center = new Vector3((float)texture.Width / 2f, (float)texture.Height / 2f, 0);

                                Sprite2d.Draw2D(Earth3d.MainWindow.RenderContext11, texture, new SizeF(size, size), new PointF(center.X, center.Y), (float)(style.IconStyle.Heading * Math.PI / 180f), new PointF(point.X, point.Y), Color.White);
                            }

                            if (style.LabelStyle.Color.A > 0 && style.LabelStyle.Scale > 0)
                            {
                                Rectangle recttext = new Rectangle((int)(point.X + (size / 2) + 10), (int)(point.Y - (size / 2)), 1000, 100);
                                //todo11 Earth3d.MainWindow.labelFont.DrawText(null, placemark.Name, recttext, DrawTextFormat.NoClip, style.LabelStyle.Color);
                            }
                        }
                    }
                }
            }
            finally
            {
            }
        }
예제 #4
0
        public void Draw(RenderContext11 renderContext, bool space3d)
        {
            Vector3d cam = Vector3d.TransformCoordinate(Earth3d.MainWindow.RenderContext11.CameraPosition, Matrix3d.Invert(Earth3d.WorldMatrix));

            if (!space3d)
            {
                if (Vector3d.Dot(cam, pos) < 0)
                {
                    return;
                }
            }
            Vector3d temp = pos;

            if (Earth3d.MainWindow.SolarSystemMode)
            {
                temp.Add(Earth3d.MainWindow.viewCamera.ViewTarget);
            }

            Matrix3d wvp = renderContext.World * renderContext.View * renderContext.Projection;

            Vector3 screenPos = Vector3.Project(temp.Vector311, renderContext.ViewPort.X, renderContext.ViewPort.Y, renderContext.ViewPort.Width, renderContext.ViewPort.Height, 0, 1, wvp.Matrix11);

            // Get the w component of the transformed object position; if it's negative the
            // object is behind the viewer.
            double w = wvp.M14 * temp.X + wvp.M24 * temp.Y + wvp.M34 * temp.Z + wvp.M44;

            if (w < 0.0 && Earth3d.MainWindow.SolarSystemMode)
            {
                // Don't show labels that are behind the viewer
                return;
            }


            screenPos = new Vector3((float)(int)screenPos.X, (float)(int)screenPos.Y, 1);

            Sprite2d.Draw2D(renderContext, texture, new SizeF(20, 20), new PointF(0, 0), 0, new PointF(screenPos.X, screenPos.Y), Color.White);

            if (Earth3d.MainWindow.SolarSystemMode || Style == LabelSytle.Telrad)
            {
                Matrix3d worldMatrix      = renderContext.World;
                Matrix3d viewMatrix       = renderContext.View;
                Matrix3d projectionMatrix = renderContext.Projection;

                double labelScale = Earth3d.MainWindow.SolarSystemMode ? 8.0 : 30.0;
                renderContext.World =
                    Matrix3d.Scaling(labelScale, labelScale, 1.0) *
                    Matrix3d.Translation(screenPos.X + 10.0, -screenPos.Y, 0.0) *
                    Matrix3d.Translation(-renderContext.ViewPort.Width / 2, renderContext.ViewPort.Height / 2, 0);
                renderContext.View       = Matrix3d.Identity;
                renderContext.Projection = Matrix3d.OrthoLH(renderContext.ViewPort.Width, renderContext.ViewPort.Height, 1, -1);

                renderContext.BlendMode = BlendMode.PremultipliedAlpha;
                textBatch.Draw(renderContext, 1, Color.White);

                renderContext.World      = worldMatrix;
                renderContext.View       = viewMatrix;
                renderContext.Projection = projectionMatrix;
            }
            else
            {
                renderContext.BlendMode = BlendMode.PremultipliedAlpha;
                textBatch.Draw(renderContext, 1, Color.White);
            }

            //todo11 Implement this
            //sprite.Begin(SpriteFlags.AlphaBlend | SpriteFlags.SortTexture);

            //sprite.Draw(texture, rect, center, screenPos, Color.White);
            //Rectangle recttext = new Rectangle((int)(screenPos.X + 15), (int)(screenPos.Y - 8), 0, 0);
            //Earth3d.MainWindow.labelFont.DrawText(sprite, Text, recttext,
            //DrawTextFormat.NoClip, System.Drawing.Color.White);


            //sprite.End();
        }