コード例 #1
0
        public override void CleanUp(bool removeFromParent)
        {
            if (starVertexBuffer != null)
            {
                starVertexBuffer.Dispose();
                starVertexBuffer = null;
            }

            if (starProfile != null)
            {
                starProfile.Dispose();
                GC.SuppressFinalize(starProfile);
                starProfile = null;
            }
            TextureReady = false;
        }
コード例 #2
0
        void InitLabelBuffer()
        {
            if (labelBuffer == null)
            {
                var count = positions.Count;

                labelBuffer = new PositionColorSizeVertexBuffer11(count, RenderContext11.PrepDevice);

                var labelPoints = (PositionColorSize[])labelBuffer.Lock(0, 0); // Lock the buffer (which will return our structs)

                var index = 0;
                foreach (var point in positions)
                {
                    labelPoints[index].Position = new Vector3(point.X, point.Y, point.Z);
                    labelPoints[index].Color = Color.White;
                    labelPoints[index].size = 20f;
                    index++;
                }

                labelBuffer.Unlock();

            }
        }
コード例 #3
0
 void EmptyLabelBuffer()
 {
     //todo11
     if (labelBuffer != null)
     {
         labelBuffer.Dispose();
         GC.SuppressFinalize(labelBuffer);
         labelBuffer = null;
     }
 }
コード例 #4
0
        public void Dispose()
        {
            if (texture != null)
            {
                texture.Dispose();
                GC.SuppressFinalize(texture);
                texture = null;
            }

            if (labelBuffer != null)
            {
                labelBuffer.Dispose();
                GC.SuppressFinalize(labelBuffer);
                labelBuffer = null;
            }
        }
コード例 #5
0
        public override bool Draw3D(RenderContext11 renderContext, float opacity, Tile parent)
        {
            InViewFrustum = true;
            RenderedGeneration = CurrentRenderGeneration;
            if (!ReadyToRender)
            {
                TileCache.AddTileToQueue(this);
                return false;
            }

            InViewFrustum = true;

            if (starVertexBuffer == null)
            {
                starProfile = Texture11.FromBitmap( Resources.StarProfile);

                var count = stars.Count;
                var index = 0;
                starCount = count;

                starVertexBuffer = new PositionColorSizeVertexBuffer11(count, RenderContext11.PrepDevice);

                var points = (PositionColorSize[])starVertexBuffer.Lock(0, 0); // Lock the buffer (which will return our structs)
                foreach (var star in stars)
                {
                    var pos = Coordinates.RADecTo3d(star.RA + 12, star.Dec, 1f);
                    points[index].Position = pos.Vector3;
                    points[index].Color = star.Col;
                    var radDec = (.5) / Math.Pow(1.6, star.Magnitude);
                    points[index].size = (float)radDec;
                    index++;
                }
                starVertexBuffer.Unlock();
            }

            renderContext.SetVertexBuffer(starVertexBuffer);
            renderContext.BlendMode = BlendMode.Additive;
            renderContext.DepthStencilMode = DepthStencilMode.Off;
            renderContext.setRasterizerState(TriangleCullMode.Off);
            var mvp = (renderContext.World * renderContext.View * renderContext.Projection).Matrix11;
            mvp.Transpose();
            PointSpriteShader11.WVPMatrix = mvp;
            PointSpriteShader11.Color = Color.White;

            var adjustedScale = (float)(1 / (Earth3d.MainWindow.ZoomFactor / 360));

            PointSpriteShader11.ViewportScale = new Vector2((2.0f / renderContext.ViewPort.Width) * adjustedScale, (2.0f / renderContext.ViewPort.Height) * adjustedScale);
            PointSpriteShader11.PointScaleFactors = new Vector3(0.0f, 0.0f, 10000.0f);
            PointSpriteShader11.Use(renderContext.Device.ImmediateContext);

            renderContext.Device.ImmediateContext.PixelShader.SetShaderResource(0, starProfile.ResourceView);

            renderContext.devContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.PointList;
            renderContext.devContext.Draw(starCount, 0);

            renderContext.Device.ImmediateContext.GeometryShader.Set(null);

            // Reset blend mode so we don't mess up subsequent sky layer rendering
            renderContext.BlendMode = BlendMode.Alpha;

            return true;
        }