Initialize() public method

public Initialize ( int resolution, float size ) : void
resolution int
size float
return void
Ejemplo n.º 1
0
    void CreateChunk(int x, int y, int z)
    {
        VoxelGrid grid = Instantiate(voxelGridPrefab);

        grid.transform.parent        = transform;
        grid.transform.localPosition = new Vector3((x * chunkSize.x - halfMapSize.x), (y * chunkSize.y - halfMapSize.y), (z * chunkSize.z - halfMapSize.z));
        grid.Initialize(voxelResolution, voxelSize);
        chunks[MathUtils.getIndexFromXYZ(x, y, z, chunkResolution)] = grid;

        if (x > 0)
        {
            chunks[MathUtils.getIndexFromXYZ(x - 1, y, z, chunkResolution)].xNeighbor = grid;
        }

        if (y > 0)
        {
            chunks[MathUtils.getIndexFromXYZ(x, y - 1, z, chunkResolution)].yNeighbor = grid;
        }

        if (z > 0)
        {
            chunks[MathUtils.getIndexFromXYZ(x, y, z - 1, chunkResolution)].zNeighbor = grid;

            if (x > 0 && y > 0)
            {
                chunks[MathUtils.getIndexFromXYZ(x - 1, y - 1, z - 1, chunkResolution)].xyzNeighbor = grid;
            }
        }
    }
Ejemplo n.º 2
0
    private void CreateChunk(int i, int x, int y)
    {
        VoxelGrid chunk = Instantiate(voxelGridPrefab) as VoxelGrid;

        chunk.Initialize(voxelResolution, chunkSize);
        chunk.transform.parent        = transform;
        chunk.transform.localPosition = new Vector3(x * chunkSize - halfSize, y * chunkSize - halfSize);
        chunks[i] = chunk;
    }
Ejemplo n.º 3
0
    private void CreateChunk(int i, int x, int y)
    {
        VoxelGrid chunk = Instantiate(voxelGridPrefab) as VoxelGrid;

        chunk.Initialize(voxelResolution, chunkSize);
        chunk.transform.parent        = transform;
        chunk.transform.localPosition = new Vector3(x * chunkSize - halfSize, y * chunkSize - halfSize);
        chunks[i] = chunk;
        if (x > 0)
        {
            chunks[i - 1].xNeighbor = chunk;
        }
        if (y > 0)
        {
            chunks[i - chunkResolution].yNeighbor = chunk;
            if (x > 0)
            {
                chunks[i - chunkResolution - 1].xyNeighbor = chunk;
            }
        }
    }
Ejemplo n.º 4
0
    private void CreateChunk(int i, int x, int y, float z, int matID, bool isLast)
    {
        VoxelGrid chunk = Instantiate(voxelGridPrefab) as VoxelGrid;

        chunk.Initialize(voxelResolution, chunkSize, maxFeatureAngle, matID, isLast, InitCallback);
        chunk.transform.parent        = transform;
        chunk.transform.localPosition = new Vector3(x * chunkSize - halfSize, y * chunkSize - halfSize, z);
        chunks[i] = chunk;
        if (x > 0)
        {
            chunks[i - 1].xNeighbor = chunk;
        }
        if (y > 0)
        {
            chunks[i - chunkResolutionX].yNeighbor = chunk;
            if (x > 0)
            {
                chunks[i - chunkResolutionX - 1].xyNeighbor = chunk;
            }
        }
    }