for(int x = x_off; x < x_off+16; x++) for(int z = z_off; z < z_off+16; z++) for(int y = 0; y < 128; y++){ data[x*16*16+z*16+y] = foobar(x,y,z); }