Exemple #1
0
        void DrawDebugGarbage(GameTime gameTime)
        {
            var fps = 1.0 / gameTime.ElapsedGameTime.TotalSeconds;

            var dbgi = GardenChunk.Index(dbgi_x, dbgi_y);
            var dbg  = garden.Chunks[0].Vertices[dbgi];

            var cat = (squareEffect.World * squareEffect.View * squareEffect.Projection);
            var p2  = Vector4.Transform(new Vector4(dbg.Position, 1), cat);
            var pp  = GraphicsDevice.Viewport.Project(
                dbg.Position,
                squareEffect.Projection,
                squareEffect.View,
                squareEffect.World);

            var spriteBatch = new SpriteBatch(GraphicsDevice);

            spriteBatch.Begin();
            spriteBatch.DrawString(
                font,
                $"{fps:0.00} {zoom:0.00} {yaw:0.00} {dv(dbg.Position)} " +
                $"{dv(p2)} {dv(pp)}",
                new Vector2(10, 10),
                Color.White);

            Vector2 xp = new Vector2(pp.X - 6, pp.Y - 6);

            spriteBatch.DrawString(font, "X", xp, Color.White);
            spriteBatch.End();
        }
Exemple #2
0
        static IndexBuffer BuildChunkIndexBuffer(GraphicsDevice device, GardenChunk chunk)
        {
            int cursor = 0;

            int indexCount =
                (GardenChunk.Width - 1) * (GardenChunk.Height - 1) * 6;

            short[] indices = new short[indexCount];
            for (int y = 0; y < GardenChunk.Height - 1; y++)
            {
                for (int x = 0; x < GardenChunk.Width - 1; x++)
                {
                    indices[cursor + 0] = (short)GardenChunk.Index(x + 0, y + 1);
                    indices[cursor + 1] = (short)GardenChunk.Index(x + 0, y + 0);
                    indices[cursor + 2] = (short)GardenChunk.Index(x + 1, y + 1);

                    indices[cursor + 3] = (short)GardenChunk.Index(x + 1, y + 1);
                    indices[cursor + 4] = (short)GardenChunk.Index(x + 0, y + 0);
                    indices[cursor + 5] = (short)GardenChunk.Index(x + 1, y + 0);

                    cursor += 6;
                }
            }
            var gardenIndices = new IndexBuffer(
                device,
                typeof(short),
                indices.Length,
                BufferUsage.WriteOnly);

            gardenIndices.SetData(indices);
            return(gardenIndices);
        }