mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-24 22:16:17 +01:00
[L-system] Add 3D option.
This commit is contained in:
parent
b6b0c8e042
commit
7bf027236a
20 changed files with 588 additions and 188 deletions
|
@ -716,6 +716,7 @@
|
|||
{"name":"node_3d_repeat","order":1,"path":"scripts/node_3d_repeat/node_3d_repeat.yy",},
|
||||
{"name":"node_3d_round_vertex","order":1,"path":"scripts/node_3d_round_vertex/node_3d_round_vertex.yy",},
|
||||
{"name":"node_3d_set_material","order":2,"path":"scripts/node_3d_set_material/node_3d_set_material.yy",},
|
||||
{"name":"node_3d_subdivide","order":9,"path":"scripts/node_3d_subdivide/node_3d_subdivide.yy",},
|
||||
{"name":"node_3d_transform_image","order":12,"path":"scripts/node_3d_transform_image/node_3d_transform_image.yy",},
|
||||
{"name":"node_3d_transform_scene","order":4,"path":"scripts/node_3d_transform_scene/node_3d_transform_scene.yy",},
|
||||
{"name":"node_3d_transform","order":6,"path":"scripts/node_3d_transform/node_3d_transform.yy",},
|
||||
|
@ -2082,6 +2083,7 @@
|
|||
{"name":"s_node_3d_sphere_uv","order":16,"path":"sprites/s_node_3d_sphere_uv/s_node_3d_sphere_uv.yy",},
|
||||
{"name":"s_node_3d_sphere","order":8,"path":"sprites/s_node_3d_sphere/s_node_3d_sphere.yy",},
|
||||
{"name":"s_node_3d_stack_slice","order":32,"path":"sprites/s_node_3d_stack_slice/s_node_3d_stack_slice.yy",},
|
||||
{"name":"s_node_3d_subdivide","order":37,"path":"sprites/s_node_3d_subdivide/s_node_3d_subdivide.yy",},
|
||||
{"name":"s_node_3d_torus","order":35,"path":"sprites/s_node_3d_torus/s_node_3d_torus.yy",},
|
||||
{"name":"s_node_3d_transform_scene","order":22,"path":"sprites/s_node_3d_transform_scene/s_node_3d_transform_scene.yy",},
|
||||
{"name":"s_node_3d_transform","order":4,"path":"sprites/s_node_3d_transform/s_node_3d_transform.yy",},
|
||||
|
|
|
@ -1259,6 +1259,7 @@
|
|||
{"id":{"name":"node_3d_round_vertex","path":"scripts/node_3d_round_vertex/node_3d_round_vertex.yy",},},
|
||||
{"id":{"name":"node_3d_scene","path":"scripts/node_3d_scene/node_3d_scene.yy",},},
|
||||
{"id":{"name":"node_3d_set_material","path":"scripts/node_3d_set_material/node_3d_set_material.yy",},},
|
||||
{"id":{"name":"node_3d_subdivide","path":"scripts/node_3d_subdivide/node_3d_subdivide.yy",},},
|
||||
{"id":{"name":"node_3d_transform_image","path":"scripts/node_3d_transform_image/node_3d_transform_image.yy",},},
|
||||
{"id":{"name":"node_3d_transform_scene","path":"scripts/node_3d_transform_scene/node_3d_transform_scene.yy",},},
|
||||
{"id":{"name":"node_3d_transform","path":"scripts/node_3d_transform/node_3d_transform.yy",},},
|
||||
|
@ -2798,6 +2799,7 @@
|
|||
{"id":{"name":"s_node_3d_sphere_uv","path":"sprites/s_node_3d_sphere_uv/s_node_3d_sphere_uv.yy",},},
|
||||
{"id":{"name":"s_node_3d_sphere","path":"sprites/s_node_3d_sphere/s_node_3d_sphere.yy",},},
|
||||
{"id":{"name":"s_node_3d_stack_slice","path":"sprites/s_node_3d_stack_slice/s_node_3d_stack_slice.yy",},},
|
||||
{"id":{"name":"s_node_3d_subdivide","path":"sprites/s_node_3d_subdivide/s_node_3d_subdivide.yy",},},
|
||||
{"id":{"name":"s_node_3d_torus","path":"sprites/s_node_3d_torus/s_node_3d_torus.yy",},},
|
||||
{"id":{"name":"s_node_3d_transform_scene","path":"sprites/s_node_3d_transform_scene/s_node_3d_transform_scene.yy",},},
|
||||
{"id":{"name":"s_node_3d_transform","path":"sprites/s_node_3d_transform/s_node_3d_transform.yy",},},
|
||||
|
|
|
@ -22,6 +22,9 @@ event_inherited();
|
|||
["-", "Rotate to the right"],
|
||||
["[", "Save current state in a stack."],
|
||||
["]", "Restore state from the top of the stack."],
|
||||
|
||||
["*", "Rotate the secondary angle positively"],
|
||||
["/", "Rotate the secondary angle negatively"],
|
||||
],
|
||||
"Move distance and turn angle is fixed.",
|
||||
"Rules is generate by repeatedly replace a letter with another letter/string. For example.",
|
||||
|
|
|
@ -11,9 +11,18 @@ function d3_normalize(vec) {
|
|||
function d3_cross_product(a, b) {
|
||||
var ax = a[0], ay = a[1], az = a[2],
|
||||
bx = b[0], by = b[1], bz = b[2];
|
||||
|
||||
var result = [];
|
||||
result[0] = ay * bz - az * by;
|
||||
result[1] = az * bx - ax * bz;
|
||||
result[2] = ax * by - ay * bx;
|
||||
return result;
|
||||
}
|
||||
|
||||
function d3_cross_product_element(x1, y1, z1, x2, y2, z2) {
|
||||
return [
|
||||
y1 * z2 - z1 * y2,
|
||||
z1 * x2 - x1 * z2,
|
||||
x1 * y2 - y1 * x2,
|
||||
]
|
||||
}
|
||||
|
|
|
@ -2,64 +2,65 @@ function __3dCube() : __3dObject() constructor {
|
|||
VF = global.VF_POS_NORM_TEX_COL;
|
||||
render_type = pr_trianglelist;
|
||||
|
||||
static initModel = function(size) {
|
||||
size /= 2;
|
||||
static initModel = function() {
|
||||
|
||||
vertex = [[
|
||||
new __vertex(-size, -size, size).setNormal(0, 0, 1).setUV(1, 1),
|
||||
new __vertex( size, size, size).setNormal(0, 0, 1).setUV(0, 0),
|
||||
new __vertex( size, -size, size).setNormal(0, 0, 1).setUV(0, 1),
|
||||
vertex = [
|
||||
[
|
||||
new __vertex(-.5, -.5, .5).setNormal(0, 0, 1).setUV(1, 1),
|
||||
new __vertex( .5, .5, .5).setNormal(0, 0, 1).setUV(0, 0),
|
||||
new __vertex( .5, -.5, .5).setNormal(0, 0, 1).setUV(0, 1),
|
||||
|
||||
new __vertex(-size, -size, size).setNormal(0, 0, 1).setUV(1, 1),
|
||||
new __vertex(-size, size, size).setNormal(0, 0, 1).setUV(1, 0),
|
||||
new __vertex( size, size, size).setNormal(0, 0, 1).setUV(0, 0),
|
||||
new __vertex(-.5, -.5, .5).setNormal(0, 0, 1).setUV(1, 1),
|
||||
new __vertex(-.5, .5, .5).setNormal(0, 0, 1).setUV(1, 0),
|
||||
new __vertex( .5, .5, .5).setNormal(0, 0, 1).setUV(0, 0),
|
||||
|
||||
|
||||
new __vertex(-size, -size, -size).setNormal(0, 0, -1).setUV(1, 1),
|
||||
new __vertex( size, -size, -size).setNormal(0, 0, -1).setUV(0, 1),
|
||||
new __vertex( size, size, -size).setNormal(0, 0, -1).setUV(0, 0),
|
||||
new __vertex(-.5, -.5, -.5).setNormal(0, 0, -1).setUV(1, 1),
|
||||
new __vertex( .5, -.5, -.5).setNormal(0, 0, -1).setUV(0, 1),
|
||||
new __vertex( .5, .5, -.5).setNormal(0, 0, -1).setUV(0, 0),
|
||||
|
||||
new __vertex(-size, -size, -size).setNormal(0, 0, -1).setUV(1, 1),
|
||||
new __vertex( size, size, -size).setNormal(0, 0, -1).setUV(0, 0),
|
||||
new __vertex(-size, size, -size).setNormal(0, 0, -1).setUV(1, 0),
|
||||
new __vertex(-.5, -.5, -.5).setNormal(0, 0, -1).setUV(1, 1),
|
||||
new __vertex( .5, .5, -.5).setNormal(0, 0, -1).setUV(0, 0),
|
||||
new __vertex(-.5, .5, -.5).setNormal(0, 0, -1).setUV(1, 0),
|
||||
|
||||
|
||||
new __vertex(-size, -size, size).setNormal(-1, 0, 0).setUV(1, 0),
|
||||
new __vertex(-size, size, -size).setNormal(-1, 0, 0).setUV(0, 1),
|
||||
new __vertex(-size, size, size).setNormal(-1, 0, 0).setUV(0, 0),
|
||||
new __vertex(-.5, -.5, .5).setNormal(-1, 0, 0).setUV(1, 0),
|
||||
new __vertex(-.5, .5, -.5).setNormal(-1, 0, 0).setUV(0, 1),
|
||||
new __vertex(-.5, .5, .5).setNormal(-1, 0, 0).setUV(0, 0),
|
||||
|
||||
new __vertex(-size, -size, size).setNormal(-1, 0, 0).setUV(1, 0),
|
||||
new __vertex(-size, -size, -size).setNormal(-1, 0, 0).setUV(1, 1),
|
||||
new __vertex(-size, size, -size).setNormal(-1, 0, 0).setUV(0, 1),
|
||||
new __vertex(-.5, -.5, .5).setNormal(-1, 0, 0).setUV(1, 0),
|
||||
new __vertex(-.5, -.5, -.5).setNormal(-1, 0, 0).setUV(1, 1),
|
||||
new __vertex(-.5, .5, -.5).setNormal(-1, 0, 0).setUV(0, 1),
|
||||
|
||||
|
||||
new __vertex( size, -size, size).setNormal(1, 0, 0).setUV(0, 0),
|
||||
new __vertex( size, size, size).setNormal(1, 0, 0).setUV(1, 0),
|
||||
new __vertex( size, size, -size).setNormal(1, 0, 0).setUV(1, 1),
|
||||
new __vertex( .5, -.5, .5).setNormal(1, 0, 0).setUV(0, 0),
|
||||
new __vertex( .5, .5, .5).setNormal(1, 0, 0).setUV(1, 0),
|
||||
new __vertex( .5, .5, -.5).setNormal(1, 0, 0).setUV(1, 1),
|
||||
|
||||
new __vertex( size, -size, size).setNormal(1, 0, 0).setUV(0, 0),
|
||||
new __vertex( size, size, -size).setNormal(1, 0, 0).setUV(1, 1),
|
||||
new __vertex( size, -size, -size).setNormal(1, 0, 0).setUV(0, 1),
|
||||
new __vertex( .5, -.5, .5).setNormal(1, 0, 0).setUV(0, 0),
|
||||
new __vertex( .5, .5, -.5).setNormal(1, 0, 0).setUV(1, 1),
|
||||
new __vertex( .5, -.5, -.5).setNormal(1, 0, 0).setUV(0, 1),
|
||||
|
||||
|
||||
new __vertex(-size, size, size).setNormal(0, 1, 0).setUV(1, 0),
|
||||
new __vertex( size, size, -size).setNormal(0, 1, 0).setUV(0, 1),
|
||||
new __vertex( size, size, size).setNormal(0, 1, 0).setUV(0, 0),
|
||||
new __vertex(-.5, .5, .5).setNormal(0, 1, 0).setUV(1, 0),
|
||||
new __vertex( .5, .5, -.5).setNormal(0, 1, 0).setUV(0, 1),
|
||||
new __vertex( .5, .5, .5).setNormal(0, 1, 0).setUV(0, 0),
|
||||
|
||||
new __vertex(-size, size, size).setNormal(0, 1, 0).setUV(1, 0),
|
||||
new __vertex(-size, size, -size).setNormal(0, 1, 0).setUV(1, 1),
|
||||
new __vertex( size, size, -size).setNormal(0, 1, 0).setUV(0, 1),
|
||||
new __vertex(-.5, .5, .5).setNormal(0, 1, 0).setUV(1, 0),
|
||||
new __vertex(-.5, .5, -.5).setNormal(0, 1, 0).setUV(1, 1),
|
||||
new __vertex( .5, .5, -.5).setNormal(0, 1, 0).setUV(0, 1),
|
||||
|
||||
|
||||
new __vertex(-size, -size, size).setNormal(0, -1, 0).setUV(0, 0),
|
||||
new __vertex( size, -size, size).setNormal(0, -1, 0).setUV(1, 0),
|
||||
new __vertex( size, -size, -size).setNormal(0, -1, 0).setUV(1, 1),
|
||||
new __vertex(-.5, -.5, .5).setNormal(0, -1, 0).setUV(0, 0),
|
||||
new __vertex( .5, -.5, .5).setNormal(0, -1, 0).setUV(1, 0),
|
||||
new __vertex( .5, -.5, -.5).setNormal(0, -1, 0).setUV(1, 1),
|
||||
|
||||
new __vertex(-size, -size, size).setNormal(0, -1, 0).setUV(0, 0),
|
||||
new __vertex( size, -size, -size).setNormal(0, -1, 0).setUV(1, 1),
|
||||
new __vertex(-size, -size, -size).setNormal(0, -1, 0).setUV(0, 1),
|
||||
]];
|
||||
new __vertex(-.5, -.5, .5).setNormal(0, -1, 0).setUV(0, 0),
|
||||
new __vertex( .5, -.5, -.5).setNormal(0, -1, 0).setUV(1, 1),
|
||||
new __vertex(-.5, -.5, -.5).setNormal(0, -1, 0).setUV(0, 1),
|
||||
]
|
||||
];
|
||||
|
||||
VB = build();
|
||||
} initModel(1);
|
||||
} initModel();
|
||||
}
|
|
@ -3,66 +3,65 @@ function __3dCubeFaces() : __3dObject() constructor {
|
|||
render_type = pr_trianglelist;
|
||||
object_counts = 6;
|
||||
|
||||
static initModel = function(size) {
|
||||
size /= 2;
|
||||
static initModel = function() {
|
||||
|
||||
vertex = [
|
||||
[
|
||||
new __vertex(-size, -size, size).setNormal(0, 0, 1).setUV(1, 1),
|
||||
new __vertex( size, size, size).setNormal(0, 0, 1).setUV(0, 0),
|
||||
new __vertex( size, -size, size).setNormal(0, 0, 1).setUV(0, 1),
|
||||
new __vertex(-.5, -.5, .5).setNormal(0, 0, 1).setUV(1, 1),
|
||||
new __vertex( .5, .5, .5).setNormal(0, 0, 1).setUV(0, 0),
|
||||
new __vertex( .5, -.5, .5).setNormal(0, 0, 1).setUV(0, 1),
|
||||
|
||||
new __vertex(-size, -size, size).setNormal(0, 0, 1).setUV(1, 1),
|
||||
new __vertex(-size, size, size).setNormal(0, 0, 1).setUV(1, 0),
|
||||
new __vertex( size, size, size).setNormal(0, 0, 1).setUV(0, 0),
|
||||
new __vertex(-.5, -.5, .5).setNormal(0, 0, 1).setUV(1, 1),
|
||||
new __vertex(-.5, .5, .5).setNormal(0, 0, 1).setUV(1, 0),
|
||||
new __vertex( .5, .5, .5).setNormal(0, 0, 1).setUV(0, 0),
|
||||
],
|
||||
[
|
||||
new __vertex(-size, -size, -size).setNormal(0, 0, -1).setUV(1, 1),
|
||||
new __vertex( size, -size, -size).setNormal(0, 0, -1).setUV(0, 1),
|
||||
new __vertex( size, size, -size).setNormal(0, 0, -1).setUV(0, 0),
|
||||
new __vertex(-.5, -.5, -.5).setNormal(0, 0, -1).setUV(1, 1),
|
||||
new __vertex( .5, -.5, -.5).setNormal(0, 0, -1).setUV(0, 1),
|
||||
new __vertex( .5, .5, -.5).setNormal(0, 0, -1).setUV(0, 0),
|
||||
|
||||
new __vertex(-size, -size, -size).setNormal(0, 0, -1).setUV(1, 1),
|
||||
new __vertex( size, size, -size).setNormal(0, 0, -1).setUV(0, 0),
|
||||
new __vertex(-size, size, -size).setNormal(0, 0, -1).setUV(1, 0),
|
||||
new __vertex(-.5, -.5, -.5).setNormal(0, 0, -1).setUV(1, 1),
|
||||
new __vertex( .5, .5, -.5).setNormal(0, 0, -1).setUV(0, 0),
|
||||
new __vertex(-.5, .5, -.5).setNormal(0, 0, -1).setUV(1, 0),
|
||||
],
|
||||
[
|
||||
new __vertex(-size, -size, size).setNormal(-1, 0, 0).setUV(1, 0),
|
||||
new __vertex(-size, size, -size).setNormal(-1, 0, 0).setUV(0, 1),
|
||||
new __vertex(-size, size, size).setNormal(-1, 0, 0).setUV(0, 0),
|
||||
new __vertex(-.5, -.5, .5).setNormal(-1, 0, 0).setUV(1, 0),
|
||||
new __vertex(-.5, .5, -.5).setNormal(-1, 0, 0).setUV(0, 1),
|
||||
new __vertex(-.5, .5, .5).setNormal(-1, 0, 0).setUV(0, 0),
|
||||
|
||||
new __vertex(-size, -size, size).setNormal(-1, 0, 0).setUV(1, 0),
|
||||
new __vertex(-size, -size, -size).setNormal(-1, 0, 0).setUV(1, 1),
|
||||
new __vertex(-size, size, -size).setNormal(-1, 0, 0).setUV(0, 1),
|
||||
new __vertex(-.5, -.5, .5).setNormal(-1, 0, 0).setUV(1, 0),
|
||||
new __vertex(-.5, -.5, -.5).setNormal(-1, 0, 0).setUV(1, 1),
|
||||
new __vertex(-.5, .5, -.5).setNormal(-1, 0, 0).setUV(0, 1),
|
||||
],
|
||||
[
|
||||
new __vertex( size, -size, size).setNormal(1, 0, 0).setUV(0, 0),
|
||||
new __vertex( size, size, size).setNormal(1, 0, 0).setUV(1, 0),
|
||||
new __vertex( size, size, -size).setNormal(1, 0, 0).setUV(1, 1),
|
||||
new __vertex( .5, -.5, .5).setNormal(1, 0, 0).setUV(0, 0),
|
||||
new __vertex( .5, .5, .5).setNormal(1, 0, 0).setUV(1, 0),
|
||||
new __vertex( .5, .5, -.5).setNormal(1, 0, 0).setUV(1, 1),
|
||||
|
||||
new __vertex( size, -size, size).setNormal(1, 0, 0).setUV(0, 0),
|
||||
new __vertex( size, size, -size).setNormal(1, 0, 0).setUV(1, 1),
|
||||
new __vertex( size, -size, -size).setNormal(1, 0, 0).setUV(0, 1),
|
||||
new __vertex( .5, -.5, .5).setNormal(1, 0, 0).setUV(0, 0),
|
||||
new __vertex( .5, .5, -.5).setNormal(1, 0, 0).setUV(1, 1),
|
||||
new __vertex( .5, -.5, -.5).setNormal(1, 0, 0).setUV(0, 1),
|
||||
],
|
||||
[
|
||||
new __vertex(-size, size, size).setNormal(0, 1, 0).setUV(1, 0),
|
||||
new __vertex( size, size, -size).setNormal(0, 1, 0).setUV(0, 1),
|
||||
new __vertex( size, size, size).setNormal(0, 1, 0).setUV(0, 0),
|
||||
new __vertex(-.5, .5, .5).setNormal(0, 1, 0).setUV(1, 0),
|
||||
new __vertex( .5, .5, -.5).setNormal(0, 1, 0).setUV(0, 1),
|
||||
new __vertex( .5, .5, .5).setNormal(0, 1, 0).setUV(0, 0),
|
||||
|
||||
new __vertex(-size, size, size).setNormal(0, 1, 0).setUV(1, 0),
|
||||
new __vertex(-size, size, -size).setNormal(0, 1, 0).setUV(1, 1),
|
||||
new __vertex( size, size, -size).setNormal(0, 1, 0).setUV(0, 1),
|
||||
new __vertex(-.5, .5, .5).setNormal(0, 1, 0).setUV(1, 0),
|
||||
new __vertex(-.5, .5, -.5).setNormal(0, 1, 0).setUV(1, 1),
|
||||
new __vertex( .5, .5, -.5).setNormal(0, 1, 0).setUV(0, 1),
|
||||
],
|
||||
[
|
||||
new __vertex(-size, -size, size).setNormal(0, -1, 0).setUV(0, 0),
|
||||
new __vertex( size, -size, size).setNormal(0, -1, 0).setUV(1, 0),
|
||||
new __vertex( size, -size, -size).setNormal(0, -1, 0).setUV(1, 1),
|
||||
new __vertex(-.5, -.5, .5).setNormal(0, -1, 0).setUV(0, 0),
|
||||
new __vertex( .5, -.5, .5).setNormal(0, -1, 0).setUV(1, 0),
|
||||
new __vertex( .5, -.5, -.5).setNormal(0, -1, 0).setUV(1, 1),
|
||||
|
||||
new __vertex(-size, -size, size).setNormal(0, -1, 0).setUV(0, 0),
|
||||
new __vertex( size, -size, -size).setNormal(0, -1, 0).setUV(1, 1),
|
||||
new __vertex(-size, -size, -size).setNormal(0, -1, 0).setUV(0, 1),
|
||||
new __vertex(-.5, -.5, .5).setNormal(0, -1, 0).setUV(0, 0),
|
||||
new __vertex( .5, -.5, -.5).setNormal(0, -1, 0).setUV(1, 1),
|
||||
new __vertex(-.5, -.5, -.5).setNormal(0, -1, 0).setUV(0, 1),
|
||||
]
|
||||
];
|
||||
|
||||
VB = build();
|
||||
} initModel(1);
|
||||
} initModel();
|
||||
}
|
|
@ -2,7 +2,6 @@ function __3dPlane() : __3dObject() constructor {
|
|||
VF = global.VF_POS_NORM_TEX_COL;
|
||||
render_type = pr_trianglelist;
|
||||
|
||||
self.side = 0.5;
|
||||
self.normal = 0;
|
||||
|
||||
two_side = false;
|
||||
|
@ -15,35 +14,37 @@ function __3dPlane() : __3dObject() constructor {
|
|||
switch(normal) {
|
||||
case 0 :
|
||||
vertex[0] = [
|
||||
new __vertex(0, -side, -side).setNormal(1, 0, 0).setUV(0, 1),
|
||||
new __vertex(0, side, side).setNormal(1, 0, 0).setUV(1, 0),
|
||||
new __vertex(0, side, -side).setNormal(1, 0, 0).setUV(1, 1),
|
||||
new __vertex(0, -.5, -.5).setNormal(1, 0, 0).setUV(0, 1),
|
||||
new __vertex(0, .5, .5).setNormal(1, 0, 0).setUV(1, 0),
|
||||
new __vertex(0, .5, -.5).setNormal(1, 0, 0).setUV(1, 1),
|
||||
|
||||
new __vertex(0, -side, -side).setNormal(1, 0, 0).setUV(0, 1),
|
||||
new __vertex(0, -side, side).setNormal(1, 0, 0).setUV(0, 0),
|
||||
new __vertex(0, side, side).setNormal(1, 0, 0).setUV(1, 0),
|
||||
new __vertex(0, -.5, -.5).setNormal(1, 0, 0).setUV(0, 1),
|
||||
new __vertex(0, -.5, .5).setNormal(1, 0, 0).setUV(0, 0),
|
||||
new __vertex(0, .5, .5).setNormal(1, 0, 0).setUV(1, 0),
|
||||
];
|
||||
break;
|
||||
|
||||
case 1 :
|
||||
vertex[0] = [
|
||||
new __vertex(-side, 0, -side).setNormal(0, 1, 0).setUV(1, 1),
|
||||
new __vertex( side, 0, -side).setNormal(0, 1, 0).setUV(0, 1),
|
||||
new __vertex( side, 0, side).setNormal(0, 1, 0).setUV(0, 0),
|
||||
new __vertex(-.5, 0, -.5).setNormal(0, 1, 0).setUV(1, 1),
|
||||
new __vertex( .5, 0, -.5).setNormal(0, 1, 0).setUV(0, 1),
|
||||
new __vertex( .5, 0, .5).setNormal(0, 1, 0).setUV(0, 0),
|
||||
|
||||
new __vertex(-side, 0, -side).setNormal(0, 1, 0).setUV(1, 1),
|
||||
new __vertex( side, 0, side).setNormal(0, 1, 0).setUV(0, 0),
|
||||
new __vertex(-side, 0, side).setNormal(0, 1, 0).setUV(1, 0),
|
||||
new __vertex(-.5, 0, -.5).setNormal(0, 1, 0).setUV(1, 1),
|
||||
new __vertex( .5, 0, .5).setNormal(0, 1, 0).setUV(0, 0),
|
||||
new __vertex(-.5, 0, .5).setNormal(0, 1, 0).setUV(1, 0),
|
||||
];
|
||||
break;
|
||||
|
||||
case 2 :
|
||||
vertex[0] = [
|
||||
new __vertex(-side, -side, 0).setNormal(0, 0, 1).setUV(0, 0),
|
||||
new __vertex( side, side, 0).setNormal(0, 0, 1).setUV(1, 1),
|
||||
new __vertex( side, -side, 0).setNormal(0, 0, 1).setUV(0, 1),
|
||||
new __vertex(-.5, -.5, 0).setNormal(0, 0, 1).setUV(0, 0),
|
||||
new __vertex( .5, .5, 0).setNormal(0, 0, 1).setUV(1, 1),
|
||||
new __vertex( .5, -.5, 0).setNormal(0, 0, 1).setUV(0, 1),
|
||||
|
||||
new __vertex(-side, -side, 0).setNormal(0, 0, 1).setUV(0, 0),
|
||||
new __vertex(-side, side, 0).setNormal(0, 0, 1).setUV(1, 0),
|
||||
new __vertex( side, side, 0).setNormal(0, 0, 1).setUV(1, 1),
|
||||
new __vertex(-.5, -.5, 0).setNormal(0, 0, 1).setUV(0, 0),
|
||||
new __vertex(-.5, .5, 0).setNormal(0, 0, 1).setUV(1, 0),
|
||||
new __vertex( .5, .5, 0).setNormal(0, 0, 1).setUV(1, 1),
|
||||
];
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -8,9 +8,11 @@ function Node_3D_Displace(_x, _y, _group = noone) : Node_3D_Modifier(_x, _y, _gr
|
|||
|
||||
newInput(in_mesh + 2, nodeValue_Float("Subobjects", self, -1));
|
||||
|
||||
newInput(in_mesh + 3, nodeValue_Bool("Recalculate normal", self, true));
|
||||
|
||||
input_display_list = [
|
||||
["Mesh", false], 0, in_mesh + 2,
|
||||
["Displace", false], in_mesh + 0, in_mesh + 1,
|
||||
["Displace", false], in_mesh + 0, in_mesh + 1, in_mesh + 3
|
||||
];
|
||||
|
||||
static processData = function(_output, _data, _output_index, _array_index = 0) {
|
||||
|
@ -18,6 +20,7 @@ function Node_3D_Displace(_x, _y, _group = noone) : Node_3D_Modifier(_x, _y, _gr
|
|||
var _tex = _data[in_mesh + 0];
|
||||
var _hei = _data[in_mesh + 1];
|
||||
var _trg = _data[in_mesh + 2];
|
||||
var _nrm = _data[in_mesh + 3];
|
||||
|
||||
if(!is_instanceof(_obj, __3dObject)) return noone;
|
||||
if(!is_instanceof(_tex, __d3dMaterial)) return noone;
|
||||
|
@ -40,9 +43,10 @@ function Node_3D_Displace(_x, _y, _group = noone) : Node_3D_Modifier(_x, _y, _gr
|
|||
|
||||
for( var i = 0, n = array_length(_tarr); i < n; i++ ) {
|
||||
var _vi = _tarr[i];
|
||||
var _vt = _res.vertex[_vi];
|
||||
|
||||
for( var j = 0, m = array_length(_res.vertex[_vi]); j < m; j++ ) {
|
||||
var _v = _res.vertex[_vi][j];
|
||||
for( var j = 0, m = array_length(_vt); j < m; j++ ) {
|
||||
var _v = _vt[j];
|
||||
var _vu = frac(clamp(_v.u, 0, 0.9999) * _tsc[0] + _tif[0]);
|
||||
var _vv = frac(clamp(_v.v, 0, 0.9999) * _tsc[1] + _tif[1]);
|
||||
|
||||
|
@ -59,6 +63,25 @@ function Node_3D_Displace(_x, _y, _group = noone) : Node_3D_Modifier(_x, _y, _gr
|
|||
_v.y += _v.ny * _hh;
|
||||
_v.z += _v.nz * _hh;
|
||||
}
|
||||
|
||||
if(_nrm)
|
||||
for( var j = 0, m = array_length(_vt); j < m; j += 3 ) {
|
||||
var _v0 = _vt[j + 0];
|
||||
var _v1 = _vt[j + 1];
|
||||
var _v2 = _vt[j + 2];
|
||||
|
||||
var _nres = d3_cross_product_element(_v1.x - _v0.x, _v1.y - _v0.y, _v1.z - _v0.z,
|
||||
_v0.x - _v2.x, _v0.y - _v2.y, _v0.z - _v2.z);
|
||||
|
||||
var _nnl = sqrt(_nres[0] * _nres[0] + _nres[1] * _nres[1] + _nres[2] * _nres[2]);
|
||||
_nres[0] /= _nnl;
|
||||
_nres[1] /= _nnl;
|
||||
_nres[2] /= _nnl;
|
||||
|
||||
_v0.nx = _nres[0]; _v0.ny = _nres[1]; _v0.nz = _nres[2];
|
||||
_v1.nx = _nres[0]; _v1.ny = _nres[1]; _v1.nz = _nres[2];
|
||||
_v2.nx = _nres[0]; _v2.ny = _nres[1]; _v2.nz = _nres[2];
|
||||
}
|
||||
}
|
||||
|
||||
_res.VB = _res.build();
|
||||
|
|
|
@ -25,7 +25,7 @@ function Node_3D_Mesh_Plane(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _grou
|
|||
inputs[in_mesh + 3].setVisible(_both, _both);
|
||||
}
|
||||
|
||||
static processData = function(_output, _data, _output_index, _array_index = 0) { #region
|
||||
static processData = function(_output, _data, _output_index, _array_index = 0) {
|
||||
var _mat = _data[in_mesh + 0];
|
||||
var _axs = _data[in_mesh + 1];
|
||||
var _both = _data[in_mesh + 2];
|
||||
|
@ -38,7 +38,7 @@ function Node_3D_Mesh_Plane(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _grou
|
|||
setTransform(object, _data);
|
||||
|
||||
return object;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static getPreviewValues = function() { return getSingleValue(in_mesh + 0); }
|
||||
}
|
76
scripts/node_3d_subdivide/node_3d_subdivide.gml
Normal file
76
scripts/node_3d_subdivide/node_3d_subdivide.gml
Normal file
|
@ -0,0 +1,76 @@
|
|||
function Node_3D_Subdivide(_x, _y, _group = noone) : Node_3D_Modifier(_x, _y, _group) constructor {
|
||||
name = "3D Subdivide";
|
||||
|
||||
newInput(in_mesh + 0, nodeValue_Float("Subobjects", self, -1));
|
||||
|
||||
newInput(in_mesh + 1, nodeValue_Int("Level", self, 1));
|
||||
|
||||
input_display_list = [
|
||||
["Mesh", false], 0, in_mesh + 0,
|
||||
["Subdivide", false], in_mesh + 1,
|
||||
];
|
||||
|
||||
static processData = function(_output, _data, _output_index, _array_index = 0) {
|
||||
var _obj = _data[0];
|
||||
var _trg = _data[in_mesh + 0];
|
||||
var _sub = _data[in_mesh + 1];
|
||||
|
||||
if(!is_instanceof(_obj, __3dObject)) return noone;
|
||||
|
||||
var _res = _obj.clone();
|
||||
|
||||
var _vlen = array_length(_res.vertex);
|
||||
var _tarr = _trg == -1? array_create_ext(_vlen, function(i) /*=>*/ {return i}) : [ clamp(_trg, 0, _vlen - 1) ];
|
||||
|
||||
if(_sub > 8) noti_warning("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
|
||||
|
||||
repeat(_sub)
|
||||
for( var i = 0, n = array_length(_tarr); i < n; i++ ) {
|
||||
var _vi = _tarr[i];
|
||||
var _vt = _res.vertex[_vi];
|
||||
var _svt = array_create(array_length(_vt) * 4);
|
||||
var _ind = 0;
|
||||
|
||||
for( var j = 0, m = array_length(_vt); j < m; j += 3 ) {
|
||||
var _v0 = _vt[j + 0];
|
||||
var _v1 = _vt[j + 1];
|
||||
var _v2 = _vt[j + 2];
|
||||
|
||||
var _v01 = new __vertex().set((_v0.x + _v1.x) / 2, (_v0.y + _v1.y) / 2, (_v0.z + _v1.z) / 2,
|
||||
(_v0.nx + _v1.nx) / 2, (_v0.ny + _v1.ny) / 2, (_v0.nz + _v1.nz) / 2,
|
||||
(_v0.u + _v1.u) / 2, (_v0.v + _v1.v) / 2);
|
||||
|
||||
var _v02 = new __vertex().set((_v0.x + _v2.x) / 2, (_v0.y + _v2.y) / 2, (_v0.z + _v2.z) / 2,
|
||||
(_v0.nx + _v2.nx) / 2, (_v0.ny + _v2.ny) / 2, (_v0.nz + _v2.nz) / 2,
|
||||
(_v0.u + _v2.u) / 2, (_v0.v + _v2.v) / 2);
|
||||
|
||||
var _v12 = new __vertex().set((_v2.x + _v1.x) / 2, (_v2.y + _v1.y) / 2, (_v2.z + _v1.z) / 2,
|
||||
(_v2.nx + _v1.nx) / 2, (_v2.ny + _v1.ny) / 2, (_v2.nz + _v1.nz) / 2,
|
||||
(_v2.u + _v1.u) / 2, (_v2.v + _v1.v) / 2);
|
||||
|
||||
_svt[_ind++] = _v0;
|
||||
_svt[_ind++] = _v01;
|
||||
_svt[_ind++] = _v02;
|
||||
|
||||
_svt[_ind++] = _v01;
|
||||
_svt[_ind++] = _v1;
|
||||
_svt[_ind++] = _v12;
|
||||
|
||||
_svt[_ind++] = _v02;
|
||||
_svt[_ind++] = _v12;
|
||||
_svt[_ind++] = _v2;
|
||||
|
||||
_svt[_ind++] = _v01;
|
||||
_svt[_ind++] = _v12;
|
||||
_svt[_ind++] = _v02;
|
||||
|
||||
}
|
||||
|
||||
_res.vertex[_vi] = _svt;
|
||||
}
|
||||
|
||||
_res.VB = _res.build();
|
||||
|
||||
return _res;
|
||||
}
|
||||
}
|
13
scripts/node_3d_subdivide/node_3d_subdivide.yy
Normal file
13
scripts/node_3d_subdivide/node_3d_subdivide.yy
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"$GMScript":"v1",
|
||||
"%Name":"node_3d_subdivide",
|
||||
"isCompatibility":false,
|
||||
"isDnD":false,
|
||||
"name":"node_3d_subdivide",
|
||||
"parent":{
|
||||
"name":"d3d_modifier",
|
||||
"path":"folders/nodes/data/3D/d3d_modifier.yy",
|
||||
},
|
||||
"resourceType":"GMScript",
|
||||
"resourceVersion":"2.0",
|
||||
}
|
12
scripts/node_3d_subdivide/node_counter.yy
Normal file
12
scripts/node_3d_subdivide/node_counter.yy
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"isDnD": false,
|
||||
"isCompatibility": false,
|
||||
"parent": {
|
||||
"name": "variable",
|
||||
"path": "folders/nodes/data/variable.yy",
|
||||
},
|
||||
"resourceVersion": "1.0",
|
||||
"name": "node_counter",
|
||||
"tags": [],
|
||||
"resourceType": "GMScript",
|
||||
}
|
|
@ -30,7 +30,7 @@ function Node_Base_Convert(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
|
|||
var b1 = BBOX().fromPoints(bbox.x0, bbox.y0, bbox.xc - _s * 8, bbox.y1);
|
||||
var b2 = BBOX().fromPoints(bbox.xc + _s * 8, bbox.y0, bbox.x1, bbox.y1);
|
||||
|
||||
draw_sprite_ext(THEME.arrow, 0, bbox.xc, bbox.yc + 1 * _s, .5 * _s, .5 * _s, 0, COLORS._main_icon, 1);
|
||||
draw_sprite_ext(THEME.arrow, 0, bbox.xc, bbox.yc - 2 * _s, _s, _s, 0, COLORS._main_accent, 1);
|
||||
draw_text_bbox(b1, baseFrom);
|
||||
draw_text_bbox(b2, baseTo);
|
||||
}
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
function L_Turtle(x = 0, y = 0, ang = 90, w = 1, color = c_white, itr = 0) constructor {
|
||||
function L_Turtle(x = 0, y = 0, z = 0, ang = 90, w = 1, color = c_white, itr = 0) constructor {
|
||||
self.x = x;
|
||||
self.y = y;
|
||||
self.z = z;
|
||||
self.ang = ang;
|
||||
self.vang = 0;
|
||||
self.w = w;
|
||||
self.color = color;
|
||||
|
||||
self.itr = itr;
|
||||
|
||||
static clone = function() { return new L_Turtle(x, y, ang, w, color, itr); }
|
||||
static clone = function() {
|
||||
var t = new L_Turtle(x, y, z, ang, w, color, itr);
|
||||
t.vang = vang;
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
function Node_Path_L_System(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
||||
|
@ -31,10 +36,20 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
newInput(7, nodeValue_Int("Seed", self, seed_random(6)))
|
||||
.setDisplay(VALUE_DISPLAY._default, { side_button : button(function() { randomize(); inputs[7].setValue(seed_random(6)); }).setIcon(THEME.icon_random, 0, COLORS._main_icon) });
|
||||
|
||||
newInput(8, nodeValue_Bool("3D", self, false));
|
||||
|
||||
newInput(9, nodeValue_Enum_Button("Forward", self, 1, [ "X", "Y", "Z" ]));
|
||||
|
||||
newInput(10, nodeValue_Vec3("Starting position", self, [ 0, 0, 0 ]));
|
||||
|
||||
newInput(11, nodeValue_Rotation("Subangle", self, 45));
|
||||
|
||||
static createNewInput = function() {
|
||||
var index = array_length(inputs);
|
||||
newInput(index + 0, nodeValue_Text("Name " + string(index - input_fix_len), self, "" ));
|
||||
newInput(index + 1, nodeValue_Text("Rule " + string(index - input_fix_len), self, "" ));
|
||||
var _idx = index - input_fix_len;
|
||||
|
||||
newInput(index + 0, nodeValue_Text($"Name {_idx}", self, "" ));
|
||||
newInput(index + 1, nodeValue_Text($"Rule {_idx}", self, "" ));
|
||||
|
||||
return inputs[index + 0];
|
||||
}
|
||||
|
@ -42,7 +57,7 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
setDynamicInput(2, false);
|
||||
if(!LOADING && !APPENDING) createNewInput();
|
||||
|
||||
newOutput(0, nodeValue_Output("Path", self, VALUE_TYPE.pathnode, self));
|
||||
newOutput(0, nodeValue_Output("Path", self, VALUE_TYPE.pathnode, noone));
|
||||
|
||||
rule_renderer = new Inspector_Custom_Renderer(function(_x, _y, _w, _m, _hover, _focus) {
|
||||
rule_renderer.x = _x;
|
||||
|
@ -77,6 +92,7 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
|
||||
return hh;
|
||||
},
|
||||
|
||||
function(parent = noone) {
|
||||
for( var i = input_fix_len; i < array_length(inputs); i += data_length ) {
|
||||
var _name = inputs[i + 0];
|
||||
|
@ -88,8 +104,9 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
});
|
||||
|
||||
input_display_list = [
|
||||
["Origin", false], 2, 6,
|
||||
["Origin", false], 2, 10, 6,
|
||||
["Properties", false], 0, 1, 7,
|
||||
["3D", false, 8], 9, 11,
|
||||
["Rules", false], 3, 4, rule_renderer, 5,
|
||||
];
|
||||
|
||||
|
@ -102,13 +119,14 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
triggerRender();
|
||||
}) ]);
|
||||
|
||||
path_3d = false;
|
||||
cache_data = {
|
||||
start : "",
|
||||
rules : {},
|
||||
end_rule : "",
|
||||
iteration : 0,
|
||||
seed : 0,
|
||||
result : ""
|
||||
result : "",
|
||||
}
|
||||
|
||||
static refreshDynamicInput = function() {
|
||||
|
@ -166,12 +184,49 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
}
|
||||
}
|
||||
|
||||
static drawOverlay3D = function(active, params, _mx, _my, _snx, _sny, _panel) {
|
||||
|
||||
var _out = getSingleValue(0, preview_index, true);
|
||||
if(!is_struct(_out)) return;
|
||||
|
||||
var _qinv = new BBMOD_Quaternion().FromAxisAngle(new BBMOD_Vec3(1, 0, 0), 90);
|
||||
|
||||
var _camera = params.camera;
|
||||
var _qview = new BBMOD_Quaternion().FromEuler(_camera.focus_angle_y, -_camera.focus_angle_x, 0);
|
||||
var ray = _camera.viewPointToWorldRay(_mx, _my);
|
||||
|
||||
var _v3 = new __vec3();
|
||||
var _ox = 0, _oy = 0;
|
||||
var _nx = 0, _ny = 0;
|
||||
|
||||
draw_set_color(COLORS._main_accent);
|
||||
for( var i = 0, n = array_length(_out.lines); i < n; i++ ) {
|
||||
var p0 = _out.lines[i][0];
|
||||
var p1 = _out.lines[i][1];
|
||||
|
||||
_v3.x = p0[0];
|
||||
_v3.y = p0[1];
|
||||
_v3.z = p0[2];
|
||||
|
||||
var _posView = _camera.worldPointToViewPoint(_v3);
|
||||
_nx = _posView.x;
|
||||
_ny = _posView.y;
|
||||
|
||||
if(i) draw_line(_ox, _oy, _nx, _ny);
|
||||
|
||||
_ox = _nx;
|
||||
_oy = _ny;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function Path_LSystem() constructor {
|
||||
lines = [];
|
||||
current_length = 0;
|
||||
boundary = new BoundingBox();
|
||||
path_3d = false;
|
||||
|
||||
static getLineCount = function() { return array_length(lines); }
|
||||
static getSegmentCount = function() { return 1; }
|
||||
|
@ -190,11 +245,12 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
if(!is_array(_p0) || array_length(_p0) < 2) return 1;
|
||||
if(!is_array(_p1) || array_length(_p1) < 2) return 1;
|
||||
|
||||
return lerp(_p0[2], _p1[2], _rat);
|
||||
return lerp(_p0[3], _p1[3], _rat);
|
||||
}
|
||||
|
||||
static getPointRatio = function(_rat, _ind = 0, out = undefined) {
|
||||
if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; }
|
||||
if(out == undefined) out = path_3d? new __vec3() : new __vec2();
|
||||
else { out.x = 0; out.y = 0; if(path_3d) out.z = 0; }
|
||||
|
||||
var _p0 = lines[_ind][0];
|
||||
var _p1 = lines[_ind][1];
|
||||
|
@ -205,6 +261,8 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
out.x = lerp(_p0[0], _p1[0], _rat);
|
||||
out.y = lerp(_p0[1], _p1[1], _rat);
|
||||
|
||||
if(path_3d) out.z = lerp(_p0[2], _p1[2], _rat);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
@ -272,17 +330,26 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
|
||||
var _len = _data[0];
|
||||
var _ang = _data[1];
|
||||
var _pos = _data[2];
|
||||
var _itr = _data[3];
|
||||
var _sta = _data[4];
|
||||
var _end = _data[5];
|
||||
var _san = _data[6];
|
||||
var _sad = _data[7];
|
||||
path_3d = _data[8];
|
||||
var _for = _data[9];
|
||||
var _pos = path_3d? _data[10] : _data[2];
|
||||
var _vang = _data[11];
|
||||
|
||||
inputs[ 2].setVisible(!path_3d);
|
||||
inputs[10].setVisible( path_3d);
|
||||
|
||||
is_3D = path_3d? NODE_3D.polygon : NODE_3D.none;
|
||||
lineq = ds_queue_create();
|
||||
|
||||
random_set_seed(_sad);
|
||||
__curr_path = new Path_LSystem();
|
||||
__curr_path.current_length = _len;
|
||||
__curr_path.path_3d = path_3d;
|
||||
|
||||
if(array_length(inputs) < input_fix_len + 2) return __curr_path;
|
||||
|
||||
|
@ -301,39 +368,87 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
l_system(_sta, rules, _end, _itr, _sad);
|
||||
itr = _itr;
|
||||
ang = _ang;
|
||||
vang = _vang;
|
||||
len = _len;
|
||||
forw = _for;
|
||||
st = ds_stack_create();
|
||||
t = new L_Turtle(_pos[0], _pos[1], _san);
|
||||
t = new L_Turtle(_pos[0], _pos[1], path_3d? _pos[2] : 0, _san);
|
||||
maxItr = 0;
|
||||
|
||||
var nx, ny, nz;
|
||||
_llen = _len / 25;
|
||||
|
||||
string_foreach(cache_data.result, function(_ch, _) {
|
||||
switch(_ch) {
|
||||
case "F":
|
||||
var nx = t.x + lengthdir_x(len, t.ang);
|
||||
var ny = t.y + lengthdir_y(len, t.ang);
|
||||
if(path_3d) {
|
||||
nx = t.x + _llen * dcos(t.vang) * dcos(t.ang);
|
||||
ny = t.y + _llen * dcos(t.vang) * dsin(t.ang);
|
||||
nz = t.z + _llen * dsin(t.vang);
|
||||
|
||||
ds_queue_enqueue(lineq, [ [ t.x, t.y, t.w, t.itr ], [ nx, ny, t.w, t.itr + 1 ] ]);
|
||||
switch(forw) {
|
||||
case 0 : ds_queue_enqueue(lineq, [ [ t.y, t.x, t.z, t.w, t.itr ], [ ny, nx, nz, t.w, t.itr + 1 ] ]); break;
|
||||
case 1 : ds_queue_enqueue(lineq, [ [ t.x, t.y, t.z, t.w, t.itr ], [ nx, ny, nz, t.w, t.itr + 1 ] ]); break;
|
||||
case 2 : ds_queue_enqueue(lineq, [ [ t.x, t.z, t.y, t.w, t.itr ], [ nx, nz, ny, t.w, t.itr + 1 ] ]); break;
|
||||
}
|
||||
|
||||
} else {
|
||||
nx = t.x + lengthdir_x(len, t.ang);
|
||||
ny = t.y + lengthdir_y(len, t.ang);
|
||||
nz = t.z;
|
||||
ds_queue_enqueue(lineq, [ [ t.x, t.y, t.z, t.w, t.itr ], [ nx, ny, nz, t.w, t.itr + 1 ] ]);
|
||||
|
||||
}
|
||||
|
||||
t.x = nx;
|
||||
t.y = ny;
|
||||
t.z = nz;
|
||||
t.itr++;
|
||||
maxItr = max(maxItr, t.itr);
|
||||
|
||||
break;
|
||||
|
||||
case "G":
|
||||
t.x = t.x + lengthdir_x(len, t.ang);
|
||||
t.y = t.y + lengthdir_y(len, t.ang);
|
||||
break;
|
||||
if(path_3d) {
|
||||
nx = t.x + _llen * dcos(t.vang) * dcos(t.ang);
|
||||
ny = t.y + _llen * dcos(t.vang) * dsin(t.ang);
|
||||
nz = t.z + _llen * dsin(t.vang);
|
||||
|
||||
case "f":
|
||||
var nx = t.x + lengthdir_x(len * frac(itr), t.ang);
|
||||
var ny = t.y + lengthdir_y(len * frac(itr), t.ang);
|
||||
|
||||
ds_queue_enqueue(lineq, [ [ t.x, t.y, t.w, t.itr ], [ nx, ny, t.w, t.itr + 1 ] ]);
|
||||
} else {
|
||||
nx = t.x + lengthdir_x(len, t.ang);
|
||||
ny = t.y + lengthdir_y(len, t.ang);
|
||||
nz = t.z;
|
||||
}
|
||||
|
||||
t.x = nx;
|
||||
t.y = ny;
|
||||
break;
|
||||
|
||||
case "f":
|
||||
var _ll = _llen * frac(itr);
|
||||
|
||||
if(path_3d) {
|
||||
nx = t.x + _ll * dcos(t.vang) * dcos(t.ang);
|
||||
ny = t.y + _ll * dcos(t.vang) * dsin(t.ang);
|
||||
nz = t.z + _ll * dsin(t.vang);
|
||||
|
||||
switch(forw) {
|
||||
case 0 : ds_queue_enqueue(lineq, [ [ t.y, t.x, t.z, t.w, t.itr ], [ ny, nx, nz, t.w, t.itr + 1 ] ]); break;
|
||||
case 1 : ds_queue_enqueue(lineq, [ [ t.x, t.y, t.z, t.w, t.itr ], [ nx, ny, nz, t.w, t.itr + 1 ] ]); break;
|
||||
case 2 : ds_queue_enqueue(lineq, [ [ t.x, t.z, t.y, t.w, t.itr ], [ nx, nz, ny, t.w, t.itr + 1 ] ]); break;
|
||||
}
|
||||
|
||||
} else {
|
||||
nx = t.x + lengthdir_x(_ll, t.ang);
|
||||
ny = t.y + lengthdir_y(_ll, t.ang);
|
||||
nz = t.z;
|
||||
ds_queue_enqueue(lineq, [ [ t.x, t.y, t.z, t.w, t.itr ], [ nx, ny, nz, t.w, t.itr + 1 ] ]);
|
||||
|
||||
}
|
||||
|
||||
t.x = nx;
|
||||
t.y = ny;
|
||||
t.z = nz;
|
||||
t.itr++;
|
||||
maxItr = max(maxItr, t.itr);
|
||||
break;
|
||||
|
@ -342,6 +457,9 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
case "-": t.ang -= ang; break;
|
||||
case "|": t.ang += 180; break;
|
||||
|
||||
case "*": t.vang += vang; break;
|
||||
case "/": t.vang -= vang; break;
|
||||
|
||||
case "[": ds_stack_push(st, t.clone()); break;
|
||||
case "]":
|
||||
if(ds_stack_empty(st)) noti_warning("L-system: Trying to pop an empty stack. Make sure that all close brackets ']' has a corresponding open bracket '['.");
|
||||
|
@ -351,7 +469,6 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
case ">": t.w += 0.1; break;
|
||||
case "<": t.w -= 0.1; break;
|
||||
|
||||
// default : noti_warning($"L-system: Invalid rule '{_ch}'");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -379,4 +496,9 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
var bbox = drawGetBbox(xx, yy, _s);
|
||||
draw_sprite_fit(s_node_path_l_system, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
|
||||
}
|
||||
|
||||
static getPreviewObject = function() { return noone; }
|
||||
static getPreviewObjects = function() { return []; }
|
||||
static getPreviewObjectOutline = function() { return []; }
|
||||
|
||||
}
|
|
@ -724,6 +724,7 @@ function __initNodes() {
|
|||
ds_list_add(d3d, "Modify");
|
||||
addNodeObject(d3d, "Discretize vertex", s_node_3d_discretize, "Node_3D_Round_Vertex", [1, Node_3D_Round_Vertex],, "Round out vertex position to a specified step.").setVersion(11560);
|
||||
addNodeObject(d3d, "3D Displace", s_node_3d_displace, "Node_3D_Displace", [1, Node_3D_Displace],, "").setVersion(1_18_01_0);
|
||||
addNodeObject(d3d, "3D Subdivide", s_node_3d_subdivide, "Node_3D_Subdivide", [1, Node_3D_Subdivide],, "").setVersion(1_18_03_0);
|
||||
addNodeObject(d3d, "Set Material", s_node_3d_set_material, "Node_3D_Set_Material", [1, Node_3D_Set_Material],, "Replace mesh material with a new one.").setVersion(11560);
|
||||
addNodeObject(d3d, "Transform", s_node_3d_transform, "Node_3D_Transform", [1, Node_3D_Transform],, "Transform 3D object.").setVersion(11570);
|
||||
addNodeObject(d3d, "Transform Scene", s_node_3d_transform_scene, "Node_3D_Transform_Scene", [1, Node_3D_Transform_Scene],, "Transform 3D scene, accepts array of transformations for each objects.").setVersion(11570);
|
||||
|
|
|
@ -8,25 +8,63 @@ function Node_String_Split(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
|
|||
newInput(1, nodeValue_Text("Delimiter", self, " ", "Character that used to split text,\nleave blank to create character array."));
|
||||
inputs[1].editWidget.format = TEXT_AREA_FORMAT.delimiter;
|
||||
|
||||
newInput(2, nodeValue_Enum_Scroll("Mode", self, 0, [ "Delimiter", "Periordic" ]))
|
||||
|
||||
newInput(3, nodeValue_Int("Period", self, 1));
|
||||
|
||||
newOutput(0, nodeValue_Output("Text", self, VALUE_TYPE.text, ""));
|
||||
|
||||
static processData = function(_output, _data, _index = 0) {
|
||||
if(_data[1] == "")
|
||||
return string_to_array(_data[0]);
|
||||
input_display_list = [ 0,
|
||||
2, 1, 3,
|
||||
];
|
||||
|
||||
var delim = _data[1];
|
||||
delim = string_replace_all(delim, "\\n", "\n");
|
||||
delim = string_replace_all(delim, "\\t", "\t");
|
||||
return string_splice(_data[0], delim);
|
||||
static processData = function(_output, _data, _index = 0) {
|
||||
var _text = _data[0];
|
||||
var _deli = _data[1];
|
||||
var _mode = _data[2];
|
||||
var _peri = max(1, _data[3]);
|
||||
|
||||
inputs[1].setVisible(_mode == 0);
|
||||
inputs[3].setVisible(_mode == 1);
|
||||
|
||||
if(_deli == "") return string_to_array(_text);
|
||||
|
||||
if(_mode == 0) {
|
||||
_deli = string_replace_all(_deli, "\\n", "\n");
|
||||
_deli = string_replace_all(_deli, "\\t", "\t");
|
||||
return string_splice(_text, _deli);
|
||||
|
||||
} else if(_mode == 1) {
|
||||
var _len = string_length(_text);
|
||||
var _amo = ceil(_len / _peri);
|
||||
var _arr = array_create(_amo);
|
||||
|
||||
for( var i = 0; i < _amo; i++ ) {
|
||||
var _st = 1 + i * _peri;
|
||||
var _ed = min(_st + _peri, _len + 1);
|
||||
|
||||
_arr[i] = string_copy(_text, _st, _ed - _st);
|
||||
}
|
||||
// print($"{_amo}: {_arr}");
|
||||
|
||||
return _arr;
|
||||
|
||||
}
|
||||
|
||||
return [ _text ];
|
||||
}
|
||||
|
||||
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
||||
var str = getInputData(1);
|
||||
var bbox = drawGetBbox(xx, yy, _s);
|
||||
var cx = bbox.xc;
|
||||
var cy = bbox.yc;
|
||||
|
||||
if(string_length(str) == 0) {
|
||||
var _deli = getInputData(1);
|
||||
var _mode = getInputData(2);
|
||||
var _peri = getInputData(3);
|
||||
|
||||
if(_mode == 0) {
|
||||
if(string_length(_deli) == 0) {
|
||||
draw_set_text(f_sdf, fa_center, fa_center, COLORS._main_text_sub);
|
||||
draw_text_bbox(bbox, __txt("None"));
|
||||
return;
|
||||
|
@ -35,14 +73,19 @@ function Node_String_Split(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
|
|||
_s *= 0.5;
|
||||
|
||||
draw_set_text(f_sdf, fa_center, fa_center, COLORS._main_text);
|
||||
str = string_cut(str, bbox.w - _s * 32, "...", _s);
|
||||
draw_text_add(cx, cy, str, _s);
|
||||
_deli = string_cut(_deli, bbox.w - _s * 32, "...", _s);
|
||||
draw_text_add(cx, cy, _deli, _s);
|
||||
|
||||
var ww = (string_width(str) / 2) * _s;
|
||||
var ww = (string_width(_deli) / 2) * _s;
|
||||
draw_set_text(f_sdf, fa_right, fa_center, COLORS._main_text_sub);
|
||||
draw_text_transformed(cx - ww, cy, "|", _s, _s, 0);
|
||||
|
||||
draw_set_halign(fa_left);
|
||||
draw_text_transformed(cx + ww, cy, "|", _s, _s, 0);
|
||||
|
||||
} else if(_mode == 1) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1041,6 +1041,8 @@ function Panel_Preview() : PanelContent() constructor {
|
|||
sample_x = floor((mx - canvas_x) / canvas_s);
|
||||
sample_y = floor((my - canvas_y) / canvas_s);
|
||||
var surf = getNodePreviewSurface();
|
||||
|
||||
if(is_surface(surf)) {
|
||||
sample_color_raw = surface_getpixel_ext(surf, sample_x, sample_y);
|
||||
sample_color = is_array(sample_color_raw)? make_color_rgba(clamp(sample_color_raw[0] * 255, 0, 255),
|
||||
clamp(sample_color_raw[1] * 255, 0, 255),
|
||||
|
@ -1048,6 +1050,7 @@ function Panel_Preview() : PanelContent() constructor {
|
|||
clamp(sample_color_raw[3] * 255, 0, 255)) : sample_color_raw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(is_surface(preview_surfaces[0])) { // outline
|
||||
if(PROJECT.previewGrid.pixel && canvas_s >= 16) {
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
90
sprites/s_node_3d_subdivide/s_node_3d_subdivide.yy
Normal file
90
sprites/s_node_3d_subdivide/s_node_3d_subdivide.yy
Normal file
|
@ -0,0 +1,90 @@
|
|||
{
|
||||
"$GMSprite":"",
|
||||
"%Name":"s_node_3d_subdivide",
|
||||
"bboxMode":0,
|
||||
"bbox_bottom":61,
|
||||
"bbox_left":6,
|
||||
"bbox_right":57,
|
||||
"bbox_top":2,
|
||||
"collisionKind":1,
|
||||
"collisionTolerance":0,
|
||||
"DynamicTexturePage":false,
|
||||
"edgeFiltering":false,
|
||||
"For3D":false,
|
||||
"frames":[
|
||||
{"$GMSpriteFrame":"","%Name":"daffd462-b1cb-4336-b10e-50faf1aa62f9","name":"daffd462-b1cb-4336-b10e-50faf1aa62f9","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
|
||||
],
|
||||
"gridX":0,
|
||||
"gridY":0,
|
||||
"height":64,
|
||||
"HTile":false,
|
||||
"layers":[
|
||||
{"$GMImageLayer":"","%Name":"3efeaa52-14bc-4c86-96fe-3122954e5358","blendMode":0,"displayName":"default","isLocked":false,"name":"3efeaa52-14bc-4c86-96fe-3122954e5358","opacity":100.0,"resourceType":"GMImageLayer","resourceVersion":"2.0","visible":true,},
|
||||
],
|
||||
"name":"s_node_3d_subdivide",
|
||||
"nineSlice":null,
|
||||
"origin":4,
|
||||
"parent":{
|
||||
"name":"3D",
|
||||
"path":"folders/nodes/icons/3D.yy",
|
||||
},
|
||||
"preMultiplyAlpha":false,
|
||||
"resourceType":"GMSprite",
|
||||
"resourceVersion":"2.0",
|
||||
"sequence":{
|
||||
"$GMSequence":"",
|
||||
"%Name":"s_node_3d_subdivide",
|
||||
"autoRecord":true,
|
||||
"backdropHeight":768,
|
||||
"backdropImageOpacity":0.5,
|
||||
"backdropImagePath":"",
|
||||
"backdropWidth":1366,
|
||||
"backdropXOffset":0.0,
|
||||
"backdropYOffset":0.0,
|
||||
"events":{
|
||||
"$KeyframeStore<MessageEventKeyframe>":"",
|
||||
"Keyframes":[],
|
||||
"resourceType":"KeyframeStore<MessageEventKeyframe>",
|
||||
"resourceVersion":"2.0",
|
||||
},
|
||||
"eventStubScript":null,
|
||||
"eventToFunction":{},
|
||||
"length":1.0,
|
||||
"lockOrigin":false,
|
||||
"moments":{
|
||||
"$KeyframeStore<MomentsEventKeyframe>":"",
|
||||
"Keyframes":[],
|
||||
"resourceType":"KeyframeStore<MomentsEventKeyframe>",
|
||||
"resourceVersion":"2.0",
|
||||
},
|
||||
"name":"s_node_3d_subdivide",
|
||||
"playback":1,
|
||||
"playbackSpeed":30.0,
|
||||
"playbackSpeedType":0,
|
||||
"resourceType":"GMSequence",
|
||||
"resourceVersion":"2.0",
|
||||
"showBackdrop":true,
|
||||
"showBackdropImage":false,
|
||||
"timeUnits":1,
|
||||
"tracks":[
|
||||
{"$GMSpriteFramesTrack":"","builtinName":0,"events":[],"inheritsTrackColour":true,"interpolation":1,"isCreationTrack":false,"keyframes":{"$KeyframeStore<SpriteFrameKeyframe>":"","Keyframes":[
|
||||
{"$Keyframe<SpriteFrameKeyframe>":"","Channels":{
|
||||
"0":{"$SpriteFrameKeyframe":"","Id":{"name":"daffd462-b1cb-4336-b10e-50faf1aa62f9","path":"sprites/s_node_3d_subdivide/s_node_3d_subdivide.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",},
|
||||
},"Disabled":false,"id":"bbce277a-9b0c-434f-b1c4-91548682b904","IsCreationKey":false,"Key":0.0,"Length":1.0,"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"2.0","Stretch":false,},
|
||||
],"resourceType":"KeyframeStore<SpriteFrameKeyframe>","resourceVersion":"2.0",},"modifiers":[],"name":"frames","resourceType":"GMSpriteFramesTrack","resourceVersion":"2.0","spriteId":null,"trackColour":0,"tracks":[],"traits":0,},
|
||||
],
|
||||
"visibleRange":null,
|
||||
"volume":1.0,
|
||||
"xorigin":32,
|
||||
"yorigin":32,
|
||||
},
|
||||
"swatchColours":null,
|
||||
"swfPrecision":0.5,
|
||||
"textureGroupId":{
|
||||
"name":"Default",
|
||||
"path":"texturegroups/Default",
|
||||
},
|
||||
"type":0,
|
||||
"VTile":false,
|
||||
"width":64,
|
||||
}
|
Loading…
Reference in a new issue