1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
for(int x = 0; x < SCX; x++)
for(int y = 0; y < SCY; y++)
for(int z = 0; z < SCZ; z++)
{
chunks[x][y][z] = new Chunk(texPath, x, y, z);
//top
if(CheckForBounds(x, y+1, z))
{
chunks[x][y][z]->SetNeighbor(chunks[x][y][z]->SIDE_FRONT, chunks[x][y+1][z]);
}
//bottom
if(CheckForBounds(x, y-1, z))
{
chunks[x][y][z]->SetNeighbor(chunks[x][y][z]->SIDE_BOTTOM, chunks[x][y-1][z]);
}
//left
if(CheckForBounds(x-1, y, z))
{
chunks[x][y][z]->SetNeighbor(chunks[x][y][z]->SIDE_LEFT, chunks[x-1][y][z]);
}
//right
if(CheckForBounds(x+1, y, z))
{
chunks[x][y][z]->SetNeighbor(chunks[x][y][z]->SIDE_RIGHT, chunks[x+1][y][z]);
}
//front
if(CheckForBounds(x, y, z+1))
{
chunks[x][y][z]->SetNeighbor(chunks[x][y][z]->SIDE_FRONT, chunks[x][y][z+1]);
}
//back
if(CheckForBounds(x, y, z-1))
{
chunks[x][y][z]->SetNeighbor(chunks[x][y][z]->SIDE_BACK, chunks[x][y][z-1]);
}
}
//chunks[0][0][0]->Test();
}
|