Beispiel #1
0
    public void Initialize(World world, int chunkSize, Vector3Int position)
    {
        this.chunkSize = chunkSize;
        this.position  = position;
        _isolevel      = world.isolevel;

        _densityGenerator = world.densityGenerator;

        int worldPosX = position.x;
        int worldPosY = position.y - 300;
        int worldPosZ = position.z;

        points = new Point[chunkSize + 1, chunkSize + 1, chunkSize + 1];

        _seed          = world.seed;
        _marchingCubes = new MarchingCubes(points, _isolevel, _seed);

        for (int x = 0; x < points.GetLength(0); x++)
        {
            for (int y = 0; y < points.GetLength(1); y++)
            {
                for (int z = 0; z < points.GetLength(2); z++)
                {
                    points[x, y, z] = new Point(
                        new Vector3Int(x, y, z),
                        _densityGenerator.CalculateDensity(x + worldPosX, y + worldPosY, z + worldPosZ)
                        );
                }
            }
        }
    }
Beispiel #2
0
    public void ResetPoints(World world)
    {
        UpdateAfterReload(world);

        points = new CubePoint[(int)Mathf.Pow(world.chunkSize + 1, 3)];

        for (int x = 0; x < world.chunkSize + 1; x++)
        {
            for (int y = 0; y < world.chunkSize + 1; y++)
            {
                for (int z = 0; z < world.chunkSize + 1; z++)
                {
                    points[x + (world.chunkSize + 1) * (y + z * (world.chunkSize + 1))] = new CubePoint(new Vector3Int(x, y, z), _densityGenerator.CalculateDensity(world, world.transform.lossyScale.x * x + transform.position.x, world.transform.lossyScale.x * y + transform.position.y, world.transform.lossyScale.x * z + transform.position.z), Color.green);
                }
            }
        }
    }