public void TestGenerateLodTerrainMeshes()
        {
            var tree = new LodOctree();
            var size = 128;
            var root = tree.Create(size, size);

            tree.UpdateQuadtreeClipmaps(root, new Vector3(size / 2, size / 2, size / 2), 8);

            var density = new Func <Vector3, float>(v => DensityHermiteGridTest.SineXzDensityFunction(v, 1 / 5f, size / 2, 3));
            var builder = new LodOctreeMeshBuilder();
            var list    = new List <LodOctreeNode>();

            builder.ListMeshLessNodes(root, list);
            list.ForEach(n =>
            {
                if (n.Children != null)
                {
                    return;
                }
                var mesh = builder.CalculateNodeMesh(n, 8, density);
                n.Mesh   = mesh;   // This is flakey

                builder.CreateRenderElementForNode(n, 8, mesh);
            });

            EngineFactory.CreateEngine().AddSimulator(() => { tree.DrawLines(root, TW.Graphics.LineManager3D); }, "Octreelines");

            VisualTestingEnvironment.Load();
        }
        public void TestLodOctree()
        {
            var tree = new LodOctree();
            var root = tree.Create(32 * 4, 32);

            var engine = EngineFactory.CreateEngine();

            engine.AddSimulator(new WorldRenderingSimulator());
            engine.AddSimulator(() =>
            {
                tree.DrawLines(root, TW.Graphics.LineManager3D);
            }, "LinesOctree");
        }
        public TerrainLodEnvironment()
        {

            tree = new LodOctree();

            var size = 32 * (1 << 10);
            rootNode = tree.Create(size, size);

            //octreeOffset = new Vector3(0, size, 0);
            octreeOffset = new Vector3(0, 0, 0);


            density = VoxelTerrainGenerationTest.createDensityFunction5Perlin(17, size / 2);
            //density = v => DensityHermiteGridTest.SineXzDensityFunction(v, 1/5f, size/2, 3);
            density = densityFunction;
            densityGrid = new DensityFunctionHermiteGrid(density, new Point3(size, size, size));
            minNodeSize = 32;




        }