Ejemplo n.º 1
0
        public override bool Draw(RenderContext11 renderContext, float opacity, bool flat)
        {
            if (triangleList == null)
            {
                InitializeRoute(renderContext);
            }
            triangleList.JNow = percentComplete / 100;
            triangleList.Draw(renderContext, opacity * this.Opacity, TriangleList.CullMode.CounterClockwise);



            return(true);
        }
Ejemplo n.º 2
0
        public override bool Draw(RenderContext11 renderContext, float opacity, bool flat)
        {
            if (RetainedVisualsDirty)
            {
                UpdateRetainedVisuals();
                RetainedVisualsDirty = false;
            }

            triangles.Draw(renderContext, opacity, TriangleList.CullMode.Clockwise);
            lines.DrawLines(renderContext, opacity);
            DrawPlaceMarks();
            DrawScreenOverlays(renderContext);
            return(true);
        }
Ejemplo n.º 3
0
        public override bool Draw(RenderContext11 renderContext, float opacity, bool flat)
        {
            if (bufferIsFlat != flat)
            {
                CleanUp();
                bufferIsFlat = flat;
            }

            if (!CleanAndReady)
            {
                PrepVertexBuffer(opacity);
            }

            Matrix3d oldWorld = renderContext.World;

            if (astronomical && !bufferIsFlat)
            {
                double ecliptic = Coordinates.MeanObliquityOfEcliptic(SpaceTimeController.JNow) / 180.0 * Math.PI;
                renderContext.World = Matrix3d.RotationX(ecliptic) * renderContext.World;
            }


            if (triangleList2d != null)
            {
                triangleList2d.Decay      = decay;
                triangleList2d.Sky        = this.Astronomical;
                triangleList2d.TimeSeries = timeSeries;
                triangleList2d.Draw(renderContext, opacity * Opacity, TerraViewer.TriangleList.CullMode.CounterClockwise);
            }

            if (triangleList != null)
            {
                triangleList.Decay      = decay;
                triangleList.Sky        = this.Astronomical;
                triangleList.TimeSeries = timeSeries;
                triangleList.Draw(renderContext, opacity * Opacity, TerraViewer.TriangleList.CullMode.CounterClockwise);
            }

            if (lineList != null)
            {
                lineList.Sky        = this.Astronomical;
                lineList.Decay      = decay;
                lineList.TimeSeries = timeSeries;

                lineList.DrawLines(renderContext, opacity * Opacity);
            }

            if (lineList2d != null)
            {
                lineList2d.Sky         = !this.Astronomical;
                lineList2d.Decay       = decay;
                lineList2d.TimeSeries  = timeSeries;
                lineList2d.ShowFarSide = ShowFarSide;
                lineList2d.DrawLines(renderContext, opacity * Opacity);
            }

            if (textBatch != null)
            {
                DepthStencilMode mode = renderContext.DepthStencilMode;

                renderContext.DepthStencilMode = DepthStencilMode.Off;

                textBatch.Draw(renderContext, 1, Color.White);
                renderContext.DepthStencilMode = mode;
            }

            if (astronomical && !bufferIsFlat)
            {
                renderContext.DepthStencilMode = DepthStencilMode.ZReadWrite;
            }
            else
            {
                renderContext.DepthStencilMode = DepthStencilMode.Off;
            }

            DateTime baseDate = new DateTime(2010, 1, 1, 12, 00, 00);

            renderContext.setRasterizerState(TriangleCullMode.Off);

            Vector3 cam           = Vector3d.TransformCoordinate(renderContext.CameraPosition, Matrix3d.Invert(renderContext.World)).Vector311;
            float   adjustedScale = scaleFactor;

            if (flat && astronomical && (markerScale == MarkerScales.World))
            {
                adjustedScale = (float)(scaleFactor / (Earth3d.MainWindow.ZoomFactor / 360));
            }

            Matrix matrixWVP = (renderContext.World * renderContext.View * renderContext.Projection).Matrix11;

            matrixWVP.Transpose();
            switch (plotType)
            {
            default:
            case PlotTypes.Gaussian:
                renderContext.BlendMode = BlendMode.Additive;
                renderContext.Device.ImmediateContext.PixelShader.SetShaderResource(0, Grids.StarProfile.ResourceView);
                break;

            case PlotTypes.Circle:
                renderContext.BlendMode = BlendMode.Alpha;
                renderContext.Device.ImmediateContext.PixelShader.SetShaderResource(0, CircleTexture.ResourceView);
                break;

            case PlotTypes.Point:
                renderContext.BlendMode = BlendMode.Alpha;
                renderContext.Device.ImmediateContext.PixelShader.SetShaderResource(0, PointTexture.ResourceView);
                break;

            case PlotTypes.Square:
                renderContext.BlendMode = BlendMode.Alpha;
                renderContext.Device.ImmediateContext.PixelShader.SetShaderResource(0, SquareTexture.ResourceView);
                break;

            case PlotTypes.Target1:
                renderContext.BlendMode = BlendMode.Alpha;
                renderContext.Device.ImmediateContext.PixelShader.SetShaderResource(0, Target1Texture.ResourceView);
                break;

            case PlotTypes.Target2:
                renderContext.BlendMode = BlendMode.Alpha;
                renderContext.Device.ImmediateContext.PixelShader.SetShaderResource(0, Target2Texture.ResourceView);
                break;

            case PlotTypes.PushPin:
                renderContext.BlendMode = BlendMode.Alpha;
                renderContext.Device.ImmediateContext.PixelShader.SetShaderResource(0, PushPin.GetPushPinTexture(markerIndex).ResourceView);
                break;
            }

            columnChartsActivate.TargetState = plotType == PlotTypes.Column;

            if (shapeFileVertex != null)
            {
                if (plotType == PlotTypes.Column && !RenderContext11.Downlevel) // column chart mode
                {
                    columnChartsActivate.TargetState = true;

                    renderContext.BlendMode = BlendMode.Alpha;
                    renderContext.setRasterizerState(TriangleCullMode.CullClockwise);
                    renderContext.Device.ImmediateContext.PixelShader.SetShaderResource(0, null);
                    renderContext.DepthStencilMode = DepthStencilMode.ZReadWrite;
                    TimeSeriesColumnChartShader11.Constants.CameraPosition = new SharpDX.Vector4(cam, 1);
                    TimeSeriesColumnChartShader11.Constants.JNow           = (float)(SpaceTimeController.JNow - SpaceTimeController.UtcToJulian(baseDate));
                    TimeSeriesColumnChartShader11.Constants.Decay          = timeSeries ? decay : 0f;
                    TimeSeriesColumnChartShader11.Constants.Scale          = (float)(adjustedScale);
                    TimeSeriesColumnChartShader11.Constants.Sky            = astronomical ? -1 : 1;
                    TimeSeriesColumnChartShader11.Constants.Opacity        = opacity * this.Opacity;
                    TimeSeriesColumnChartShader11.Constants.ShowFarSide    = ShowFarSide ? 1f : 0f;
                    TimeSeriesColumnChartShader11.Color = new SharpDX.Color4(Color.R / 255f, Color.G / 255f, Color.B / 255f, Color.A / 255f);
                    TimeSeriesColumnChartShader11.Constants.WorldViewProjection = matrixWVP;
                    TimeSeriesColumnChartShader11.ViewportScale = new SharpDX.Vector2(2.0f / renderContext.ViewPort.Width, 2.0f / renderContext.ViewPort.Height);
                    TimeSeriesColumnChartShader11.Use(renderContext.devContext);
                }
                else if (plotType == PlotTypes.Cylinder && !RenderContext11.Downlevel)
                {
                    renderContext.BlendMode = BlendMode.Alpha;
                    renderContext.setRasterizerState(TriangleCullMode.CullClockwise);
                    renderContext.Device.ImmediateContext.PixelShader.SetShaderResource(0, null);
                    renderContext.DepthStencilMode = DepthStencilMode.ZReadWrite;
                    TimeSeriesColumnChartShaderNGon11.Constants.CameraPosition = new SharpDX.Vector4(cam, 1);
                    TimeSeriesColumnChartShaderNGon11.Constants.JNow           = (float)(SpaceTimeController.JNow - SpaceTimeController.UtcToJulian(baseDate));
                    TimeSeriesColumnChartShaderNGon11.Constants.Decay          = timeSeries ? decay : 0f;
                    TimeSeriesColumnChartShaderNGon11.Constants.Scale          = (float)(adjustedScale);
                    TimeSeriesColumnChartShaderNGon11.Constants.Sky            = astronomical ? -1 : 1;
                    TimeSeriesColumnChartShaderNGon11.Constants.Opacity        = opacity * this.Opacity;
                    TimeSeriesColumnChartShaderNGon11.Constants.ShowFarSide    = ShowFarSide ? 1f : 0f;
                    TimeSeriesColumnChartShaderNGon11.Color = new SharpDX.Color4(Color.R / 255f, Color.G / 255f, Color.B / 255f, Color.A / 255f);
                    TimeSeriesColumnChartShaderNGon11.Constants.WorldViewProjection = matrixWVP;
                    TimeSeriesColumnChartShaderNGon11.ViewportScale = new SharpDX.Vector2(2.0f / renderContext.ViewPort.Width, 2.0f / renderContext.ViewPort.Height);
                    TimeSeriesColumnChartShaderNGon11.Use(renderContext.devContext);
                }
                else
                {
                    TimeSeriesPointSpriteShader11.Constants.CameraPosition = new SharpDX.Vector4(cam, 1);
                    double jBase = SpaceTimeController.UtcToJulian(baseDate);
                    TimeSeriesPointSpriteShader11.Constants.JNow        = (float)(SpaceTimeController.JNow - jBase);
                    TimeSeriesPointSpriteShader11.Constants.Decay       = timeSeries ? decay : 0f;
                    TimeSeriesPointSpriteShader11.Constants.Scale       = ((markerScale == MarkerScales.World) ? ((float)adjustedScale) : (-(float)adjustedScale));
                    TimeSeriesPointSpriteShader11.Constants.Sky         = astronomical ? -1 : 1;
                    TimeSeriesPointSpriteShader11.Constants.Opacity     = opacity * this.Opacity;
                    TimeSeriesPointSpriteShader11.Constants.ShowFarSide = ShowFarSide ? 1f : 0f;
                    TimeSeriesPointSpriteShader11.Color = new SharpDX.Color4(Color.R / 255f, Color.G / 255f, Color.B / 255f, Color.A / 255f);
                    TimeSeriesPointSpriteShader11.Constants.WorldViewProjection = matrixWVP;
                    TimeSeriesPointSpriteShader11.ViewportScale     = new SharpDX.Vector2(2.0f / renderContext.ViewPort.Width, 2.0f / renderContext.ViewPort.Height);
                    TimeSeriesPointSpriteShader11.PointScaleFactors = new SharpDX.Vector3(0.0f, 0.0f, 10.0f);
                    if (shapeFileVertex.Downlevel)
                    {
                        DownlevelTimeSeriesPointSpriteShader.Use(renderContext.devContext, shapeFileVertex.Instanced);
                    }
                    else
                    {
                        TimeSeriesPointSpriteShader11.Use(renderContext.devContext);
                    }
                }


                shapeFileVertex.Draw(renderContext, shapeFileVertex.Count, null, 1.0f);
            }
            renderContext.Device.ImmediateContext.GeometryShader.Set(null);
            renderContext.BlendMode = BlendMode.Alpha;


            renderContext.World = oldWorld;

            return(true);
        }