Exemple #1
0
    public void LoadVOXData(byte[] data, bool asIndividualVoxels, byte[] alphaMaskData = null)
    {
        ClearVoxMeshes();

        MVVoxelChunk alphaMask = null;

        if (alphaMaskData != null)
        {
            MVMainChunk mc = MVImporter.LoadVOXFromData(alphaMaskData, generateFaces: false);
            if (mc != null)
            {
                alphaMask = mc.voxelChunk;
            }
        }
        MVMainChunk v = MVImporter.LoadVOXFromData(data, alphaMask);

        if (v != null)
        {
            Material mat = (this.voxMaterial != null) ? this.voxMaterial : MVImporter.DefaultMaterial;
            if (!asIndividualVoxels)
            {
                MVImporter.CreateVoxelGameObjects(v, this.gameObject.transform, mat, sizePerVox);
            }
            else
            {
                MVImporter.CreateIndividualVoxelGameObjects(v, this.gameObject.transform, mat, sizePerVox);
            }

            this.vox = v;
        }
    }
    public void LoadVOXData(byte[] data, bool asIndividualVoxels)
    {
        ClearVoxMeshes();

        MVMainChunk v = MVImporter.LoadVOXFromData(data);

        if (v != null)
        {
            Material mat = (this.voxMaterial != null) ? this.voxMaterial : MVImporter.DefaultMaterial;

            if (paletteToTex)
            {
                mat.mainTexture = v.PaletteToTexture();
            }

            if (!asIndividualVoxels)
            {
                MVImporter.CreateVoxelGameObjects(v, this.gameObject.transform, mat, sizePerVox);
            }
            else
            {
                MVImporter.CreateIndividualVoxelGameObjects(v, this.gameObject.transform, mat, sizePerVox);
            }

            this.vox = v;
        }
    }
Exemple #3
0
    public static MVMainChunk LoadVOX(string path, bool generateFaces = true)
    {
        byte[] bytes = File.ReadAllBytes(path);
        if (bytes [0] != 'V' ||
            bytes [1] != 'O' ||
            bytes [2] != 'X' ||
            bytes [3] != ' ')
        {
            Debug.LogError("Invalid VOX file, magic number mismatch");
            return(null);
        }

        return(MVImporter.LoadVOXFromData(bytes, generateFaces));
    }