mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2025-01-12 07:16:49 +01:00
[Scale Algorithm] Fix node not outputing,
This commit is contained in:
parent
ca8c746321
commit
e37a2223b5
11 changed files with 345 additions and 203 deletions
|
@ -747,6 +747,7 @@
|
||||||
{"name":"node_area","order":15,"path":"scripts/node_area/node_area.yy",},
|
{"name":"node_area","order":15,"path":"scripts/node_area/node_area.yy",},
|
||||||
{"name":"node_argument","order":22,"path":"scripts/node_argument/node_argument.yy",},
|
{"name":"node_argument","order":22,"path":"scripts/node_argument/node_argument.yy",},
|
||||||
{"name":"node_armature_bind","order":1,"path":"scripts/node_armature_bind/node_armature_bind.yy",},
|
{"name":"node_armature_bind","order":1,"path":"scripts/node_armature_bind/node_armature_bind.yy",},
|
||||||
|
{"name":"node_armature_mesh_rig","order":6,"path":"scripts/node_armature_mesh_rig/node_armature_mesh_rig.yy",},
|
||||||
{"name":"node_armature_path","order":4,"path":"scripts/node_armature_path/node_armature_path.yy",},
|
{"name":"node_armature_path","order":4,"path":"scripts/node_armature_path/node_armature_path.yy",},
|
||||||
{"name":"node_armature_pose","order":3,"path":"scripts/node_armature_pose/node_armature_pose.yy",},
|
{"name":"node_armature_pose","order":3,"path":"scripts/node_armature_pose/node_armature_pose.yy",},
|
||||||
{"name":"node_armature_sample","order":5,"path":"scripts/node_armature_sample/node_armature_sample.yy",},
|
{"name":"node_armature_sample","order":5,"path":"scripts/node_armature_sample/node_armature_sample.yy",},
|
||||||
|
@ -1217,6 +1218,7 @@
|
||||||
{"name":"node_value_fdomain","order":8,"path":"scripts/node_value_fdomain/node_value_fdomain.yy",},
|
{"name":"node_value_fdomain","order":8,"path":"scripts/node_value_fdomain/node_value_fdomain.yy",},
|
||||||
{"name":"node_value_gradient","order":1,"path":"scripts/node_value_gradient/node_value_gradient.yy",},
|
{"name":"node_value_gradient","order":1,"path":"scripts/node_value_gradient/node_value_gradient.yy",},
|
||||||
{"name":"node_value_int","order":1,"path":"scripts/node_value_int/node_value_int.yy",},
|
{"name":"node_value_int","order":1,"path":"scripts/node_value_int/node_value_int.yy",},
|
||||||
|
{"name":"node_value_mesh","order":5,"path":"scripts/node_value_mesh/node_value_mesh.yy",},
|
||||||
{"name":"node_value_output","order":1,"path":"scripts/node_value_output/node_value_output.yy",},
|
{"name":"node_value_output","order":1,"path":"scripts/node_value_output/node_value_output.yy",},
|
||||||
{"name":"node_value_padding","order":16,"path":"scripts/node_value_padding/node_value_padding.yy",},
|
{"name":"node_value_padding","order":16,"path":"scripts/node_value_padding/node_value_padding.yy",},
|
||||||
{"name":"node_value_palette","order":2,"path":"scripts/node_value_palette/node_value_palette.yy",},
|
{"name":"node_value_palette","order":2,"path":"scripts/node_value_palette/node_value_palette.yy",},
|
||||||
|
|
|
@ -1301,6 +1301,7 @@
|
||||||
{"id":{"name":"node_area","path":"scripts/node_area/node_area.yy",},},
|
{"id":{"name":"node_area","path":"scripts/node_area/node_area.yy",},},
|
||||||
{"id":{"name":"node_argument","path":"scripts/node_argument/node_argument.yy",},},
|
{"id":{"name":"node_argument","path":"scripts/node_argument/node_argument.yy",},},
|
||||||
{"id":{"name":"node_armature_bind","path":"scripts/node_armature_bind/node_armature_bind.yy",},},
|
{"id":{"name":"node_armature_bind","path":"scripts/node_armature_bind/node_armature_bind.yy",},},
|
||||||
|
{"id":{"name":"node_armature_mesh_rig","path":"scripts/node_armature_mesh_rig/node_armature_mesh_rig.yy",},},
|
||||||
{"id":{"name":"node_armature_path","path":"scripts/node_armature_path/node_armature_path.yy",},},
|
{"id":{"name":"node_armature_path","path":"scripts/node_armature_path/node_armature_path.yy",},},
|
||||||
{"id":{"name":"node_armature_pose","path":"scripts/node_armature_pose/node_armature_pose.yy",},},
|
{"id":{"name":"node_armature_pose","path":"scripts/node_armature_pose/node_armature_pose.yy",},},
|
||||||
{"id":{"name":"node_armature_sample","path":"scripts/node_armature_sample/node_armature_sample.yy",},},
|
{"id":{"name":"node_armature_sample","path":"scripts/node_armature_sample/node_armature_sample.yy",},},
|
||||||
|
@ -1834,6 +1835,7 @@
|
||||||
{"id":{"name":"node_value_float","path":"scripts/node_value_float/node_value_float.yy",},},
|
{"id":{"name":"node_value_float","path":"scripts/node_value_float/node_value_float.yy",},},
|
||||||
{"id":{"name":"node_value_gradient","path":"scripts/node_value_gradient/node_value_gradient.yy",},},
|
{"id":{"name":"node_value_gradient","path":"scripts/node_value_gradient/node_value_gradient.yy",},},
|
||||||
{"id":{"name":"node_value_int","path":"scripts/node_value_int/node_value_int.yy",},},
|
{"id":{"name":"node_value_int","path":"scripts/node_value_int/node_value_int.yy",},},
|
||||||
|
{"id":{"name":"node_value_mesh","path":"scripts/node_value_mesh/node_value_mesh.yy",},},
|
||||||
{"id":{"name":"node_value_output","path":"scripts/node_value_output/node_value_output.yy",},},
|
{"id":{"name":"node_value_output","path":"scripts/node_value_output/node_value_output.yy",},},
|
||||||
{"id":{"name":"node_value_padding","path":"scripts/node_value_padding/node_value_padding.yy",},},
|
{"id":{"name":"node_value_padding","path":"scripts/node_value_padding/node_value_padding.yy",},},
|
||||||
{"id":{"name":"node_value_palette","path":"scripts/node_value_palette/node_value_palette.yy",},},
|
{"id":{"name":"node_value_palette","path":"scripts/node_value_palette/node_value_palette.yy",},},
|
||||||
|
|
|
@ -1,34 +1,30 @@
|
||||||
function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length = 0, node = noone) constructor {
|
function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length = 0, node = noone) constructor {
|
||||||
ID = UUID_generate();
|
ID = UUID_generate();
|
||||||
self.name = "New bone";
|
self.name = "New bone";
|
||||||
self.distance = distance;
|
self.distance = distance;
|
||||||
self.direction = direction;
|
self.direction = direction;
|
||||||
self.angle = angle;
|
self.angle = angle;
|
||||||
self.length = length;
|
self.length = length;
|
||||||
self.node = node;
|
self.node = node;
|
||||||
|
|
||||||
init_length = length;
|
init_length = length;
|
||||||
init_angle = angle;
|
init_angle = angle;
|
||||||
|
|
||||||
pose_angle = 0;
|
pose_angle = 0;
|
||||||
pose_scale = 1;
|
pose_scale = 1;
|
||||||
pose_posit = [ 0, 0 ];
|
pose_posit = [ 0, 0 ];
|
||||||
pose_local_angle = 0;
|
pose_local_angle = 0;
|
||||||
pose_local_scale = 1;
|
pose_local_scale = 1;
|
||||||
pose_local_posit = [ 0, 0 ];
|
pose_local_posit = [ 0, 0 ];
|
||||||
|
|
||||||
apply_scale = true;
|
apply_scale = true;
|
||||||
apply_rotation = true;
|
apply_rotation = true;
|
||||||
|
|
||||||
self.is_main = false;
|
childs = [];
|
||||||
self.parent_anchor = true;
|
is_main = false;
|
||||||
self.childs = [];
|
parent_anchor = true;
|
||||||
|
|
||||||
tb_name = new textBox(TEXTBOX_INPUT.text,
|
tb_name = new textBox(TEXTBOX_INPUT.text, function(_name) /*=>*/ { name = _name; if(node) node.triggerRender(); });
|
||||||
function(_name) {
|
|
||||||
name = _name;
|
|
||||||
if(node) node.triggerRender();
|
|
||||||
});
|
|
||||||
tb_name.font = f_p2;
|
tb_name.font = f_p2;
|
||||||
tb_name.hide = true;
|
tb_name.hide = true;
|
||||||
|
|
||||||
|
@ -544,4 +540,12 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length =
|
||||||
}
|
}
|
||||||
|
|
||||||
static toString = function() { return $"Bone {name} [{ID}]"; }
|
static toString = function() { return $"Bone {name} [{ID}]"; }
|
||||||
|
|
||||||
|
static toArray = function(arr = []) {
|
||||||
|
array_push(arr, self);
|
||||||
|
for( var i = 0, n = array_length(childs); i < n; i++ )
|
||||||
|
childs[i].toArray(arr);
|
||||||
|
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -42,7 +42,7 @@
|
||||||
LATEST_VERSION = 1_18_00_0;
|
LATEST_VERSION = 1_18_00_0;
|
||||||
VERSION = 1_18_03_1;
|
VERSION = 1_18_03_1;
|
||||||
SAVE_VERSION = 1_18_02_0;
|
SAVE_VERSION = 1_18_02_0;
|
||||||
VERSION_STRING = MAC? "1.18.003m" : "1.18.3.2";
|
VERSION_STRING = MAC? "1.18.003m" : "1.18.4.001";
|
||||||
BUILD_NUMBER = 1_18_03_1;
|
BUILD_NUMBER = 1_18_03_1;
|
||||||
|
|
||||||
HOTKEYS = ds_map_create();
|
HOTKEYS = ds_map_create();
|
||||||
|
|
|
@ -60,6 +60,8 @@ function __initHotKey() {
|
||||||
hotkeySimple("Node_3D_Object", "Scale", "S");
|
hotkeySimple("Node_3D_Object", "Scale", "S");
|
||||||
|
|
||||||
hotkeySimple("Node_3D_Camera", "Move Target", "T");
|
hotkeySimple("Node_3D_Camera", "Move Target", "T");
|
||||||
|
|
||||||
|
hotkeySimple("Node_Armature_Bind", "Pose", "P");
|
||||||
}
|
}
|
||||||
|
|
||||||
function getToolHotkey(_group, _key) {
|
function getToolHotkey(_group, _key) {
|
||||||
|
|
86
scripts/node_armature_mesh_rig/node_armature_mesh_rig.gml
Normal file
86
scripts/node_armature_mesh_rig/node_armature_mesh_rig.gml
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
function RiggedMeshedSurface() constructor {
|
||||||
|
mesh = noone;
|
||||||
|
rigMap = {};
|
||||||
|
|
||||||
|
static getSurface = function() { return mesh == noone? noone : mesh.surface; }
|
||||||
|
}
|
||||||
|
|
||||||
|
function Node_Armature_Mesh_Rig(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
|
name = "Armature Mesh Rig";
|
||||||
|
setDimension(96, 72);
|
||||||
|
|
||||||
|
newInput(0, nodeValue_Armature("Armature", self, noone))
|
||||||
|
.setVisible(true, true);
|
||||||
|
|
||||||
|
newInput(1, nodeValue_Mesh("Mesh", self, noone))
|
||||||
|
.setVisible(true, true);
|
||||||
|
|
||||||
|
newInput(2, nodeValue_Trigger("Autoweight", self, false ))
|
||||||
|
.setDisplay(VALUE_DISPLAY.button, { name: "Auto weight", UI : true, onClick: function() /*=>*/ {return AutoWeightPaint()} });
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
newOutput(0, nodeValue_Output("Rigged mesh", self, VALUE_TYPE.mesh, noone));
|
||||||
|
|
||||||
|
rigdata = {};
|
||||||
|
|
||||||
|
static AutoWeightPaint = function() {
|
||||||
|
var _bones = inputs[0].getValue();
|
||||||
|
var _mesh = inputs[1].getValue();
|
||||||
|
|
||||||
|
if(!is(_bones, __Bone)) return;
|
||||||
|
if(!is(_mesh, MeshedSurface)) return;
|
||||||
|
|
||||||
|
rigdata = {};
|
||||||
|
|
||||||
|
var _boneArr = _bones.toArray();
|
||||||
|
var _boneDat = array_create(array_length(_boneArr));
|
||||||
|
|
||||||
|
for( var i = 0, n = array_length(_boneArr); i < n; i++ ) {
|
||||||
|
var _b = _boneArr[i];
|
||||||
|
|
||||||
|
_boneDat[i] = {
|
||||||
|
b : _b,
|
||||||
|
ID : _b.ID,
|
||||||
|
p0 : _b.getPoint(0),
|
||||||
|
p1 : _b.getPoint(1),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
var _pnts = _mesh.points;
|
||||||
|
|
||||||
|
for( var i = 0, n = array_length(_pnts); i < n; i++ ) {
|
||||||
|
var _p = _pnts[i];
|
||||||
|
var _px = _p.x;
|
||||||
|
var _py = _p.y;
|
||||||
|
|
||||||
|
var _minDist = 9999;
|
||||||
|
var _minBone = noone;
|
||||||
|
|
||||||
|
for( var j = 0, m = array_length(_boneDat); j < m; j++ ) {
|
||||||
|
var _b = _boneDat[j];
|
||||||
|
|
||||||
|
var _dist = distance_to_line(_px, _py, _b.p0.x, _b.p0.y, _b.p1.x, _b.p1.y);
|
||||||
|
if(_dist < _minDist) {
|
||||||
|
_minDist = _dist;
|
||||||
|
_minBone = _b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static update = function() {
|
||||||
|
var _bones = inputs[0].getValue();
|
||||||
|
var _mesh = inputs[1].getValue();
|
||||||
|
|
||||||
|
if(!is(_bones, __Bone)) return;
|
||||||
|
if(!is(_mesh, MeshedSurface)) return;
|
||||||
|
|
||||||
|
var _meshRigged = new RiggedMeshedSurface();
|
||||||
|
_meshRigged.mesh = _mesh;
|
||||||
|
_meshRigged.rigMap = rigdata;
|
||||||
|
|
||||||
|
outputs[0].setValue(_meshRigged);
|
||||||
|
}
|
||||||
|
}
|
13
scripts/node_armature_mesh_rig/node_armature_mesh_rig.yy
Normal file
13
scripts/node_armature_mesh_rig/node_armature_mesh_rig.yy
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"$GMScript":"v1",
|
||||||
|
"%Name":"node_armature_mesh_rig",
|
||||||
|
"isCompatibility":false,
|
||||||
|
"isDnD":false,
|
||||||
|
"name":"node_armature_mesh_rig",
|
||||||
|
"parent":{
|
||||||
|
"name":"armature",
|
||||||
|
"path":"folders/nodes/data/compose/armature.yy",
|
||||||
|
},
|
||||||
|
"resourceType":"GMScript",
|
||||||
|
"resourceVersion":"2.0",
|
||||||
|
}
|
|
@ -1,151 +1,161 @@
|
||||||
|
function MeshedSurface() constructor {
|
||||||
|
surface = noone;
|
||||||
|
points = [];
|
||||||
|
tris = [];
|
||||||
|
links = [];
|
||||||
|
controls = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
function MeshedPoint(node, index, _x, _y) constructor {
|
||||||
|
self.index = index;
|
||||||
|
self.node = node;
|
||||||
|
x = _x;
|
||||||
|
y = _y;
|
||||||
|
xp = x;
|
||||||
|
yp = y;
|
||||||
|
|
||||||
|
node.points[index] = self;
|
||||||
|
|
||||||
|
ndx = 0;
|
||||||
|
ndy = 0;
|
||||||
|
|
||||||
|
sx = x;
|
||||||
|
sy = y;
|
||||||
|
pin = false;
|
||||||
|
|
||||||
|
u = 0;
|
||||||
|
v = 0;
|
||||||
|
|
||||||
|
controlWeights = [];
|
||||||
|
|
||||||
|
static reset = function(_mesh_data) {
|
||||||
|
x = sx;
|
||||||
|
y = sy;
|
||||||
|
xp = x;
|
||||||
|
yp = y;
|
||||||
|
|
||||||
|
var dist = 0;
|
||||||
|
|
||||||
|
for( var i = 0, n = array_length(_mesh_data.controls); i < n; i++ ) {
|
||||||
|
var c = _mesh_data.controls[i];
|
||||||
|
var d = point_distance(x, y, c[PUPPET_CONTROL.cx], c[PUPPET_CONTROL.cy]);
|
||||||
|
|
||||||
|
controlWeights[i] = 1 / d;
|
||||||
|
dist += 1 / d;
|
||||||
|
}
|
||||||
|
|
||||||
|
for( var i = 0, n = array_length(controlWeights); i < n; i++ )
|
||||||
|
controlWeights[i] /= dist;
|
||||||
|
}
|
||||||
|
|
||||||
|
static draw = function(_x, _y, _s) {
|
||||||
|
if(pin) {
|
||||||
|
draw_set_color(COLORS._main_accent);
|
||||||
|
draw_circle_prec(_x + x * _s, _y + y * _s, 3, false);
|
||||||
|
} else {
|
||||||
|
draw_set_color(COLORS.node_overlay_gizmo_inactive);
|
||||||
|
draw_circle_prec(_x + x * _s, _y + y * _s, 2, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static mapTexture = function(ww, hh) { u = x / ww; v = y / hh; }
|
||||||
|
|
||||||
|
static move = function(dx, dy) { if(pin) return; x += dx; y += dy; }
|
||||||
|
static planMove = function(dx, dy) { if(pin) return; ndx += dx; ndy += dy; }
|
||||||
|
static stepMove = function(rat) { if(pin) return; move(ndx * rat, ndy * rat); }
|
||||||
|
static clearMove = function(rat) { if(pin) return; ndx = 0; ndy = 0; }
|
||||||
|
|
||||||
|
static setPin = function(pin) { self.pin = pin; }
|
||||||
|
static equal = function(point) { return x == point.x && y == point.y; }
|
||||||
|
}
|
||||||
|
|
||||||
|
function MeshedLink(_p0, _p1, _k = 1) constructor {
|
||||||
|
p0 = _p0;
|
||||||
|
p1 = _p1;
|
||||||
|
k = _k;
|
||||||
|
|
||||||
|
len = point_distance(p0.x, p0.y, p1.x, p1.y);
|
||||||
|
|
||||||
|
static resolve = function(strength = 1) {
|
||||||
|
INLINE
|
||||||
|
|
||||||
|
var _len = point_distance(p0.x, p0.y, p1.x, p1.y);
|
||||||
|
var _dir = point_direction(p0.x, p0.y, p1.x, p1.y);
|
||||||
|
|
||||||
|
var _slen = lerp(_len, len, strength);
|
||||||
|
var f = k * (_len - _slen);
|
||||||
|
var dx = lengthdir_x(f, _dir);
|
||||||
|
var dy = lengthdir_y(f, _dir);
|
||||||
|
|
||||||
|
p0.move( dx / 2, dy / 2);
|
||||||
|
p1.move(-dx / 2, -dy / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static draw = function(_x, _y, _s) {
|
||||||
|
INLINE
|
||||||
|
|
||||||
|
draw_set_color(c_red);
|
||||||
|
draw_line(_x + p0.x * _s, _y + p0.y * _s, _x + p1.x * _s, _y + p1.y * _s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function MeshedTriangle(_p0, _p1, _p2) constructor {
|
||||||
|
p0 = _p0;
|
||||||
|
p1 = _p1;
|
||||||
|
p2 = _p2;
|
||||||
|
|
||||||
|
static reset = function(_mesh_data) {
|
||||||
|
INLINE
|
||||||
|
|
||||||
|
p0.reset(_mesh_data);
|
||||||
|
p1.reset(_mesh_data);
|
||||||
|
p2.reset(_mesh_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static initSurface = function(surf) {
|
||||||
|
INLINE
|
||||||
|
|
||||||
|
p0.mapTexture(surface_get_width_safe(surf), surface_get_height_safe(surf));
|
||||||
|
p1.mapTexture(surface_get_width_safe(surf), surface_get_height_safe(surf));
|
||||||
|
p2.mapTexture(surface_get_width_safe(surf), surface_get_height_safe(surf));
|
||||||
|
}
|
||||||
|
|
||||||
|
static drawSurface = function(surf) {
|
||||||
|
INLINE
|
||||||
|
|
||||||
|
draw_set_color(c_white);
|
||||||
|
draw_set_alpha(1);
|
||||||
|
|
||||||
|
draw_primitive_begin_texture(pr_trianglelist, surface_get_texture(surf));
|
||||||
|
draw_vertex_texture(p0.x, p0.y, p0.u, p0.v);
|
||||||
|
draw_vertex_texture(p1.x, p1.y, p1.u, p1.v);
|
||||||
|
draw_vertex_texture(p2.x, p2.y, p2.u, p2.v);
|
||||||
|
draw_primitive_end();
|
||||||
|
}
|
||||||
|
|
||||||
|
static drawPoints = function(_x, _y, _s) {
|
||||||
|
INLINE
|
||||||
|
|
||||||
|
p0.draw(_x, _y, _s);
|
||||||
|
p1.draw(_x, _y, _s);
|
||||||
|
p2.draw(_x, _y, _s);
|
||||||
|
}
|
||||||
|
|
||||||
|
static contain = function(p) {
|
||||||
|
INLINE
|
||||||
|
|
||||||
|
return p == p0 || p == p1 || p == p2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
||||||
name = "Mesh Warp";
|
name = "Mesh Warp";
|
||||||
|
|
||||||
attributes.mesh_bound = [];
|
attributes.mesh_bound = [];
|
||||||
|
|
||||||
points = [];
|
points = [];
|
||||||
mesh_data = { points : [], tris : [], links : [], controls: [] };
|
mesh_data = new MeshedSurface();
|
||||||
|
|
||||||
function _Point(node, index, _x, _y) constructor {
|
|
||||||
self.index = index;
|
|
||||||
self.node = node;
|
|
||||||
x = _x;
|
|
||||||
y = _y;
|
|
||||||
xp = x;
|
|
||||||
yp = y;
|
|
||||||
|
|
||||||
node.points[index] = self;
|
|
||||||
|
|
||||||
ndx = 0;
|
|
||||||
ndy = 0;
|
|
||||||
|
|
||||||
sx = x;
|
|
||||||
sy = y;
|
|
||||||
pin = false;
|
|
||||||
|
|
||||||
u = 0;
|
|
||||||
v = 0;
|
|
||||||
|
|
||||||
controlWeights = [];
|
|
||||||
|
|
||||||
static reset = function(_mesh_data) {
|
|
||||||
x = sx;
|
|
||||||
y = sy;
|
|
||||||
xp = x;
|
|
||||||
yp = y;
|
|
||||||
|
|
||||||
var dist = 0;
|
|
||||||
|
|
||||||
for( var i = 0, n = array_length(_mesh_data.controls); i < n; i++ ) {
|
|
||||||
var c = _mesh_data.controls[i];
|
|
||||||
var d = point_distance(x, y, c[PUPPET_CONTROL.cx], c[PUPPET_CONTROL.cy]);
|
|
||||||
|
|
||||||
controlWeights[i] = 1 / d;
|
|
||||||
dist += 1 / d;
|
|
||||||
}
|
|
||||||
|
|
||||||
for( var i = 0, n = array_length(controlWeights); i < n; i++ )
|
|
||||||
controlWeights[i] /= dist;
|
|
||||||
}
|
|
||||||
|
|
||||||
static draw = function(_x, _y, _s) {
|
|
||||||
if(pin) {
|
|
||||||
draw_set_color(COLORS._main_accent);
|
|
||||||
draw_circle_prec(_x + x * _s, _y + y * _s, 3, false);
|
|
||||||
} else {
|
|
||||||
draw_set_color(COLORS.node_overlay_gizmo_inactive);
|
|
||||||
draw_circle_prec(_x + x * _s, _y + y * _s, 2, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static mapTexture = function(ww, hh) { u = x / ww; v = y / hh; }
|
|
||||||
static move = function(dx, dy) { if(pin) return; x += dx; y += dy; }
|
|
||||||
static planMove = function(dx, dy) { if(pin) return; ndx += dx; ndy += dy; }
|
|
||||||
static stepMove = function(rat) { if(pin) return; move(ndx * rat, ndy * rat); }
|
|
||||||
static clearMove = function(rat) { if(pin) return; ndx = 0; ndy = 0; }
|
|
||||||
static setPin = function(pin) { self.pin = pin; }
|
|
||||||
static equal = function(point) { return x == point.x && y == point.y; }
|
|
||||||
}
|
|
||||||
|
|
||||||
function _Link(_p0, _p1, _k = 1) constructor {
|
|
||||||
p0 = _p0;
|
|
||||||
p1 = _p1;
|
|
||||||
k = _k;
|
|
||||||
|
|
||||||
len = point_distance(p0.x, p0.y, p1.x, p1.y);
|
|
||||||
|
|
||||||
static resolve = function(strength = 1) {
|
|
||||||
INLINE
|
|
||||||
|
|
||||||
var _len = point_distance(p0.x, p0.y, p1.x, p1.y);
|
|
||||||
var _dir = point_direction(p0.x, p0.y, p1.x, p1.y);
|
|
||||||
|
|
||||||
var _slen = lerp(_len, len, strength);
|
|
||||||
var f = k * (_len - _slen);
|
|
||||||
var dx = lengthdir_x(f, _dir);
|
|
||||||
var dy = lengthdir_y(f, _dir);
|
|
||||||
|
|
||||||
p0.move( dx / 2, dy / 2);
|
|
||||||
p1.move(-dx / 2, -dy / 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static draw = function(_x, _y, _s) {
|
|
||||||
INLINE
|
|
||||||
|
|
||||||
draw_set_color(c_red);
|
|
||||||
draw_line(_x + p0.x * _s, _y + p0.y * _s, _x + p1.x * _s, _y + p1.y * _s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function _Triangle(_p0, _p1, _p2) constructor {
|
|
||||||
p0 = _p0;
|
|
||||||
p1 = _p1;
|
|
||||||
p2 = _p2;
|
|
||||||
|
|
||||||
static reset = function(_mesh_data) {
|
|
||||||
INLINE
|
|
||||||
|
|
||||||
p0.reset(_mesh_data);
|
|
||||||
p1.reset(_mesh_data);
|
|
||||||
p2.reset(_mesh_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
static initSurface = function(surf) {
|
|
||||||
INLINE
|
|
||||||
|
|
||||||
p0.mapTexture(surface_get_width_safe(surf), surface_get_height_safe(surf));
|
|
||||||
p1.mapTexture(surface_get_width_safe(surf), surface_get_height_safe(surf));
|
|
||||||
p2.mapTexture(surface_get_width_safe(surf), surface_get_height_safe(surf));
|
|
||||||
}
|
|
||||||
|
|
||||||
static drawSurface = function(surf) {
|
|
||||||
INLINE
|
|
||||||
|
|
||||||
draw_set_color(c_white);
|
|
||||||
draw_set_alpha(1);
|
|
||||||
|
|
||||||
draw_primitive_begin_texture(pr_trianglelist, surface_get_texture(surf));
|
|
||||||
draw_vertex_texture(p0.x, p0.y, p0.u, p0.v);
|
|
||||||
draw_vertex_texture(p1.x, p1.y, p1.u, p1.v);
|
|
||||||
draw_vertex_texture(p2.x, p2.y, p2.u, p2.v);
|
|
||||||
draw_primitive_end();
|
|
||||||
}
|
|
||||||
|
|
||||||
static drawPoints = function(_x, _y, _s) {
|
|
||||||
INLINE
|
|
||||||
|
|
||||||
p0.draw(_x, _y, _s);
|
|
||||||
p1.draw(_x, _y, _s);
|
|
||||||
p2.draw(_x, _y, _s);
|
|
||||||
}
|
|
||||||
|
|
||||||
static contain = function(p) {
|
|
||||||
INLINE
|
|
||||||
|
|
||||||
return p == p0 || p == p1 || p == p2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
is_convex = true;
|
is_convex = true;
|
||||||
hover = -1;
|
hover = -1;
|
||||||
anchor_dragging = -1;
|
anchor_dragging = -1;
|
||||||
|
@ -163,7 +173,7 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||||
.setDisplay(VALUE_DISPLAY.slider);
|
.setDisplay(VALUE_DISPLAY.slider);
|
||||||
|
|
||||||
newInput(3, nodeValue_Trigger("Mesh", self, false ))
|
newInput(3, nodeValue_Trigger("Mesh", self, false ))
|
||||||
.setDisplay(VALUE_DISPLAY.button, { name: "Generate", UI : true, onClick: function() { Mesh_setTriangle(); } });
|
.setDisplay(VALUE_DISPLAY.button, { name: "Generate", UI : true, onClick: function() /*=>*/ {return Mesh_build()} });
|
||||||
|
|
||||||
newInput(4, nodeValue_Bool("Diagonal Link", self, false, "Include diagonal link to prevent drastic grid deformation."));
|
newInput(4, nodeValue_Bool("Diagonal Link", self, false, "Include diagonal link to prevent drastic grid deformation."));
|
||||||
|
|
||||||
|
@ -184,7 +194,7 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||||
|
|
||||||
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone));
|
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone));
|
||||||
|
|
||||||
newOutput(1, nodeValue_Output("Mesh data", self, VALUE_TYPE.object, mesh_data));
|
newOutput(1, nodeValue_Output("Mesh data", self, VALUE_TYPE.mesh, mesh_data));
|
||||||
|
|
||||||
input_display_list = [ 5,
|
input_display_list = [ 5,
|
||||||
["Mesh", false], 0, 8, 9, 1, 7, 3,
|
["Mesh", false], 0, 8, 9, 1, 7, 3,
|
||||||
|
@ -210,7 +220,7 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||||
|
|
||||||
#region ============ attributes & tools ============
|
#region ============ attributes & tools ============
|
||||||
array_push(attributeEditors, "Warp");
|
array_push(attributeEditors, "Warp");
|
||||||
|
|
||||||
attributes.iteration = 4;
|
attributes.iteration = 4;
|
||||||
array_push(attributeEditors, ["Iteration", function() { return attributes.iteration; },
|
array_push(attributeEditors, ["Iteration", function() { return attributes.iteration; },
|
||||||
new textBox(TEXTBOX_INPUT.number, function(val) {
|
new textBox(TEXTBOX_INPUT.number, function(val) {
|
||||||
|
@ -237,14 +247,13 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||||
insp1UpdateIcon = [ THEME.refresh_icon, 1, COLORS._main_value_positive ];
|
insp1UpdateIcon = [ THEME.refresh_icon, 1, COLORS._main_value_positive ];
|
||||||
will_triangluate = false;
|
will_triangluate = false;
|
||||||
|
|
||||||
static onInspector1Update = function() {
|
static onInspector1Update = function() { Mesh_build(); }
|
||||||
Mesh_setTriangle();
|
|
||||||
}
|
|
||||||
|
|
||||||
static onValueFromUpdate = function(index) {
|
static onValueFromUpdate = function(index) {
|
||||||
if(LOADING || APPENDING) return;
|
if(LOADING || APPENDING) return;
|
||||||
|
|
||||||
if(index == 0 && array_empty(mesh_data.tris))
|
if(index == 0 && array_empty(mesh_data.tris))
|
||||||
Mesh_setTriangle();
|
Mesh_build();
|
||||||
}
|
}
|
||||||
|
|
||||||
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
||||||
|
@ -310,7 +319,7 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||||
|
|
||||||
attributes.mesh_bound[anchor_dragging][0] = dx;
|
attributes.mesh_bound[anchor_dragging][0] = dx;
|
||||||
attributes.mesh_bound[anchor_dragging][1] = dy;
|
attributes.mesh_bound[anchor_dragging][1] = dy;
|
||||||
Mesh_setTriangle();
|
Mesh_build();
|
||||||
|
|
||||||
if(mouse_release(mb_left))
|
if(mouse_release(mb_left))
|
||||||
anchor_dragging = -1;
|
anchor_dragging = -1;
|
||||||
|
@ -327,7 +336,7 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||||
} else if(isUsingTool("Mesh anchor remove")) {
|
} else if(isUsingTool("Mesh anchor remove")) {
|
||||||
if(array_length(mesh) > 3) {
|
if(array_length(mesh) > 3) {
|
||||||
array_delete(mesh, hover, 1);
|
array_delete(mesh, hover, 1);
|
||||||
Mesh_setTriangle();
|
Mesh_build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(isUsingTool("Mesh edit")) {
|
} else if(isUsingTool("Mesh edit")) {
|
||||||
|
@ -345,6 +354,7 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||||
|
|
||||||
for(var i = 0; i < array_length(mesh_data.links); i++)
|
for(var i = 0; i < array_length(mesh_data.links); i++)
|
||||||
mesh_data.links[i].draw(_x, _y, _s);
|
mesh_data.links[i].draw(_x, _y, _s);
|
||||||
|
|
||||||
for(var i = 0; i < array_length(mesh_data.tris); i++)
|
for(var i = 0; i < array_length(mesh_data.tris); i++)
|
||||||
mesh_data.tris[i].drawPoints(_x, _y, _s);
|
mesh_data.tris[i].drawPoints(_x, _y, _s);
|
||||||
|
|
||||||
|
@ -410,8 +420,8 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||||
inputs[4].setVisible(_type == 0);
|
inputs[4].setVisible(_type == 0);
|
||||||
inputs[7].setVisible(_type == 0);
|
inputs[7].setVisible(_type == 0);
|
||||||
|
|
||||||
if(_type == 0) tools = tools_edit;
|
if(_type == 0) tools = tools_edit;
|
||||||
else if (_type == 1) tools = tools_mesh;
|
else if(_type == 1) tools = tools_mesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
static reset = function() {
|
static reset = function() {
|
||||||
|
@ -421,7 +431,7 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
static Mesh_regularTri = function(surf) {
|
static Mesh_build_RegularTri = function(surf) {
|
||||||
if(is_array(surf)) surf = array_safe_get_fast(surf, 0);
|
if(is_array(surf)) surf = array_safe_get_fast(surf, 0);
|
||||||
|
|
||||||
if(!is_surface(surf)) return;
|
if(!is_surface(surf)) return;
|
||||||
|
@ -487,14 +497,14 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||||
var px = min(j * gw, ww);
|
var px = min(j * gw, ww);
|
||||||
var py = min(i * gh, hh);
|
var py = min(i * gh, hh);
|
||||||
|
|
||||||
mesh_data.points[i * _sam + j] = new _Point(self, ind++, px, py);
|
mesh_data.points[i * _sam + j] = new MeshedPoint(self, ind++, px, py);
|
||||||
if(i == 0) continue;
|
if(i == 0) continue;
|
||||||
|
|
||||||
if(j && mesh_data.points[(i - 1) * _sam + j] != 0 && mesh_data.points[i * _sam + j - 1] != 0)
|
if(j && mesh_data.points[(i - 1) * _sam + j] != 0 && mesh_data.points[i * _sam + j - 1] != 0)
|
||||||
array_push(mesh_data.tris, new _Triangle(mesh_data.points[(i - 1) * _sam + j], mesh_data.points[i * _sam + j - 1], mesh_data.points[i * _sam + j]));
|
array_push(mesh_data.tris, new MeshedTriangle(mesh_data.points[(i - 1) * _sam + j], mesh_data.points[i * _sam + j - 1], mesh_data.points[i * _sam + j]));
|
||||||
|
|
||||||
if(j < sample && mesh_data.points[(i - 1) * _sam + j] != 0 && mesh_data.points[(i - 1) * _sam + j + 1] != 0)
|
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]));
|
array_push(mesh_data.tris, new MeshedTriangle(mesh_data.points[(i - 1) * _sam + j], mesh_data.points[(i - 1) * _sam + j + 1], mesh_data.points[i * _sam + j]));
|
||||||
}
|
}
|
||||||
|
|
||||||
for(var i = 0; i < _sam; i++)
|
for(var i = 0; i < _sam; i++)
|
||||||
|
@ -504,22 +514,22 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||||
var p2 = j? mesh_data.points[ (i ) * _sam + j - 1 ] : 0;
|
var p2 = j? mesh_data.points[ (i ) * _sam + j - 1 ] : 0;
|
||||||
var p3 = mesh_data.points[ (i ) * _sam + j ];
|
var p3 = mesh_data.points[ (i ) * _sam + j ];
|
||||||
|
|
||||||
if(p3 && p1) array_push(mesh_data.links, new _Link(p3, p1));
|
if(p3 && p1) array_push(mesh_data.links, new MeshedLink(p3, p1));
|
||||||
if(p3 && p2) array_push(mesh_data.links, new _Link(p3, p2));
|
if(p3 && p2) array_push(mesh_data.links, new MeshedLink(p3, p2));
|
||||||
|
|
||||||
var d0 = p0 && p3;
|
var d0 = p0 && p3;
|
||||||
var d1 = p1 && p2;
|
var d1 = p1 && p2;
|
||||||
|
|
||||||
if(diagon || d0 ^ d1) {
|
if(diagon || d0 ^ d1) {
|
||||||
if(d0) array_push(mesh_data.links, new _Link(p0, p3, spring));
|
if(d0) array_push(mesh_data.links, new MeshedLink(p0, p3, spring));
|
||||||
if(d1) array_push(mesh_data.links, new _Link(p1, p2, spring));
|
if(d1) array_push(mesh_data.links, new MeshedLink(p1, p2, spring));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_surface(cont)) surface_free(cont);
|
if(is_surface(cont)) surface_free(cont);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Mesh_triangulate = function(surf) {
|
static Mesh_build_Triangulate = function(surf) {
|
||||||
var sample = getInputData(1);
|
var sample = getInputData(1);
|
||||||
var seed = getInputData(9);
|
var seed = getInputData(9);
|
||||||
|
|
||||||
|
@ -573,32 +583,32 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||||
mesh_data.points = array_create(_mb + array_length(_p));
|
mesh_data.points = array_create(_mb + array_length(_p));
|
||||||
|
|
||||||
for( var i = 0, n = _mb; i < n; i++ )
|
for( var i = 0, n = _mb; i < n; i++ )
|
||||||
mesh_data.points[i] = new _Point(self, ind++, _m[i][0], _m[i][1]);
|
mesh_data.points[i] = new MeshedPoint(self, ind++, _m[i][0], _m[i][1]);
|
||||||
for( var i = 0, n = array_length(_p); i < n; i++ )
|
for( var i = 0, n = array_length(_p); i < n; i++ )
|
||||||
mesh_data.points[_mb + i] = new _Point(self, ind++, _p[i][0], _p[i][1]);
|
mesh_data.points[_mb + i] = new MeshedPoint(self, ind++, _p[i][0], _p[i][1]);
|
||||||
|
|
||||||
var _t = delaunay_triangulation(mesh_data.points);
|
var _t = delaunay_triangulation(mesh_data.points);
|
||||||
|
|
||||||
for( var i = 0, n = array_length(_t); i < n; i++ ) {
|
for( var i = 0, n = array_length(_t); i < n; i++ ) {
|
||||||
var t = _t[i];
|
var t = _t[i];
|
||||||
array_push(mesh_data.tris, new _Triangle(t[0], t[1], t[2]));
|
array_push(mesh_data.tris, new MeshedTriangle(t[0], t[1], t[2]));
|
||||||
|
|
||||||
array_push(mesh_data.links, new _Link(t[0], t[1]));
|
array_push(mesh_data.links, new MeshedLink(t[0], t[1]));
|
||||||
array_push(mesh_data.links, new _Link(t[1], t[2]));
|
array_push(mesh_data.links, new MeshedLink(t[1], t[2]));
|
||||||
array_push(mesh_data.links, new _Link(t[2], t[0]));
|
array_push(mesh_data.links, new MeshedLink(t[2], t[0]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Mesh_setTriangle = function() {
|
static Mesh_build = function() {
|
||||||
var _inSurf = getInputData(0);
|
var _inSurf = getInputData(0);
|
||||||
var _type = getInputData(8);
|
var _type = getInputData(8);
|
||||||
|
|
||||||
points = [];
|
points = [];
|
||||||
mesh_data = { points : [], tris : [], links : [], controls: [] };
|
mesh_data = new MeshedSurface();
|
||||||
|
|
||||||
switch(_type) {
|
switch(_type) {
|
||||||
case 0 : Mesh_regularTri(_inSurf); break;
|
case 0 : Mesh_build_RegularTri(_inSurf); break;
|
||||||
case 1 : Mesh_triangulate(_inSurf); break;
|
case 1 : Mesh_build_Triangulate(_inSurf); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(var i = 0; i < array_length(mesh_data.tris); i++)
|
for(var i = 0; i < array_length(mesh_data.tris); i++)
|
||||||
|
@ -616,7 +626,7 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Control_affectPoint = function(c, p) {
|
static control_affectPoint = function(c, p) {
|
||||||
var mode = c[PUPPET_CONTROL.mode];
|
var mode = c[PUPPET_CONTROL.mode];
|
||||||
var cx = c[PUPPET_CONTROL.cx];
|
var cx = c[PUPPET_CONTROL.cx];
|
||||||
var cy = c[PUPPET_CONTROL.cy];
|
var cy = c[PUPPET_CONTROL.cy];
|
||||||
|
@ -656,7 +666,7 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||||
|
|
||||||
for( var j = 0, m = array_length(mesh_data.points); j < m; j++ ) {
|
for( var j = 0, m = array_length(mesh_data.points); j < m; j++ ) {
|
||||||
if(mesh_data.points[j] == 0) continue;
|
if(mesh_data.points[j] == 0) continue;
|
||||||
Control_affectPoint(c, mesh_data.points[j]);
|
control_affectPoint(c, mesh_data.points[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -699,12 +709,14 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||||
|
|
||||||
static processData = function(_outData, _data, _output_index, _array_index) {
|
static processData = function(_outData, _data, _output_index, _array_index) {
|
||||||
if(will_triangluate) {
|
if(will_triangluate) {
|
||||||
Mesh_setTriangle();
|
Mesh_build();
|
||||||
will_triangluate = false;
|
will_triangluate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var _outSurf = _outData[0];
|
var _outSurf = _outData[0];
|
||||||
var _inSurf = _data[0];
|
var _inSurf = _data[0];
|
||||||
|
|
||||||
|
mesh_data.surface = inputs_data[0];
|
||||||
if(!is_surface(_inSurf)) return [ _outSurf, mesh_data ];
|
if(!is_surface(_inSurf)) return [ _outSurf, mesh_data ];
|
||||||
|
|
||||||
mesh_data.controls = [];
|
mesh_data.controls = [];
|
||||||
|
|
|
@ -13,7 +13,6 @@ function Node_create_Scale_Algo(_x, _y, _group = noone, _param = {}) {
|
||||||
|
|
||||||
function Node_Scale_Algo(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
function Node_Scale_Algo(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
||||||
name = "Scale Algorithm";
|
name = "Scale Algorithm";
|
||||||
|
|
||||||
manage_atlas = false;
|
manage_atlas = false;
|
||||||
|
|
||||||
newInput(0, nodeValue_Surface("Surface in", self));
|
newInput(0, nodeValue_Surface("Surface in", self));
|
||||||
|
@ -60,20 +59,21 @@ function Node_Scale_Algo(_x, _y, _group = noone) : Node_Processor(_x, _y, _group
|
||||||
var ww = surface_get_width_safe(inSurf);
|
var ww = surface_get_width_safe(inSurf);
|
||||||
var hh = surface_get_height_safe(inSurf);
|
var hh = surface_get_height_safe(inSurf);
|
||||||
var cDep = attrDepth();
|
var cDep = attrDepth();
|
||||||
|
var sc = 2, sw, sh;
|
||||||
var shader;
|
var shader;
|
||||||
var sc = 2;
|
|
||||||
|
|
||||||
var isAtlas = is_instanceof(_data[0], SurfaceAtlas);
|
var isAtlas = is_instanceof(_data[0], SurfaceAtlas);
|
||||||
if(isAtlas && !is_instanceof(_outSurf, SurfaceAtlas))
|
if(isAtlas && !is_instanceof(_outSurf, SurfaceAtlas))
|
||||||
_outSurf = _data[0].clone(true);
|
_outSurf = _data[0].clone(true);
|
||||||
|
|
||||||
var _surf = isAtlas? _outSurf.getSurface() : _outSurf;
|
var _surf = isAtlas? _outSurf.getSurface() : _outSurf;
|
||||||
|
|
||||||
switch(algo) {
|
switch(algo) {
|
||||||
case 0 :
|
case 0 :
|
||||||
shader = sh_scale2x;
|
shader = sh_scale2x;
|
||||||
sc = 2;
|
sc = 2;
|
||||||
var sw = ww * 2;
|
sw = ww * 2;
|
||||||
var sh = hh * 2;
|
sh = hh * 2;
|
||||||
|
|
||||||
_surf = surface_verify(_surf, sw, sh, cDep);
|
_surf = surface_verify(_surf, sw, sh, cDep);
|
||||||
break;
|
break;
|
||||||
|
@ -81,8 +81,8 @@ function Node_Scale_Algo(_x, _y, _group = noone) : Node_Processor(_x, _y, _group
|
||||||
case 1 :
|
case 1 :
|
||||||
shader = sh_scale3x;
|
shader = sh_scale3x;
|
||||||
sc = 3;
|
sc = 3;
|
||||||
var sw = ww * 3;
|
sw = ww * 3;
|
||||||
var sh = hh * 3;
|
sh = hh * 3;
|
||||||
|
|
||||||
_surf = surface_verify(_surf, sw, sh, cDep);
|
_surf = surface_verify(_surf, sw, sh, cDep);
|
||||||
break;
|
break;
|
||||||
|
@ -119,6 +119,9 @@ function Node_Scale_Algo(_x, _y, _group = noone) : Node_Processor(_x, _y, _group
|
||||||
}
|
}
|
||||||
|
|
||||||
_outSurf.setSurface(_surf);
|
_outSurf.setSurface(_surf);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
_outSurf = _surf;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _outSurf;
|
return _outSurf;
|
||||||
|
|
5
scripts/node_value_mesh/node_value_mesh.gml
Normal file
5
scripts/node_value_mesh/node_value_mesh.gml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
function nodeValue_Mesh(_name, _node, _value, _tooltip = "") { return new __NodeValue_Mesh(_name, _node, _value, _tooltip); }
|
||||||
|
|
||||||
|
function __NodeValue_Mesh(_name, _node, _value, _tooltip = "") : __NodeValue_Object_Generic(_name, _node, VALUE_TYPE.mesh, _value, _tooltip) constructor {
|
||||||
|
|
||||||
|
}
|
13
scripts/node_value_mesh/node_value_mesh.yy
Normal file
13
scripts/node_value_mesh/node_value_mesh.yy
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"$GMScript":"v1",
|
||||||
|
"%Name":"node_value_mesh",
|
||||||
|
"isCompatibility":false,
|
||||||
|
"isDnD":false,
|
||||||
|
"name":"node_value_mesh",
|
||||||
|
"parent":{
|
||||||
|
"name":"3d",
|
||||||
|
"path":"folders/nodes/values/types/3d.yy",
|
||||||
|
},
|
||||||
|
"resourceType":"GMScript",
|
||||||
|
"resourceVersion":"2.0",
|
||||||
|
}
|
Loading…
Reference in a new issue