Pixel-Composer/scripts/d3d_cube_faces/d3d_cube_faces.gml

99 lines
2.9 KiB
Plaintext
Raw Normal View History

2023-08-17 16:56:54 +02:00
function __3dCubeFaces() : __3dObject() constructor {
VF = global.VF_POS_NORM_TEX_COL;
render_type = pr_trianglelist;
object_counts = 6;
2023-08-17 16:56:54 +02:00
static initModel = function(size) {
size /= 2;
vertex = [
[
V3(-size, -size, size), V3(size, -size, size), V3(size, size, size),
V3(-size, -size, size), V3(size, size, size), V3(-size, size, size),
2023-08-17 16:56:54 +02:00
],
[
V3(-size, -size, -size), V3(size, -size, -size), V3(size, size, -size),
V3(-size, -size, -size), V3(size, size, -size), V3(-size, size, -size),
2023-08-17 16:56:54 +02:00
],
[
V3(-size, -size, size), V3(-size, size, size), V3(-size, size, -size),
V3(-size, -size, size), V3(-size, size, -size), V3(-size, -size, -size),
2023-08-17 16:56:54 +02:00
],
[
V3(size, -size, size), V3(size, size, size), V3(size, size, -size),
V3(size, -size, size), V3(size, size, -size), V3(size, -size, -size),
2023-08-17 16:56:54 +02:00
],
[
V3(-size, size, size), V3(size, size, size), V3(size, size, -size),
V3(-size, size, size), V3(size, size, -size), V3(-size, size, -size),
2023-08-17 16:56:54 +02:00
],
[
V3(-size, -size, size), V3(size, -size, size), V3(size, -size, -size),
V3(-size, -size, size), V3(size, -size, -size), V3(-size, -size, -size)
2023-08-17 16:56:54 +02:00
]
];
normals = [
[
[0, 0, 1], [0, 0, 1], [0, 0, 1],
[0, 0, 1], [0, 0, 1], [0, 0, 1],
],
[
[0, 0, -1], [0, 0, -1], [0, 0, -1],
[0, 0, -1], [0, 0, -1], [0, 0, -1],
],
[
[-1, 0, 0], [-1, 0, 0], [-1, 0, 0],
[-1, 0, 0], [-1, 0, 0], [-1, 0, 0],
],
[
[1, 0, 0], [1, 0, 0], [1, 0, 0],
[1, 0, 0], [1, 0, 0], [1, 0, 0],
],
[
[0, 1, 0], [0, 1, 0], [0, 1, 0],
[0, 1, 0], [0, 1, 0], [0, 1, 0],
],
[
[0, -1, 0], [0, -1, 0], [0, -1, 0],
[0, -1, 0], [0, -1, 0], [0, -1, 0]
]
];
uv = [
[
[0, 0], [1, 0], [1, 1],
[0, 0], [1, 1], [0, 1],
],
[
[0, 0], [1, 0], [1, 1],
[0, 0], [1, 1], [0, 1],
],
[
[0, 0], [1, 0], [1, 1],
[0, 0], [1, 1], [0, 1],
],
[
[0, 0], [1, 0], [1, 1],
[0, 0], [1, 1], [0, 1],
],
[
[0, 0], [1, 0], [1, 1],
[0, 0], [1, 1], [0, 1],
],
[
[0, 0], [1, 0], [1, 1],
[0, 0], [1, 1], [0, 1]
]
];
array_foreach(vertex[0], function(val, ind) { val.normal.set(normals[0][ind]); val.uv.set(uv[0][ind]); })
array_foreach(vertex[1], function(val, ind) { val.normal.set(normals[1][ind]); val.uv.set(uv[1][ind]); })
array_foreach(vertex[2], function(val, ind) { val.normal.set(normals[2][ind]); val.uv.set(uv[2][ind]); })
array_foreach(vertex[3], function(val, ind) { val.normal.set(normals[3][ind]); val.uv.set(uv[3][ind]); })
array_foreach(vertex[4], function(val, ind) { val.normal.set(normals[4][ind]); val.uv.set(uv[4][ind]); })
array_foreach(vertex[5], function(val, ind) { val.normal.set(normals[5][ind]); val.uv.set(uv[5][ind]); })
2023-08-17 16:56:54 +02:00
VB = build();
} initModel(1);
}