GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2016-09-17 12:20:54

DJ Coco
Member
Registered: 2016-09-13
Posts: 5

d3d_floor_create_from_tile(x, y, w, h, tilelayer)

Returns a flat floor where you can use a specific tileset as its texture. If a tile from that tileset is found at the location you check from, the texture will be shown as that tile.
When you draw the model, it is crucial you draw it at 0, 0, 0 and not x, y, z! Also, the script requires that the z variable has been initialized.

Expand/// d3d_floor_create_from_tile(x, y, w, h, tilelayer)
//  Argument x: x coordinate to check from
//  Argument y: y coordinate to check from
//  Argument w: width of the tile
//  Argument h: height of the tile
//  Argument tilelayer: tile layer to check on
//  Returns: 3D Model as flat floor (use the tileset as its texture), "noone" when no tile is found
/// GMLscripts.com/license

var tile = tile_layer_find(argument4, argument0, argument1);
if (tile) {
    var xx, yy, bg, hsize, vsize;
    xx = tile_get_left(tile);
    yy = tile_get_top(tile);
    bg = tile_get_background(tile);
    hsize = background_get_width(bg);
    vsize = background_get_height(bg);

    var model = d3d_model_create();
    d3d_model_primitive_begin(model, pr_trianglelist);

    d3d_model_vertex_normal_texture(model, x, y, z, 0, 0, 1, xx / hsize, yy / vsize);
    d3d_model_vertex_normal_texture(model, x + argument2, y, z, 0, 0, 1, (xx + argument2) / hsize, yy / vsize);
    d3d_model_vertex_normal_texture(model, x, y + argument3, z, 0, 0, 1, xx / hsize, (yy + argument3) / vsize);

    d3d_model_vertex_normal_texture(model, x + argument2, y, z, 0, 0, 1, (xx + argument2) / hsize, yy / vsize);
    d3d_model_vertex_normal_texture(model, x, y + argument3, z, 0, 0, 1, xx / hsize, (yy + argument3) / vsize);
    d3d_model_vertex_normal_texture(model, x + argument2, y + argument3, z, 0, 0, 1, (xx + argument2) / hsize, (yy + argument3) / vsize);

    d3d_model_primitive_end(model);

    return model;
}
return noone;

Offline

Board footer

Powered by FluxBB