if once exit;
once = true;
var ixs = image_xscale*8;
var iys = image_yscale*8;
vertex_begin(buff, format);
for(var ih = 0; ih < height; ih += 8)
{
for(var iy = 0; iy < ixs; iy += 8)
{
// s4
vertex_position_3d(buff, x, y+iy, z+ih);
vertex_texcoord(buff, 0.75, 0.25);
vertex_position_3d(buff, x, y+iy, z+ih+8);
vertex_texcoord(buff, 1, 0.25);
vertex_position_3d(buff, x, y+iy+8, z+ih);
vertex_texcoord(buff, 0.75, 0.5);
vertex_position_3d(buff, x, y+iy, z+ih+8);
vertex_texcoord(buff, 1, 0.25);
vertex_position_3d(buff, x, y+iy+8, z+ih+8);
vertex_texcoord(buff, 1, 0.5);
vertex_position_3d(buff, x, y+iy+8, z+ih);
vertex_texcoord(buff, 0.75, 0.5);
// s2
vertex_position_3d(buff, x+ixs, y+iy+8, z+ih);
vertex_texcoord(buff, 0.25, 0.25);
vertex_position_3d(buff, x+ixs, y+iy+8, z+ih+8);
vertex_texcoord(buff, 0.5, 0.25);
vertex_position_3d(buff, x+ixs, y+iy, z+ih);
vertex_texcoord(buff, 0.25, 0.5);
vertex_position_3d(buff, x+ixs, y+iy+8, z+ih+8);
vertex_texcoord(buff, 0.5, 0.25);
vertex_position_3d(buff, x+ixs, y+iy, z+ih+8);
vertex_texcoord(buff, 0.5, 0.5);
vertex_position_3d(buff, x+ixs, y+iy, z+ih);
vertex_texcoord(buff, 0.25, 0.5);
}
for(var ix = 0; ix < iys; ix += 8)
{
// s1
vertex_position_3d(buff, x+ix+8, y, z+ih);
vertex_texcoord(buff, 0, 0.25);
vertex_position_3d(buff, x+ix+8, y, z+ih+8);
vertex_texcoord(buff, 0.25, 0.25);
vertex_position_3d(buff, x+ix, y, z+ih);
vertex_texcoord(buff, 0, 0.5);
vertex_position_3d(buff, x+ix+8, y, z+ih+8);
vertex_texcoord(buff, 0.25, 0.25);
vertex_position_3d(buff, x+ix, y, z+ih+8);
vertex_texcoord(buff, 0.25, 0.5);
vertex_position_3d(buff, x+ix, y, z+ih);
vertex_texcoord(buff, 0, 0.5);
// s3
vertex_position_3d(buff, x+ix, y+iys, z+ih);
vertex_texcoord(buff, 0.5, 0.25);
vertex_position_3d(buff, x+ix, y+iys, z+ih+8);
vertex_texcoord(buff, 0.75, 0.25);
vertex_position_3d(buff, x+ix+8, y+iys, z+ih);
vertex_texcoord(buff, 0.5, 0.5);
vertex_position_3d(buff, x+ix, y+iys, z+ih+8);
vertex_texcoord(buff, 0.75, 0.25);
vertex_position_3d(buff, x+ix+8, y+iys, z+ih+8);
vertex_texcoord(buff, 0.75, 0.5);
vertex_position_3d(buff, x+ix+8, y+iys, z+ih);
vertex_texcoord(buff, 0.5, 0.5);
}
}
for(var iy = 0; iy < ixs; iy += 8)
{
for(var ix = 0; ix < iys; ix += 8)
{
// top
vertex_position_3d(buff, x+ix, y+iy, z+height);
vertex_texcoord(buff, 0.25, 0);
vertex_position_3d(buff, x+ix+8, y+iy, z+height);
vertex_texcoord(buff, 0.5, 0);
vertex_position_3d(buff, x+ix, y+iy+8, z+height);
vertex_texcoord(buff, 0.25, 0.25);
vertex_position_3d(buff, x+ix+8, y+iy, z+height);
vertex_texcoord(buff, 0.5, 0);
vertex_position_3d(buff, x+ix+8, y+iy+8, z+height);
vertex_texcoord(buff, 0.5, 0.25);
vertex_position_3d(buff, x+ix, y+iy+8, z+height);
vertex_texcoord(buff, 0.25, 0.25);
// floor
vertex_position_3d(buff, x+ix+8, y+iy, z);
vertex_texcoord(buff, 0.25, 0.5);
vertex_position_3d(buff, x+ix, y+iy, z);
vertex_texcoord(buff, 0.5, 0.5);
vertex_position_3d(buff, x+ix+8, y+iy+8, z);
vertex_texcoord(buff, 0.25, 0.75);
vertex_position_3d(buff, x+ix, y+iy, z);
vertex_texcoord(buff, 0.5, 0.5);
vertex_position_3d(buff, x+ix, y+iy+8, z);
vertex_texcoord(buff, 0.5, 0.75);
vertex_position_3d(buff, x+ix+8, y+iy+8, z);
vertex_texcoord(buff, 0.25, 0.75);
}
}
vertex_end(buff);
vertex_freeze(buff);
tex = background_get_texture(uv_grass);