public void Generate(IModule module, int _seed, bool _enableCaves, float _amp, float _caveDensity, float _grassOffset)
    {
        try
        {
            Sampler = new TerrainSampler(module, _seed, _enableCaves, _amp, _caveDensity, _grassOffset);;
            Sampler.SetChunkSettings(VoxelsPerMeter,
                                     new Vector3Int(ChunkSizeX, ChunkSizeY, ChunkSizeZ),
                                     new Vector3Int(ChunkMeterSizeX, ChunkMeterSizeY, ChunkMeterSizeZ),
                                     skipDist,
                                     half, new Vector3(xSideLength, ySideLength, zSideLength));


            Vector2Int bottomLeft = new Vector2(location.x * ChunkSizeX, location.z * ChunkSizeZ);
            Vector2Int topRight   = new Vector2(location.x * ChunkSizeX + ChunkSizeX, location.z * ChunkSizeZ + ChunkSizeZ);
            watch.Start();
            Sampler.SetSurfaceData(bottomLeft, topRight);
            watch.Stop();
            noiseGenTime = watch.Elapsed.ToString();

            int bottom = VoxelConversions.ChunkToVoxel(location).y;
            empty = bottom > Sampler.GetMax();
        }
        catch (Exception e)
        {
            SafeDebug.LogError(string.Format("{0}\nFunction: Generate\n Chunk: {1}", e.Message, location.ToString()), e);
        }
    }
    public void Generate(ISampler sampler)
    {
        Sampler = sampler;

        /*Sampler.SetChunkSettings(VoxelsPerMeter,
         *                             new Vector3Int(ChunkSizeX, ChunkSizeY, ChunkSizeZ),
         *                             new Vector3Int(ChunkMeterSizeX, ChunkMeterSizeY, ChunkMeterSizeZ),
         *                             skipDist,
         *                             half, new Vector3(xSideLength, ySideLength, zSideLength));
         * Vector2Int bottomLeft = new Vector2(location.x * ChunkSizeX, location.z * ChunkSizeZ);
         * Vector2Int topRight = new Vector2(location.x * ChunkSizeX + ChunkSizeX, location.z * ChunkSizeZ + ChunkSizeZ);
         * Sampler.SetSurfaceData(bottomLeft, topRight);*/

        int bottom = VoxelConversions.ChunkToVoxel(location).y;

        empty = bottom > Sampler.GetMax();
    }
Exemple #3
0
    public float[] GetBlockTypeTexture()
    {
        int data_size = (builderInstance.ChunkSizeX + 2) * (builderInstance.ChunkSizeY + 2) * (builderInstance.ChunkSizeZ + 2);

        tex = new Texture3D(builderInstance.ChunkSizeX + 2, builderInstance.ChunkSizeY + 2, builderInstance.ChunkSizeZ + 2, TextureFormat.RGBA32, false);

        Vector3Int orig = VoxelConversions.ChunkToVoxel(chunkPosition);

        Debug.Log(orig);

        //type_data = new Color32[data_size];
        Mat_index_array = new float[data_size];
        for (int x_g = orig.x - 1, x = 0; x < builderInstance.ChunkSizeX + 2; x_g++, x++)
        {
            for (int y_g = orig.y - 1, y = 0; y < builderInstance.ChunkSizeY + 2; y_g++, y++)
            {
                for (int z_g = orig.z - 1, z = 0; z < builderInstance.ChunkSizeZ + 2; z_g++, z++)
                {
                    uint type = SingleChunkController.Instance.GetBlock(x_g, y_g, z_g).type;
                    if (type == 0)
                    {
                        //type_data[builderInstance.Get_Flat_Index(x, y, z)] = new Color32(0, 255, 0, 0);
                        Mat_index_array[builderInstance.Get_Flat_Index(x, y, z)] = -1f;
                    }
                    else
                    {
                        int index = SingleChunkController.Instance.BlockTypes[type].textureIndex[0];
                        Mat_index_array[builderInstance.Get_Flat_Index(x, y, z)] = index;
                        //type_data[builderInstance.Get_Flat_Index(x, y, z)] = new Color32((byte)index, 0, 0, 0);
                    }
                }
            }
        }

        //Debug.Log("pos: " + builderInstance.Get_Flat_Index(8, 8, 10));

        //tex.SetPixels32(type_data, 0);
        //tex.Apply();

        return(Mat_index_array);
    }