public static void DrawBatch(RenderContext renderContext)
        {
            BatchDirty = false;
            if (renderContext.gl == null)
            {
                return;
            }

            if (PointList != null)
            {
                PointList.Draw(renderContext, 1, false);
            }

            if (LineList != null)
            {
                LineList.DrawLines(renderContext, 1);
            }


            if (TriangleFanPointList != null)
            {
                TriangleFanPointList.Draw(renderContext, 1);
            }

            if (TriangleList != null)
            {
                TriangleList.Draw(renderContext, 1, CullMode.None);
            }
        }
Example #2
0
        public override bool Draw(RenderContext renderContext, float opacity, bool flat)
        {
            if (triangleList == null)
            {
                InitializeRoute(renderContext);
            }
            triangleList.JNow = percentComplete / 100;
            triangleList.Draw(renderContext, opacity * this.Opacity, CullMode.CounterClockwise);


            return(true);
        }
Example #3
0
        public override bool Draw(RenderContext renderContext, float opacity, bool flat)
        {
            RenderContext device = renderContext;

            //if (shaderA == null)
            //{
            //    MakeVertexShaderA(device);
            //}

            if (bufferIsFlat != flat)
            {
                CleanUp();
                bufferIsFlat = flat;
            }

            if (dirty)
            {
                PrepVertexBuffer(device, opacity);
            }

            double jNow = SpaceTimeController.JNow - SpaceTimeController.UtcToJulian(baseDate);


            float adjustedScale = scaleFactor;

            if (flat && astronomical && (markerScale == MarkerScales.World))
            {
                adjustedScale = (float)(scaleFactor / (renderContext.ViewCamera.Zoom / 360));
            }


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

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


            if (pointList != null)
            {
                pointList.DepthBuffered = false;
                pointList.Decay         = decay;
                pointList.Sky           = this.Astronomical;
                pointList.TimeSeries    = timeSeries;
                pointList.JNow          = jNow;
                pointList.scale         = (markerScale == MarkerScales.World) ? (float)adjustedScale : -(float)adjustedScale;
                pointList.Draw(renderContext, opacity * Opacity, false);
            }

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

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

            //device.RenderState.AlphaBlendEnable = true;
            //device.RenderState.SourceBlend = Microsoft.DirectX.Direct3D.Blend.SourceAlpha;
            //device.RenderState.DestinationBlend = Microsoft.DirectX.Direct3D.Blend.InvSourceAlpha;
            //device.RenderState.ColorWriteEnable = ColorWriteEnable.RedGreenBlueAlpha;

            //TextureOperation oldTexOp = device.TextureState[0].ColorOperation;

            //bool zBufferEnabled = device.RenderState.ZBufferEnable;

            //if (astronomical && !bufferIsFlat)
            //{
            //    device.RenderState.ZBufferEnable = true;
            //}
            //else
            //{
            //    device.RenderState.ZBufferEnable = false;
            //}
            //device.TextureState[0].ColorOperation = TextureOperation.Disable;

            //FillMode oldMode = device.RenderState.FillMode;
            //DateTime baseDate = new DateTime(2010, 1, 1, 12, 00, 00);
            //device.RenderState.FillMode = FillMode.Solid;
            //device.SetTexture(0, null);
            //device.Indices = shapeFileIndex;
            //device.VertexShader = shaderA;
            //// Vector3 cam = Vector3d.TransformCoordinate(Earth3d.cameraPosition, Matrix3d.Invert(renderContext.World)).Vector3;
            //Vector3 cam = Vector3.TransformCoordinate(renderContext.CameraPosition.Vector3, Matrix.Invert(renderContext.Device.Transform.World));
            //constantTableA.SetValue(device, cameraHandleA, new Vector4(cam.X, cam.Y, cam.Z, 1));
            //constantTableA.SetValue(device, jNowHandleA, (float)(SpaceTimeController.JNow - SpaceTimeController.UtcToJulian(baseDate)));
            //constantTableA.SetValue(device, decayHandleA, timeSeries ? decay : 0f);

            //float adjustedScale = scaleFactor;

            //if (flat && astronomical && (markerScale == MarkerScales.World))
            //{
            //    adjustedScale = (float)(scaleFactor / (Earth3d.MainWindow.ZoomFactor / 360));
            //}
            //constantTableA.SetValue(device, scaleHandleA, (markerScale == MarkerScales.World) ? (float)adjustedScale : -(float)adjustedScale);
            //constantTableA.SetValue(device, skyHandleA, astronomical ? -1 : 1);
            //constantTableA.SetValue(device, opacityHandleA, opacity * this.Opacity);
            //constantTableA.SetValue(device, showFarSideHandleA, ShowFarSide ? 1f : 0f);

            //// Matrix matrixWVP = Earth3d.WorldMatrix * Earth3d.ViewMatrix * Earth3d.ProjMatrix;
            ////Matrix matrixWVP = device.Transform.World * device.Transform.View * device.Transform.Projection;
            //Matrix3d matrixWVP = renderContext.World * renderContext.View * renderContext.Projection;

            //constantTableA.SetValue(device, worldViewHandleA, matrixWVP.Matrix);

            //device.SetStreamSource(0, shapeFileVertex, 0);
            ////device.VertexFormat = VertexFormats.None;
            ////device.VertexDeclaration = vertexDeclA;
            //device.VertexFormat = PointVertex.Format;

            //device.RenderState.PointSpriteEnable = plotType != PlotTypes.Point;

            //device.RenderState.PointScaleEnable = (markerScale == MarkerScales.World && plotType != PlotTypes.Point) ? true : false;
            //device.RenderState.PointSize = 0;
            //device.RenderState.PointScaleA = 0;
            //device.RenderState.PointScaleB = 0;

            //device.RenderState.PointScaleC = 10000000f;

            //switch (plotType)
            //{
            //    case PlotTypes.Gaussian:
            //        device.SetTexture(0, Grids.StarProfile);
            //        break;
            //    case PlotTypes.Circle:
            //        device.SetTexture(0, CircleTexture);
            //        break;
            //    case PlotTypes.Point:
            //        device.SetTexture(0, null);
            //        break;
            //    //case PlotTypes.Square:
            //    //    device.SetTexture(0, null);
            //    //    break;
            //    //case PlotTypes.Custom:
            //    //    break;
            //    case PlotTypes.PushPin:
            //        device.SetTexture(0, PushPin.GetPushPinTexture(markerIndex));
            //        break;

            //    default:
            //        break;
            //}



            //device.RenderState.CullMode = Cull.None;
            //device.RenderState.AlphaBlendEnable = true;
            //device.RenderState.SourceBlend = Microsoft.DirectX.Direct3D.Blend.SourceAlpha;
            //if (plotType == PlotTypes.Gaussian)
            //{
            //    device.RenderState.DestinationBlend = Microsoft.DirectX.Direct3D.Blend.One;
            //}
            //else
            //{
            //    device.RenderState.DestinationBlend = Microsoft.DirectX.Direct3D.Blend.InvSourceAlpha;
            //}


            //device.RenderState.ColorWriteEnable = ColorWriteEnable.RedGreenBlueAlpha;
            //device.TextureState[0].ColorOperation = TextureOperation.Modulate;
            //device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor;
            //device.TextureState[0].ColorArgument2 = TextureArgument.Diffuse;
            //device.TextureState[0].AlphaOperation = TextureOperation.Modulate;
            //device.TextureState[0].AlphaArgument1 = TextureArgument.TextureColor;
            //device.TextureState[0].AlphaArgument2 = TextureArgument.Diffuse;

            //device.TextureState[1].ColorOperation = TextureOperation.Disable;
            //device.TextureState[1].ColorArgument1 = TextureArgument.Current;
            //device.TextureState[1].ColorArgument2 = TextureArgument.Constant;
            //device.TextureState[1].AlphaOperation = TextureOperation.Disable;
            //device.TextureState[1].AlphaArgument1 = TextureArgument.Current;
            //device.TextureState[1].AlphaArgument2 = TextureArgument.Constant;

            //device.TextureState[1].ConstantColor = Color.FromArgb(255, 255, 255, 255);
            ////                device.TextureState[1].ConstantColor = Color.FromArgb(0, 0, 0, 0);



            //device.DrawPrimitives(PrimitiveType.PointList, 0, shapeVertexCount);
            //device.RenderState.PointSpriteEnable = false;


            ////device.DrawUserPrimitives(PrimitiveType.LineList, segments, points);

            //device.RenderState.FillMode = oldMode;
            //device.TextureState[0].ColorOperation = oldTexOp;
            //device.VertexShader = null;

            //device.RenderState.ZBufferEnable = zBufferEnabled;
            //device.RenderState.AlphaBlendEnable = false;
            //device.RenderState.ColorWriteEnable = ColorWriteEnable.RedGreenBlue;
            return(true);
        }