예제 #1
0
        public void Draw(RenderContext context)
        {
            if (context.layerPass != RenderContext.LayerPass.UI_PASS)
            {
                return;
            }
            if (debugLinesBuffer == null)
            {
                BlobCollection blobs = OSMReader.GetAllBlobs(sector);
                debugLinesBuffer = OSMLineBufferGenerator.GenerateDebugLines(context.graphicsDevice, blobs);
            }
            // draw those lines
            Effect effect = GlobalContent.DebugLinesShader;

            effect.Parameters["Texture"].SetValue(debugLinesBuffer.texture);
            effect.Parameters["WVP"].SetValue(context.WVP.toMatrix());
            effect.Parameters["LineWidth"].SetValue((float)Math.Pow(0.5, context.cameraZoom) * 50);
            context.graphicsDevice.Indices = debugLinesBuffer.indices;
            context.graphicsDevice.SetVertexBuffer(debugLinesBuffer.vertices);
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                context.graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, debugLinesBuffer.indices.IndexCount / 3);
            }
            // TODO: need to call this once for all debug buffers somehow
            string  text = $"Nothing Selected";
            Vector2 size = GlobalContent.Arial.MeasureString(text);

            spriteBatch.Begin(SpriteSortMode.Deferred, null, null, DepthStencilState.Default, null, null, null);
            spriteBatch.DrawString(GlobalContent.Arial, text, new Vector2(context.graphicsDevice.Viewport.Width - 5 - size.X, 5), Color.White);
            spriteBatch.End();
        }
예제 #2
0
        public void LoadLinesFromFile()
        {
            BlobCollection blobs = OSMReader.GetAllBlobs(sector);

            BlobsIntersector.DoIntersections(blobs);

            var allDescriptors = new List <IDescriptor>();

            allDescriptors.AddRange(descriptors);
            allDescriptors.AddRange(treeDescriptors);
            allDescriptors.AddRange(grassDescriptors);
            foreach (var descriptor in allDescriptors)
            {
                descriptor.Load(blobs);
                descriptor.Init(blobs);
            }
        }