Exemplo n.º 1
0
    public void LoadVOXFile(string path, string alphaMaskPath, bool asIndividualVoxels)
    {
        ClearVoxMeshes();

        if (path != null && path.Length > 0)
        {
            MVVoxelChunk alphaChunk = null;
            if (!string.IsNullOrEmpty(alphaMaskPath))
            {
                MVMainChunk mc = MVImporter.LoadVOX(alphaMaskPath, generateFaces: false);
                if (mc != null)
                {
                    alphaChunk = mc.voxelChunk;
                }
            }

            MVMainChunk v = MVImporter.LoadVOX(path, alphaChunk);

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

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

                this.vox = v;
            }
        }
        else
        {
            Debug.LogError("[MVVoxModel] Invalid file path");
        }
    }
Exemplo n.º 2
0
    public void LoadVOXFile(string path, bool asIndividualVoxels)
    {
        ClearVoxMeshes();

        if (path != null && path.Length > 0)
        {
            MVMainChunk v = MVImporter.LoadVOX(path);

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

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

                this.vox = v;
            }
        }
        else
        {
            Debug.LogError("[MVVoxModel] Invalid file path");
        }
    }