public void Start()
    {
        //Variables init
        _Parser = new SvoParser();
        _Parser.Init(_GameObjectName);

        _AllNodePositions   = new List <voxelPosition>();
        _VoxelFaceFlags     = new List <uint>();
        _UnitFrustumVectors = new Vector3[4];

        //Get all childeren and add mortons to list
        List <Node> nodes = new List <Node>();

        _Parser.GetAllNodes(ref nodes, _Parser.GetRootNode());
        foreach (Node n in nodes)
        {
            //if (n._morton == 0) continue;
            uint x, y, z;
            Morton.morton3DDecode(n._morton, out x, out y, out z);

            _AllNodePositions.Add(new voxelPosition(x, y, z));
        }

        CullFaces(nodes);
        //DEBUG(nodes);

        InitBuffers();

        _Parser.Dispose();
    }
Exemplo n.º 2
0
    private void TestReadMortons(int voxelAmount)
    {
        //read mortons, decrypt mortons and compare to original file
        Stream       s       = File.Open("Assets/VoxelData.bin", FileMode.Open);
        BinaryReader br      = new BinaryReader(s);
        List <ulong> mortons = new List <ulong>();
        ulong        morton  = 1;

        for (int i = 0; i < voxelAmount; ++i)
        {
            morton = br.ReadUInt64();
            mortons.Add(morton);
        }
        br.Dispose();

        StreamWriter w = new StreamWriter("Assets/DecryptedMortons.txt");

        for (int i = 0; i < mortons.Capacity; ++i)
        {
            uint x, y, z;
            Morton.morton3DDecode(mortons[i], out x, out y, out z);
            w.Write($"{x}, {y}, {z}");
            w.Write('\n');
        }
        w.Dispose();
    }