mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2025-01-24 03:48:06 +01:00
displace
This commit is contained in:
parent
988831e9b9
commit
f51f024918
23 changed files with 301 additions and 104 deletions
|
@ -687,6 +687,7 @@
|
|||
{"name":"mouse_input","order":1,"path":"scripts/mouse_input/mouse_input.yy",},
|
||||
{"name":"mtl_reader","order":6,"path":"scripts/mtl_reader/mtl_reader.yy",},
|
||||
{"name":"node_3d_camera_set","order":1,"path":"scripts/node_3d_camera_set/node_3d_camera_set.yy",},
|
||||
{"name":"node_3d_displace","order":8,"path":"scripts/node_3d_displace/node_3d_displace.yy",},
|
||||
{"name":"node_3d_instancer","order":3,"path":"scripts/node_3d_instancer/node_3d_instancer.yy",},
|
||||
{"name":"node_3d_light_point","order":2,"path":"scripts/node_3d_light_point/node_3d_light_point.yy",},
|
||||
{"name":"node_3d_material","order":10,"path":"scripts/node_3d_material/node_3d_material.yy",},
|
||||
|
@ -878,6 +879,7 @@
|
|||
{"name":"node_grid_noise","order":4,"path":"scripts/node_grid_noise/node_grid_noise.yy",},
|
||||
{"name":"node_grid_pentagonal","order":10,"path":"scripts/node_grid_pentagonal/node_grid_pentagonal.yy",},
|
||||
{"name":"node_grid_tri","order":3,"path":"scripts/node_grid_tri/node_grid_tri.yy",},
|
||||
{"name":"node_grid_warp","order":9,"path":"scripts/node_grid_warp/node_grid_warp.yy",},
|
||||
{"name":"node_grid","order":1,"path":"scripts/node_grid/node_grid.yy",},
|
||||
{"name":"node_group_input","order":1,"path":"scripts/node_group_input/node_group_input.yy",},
|
||||
{"name":"node_group_output","order":2,"path":"scripts/node_group_output/node_group_output.yy",},
|
||||
|
@ -932,7 +934,7 @@
|
|||
{"name":"node_mesh_create_path","order":1,"path":"scripts/node_mesh_create_path/node_mesh_create_path.yy",},
|
||||
{"name":"node_mesh_to_path","order":3,"path":"scripts/node_mesh_to_path/node_mesh_to_path.yy",},
|
||||
{"name":"node_mesh_transform","order":2,"path":"scripts/node_mesh_transform/node_mesh_transform.yy",},
|
||||
{"name":"node_mesh_warp","order":6,"path":"scripts/node_mesh_warp/node_mesh_warp.yy",},
|
||||
{"name":"node_mesh_warp","order":8,"path":"scripts/node_mesh_warp/node_mesh_warp.yy",},
|
||||
{"name":"node_midi_in","order":19,"path":"scripts/node_midi_in/node_midi_in.yy",},
|
||||
{"name":"node_mirror","order":3,"path":"scripts/node_mirror/node_mirror.yy",},
|
||||
{"name":"node_mk_blinker","order":10,"path":"scripts/node_mk_blinker/node_mk_blinker.yy",},
|
||||
|
|
|
@ -1226,6 +1226,7 @@
|
|||
{"id":{"name":"node_3d_camera_set","path":"scripts/node_3d_camera_set/node_3d_camera_set.yy",},},
|
||||
{"id":{"name":"node_3d_camera","path":"scripts/node_3d_camera/node_3d_camera.yy",},},
|
||||
{"id":{"name":"node_3d_depth","path":"scripts/node_3d_depth/node_3d_depth.yy",},},
|
||||
{"id":{"name":"node_3d_displace","path":"scripts/node_3d_displace/node_3d_displace.yy",},},
|
||||
{"id":{"name":"node_3d_instancer","path":"scripts/node_3d_instancer/node_3d_instancer.yy",},},
|
||||
{"id":{"name":"node_3d_light_directional","path":"scripts/node_3d_light_directional/node_3d_light_directional.yy",},},
|
||||
{"id":{"name":"node_3d_light_point","path":"scripts/node_3d_light_point/node_3d_light_point.yy",},},
|
||||
|
@ -1445,6 +1446,7 @@
|
|||
{"id":{"name":"node_grid_noise","path":"scripts/node_grid_noise/node_grid_noise.yy",},},
|
||||
{"id":{"name":"node_grid_pentagonal","path":"scripts/node_grid_pentagonal/node_grid_pentagonal.yy",},},
|
||||
{"id":{"name":"node_grid_tri","path":"scripts/node_grid_tri/node_grid_tri.yy",},},
|
||||
{"id":{"name":"node_grid_warp","path":"scripts/node_grid_warp/node_grid_warp.yy",},},
|
||||
{"id":{"name":"node_grid","path":"scripts/node_grid/node_grid.yy",},},
|
||||
{"id":{"name":"node_group_input","path":"scripts/node_group_input/node_group_input.yy",},},
|
||||
{"id":{"name":"node_group_output","path":"scripts/node_group_output/node_group_output.yy",},},
|
||||
|
|
|
@ -8,11 +8,11 @@ function Node_3D_Modifier(_x, _y, _group = noone) : Node_3D(_x, _y, _group) cons
|
|||
|
||||
newOutput(0, nodeValue_Output("Mesh", self, VALUE_TYPE.d3Mesh, noone));
|
||||
|
||||
static modify_object = function(_object, _data, _matrix) { #region
|
||||
static modify_object = function(_object, _data, _matrix) {
|
||||
return _object;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static modify_group = function(_group, _data, _matrix) { #region
|
||||
static modify_group = function(_group, _data, _matrix) {
|
||||
var _gr = new __3dGroup();
|
||||
|
||||
_gr.transform = _group.transform.clone();
|
||||
|
@ -24,16 +24,16 @@ function Node_3D_Modifier(_x, _y, _group = noone) : Node_3D(_x, _y, _group) cons
|
|||
_gr.objects[i] = modify(_group.objects[i], _data, _matrix);
|
||||
|
||||
return _gr;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static modify = function(_object, _data, _matrix = new BBMOD_Matrix()) { #region
|
||||
static modify = function(_object, _data, _matrix = new BBMOD_Matrix()) {
|
||||
if(is_instanceof(_object, __3dObject)) return modify_object(_object, _data, _matrix);
|
||||
if(is_instanceof(_object, __3dGroup)) return modify_group(_object, _data, _matrix);
|
||||
|
||||
return noone;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static processData = function(_output, _data, _output_index, _array_index = 0) { #region
|
||||
static processData = function(_output, _data, _output_index, _array_index = 0) {
|
||||
return modify(_data[0], _data);
|
||||
} #endregion
|
||||
}
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
function buffer_get_color(buffer, _x, _y, w, h) { #region
|
||||
function buffer_get_color(buffer, _x, _y, w, h) {
|
||||
buffer_seek(buffer, buffer_seek_start, (w * _y + _x) * 4);
|
||||
var c = buffer_read(buffer, buffer_u32);
|
||||
|
||||
return c;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function buffer_get_string(buffer, text = true, limit = 400) { #region
|
||||
function buffer_get_string(buffer, text = true, limit = 400) {
|
||||
if(is_array(buffer)) return "[buffer array]";
|
||||
if(!buffer_exists(buffer)) return "";
|
||||
|
||||
|
@ -21,9 +21,9 @@ function buffer_get_string(buffer, text = true, limit = 400) { #region
|
|||
}
|
||||
|
||||
return ss;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function buffer_to_string(buffer) { #region
|
||||
function buffer_to_string(buffer) {
|
||||
if(!buffer_exists(buffer)) return "";
|
||||
|
||||
buffer_seek(buffer, buffer_seek_start, 0);
|
||||
|
@ -36,16 +36,16 @@ function buffer_to_string(buffer) { #region
|
|||
}
|
||||
|
||||
return ss;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function buffer_from_string(str) { #region
|
||||
function buffer_from_string(str) {
|
||||
var _b = buffer_create(string_length(str) * 1, buffer_fast, 1);
|
||||
for( var i = 1; i <= string_length(str); i++ )
|
||||
buffer_write(_b, buffer_u8, ord(string_char_at(str, i)));
|
||||
return _b;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function buffer_from_surface(surface, header = true) { #region
|
||||
function buffer_from_surface(surface, header = true) {
|
||||
static header_length = 24;
|
||||
if(!is_surface(surface)) return noone;
|
||||
|
||||
|
@ -61,27 +61,27 @@ function buffer_from_surface(surface, header = true) { #region
|
|||
|
||||
buffer_get_surface(_b, surface, header_length * header);
|
||||
return _b;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function buffer_from_file(path) { #region
|
||||
function buffer_from_file(path) {
|
||||
if(!file_exists_empty(path)) return;
|
||||
var _b = buffer_load(path);
|
||||
return _b;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function buffer_read_at(buffer, position, type) { #region
|
||||
function buffer_read_at(buffer, position, type) {
|
||||
INLINE
|
||||
buffer_seek(buffer, buffer_seek_start, position);
|
||||
return buffer_read(buffer, type);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function buffer_write_at(buffer, position, type, data) { #region
|
||||
function buffer_write_at(buffer, position, type, data) {
|
||||
INLINE
|
||||
buffer_seek(buffer, buffer_seek_start, position);
|
||||
return buffer_write(buffer, type, data);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function buffer_serialize(buffer, compress = true) { #region
|
||||
function buffer_serialize(buffer, compress = true) {
|
||||
INLINE
|
||||
if(!buffer_exists(buffer)) return "";
|
||||
|
||||
|
@ -91,37 +91,37 @@ function buffer_serialize(buffer, compress = true) { #region
|
|||
}
|
||||
|
||||
return buffer_base64_encode(buffer, 0, buffer_get_size(buffer));
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function buffer_deserialize(buffer, compress = true) { #region
|
||||
function buffer_deserialize(buffer, compress = true) {
|
||||
INLINE
|
||||
var buff = buffer_base64_decode(buffer);
|
||||
|
||||
if(!compress) return buff;
|
||||
return buffer_decompress(buff);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function buffer_getPixel(buffer, _w, _h, _x, _y) { #region
|
||||
function buffer_getPixel(buffer, _w, _h, _x, _y) {
|
||||
if(_x < 0 || _y < 0 || _x >= _w || _y >= _h) return 0;
|
||||
|
||||
buffer_seek(buffer, buffer_seek_start, (_w * _y + _x) * 4);
|
||||
return buffer_read(buffer, buffer_u32);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function buffer_setPixel(buffer, _w, _h, _x, _y, _c) { #region
|
||||
function buffer_setPixel(buffer, _w, _h, _x, _y, _c) {
|
||||
if(_x < 0 || _y < 0 || _x >= _w || _y >= _h) return 0;
|
||||
|
||||
buffer_seek(buffer, buffer_seek_start, (_w * _y + _x) * 4);
|
||||
buffer_write(buffer, buffer_u32, _c);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function buffer_compress_string(str) { #region
|
||||
function buffer_compress_string(str) {
|
||||
var _len = string_length(str);
|
||||
var buffer = buffer_create(1, buffer_grow, 1);
|
||||
|
||||
buffer_write(buffer, buffer_string, str);
|
||||
return buffer_compress(buffer, 0, buffer_get_size(buffer));
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function buffer_to_start(buff) { INLINE buffer_seek(buff, buffer_seek_start, 0); }
|
||||
|
||||
|
|
|
@ -82,13 +82,13 @@ function __3dCylinder(radius = 0.5, height = 1, sides = 8, smooth = false) : __3
|
|||
var _h0 = -_h + _j0 * _h * 2;
|
||||
var _h1 = -_h + _j1 * _h * 2;
|
||||
|
||||
vs[_ix++] = new __vertex(x2, y2, _h1).setNormal(nx0, ny0, 0).setUV(ux0, _j0);
|
||||
vs[_ix++] = new __vertex(x0, y0, _h0).setNormal(nx0, ny0, 0).setUV(ux0, _j1);
|
||||
vs[_ix++] = new __vertex(x3, y3, _h1).setNormal(nx1, ny1, 0).setUV(ux1, _j0);
|
||||
vs[_ix++] = new __vertex(x2, y2, _h1).setNormal(nx0, ny0, 0).setUV(ux0, _j1);
|
||||
vs[_ix++] = new __vertex(x0, y0, _h0).setNormal(nx0, ny0, 0).setUV(ux0, _j0);
|
||||
vs[_ix++] = new __vertex(x3, y3, _h1).setNormal(nx1, ny1, 0).setUV(ux1, _j1);
|
||||
|
||||
vs[_ix++] = new __vertex(x0, y0, _h0).setNormal(nx0, ny0, 0).setUV(ux0, _j1);
|
||||
vs[_ix++] = new __vertex(x1, y1, _h0).setNormal(nx1, ny1, 0).setUV(ux1, _j1);
|
||||
vs[_ix++] = new __vertex(x3, y3, _h1).setNormal(nx1, ny1, 0).setUV(ux1, _j0);
|
||||
vs[_ix++] = new __vertex(x0, y0, _h0).setNormal(nx0, ny0, 0).setUV(ux0, _j0);
|
||||
vs[_ix++] = new __vertex(x1, y1, _h0).setNormal(nx1, ny1, 0).setUV(ux1, _j0);
|
||||
vs[_ix++] = new __vertex(x3, y3, _h1).setNormal(nx1, ny1, 0).setUV(ux1, _j1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -236,7 +236,7 @@ function __3dObject() constructor {
|
|||
_obj.VB[i] = vertex_create_buffer_from_buffer(_buff, VF);
|
||||
}
|
||||
} else {
|
||||
_obj.VB = VB;
|
||||
_obj.VB = [];
|
||||
}
|
||||
|
||||
_obj.NVB = NVB;
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
LATEST_VERSION = 1_18_00_0;
|
||||
VERSION = 1_18_01_0;
|
||||
SAVE_VERSION = 1_18_01_0;
|
||||
VERSION_STRING = MAC? "1.18.003m" : "1.18.1";
|
||||
VERSION_STRING = MAC? "1.18.003m" : "1.18.2.001";
|
||||
BUILD_NUMBER = 1_18_01_0;
|
||||
|
||||
HOTKEYS = ds_map_create();
|
||||
|
|
65
scripts/node_3d_displace/node_3d_displace.gml
Normal file
65
scripts/node_3d_displace/node_3d_displace.gml
Normal file
|
@ -0,0 +1,65 @@
|
|||
function Node_3D_Displace(_x, _y, _group = noone) : Node_3D_Modifier(_x, _y, _group) constructor {
|
||||
name = "Displace vertex";
|
||||
|
||||
newInput(in_mesh + 0, nodeValue_D3Material("Displace Texture", self, new __d3dMaterial()))
|
||||
|
||||
newInput(in_mesh + 1, nodeValue_Float("Height", self, .1))
|
||||
|
||||
newInput(in_mesh + 2, nodeValue_Float("Subobjects", self, -1))
|
||||
|
||||
input_display_list = [
|
||||
["Mesh", false], 0, in_mesh + 2,
|
||||
["Displace", false], in_mesh + 0, in_mesh + 1,
|
||||
];
|
||||
|
||||
static processData = function(_output, _data, _output_index, _array_index = 0) {
|
||||
var _obj = _data[0];
|
||||
var _tex = _data[in_mesh + 0];
|
||||
var _hei = _data[in_mesh + 1];
|
||||
var _trg = _data[in_mesh + 2];
|
||||
|
||||
if(!is_instanceof(_obj, __3dObject)) return noone;
|
||||
if(!is_instanceof(_tex, __d3dMaterial)) return noone;
|
||||
|
||||
var _tsc = _tex.texScale;
|
||||
var _tif = _tex.texShift;
|
||||
|
||||
var dim = surface_get_dimension(_tex.surface);
|
||||
var _sw = dim[0] - 1;
|
||||
var _sh = dim[1] - 1;
|
||||
|
||||
var buf = buffer_from_surface(_tex.surface, false);
|
||||
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) ];
|
||||
|
||||
for( var i = 0, n = array_length(_tarr); i < n; i++ ) {
|
||||
var _vi = _tarr[i];
|
||||
|
||||
for( var j = 0, m = array_length(_res.vertex[_vi]); j < m; j++ ) {
|
||||
var _v = _res.vertex[_vi][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]);
|
||||
|
||||
if(_vu < 0) _vu = 1 + _vu;
|
||||
if(_vv < 0) _vv = 1 + _vv;
|
||||
|
||||
_vu = round(_vu * _sw);
|
||||
_vv = round(_vv * _sh);
|
||||
|
||||
var _samp = buffer_getPixel(buf, dim[0], dim[1], _vu, _vv);
|
||||
var _hh = _hei * _color_get_light(_samp);
|
||||
|
||||
_v.x += _v.nx * _hh;
|
||||
_v.y += _v.ny * _hh;
|
||||
_v.z += _v.nz * _hh;
|
||||
}
|
||||
}
|
||||
|
||||
_res.VB = _res.build();
|
||||
buffer_delete(buf);
|
||||
|
||||
return _res;
|
||||
}
|
||||
}
|
13
scripts/node_3d_displace/node_3d_displace.yy
Normal file
13
scripts/node_3d_displace/node_3d_displace.yy
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"$GMScript":"v1",
|
||||
"%Name":"node_3d_displace",
|
||||
"isCompatibility":false,
|
||||
"isDnD":false,
|
||||
"name":"node_3d_displace",
|
||||
"parent":{
|
||||
"name":"d3d_modifier",
|
||||
"path":"folders/nodes/data/3D/d3d_modifier.yy",
|
||||
},
|
||||
"resourceType":"GMScript",
|
||||
"resourceVersion":"2.0",
|
||||
}
|
12
scripts/node_3d_displace/node_counter.yy
Normal file
12
scripts/node_3d_displace/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",
|
||||
}
|
|
@ -21,18 +21,18 @@ function Node_3D_Mesh_Terrain(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _gr
|
|||
|
||||
input_display_list = [
|
||||
__d3d_input_list_transform,
|
||||
["Terrain", false], in_mesh + 3, in_mesh + 1, in_mesh + 2, in_mesh + 4, in_mesh + 5, in_mesh + 6,
|
||||
["Material", false], in_mesh + 0,
|
||||
["Mesh", false], in_mesh + 3, in_mesh + 1, in_mesh + 2, in_mesh + 4, in_mesh + 6,
|
||||
["Material", false], in_mesh + 5, in_mesh + 0,
|
||||
]
|
||||
|
||||
static step = function() { #region
|
||||
static step = function() {
|
||||
var _inT = getInputData(in_mesh + 1);
|
||||
|
||||
inputs[in_mesh + 2].setVisible(_inT == 0, _inT == 0);
|
||||
inputs[in_mesh + 4].setVisible(_inT == 1, _inT == 1);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
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 _inT = _data[in_mesh + 1];
|
||||
var _sub = _data[in_mesh + 3];
|
||||
|
@ -68,9 +68,9 @@ function Node_3D_Mesh_Terrain(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _gr
|
|||
}
|
||||
|
||||
buffer_delete(_bf);
|
||||
|
||||
} else if(_inT == 1 && !array_empty(_hia)) {
|
||||
if(is_array(_hia[0])) _hia = array_spread(_hia);
|
||||
|
||||
array_copy(_h, 0, _hia, 0, min(array_length(_h), array_length(_hia)));
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ function Node_3D_Mesh_Terrain(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _gr
|
|||
setTransform(object, _data);
|
||||
|
||||
return object;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static getPreviewValues = function() { return getSingleValue(in_mesh + 0); }
|
||||
}
|
|
@ -195,7 +195,11 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
|
||||
if(_junc_canvas) hover &= _m[0] > _txx + ui(8 + 16);
|
||||
|
||||
draw_set_text(f_p1, fa_left, fa_center, hover? COLORS._main_text_accent : COLORS._main_text);
|
||||
var tc = i == dynamic_input_inspecting? COLORS._main_text_accent : COLORS._main_icon;
|
||||
if(hover) tc = COLORS._main_text;
|
||||
|
||||
draw_set_text(f_p1, fa_left, fa_center, tc);
|
||||
|
||||
if(canvas_draw != noone && _junc_canvas)
|
||||
_txt = _junc_canvas.display_name;
|
||||
|
||||
|
@ -228,6 +232,7 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
draw_set_alpha(aa);
|
||||
draw_text(_txx + ui(8 + 16), _txy, _txt);
|
||||
draw_set_alpha(1);
|
||||
|
||||
} else {
|
||||
draw_set_alpha(aa);
|
||||
draw_text(_txx, _txy, _txt);
|
||||
|
@ -286,6 +291,7 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
draw_set_color(COLORS._main_accent);
|
||||
if(layer_dragging > ind)
|
||||
draw_line_width(_x + ui(16), _cy + lh + 2, _x + _w - ui(16), _cy + lh + ui(2), 2);
|
||||
|
||||
else if(layer_dragging < ind)
|
||||
draw_line_width(_x + ui(16), _cy - 2, _x + _w - ui(16), _cy - ui(2), 2);
|
||||
}
|
||||
|
@ -318,6 +324,9 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
if(mouse_press(mb_left, _focus)) {
|
||||
layer_dragging = ind;
|
||||
surface_selecting = index;
|
||||
|
||||
dynamic_input_inspecting = i;
|
||||
refreshDynamicDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -366,14 +375,6 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
return layer_height;
|
||||
});
|
||||
|
||||
input_display_list = [
|
||||
["Output", true], 0, 1, 2,
|
||||
["Layers", false], layer_renderer,
|
||||
["Surfaces", true],
|
||||
];
|
||||
|
||||
input_display_list_len = array_length(input_display_list);
|
||||
|
||||
function deleteLayer(index) {
|
||||
var idx = input_fix_len + index * data_length;
|
||||
|
||||
|
@ -441,9 +442,20 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
while(_s >= array_length(attributes.layer_selectable))
|
||||
array_push(attributes.layer_selectable, true);
|
||||
|
||||
refreshDynamicDisplay();
|
||||
return inputs[index + 0];
|
||||
}
|
||||
|
||||
input_display_dynamic = [
|
||||
["Surface", false], 0, 4, 5,
|
||||
["Transform", false], 1, 2, 3,
|
||||
];
|
||||
|
||||
input_display_list = [
|
||||
["Output", true], 0, 1, 2,
|
||||
["Layers", false], layer_renderer,
|
||||
];
|
||||
|
||||
setDynamicInput(6, true, VALUE_TYPE.surface);
|
||||
|
||||
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone));
|
||||
|
@ -685,8 +697,12 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
}
|
||||
}
|
||||
|
||||
if(mouse_press(mb_left, active))
|
||||
if(mouse_press(mb_left, active)) {
|
||||
surface_selecting = hovering;
|
||||
dynamic_input_inspecting = hovering;
|
||||
refreshDynamicDisplay();
|
||||
}
|
||||
|
||||
if(surface_selecting != noone) {
|
||||
var a = array_safe_get_fast(anchors, surface_selecting, noone);
|
||||
if(!is_struct(a)) surface_selecting = noone;
|
||||
|
@ -756,7 +772,9 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
static processData = function(_outData, _data, _output_index, _array_index) {
|
||||
var _outSurf = _outData[0];
|
||||
|
||||
if(array_length(_data) <= input_fix_len) return [ _outSurf, noone, [1, 1] ];
|
||||
if(getInputAmount() == 0) return _outData;
|
||||
|
||||
dynamic_input_inspecting = clamp(dynamic_input_inspecting, 0, getInputAmount() - 1);
|
||||
|
||||
var _pad = _data[0];
|
||||
var _dim_type = _data[1];
|
||||
|
|
|
@ -375,7 +375,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
|
|||
dummy_input = noone;
|
||||
auto_input = false;
|
||||
dyna_input_check_shift = 0;
|
||||
input_display_dynamic = [];
|
||||
input_display_dynamic = -1;
|
||||
dynamic_input_inspecting = 0;
|
||||
static createNewInput = -1;
|
||||
|
||||
|
@ -451,7 +451,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
|
|||
}
|
||||
|
||||
static refreshDynamicDisplay = function() {
|
||||
if(array_empty(input_display_dynamic)) return;
|
||||
if(input_display_dynamic == -1) return;
|
||||
array_resize(input_display_list, array_length(input_display_list_raw));
|
||||
|
||||
var _amo = getInputAmount();
|
||||
|
@ -461,7 +461,6 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
|
|||
}
|
||||
|
||||
dynamic_input_inspecting = clamp(dynamic_input_inspecting, 0, getInputAmount() - 1);
|
||||
|
||||
var _ind = input_fix_len + dynamic_input_inspecting * data_length;
|
||||
|
||||
for( var i = 0, n = array_length(input_display_dynamic); i < n; i++ ) {
|
||||
|
@ -724,10 +723,41 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
|
|||
}
|
||||
|
||||
static getJunctionList = function() { ////getJunctionList
|
||||
|
||||
var amo = input_display_list == -1? array_length(inputs) : array_length(input_display_list);
|
||||
inputDisplayList = [];
|
||||
|
||||
var iamo = getInputAmount();
|
||||
if(iamo && input_display_dynamic != -1) {
|
||||
|
||||
for(var i = 0; i < array_length(input_display_list_raw); i++) {
|
||||
var ind = input_display_list_raw[i];
|
||||
if(!is_real(ind)) continue;
|
||||
|
||||
var jun = array_safe_get(inputs, ind, noone);
|
||||
if(jun == noone || is_undefined(jun)) continue;
|
||||
if(!jun.isVisible()) continue;
|
||||
|
||||
array_push(inputDisplayList, jun);
|
||||
}
|
||||
|
||||
for( var i = 0; i < iamo; i++ ) {
|
||||
var ind = input_fix_len + i * data_length;
|
||||
|
||||
for( var j = 0, n = array_length(input_display_dynamic); j < n; j++ ) {
|
||||
if(!is_real(input_display_dynamic[j])) continue;
|
||||
|
||||
var _in_ind = ind + input_display_dynamic[j];
|
||||
|
||||
var jun = array_safe_get(inputs, _in_ind, noone);
|
||||
if(jun == noone || is_undefined(jun)) continue;
|
||||
if(!jun.isVisible()) continue;
|
||||
|
||||
array_push(inputDisplayList, jun);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
var amo = input_display_list == -1? array_length(inputs) : array_length(input_display_list);
|
||||
|
||||
for(var i = 0; i < amo; i++) {
|
||||
var ind = getInputJunctionIndex(i);
|
||||
if(ind == noone) continue;
|
||||
|
@ -739,6 +769,8 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
|
|||
array_push(inputDisplayList, jun);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(auto_input && dummy_input) array_push(inputDisplayList, dummy_input);
|
||||
}
|
||||
|
||||
|
@ -1482,20 +1514,20 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
|
|||
if(!active) return;
|
||||
var hover = noone;
|
||||
|
||||
for(var i = 0, n = array_length(inputDisplayList); i < n; i++) {
|
||||
for(var i = 0, n = array_length(inputDisplayList); i < n; i++) { //inputs
|
||||
var jun = inputDisplayList[i];
|
||||
|
||||
if(jun.drawJunction(_s, _mx, _my)) hover = jun;
|
||||
}
|
||||
|
||||
for(var i = 0; i < array_length(outputs); i++) {
|
||||
for(var i = 0; i < array_length(outputs); i++) { // outputs
|
||||
var jun = outputs[i];
|
||||
|
||||
if(!jun.isVisible()) continue;
|
||||
if(jun.drawJunction(_s, _mx, _my)) hover = jun;
|
||||
}
|
||||
|
||||
for( var i = 0; i < array_length(inputs); i++ ) {
|
||||
for( var i = 0; i < array_length(inputs); i++ ) { // bypass
|
||||
var _inp = inputs[i];
|
||||
var jun = _inp.bypass_junc;
|
||||
|
||||
|
|
39
scripts/node_grid_warp/node_grid_warp.gml
Normal file
39
scripts/node_grid_warp/node_grid_warp.gml
Normal file
|
@ -0,0 +1,39 @@
|
|||
function Node_Grid_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
||||
name = "Grid Warp";
|
||||
|
||||
newInput(0, nodeValue_Surface("Surface in", self));
|
||||
|
||||
newInput(1, nodeValue_Bool("Active", self, true));
|
||||
active_index = 1;
|
||||
|
||||
newInput(2, nodeValue_Int("Grid", self, 1, "Amount of grid subdivision. Higher number means more grid, detail."))
|
||||
.setDisplay(VALUE_DISPLAY.slider, { range: [ 0, 4, 1 ] });
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone));
|
||||
|
||||
input_display_list = [ 1, 0,
|
||||
["Mesh", false], 2,
|
||||
];
|
||||
|
||||
attribute_surface_depth();
|
||||
attribute_interpolation();
|
||||
|
||||
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
||||
var mx = (_mx - _x) / _s;
|
||||
var my = (_my - _y) / _s;
|
||||
|
||||
}
|
||||
|
||||
static step = function() {
|
||||
|
||||
}
|
||||
|
||||
static processData = function(_outSurf, _data, _output_index, _array_index) {
|
||||
var _surf = _data[0];
|
||||
var _grid = _data[2];
|
||||
|
||||
|
||||
}
|
||||
}
|
13
scripts/node_grid_warp/node_grid_warp.yy
Normal file
13
scripts/node_grid_warp/node_grid_warp.yy
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"$GMScript":"v1",
|
||||
"%Name":"node_grid_warp",
|
||||
"isCompatibility":false,
|
||||
"isDnD":false,
|
||||
"name":"node_grid_warp",
|
||||
"parent":{
|
||||
"name":"warps",
|
||||
"path":"folders/nodes/data/filter/warps.yy",
|
||||
},
|
||||
"resourceType":"GMScript",
|
||||
"resourceVersion":"2.0",
|
||||
}
|
|
@ -195,14 +195,14 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
|
||||
control_index = array_length(inputs);
|
||||
|
||||
function createControl() { #region
|
||||
function createControl() {
|
||||
var index = array_length(inputs);
|
||||
newInput(index, nodeValue_Float("Control point", self, [ PUPPET_FORCE_MODE.move, 16, 16, 8, 0, 8, 8 ]))
|
||||
.setDisplay(VALUE_DISPLAY.puppet_control)
|
||||
|
||||
array_push(input_display_list, index);
|
||||
return inputs[index];
|
||||
} #endregion
|
||||
}
|
||||
|
||||
attribute_surface_depth();
|
||||
attribute_interpolation();
|
||||
|
@ -422,7 +422,7 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static Mesh_regularTri = function(surf) { #region
|
||||
static Mesh_regularTri = function(surf) {
|
||||
if(is_array(surf)) surf = array_safe_get_fast(surf, 0);
|
||||
|
||||
if(!is_surface(surf)) return;
|
||||
|
@ -440,7 +440,7 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
var gh = hh / sample;
|
||||
var cont = noone;
|
||||
|
||||
if(!fullmh) { #region alpha filter
|
||||
if(!fullmh) { // alpha filter
|
||||
cont = surface_create_valid(ww, hh);
|
||||
|
||||
surface_set_target(cont);
|
||||
|
@ -453,7 +453,7 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
draw_surface_safe(surf);
|
||||
shader_reset();
|
||||
surface_reset_target();
|
||||
} #endregion
|
||||
}
|
||||
|
||||
var _sam = sample + 1;
|
||||
|
||||
|
@ -461,7 +461,7 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
|
||||
var ind = 0;
|
||||
for(var i = 0; i < _sam; i++)
|
||||
for(var j = 0; j < _sam; j++) { #region mesh
|
||||
for(var j = 0; j < _sam; j++) { // mesh
|
||||
var fill = false;
|
||||
|
||||
if(fullmh) {
|
||||
|
@ -496,10 +496,10 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
|
||||
if(j < sample && mesh_data.points[(i - 1) * _sam + j] != 0 && mesh_data.points[(i - 1) * _sam + j + 1] != 0)
|
||||
array_push(mesh_data.tris, new _Triangle(mesh_data.points[(i - 1) * _sam + j], mesh_data.points[(i - 1) * _sam + j + 1], mesh_data.points[i * _sam + j]));
|
||||
} #endregion
|
||||
}
|
||||
|
||||
for(var i = 0; i < _sam; i++)
|
||||
for(var j = 0; j < _sam; j++) { #region diagonal
|
||||
for(var j = 0; j < _sam; j++) { // diagonal
|
||||
var p0 = i && j? mesh_data.points[ (i - 1) * _sam + j - 1 ] : 0;
|
||||
var p1 = i? mesh_data.points[ (i - 1) * _sam + j ] : 0;
|
||||
var p2 = j? mesh_data.points[ (i ) * _sam + j - 1 ] : 0;
|
||||
|
@ -515,12 +515,12 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
if(d0) array_push(mesh_data.links, new _Link(p0, p3, spring));
|
||||
if(d1) array_push(mesh_data.links, new _Link(p1, p2, spring));
|
||||
}
|
||||
} #endregion
|
||||
}
|
||||
|
||||
if(is_surface(cont)) surface_free(cont);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static Mesh_triangulate = function(surf) { #region
|
||||
static Mesh_triangulate = function(surf) {
|
||||
var sample = getInputData(1);
|
||||
var seed = getInputData(9);
|
||||
|
||||
|
@ -588,9 +588,9 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
array_push(mesh_data.links, new _Link(t[1], t[2]));
|
||||
array_push(mesh_data.links, new _Link(t[2], t[0]));
|
||||
}
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static Mesh_setTriangle = function() { #region
|
||||
static Mesh_setTriangle = function() {
|
||||
var _inSurf = getInputData(0);
|
||||
var _type = getInputData(8);
|
||||
|
||||
|
@ -615,9 +615,9 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
}
|
||||
loadPin = noone;
|
||||
}
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static Control_affectPoint = function(c, p) { #region
|
||||
static Control_affectPoint = function(c, p) {
|
||||
var mode = c[PUPPET_CONTROL.mode];
|
||||
var cx = c[PUPPET_CONTROL.cx];
|
||||
var cy = c[PUPPET_CONTROL.cy];
|
||||
|
@ -647,7 +647,7 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
p.planMove(lengthdir_x(fx * inf, fy), lengthdir_y(fx * inf, fy));
|
||||
break;
|
||||
}
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static control = function() {
|
||||
var lStr = getInputData(6);
|
||||
|
@ -698,7 +698,7 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
}
|
||||
}
|
||||
|
||||
static processData = function(_outData, _data, _output_index, _array_index) { #region
|
||||
static processData = function(_outData, _data, _output_index, _array_index) {
|
||||
if(will_triangluate) {
|
||||
Mesh_setTriangle();
|
||||
will_triangluate = false;
|
||||
|
@ -736,7 +736,7 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
surface_reset_shader();
|
||||
|
||||
return [ _outSurf, mesh_data ];
|
||||
} #endregion
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -771,7 +771,7 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
struct_append(attributes, attr);
|
||||
|
||||
if(struct_has(attr, "pin")) loadPin = attr.pin;
|
||||
if(struct_has(attr, "mesh_bound")) attributes.mesh_bound = attr.mesh_bound;;
|
||||
if(struct_has(attr, "mesh_bound")) attributes.mesh_bound = attr.mesh_bound;
|
||||
}
|
||||
|
||||
static postLoad = function() {
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
"isDnD":false,
|
||||
"name":"node_mesh_warp",
|
||||
"parent":{
|
||||
"name":"transform",
|
||||
"path":"folders/nodes/data/transform.yy",
|
||||
"name":"warps",
|
||||
"path":"folders/nodes/data/filter/warps.yy",
|
||||
},
|
||||
"resourceType":"GMScript",
|
||||
"resourceVersion":"2.0",
|
||||
|
|
|
@ -715,6 +715,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, "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);
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 3.7 KiB |
BIN
sprites/s_node_3d_torus/5d804546-7801-47c2-977e-dcbe6660158b.png
Normal file
BIN
sprites/s_node_3d_torus/5d804546-7801-47c2-977e-dcbe6660158b.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.7 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
|
@ -12,14 +12,14 @@
|
|||
"edgeFiltering":false,
|
||||
"For3D":false,
|
||||
"frames":[
|
||||
{"$GMSpriteFrame":"","%Name":"503138db-2536-496a-b5cc-51e32ad597e3","name":"503138db-2536-496a-b5cc-51e32ad597e3","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
|
||||
{"$GMSpriteFrame":"","%Name":"5d804546-7801-47c2-977e-dcbe6660158b","name":"5d804546-7801-47c2-977e-dcbe6660158b","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
|
||||
],
|
||||
"gridX":0,
|
||||
"gridY":0,
|
||||
"height":64,
|
||||
"HTile":false,
|
||||
"layers":[
|
||||
{"$GMImageLayer":"","%Name":"4e9d715f-43f0-4ffd-a842-0e4d79699ee0","blendMode":0,"displayName":"default","isLocked":false,"name":"4e9d715f-43f0-4ffd-a842-0e4d79699ee0","opacity":100.0,"resourceType":"GMImageLayer","resourceVersion":"2.0","visible":true,},
|
||||
{"$GMImageLayer":"","%Name":"b02f2d53-3221-499a-a322-ae2da8309220","blendMode":0,"displayName":"default","isLocked":false,"name":"b02f2d53-3221-499a-a322-ae2da8309220","opacity":100.0,"resourceType":"GMImageLayer","resourceVersion":"2.0","visible":true,},
|
||||
],
|
||||
"name":"s_node_3d_torus",
|
||||
"nineSlice":null,
|
||||
|
@ -69,8 +69,8 @@
|
|||
"tracks":[
|
||||
{"$GMSpriteFramesTrack":"","builtinName":0,"events":[],"inheritsTrackColour":true,"interpolation":1,"isCreationTrack":false,"keyframes":{"$KeyframeStore<SpriteFrameKeyframe>":"","Keyframes":[
|
||||
{"$Keyframe<SpriteFrameKeyframe>":"","Channels":{
|
||||
"0":{"$SpriteFrameKeyframe":"","Id":{"name":"503138db-2536-496a-b5cc-51e32ad597e3","path":"sprites/s_node_3d_torus/s_node_3d_torus.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",},
|
||||
},"Disabled":false,"id":"94d991bf-2ece-4ef4-af43-db030f5742a2","IsCreationKey":false,"Key":0.0,"Length":1.0,"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"2.0","Stretch":false,},
|
||||
"0":{"$SpriteFrameKeyframe":"","Id":{"name":"5d804546-7801-47c2-977e-dcbe6660158b","path":"sprites/s_node_3d_torus/s_node_3d_torus.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",},
|
||||
},"Disabled":false,"id":"89e80ba7-4567-455d-883c-7654551d00c0","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,
|
||||
|
|
Loading…
Reference in a new issue