Exemplo n.º 1
0
        static void TestLowPassFilter()
        {
            var voxels = MagicaFile.Load(@"..\..\..\..\Assets\VoxModels\cathedral-2.vox")[0];

            //var voxels = MagicaFile.Load(@"..\..\..\..\Assets\VoxModels\Twist.vox")[0];

            Console.WriteLine("Raw boxes: {0}", BoxMaker.MakeBoxes(voxels).Count);
            for (int i = 0; i <= 20; ++i)
            {
                float transference = i / 20.0f;
                var   shape        = BoxMaker.LowPassFilter(voxels, transference, 0.25f);
                Console.WriteLine("{0,3}: {1:F2} {2,6}", i, transference, BoxMaker.MakeBoxes(shape).Count);
            }
        }
Exemplo n.º 2
0
    // Makes a set of covers to completely cover the given shape.
    static List <BoxMaker.Box> MakeBoxes(VoxelSet <bool> shape, int scale)
    {
        List <BoxMaker.Box> boxes = BoxMaker.MakeBoxes(shape);

        if (scale != 1)
        {
            foreach (var box in boxes)
            {
                box.extents *= scale;
                box.origin  *= scale;
            }
        }

        return(boxes);
    }
Exemplo n.º 3
0
        static void TestSimplify4()
        {
            //var voxels = MagicaFile.Load(@"C:\Projects\FloofBox\uRogue\Assets\VoxModels\cathedral-2.vox");
            var voxels = MagicaFile.Load(@"..\..\..\..\Assets\Vox\TransparencyTest.vox");

            var boxes = BoxMaker.MakeBoxes(voxels[0]);

            Console.WriteLine("{0} boxes made", boxes.Count);

            MeshSimplifier ms = Mesher.VoxelsToMeshFull(voxels[0]);

            Console.WriteLine("Triangles before reduction: " + (ms.Edges.Length / 3));
            ms.Simplify();
            ms.Compact();
            Console.WriteLine("Triangles after reduction: " + (ms.Edges.Length / 3));
            int[]   tris;
            Vec3f[] rawPos;
            Vec3f[] rawNormals;
            Vec2f[] rawUvs;

            VoxelSet <Vec4b> atlas;

            ms.GetMesh(voxels[0], out tris, out rawPos, out rawNormals, out rawUvs, out atlas);

            Bitmap bmp = new Bitmap(atlas.Size.x, atlas.Size.y);

            for (int y = 0; y < atlas.Size.y; ++y)
            {
                for (int x = 0; x < atlas.Size.x; ++x)
                {
                    bmp.SetPixel(x, y, Color.FromArgb(
                                     atlas[x, y, 0].x,
                                     atlas[x, y, 0].y,
                                     atlas[x, y, 0].z
                                     ));
                }
            }

            bmp.Save("Atlas.png");
        }