Pixel-Composer/scripts/_3D/_3D.gml

109 lines
3.5 KiB
Text
Raw Normal View History

2022-01-13 05:24:03 +01:00
#region setup
2022-12-12 09:08:03 +01:00
globalvar PRIMITIVES, FORMAT_PT, FORMAT_PNT;
2022-01-13 05:24:03 +01:00
PRIMITIVES = ds_map_create();
vertex_format_begin();
vertex_format_add_position_3d();
vertex_format_add_texcoord();
FORMAT_PT = vertex_format_end();
2022-12-12 09:08:03 +01:00
vertex_format_begin();
vertex_format_add_position_3d();
vertex_format_add_normal();
vertex_format_add_texcoord();
FORMAT_PNT = vertex_format_end();
2022-01-13 05:24:03 +01:00
#endregion
#region plane
var _0 = -.5;
var _1 = .5;
var VB = vertex_create_buffer();
vertex_begin(VB, FORMAT_PT);
vertex_add_pt(VB, [_1, _0, 0], [1, 0]);
vertex_add_pt(VB, [_0, _0, 0], [0, 0]);
vertex_add_pt(VB, [_1, _1, 0], [1, 1]);
vertex_add_pt(VB, [_1, _1, 0], [1, 1]);
vertex_add_pt(VB, [_0, _0, 0], [0, 0]);
vertex_add_pt(VB, [_0, _1, 0], [0, 1]);
vertex_end(VB);
vertex_freeze(VB);
PRIMITIVES[? "plane"] = VB;
2022-12-12 09:08:03 +01:00
var VB = vertex_create_buffer();
vertex_begin(VB, FORMAT_PNT);
vertex_add_pnt(VB, [_1, _0, 0], [0, 0, 1], [1, 0]);
vertex_add_pnt(VB, [_0, _0, 0], [0, 0, 1], [0, 0]);
vertex_add_pnt(VB, [_1, _1, 0], [0, 0, 1], [1, 1]);
vertex_add_pnt(VB, [_1, _1, 0], [0, 0, 1], [1, 1]);
vertex_add_pnt(VB, [_0, _0, 0], [0, 0, 1], [0, 0]);
vertex_add_pnt(VB, [_0, _1, 0], [0, 0, 1], [0, 1]);
vertex_end(VB);
vertex_freeze(VB);
PRIMITIVES[? "plane_normal"] = VB;
2022-01-13 05:24:03 +01:00
#endregion
#region cube
var VB = vertex_create_buffer();
2022-12-12 09:08:03 +01:00
vertex_begin(VB, FORMAT_PNT);
2022-01-13 05:24:03 +01:00
2022-12-12 09:08:03 +01:00
vertex_add_pnt(VB, [_1, _0, _0], [0, 0, -1], [1, 0]);
vertex_add_pnt(VB, [_0, _0, _0], [0, 0, -1], [0, 0]);
vertex_add_pnt(VB, [_1, _1, _0], [0, 0, -1], [1, 1]);
2022-01-13 05:24:03 +01:00
2022-12-12 09:08:03 +01:00
vertex_add_pnt(VB, [_1, _1, _0], [0, 0, -1], [1, 1]);
vertex_add_pnt(VB, [_0, _0, _0], [0, 0, -1], [0, 0]);
vertex_add_pnt(VB, [_0, _1, _0], [0, 0, -1], [0, 1]);
2022-01-13 05:24:03 +01:00
2022-12-12 09:08:03 +01:00
vertex_add_pnt(VB, [_1, _0, _1], [0, 0, 1], [1, 0]);
vertex_add_pnt(VB, [_0, _0, _1], [0, 0, 1], [0, 0]);
vertex_add_pnt(VB, [_1, _1, _1], [0, 0, 1], [1, 1]);
2022-01-13 05:24:03 +01:00
2022-12-12 09:08:03 +01:00
vertex_add_pnt(VB, [_1, _1, _1], [0, 0, 1], [1, 1]);
vertex_add_pnt(VB, [_0, _0, _1], [0, 0, 1], [0, 0]);
vertex_add_pnt(VB, [_0, _1, _1], [0, 0, 1], [0, 1]);
2022-01-13 05:24:03 +01:00
2022-12-12 09:08:03 +01:00
vertex_add_pnt(VB, [_1, _0, _0], [0, 1, 0], [1, 0]);
vertex_add_pnt(VB, [_0, _0, _0], [0, 1, 0], [0, 0]);
vertex_add_pnt(VB, [_1, _0, _1], [0, 1, 0], [1, 1]);
vertex_add_pnt(VB, [_1, _0, _1], [0, 1, 0], [1, 1]);
vertex_add_pnt(VB, [_0, _0, _0], [0, 1, 0], [0, 0]);
vertex_add_pnt(VB, [_0, _0, _1], [0, 1, 0], [0, 1]);
2022-01-13 05:24:03 +01:00
2022-12-12 09:08:03 +01:00
vertex_add_pnt(VB, [_1, _1, _0], [0, -1, 0], [1, 0]);
vertex_add_pnt(VB, [_0, _1, _0], [0, -1, 0], [0, 0]);
vertex_add_pnt(VB, [_1, _1, _1], [0, -1, 0], [1, 1]);
2022-01-13 05:24:03 +01:00
2022-12-12 09:08:03 +01:00
vertex_add_pnt(VB, [_1, _1, _1], [0, -1, 0], [1, 1]);
vertex_add_pnt(VB, [_0, _1, _0], [0, -1, 0], [0, 0]);
vertex_add_pnt(VB, [_0, _1, _1], [0, -1, 0], [0, 1]);
2022-01-13 05:24:03 +01:00
2022-12-21 02:30:23 +01:00
vertex_add_pnt(VB, [_0, _1, _0], [1, 0, 0], [0, 1]);
2022-12-12 09:08:03 +01:00
vertex_add_pnt(VB, [_0, _0, _0], [1, 0, 0], [0, 0]);
vertex_add_pnt(VB, [_0, _1, _1], [1, 0, 0], [1, 1]);
2022-12-21 02:30:23 +01:00
2022-12-12 09:08:03 +01:00
vertex_add_pnt(VB, [_0, _1, _1], [1, 0, 0], [1, 1]);
vertex_add_pnt(VB, [_0, _0, _0], [1, 0, 0], [0, 0]);
2022-12-21 02:30:23 +01:00
vertex_add_pnt(VB, [_0, _0, _1], [1, 0, 0], [1, 0]);
2022-12-12 09:08:03 +01:00
2022-12-21 02:30:23 +01:00
vertex_add_pnt(VB, [_1, _1, _0], [-1, 0, 0], [0, 1]);
2022-12-12 09:08:03 +01:00
vertex_add_pnt(VB, [_1, _0, _0], [-1, 0, 0], [0, 0]);
vertex_add_pnt(VB, [_1, _1, _1], [-1, 0, 0], [1, 1]);
2022-12-21 02:30:23 +01:00
2022-12-12 09:08:03 +01:00
vertex_add_pnt(VB, [_1, _1, _1], [-1, 0, 0], [1, 1]);
vertex_add_pnt(VB, [_1, _0, _0], [-1, 0, 0], [0, 0]);
2022-12-21 02:30:23 +01:00
vertex_add_pnt(VB, [_1, _0, _1], [-1, 0, 0], [1, 0]);
2022-01-13 05:24:03 +01:00
vertex_end(VB);
vertex_freeze(VB);
PRIMITIVES[? "cube"] = VB;
#endregion