Exemple #1
0
    internal void LoadMeshes(BlockMesher.Result newMeshes, string suffix)
    {
        bool madeNew = false;

        if (newMeshes.tiles != null)
        {
            madeNew |= CopyMesh(MeshType.Tiles, newMeshes.tiles, suffix);
        }
        if (newMeshes.topTiles != null)
        {
            madeNew |= CopyMesh(MeshType.TopTiles, newMeshes.topTiles, suffix);
        }
        if (newMeshes.stencilTiles != null)
        {
            madeNew |= CopyMesh(MeshType.StencilTiles, newMeshes.stencilTiles, suffix);
        }
        if (newMeshes.topStencilTiles != null)
        {
            madeNew |= CopyMesh(MeshType.TopStencilTiles, newMeshes.topStencilTiles, suffix);
        }
        if (newMeshes.transparentTiles != null)
        {
            madeNew |= CopyMesh(MeshType.TransparentTiles, newMeshes.transparentTiles, suffix);
        }
        if (newMeshes.topTransparentTiles != null)
        {
            madeNew |= CopyMesh(MeshType.TopTransparentTiles, newMeshes.topTransparentTiles, suffix);
        }
        if (newMeshes.terrainMesh != null)
        {
            madeNew |= CopyMesh(MeshType.Terrain, newMeshes.terrainMesh, suffix);
            meshFilters[MeshType.Terrain].mesh.RecalculateNormals();
            meshFilters[MeshType.Terrain].mesh.RecalculateTangents();
        }
        if (newMeshes.topTerrainMesh != null)
        {
            madeNew |= CopyMesh(MeshType.TopTerrain, newMeshes.topTerrainMesh, suffix);
            meshFilters[MeshType.TopTerrain].mesh.RecalculateNormals();
            meshFilters[MeshType.TopTerrain].mesh.RecalculateTangents();
        }
        if (newMeshes.water != null)
        {
            madeNew |= CopyMesh(MeshType.Water, newMeshes.water, suffix);
        }
        if (newMeshes.magma != null)
        {
            madeNew |= CopyMesh(MeshType.Magma, newMeshes.magma, suffix);
        }
        if (madeNew)
        {
            UpdatePropertyBlock();
            SetupMaterials();
        }
    }
Exemple #2
0
 internal void LoadMeshes(BlockMesher.Result newMeshes, string suffix)
 {
     if (newMeshes.tiles != null)
     {
         if (blocks == null)
         {
             blocks.mesh      = new Mesh();
             blocks.mesh.name = string.Format("block_solid_{0}", suffix);
         }
         blocks.mesh.Clear();
         newMeshes.tiles.CopyToMesh(blocks.mesh);
     }
     if (newMeshes.stencilTiles != null)
     {
         if (stencilBlocks.mesh == null)
         {
             stencilBlocks.mesh      = new Mesh();
             stencilBlocks.mesh.name = string.Format("block_stencil_{0}", suffix);
         }
         stencilBlocks.mesh.Clear();
         newMeshes.stencilTiles.CopyToMesh(stencilBlocks.mesh);
     }
     if (newMeshes.transparentTiles != null)
     {
         if (transparentBlocks.mesh == null)
         {
             transparentBlocks.mesh      = new Mesh();
             transparentBlocks.mesh.name = string.Format("block_transparent_{0}", suffix);
         }
         transparentBlocks.mesh.Clear();
         newMeshes.transparentTiles.CopyToMesh(transparentBlocks.mesh);
     }
     if (newMeshes.terrainMesh != null)
     {
         if (voxelBlocks.mesh == null)
         {
             voxelBlocks.mesh      = new Mesh();
             voxelBlocks.mesh.name = string.Format("block_voxel_{0}", suffix);
         }
         voxelBlocks.mesh.Clear();
         newMeshes.terrainMesh.CopyToMesh(voxelBlocks.mesh);
         voxelBlocks.mesh.RecalculateNormals();
         voxelBlocks.mesh.RecalculateTangents();
     }
     if (newMeshes.water != null)
     {
         if (waterBlocks.mesh == null)
         {
             waterBlocks.mesh      = new Mesh();
             waterBlocks.mesh.name = string.Format("liquid_water_{0}", suffix);
         }
         waterBlocks.mesh.Clear();
         newMeshes.water.CopyToMesh(waterBlocks.mesh);
     }
     if (newMeshes.magma != null)
     {
         if (lavaBlocks.mesh == null)
         {
             lavaBlocks.mesh      = new Mesh();
             lavaBlocks.mesh.name = string.Format("liquid_magma_{0}", suffix);
         }
         lavaBlocks.mesh.Clear();
         newMeshes.magma.CopyToMesh(lavaBlocks.mesh);
     }
 }