[2D light] The output alpha channel now match the input.

This commit is contained in:
Tanasart 2024-11-10 11:17:30 +07:00
parent a30e481ffd
commit d3f1636077
40 changed files with 1255 additions and 377 deletions

View file

@ -703,6 +703,7 @@
{"name":"materialBox","order":14,"path":"scripts/materialBox/materialBox.yy",},
{"name":"math_function","order":3,"path":"scripts/math_function/math_function.yy",},
{"name":"matrixGrid","order":6,"path":"scripts/matrixGrid/matrixGrid.yy",},
{"name":"meshBox","order":3,"path":"scripts/meshBox/meshBox.yy",},
{"name":"meta_data","order":12,"path":"scripts/meta_data/meta_data.yy",},
{"name":"mouse_input","order":1,"path":"scripts/mouse_input/mouse_input.yy",},
{"name":"mtl_reader","order":6,"path":"scripts/mtl_reader/mtl_reader.yy",},
@ -1395,6 +1396,7 @@
{"name":"surface_functions","order":4,"path":"scripts/surface_functions/surface_functions.yy",},
{"name":"surface_get_palette","order":2,"path":"scripts/surface_get_palette/surface_get_palette.yy",},
{"name":"surfaceBox","order":4,"path":"scripts/surfaceBox/surfaceBox.yy",},
{"name":"surfaceDynaBox","order":19,"path":"scripts/surfaceDynaBox/surfaceDynaBox.yy",},
{"name":"svg_objects","order":1,"path":"scripts/svg_objects/svg_objects.yy",},
{"name":"text_file","order":5,"path":"scripts/text_file/text_file.yy",},
{"name":"textArrayBox","order":1,"path":"scripts/textArrayBox/textArrayBox.yy",},
@ -1431,6 +1433,7 @@
{"name":"window_functions","order":2,"path":"scripts/window_functions/window_functions.yy",},
{"name":"winwin_extras","order":6,"path":"scripts/winwin_extras/winwin_extras.yy",},
{"name":"winwin_utils","order":7,"path":"scripts/winwin_utils/winwin_utils.yy",},
{"name":"sh_2d_light_apply","order":32,"path":"shaders/sh_2d_light_apply/sh_2d_light_apply.yy",},
{"name":"sh_2d_light","order":10,"path":"shaders/sh_2d_light/sh_2d_light.yy",},
{"name":"sh_3d_depth","order":6,"path":"shaders/sh_3d_depth/sh_3d_depth.yy",},
{"name":"sh_3d_extrude_corner","order":7,"path":"shaders/sh_3d_extrude_corner/sh_3d_extrude_corner.yy",},
@ -2134,6 +2137,8 @@
{"name":"s_node_argument","order":40,"path":"sprites/s_node_argument/s_node_argument.yy",},
{"name":"s_node_armature_bind","order":14,"path":"sprites/s_node_armature_bind/s_node_armature_bind.yy",},
{"name":"s_node_armature_create","order":16,"path":"sprites/s_node_armature_create/s_node_armature_create.yy",},
{"name":"s_node_armature_mesh_rig","order":24,"path":"sprites/s_node_armature_mesh_rig/s_node_armature_mesh_rig.yy",},
{"name":"s_node_armature_mesh","order":31,"path":"sprites/s_node_armature_mesh/s_node_armature_mesh.yy",},
{"name":"s_node_armature_path","order":17,"path":"sprites/s_node_armature_path/s_node_armature_path.yy",},
{"name":"s_node_armature_pose","order":15,"path":"sprites/s_node_armature_pose/s_node_armature_pose.yy",},
{"name":"s_node_armature_sample","order":18,"path":"sprites/s_node_armature_sample/s_node_armature_sample.yy",},

View file

@ -1247,6 +1247,7 @@
{"id":{"name":"materialBox","path":"scripts/materialBox/materialBox.yy",},},
{"id":{"name":"math_function","path":"scripts/math_function/math_function.yy",},},
{"id":{"name":"matrixGrid","path":"scripts/matrixGrid/matrixGrid.yy",},},
{"id":{"name":"meshBox","path":"scripts/meshBox/meshBox.yy",},},
{"id":{"name":"meta_data","path":"scripts/meta_data/meta_data.yy",},},
{"id":{"name":"migration_function","path":"scripts/migration_function/migration_function.yy",},},
{"id":{"name":"mouse_input","path":"scripts/mouse_input/mouse_input.yy",},},
@ -2042,6 +2043,7 @@
{"id":{"name":"surface_functions","path":"scripts/surface_functions/surface_functions.yy",},},
{"id":{"name":"surface_get_palette","path":"scripts/surface_get_palette/surface_get_palette.yy",},},
{"id":{"name":"surfaceBox","path":"scripts/surfaceBox/surfaceBox.yy",},},
{"id":{"name":"surfaceDynaBox","path":"scripts/surfaceDynaBox/surfaceDynaBox.yy",},},
{"id":{"name":"svg_objects","path":"scripts/svg_objects/svg_objects.yy",},},
{"id":{"name":"svg_reader","path":"scripts/svg_reader/svg_reader.yy",},},
{"id":{"name":"testing_script","path":"scripts/testing_script/testing_script.yy",},},
@ -2087,6 +2089,7 @@
{"id":{"name":"windowManager","path":"scripts/windowManager/windowManager.yy",},},
{"id":{"name":"winwin_extras","path":"scripts/winwin_extras/winwin_extras.yy",},},
{"id":{"name":"winwin_utils","path":"scripts/winwin_utils/winwin_utils.yy",},},
{"id":{"name":"sh_2d_light_apply","path":"shaders/sh_2d_light_apply/sh_2d_light_apply.yy",},},
{"id":{"name":"sh_2d_light","path":"shaders/sh_2d_light/sh_2d_light.yy",},},
{"id":{"name":"sh_3d_depth","path":"shaders/sh_3d_depth/sh_3d_depth.yy",},},
{"id":{"name":"sh_3d_extrude_corner","path":"shaders/sh_3d_extrude_corner/sh_3d_extrude_corner.yy",},},
@ -2867,6 +2870,8 @@
{"id":{"name":"s_node_argument","path":"sprites/s_node_argument/s_node_argument.yy",},},
{"id":{"name":"s_node_armature_bind","path":"sprites/s_node_armature_bind/s_node_armature_bind.yy",},},
{"id":{"name":"s_node_armature_create","path":"sprites/s_node_armature_create/s_node_armature_create.yy",},},
{"id":{"name":"s_node_armature_mesh_rig","path":"sprites/s_node_armature_mesh_rig/s_node_armature_mesh_rig.yy",},},
{"id":{"name":"s_node_armature_mesh","path":"sprites/s_node_armature_mesh/s_node_armature_mesh.yy",},},
{"id":{"name":"s_node_armature_path","path":"sprites/s_node_armature_path/s_node_armature_path.yy",},},
{"id":{"name":"s_node_armature_pose","path":"sprites/s_node_armature_pose/s_node_armature_pose.yy",},},
{"id":{"name":"s_node_armature_sample","path":"sprites/s_node_armature_sample/s_node_armature_sample.yy",},},

View file

@ -34,7 +34,6 @@ if(winMan_isMinimized()) exit;
break;
case VALUE_TYPE.curve :
// draw_tooltip_text($"[{__txt("Curve Object")}]");
draw_tooltip_curve(content);
break;
@ -83,8 +82,7 @@ if(winMan_isMinimized()) exit;
case VALUE_TYPE.mesh :
var txt = __txt("Mesh Object");
if(is_struct(content))
txt += $" (triangles: {array_length(content.triangles)})";
if(is(content, MeshedSurface)) txt += $" (triangles: {array_length(content.tris)})";
draw_tooltip_text($"[{txt}]");
break;

View file

@ -1,6 +1,7 @@
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();
self.name = "New bone";
name = "New bone";
self.distance = distance;
self.direction = direction;
self.angle = angle;
@ -9,14 +10,22 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length =
init_length = length;
init_angle = angle;
init_direction = 0;
init_distance = 0;
pose_angle = 0;
pose_scale = 1;
pose_posit = [ 0, 0 ];
pose_local_angle = 0;
pose_local_scale = 1;
pose_local_posit = [ 0, 0 ];
bone_head_init = new __vec2();
bone_head_pose = new __vec2();
bone_tail_init = new __vec2();
bone_tail_pose = new __vec2();
apply_scale = true;
apply_rotation = true;
@ -36,7 +45,7 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length =
freeze_data = {};
self.parent = parent;
parent = _parent;
if(parent != noone) {
distance = parent.length;
direction = parent.angle;
@ -56,12 +65,7 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length =
}
static freeze = function() {
freeze_data = {
angle: angle,
length: length,
distance: distance,
direction: direction
}
freeze_data = { angle, length, distance, direction };
for( var i = 0, n = array_length(childs); i < n; i++ )
childs[i].freeze();
@ -94,30 +98,36 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length =
return noone;
}
static getHead = function(pose = true) { return pose? bone_head_pose.clone() : bone_head_init.clone(); }
static getTail = function(pose = true) { return pose? bone_tail_pose.clone() : bone_tail_init.clone(); }
static getPoint = function(progress, pose = true) {
var _len = pose? length : init_length;
var _ang = pose? angle : init_angle;
var _dir = pose? direction : init_direction;
var _dis = pose? distance : init_distance;
var len = _len * progress;
var _dx = lengthdir_x(_dis, _dir), _dy = lengthdir_y(_dis, _dir);
var _lx = lengthdir_x( len, _ang), _ly = lengthdir_y( len, _ang);
if(parent == noone)
return new __vec2(lengthdir_x(distance, direction), lengthdir_y(distance, direction))
.addElement(lengthdir_x(len, _ang), lengthdir_y(len, _ang));
return new __vec2(_dx, _dy)
.addElement(_lx, _ly);
if(parent_anchor) {
var p = parent.getPoint(1, pose)
.addElement(lengthdir_x(len, _ang), lengthdir_y(len, _ang))
return p;
if(parent_anchor)
return parent.getTail(pose)
.addElement(_lx, _ly);
return parent.getHead(pose)
.addElement(_dx, _dy)
.addElement(_lx, _ly);
}
var p = parent.getPoint(0, pose)
.addElement(lengthdir_x(distance, direction), lengthdir_y(distance, direction))
.addElement(lengthdir_x(len, _ang), lengthdir_y(len, _ang))
return p;
}
static draw = function(attributes, edit = false, _x = 0, _y = 0, _s = 1, _mx = 0, _my = 0, hovering = noone, selecting = noone) {
var hover = _drawBone(attributes, edit, _x, _y, _s, _mx, _my, hovering, selecting);
static draw = function(attributes, edit = false, _x = 0, _y = 0, _s = 1, _mx = 0, _my = 0, _hover = noone, _select = noone, _blend = c_white, _alpha = 1) {
var hover = _drawBone(attributes, edit, _x, _y, _s, _mx, _my, _hover, _select, _blend, _alpha);
drawControl(attributes);
return hover;
}
@ -125,119 +135,131 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length =
control_x0 = 0; control_y0 = 0; control_i0 = 0;
control_x1 = 0; control_y1 = 0; control_i1 = 0;
static _drawBone = function(attributes, edit = false, _x = 0, _y = 0, _s = 1, _mx = 0, _my = 0, hovering = noone, selecting = noone) {
static _drawBone = function(attributes, edit = false, _x = 0, _y = 0, _s = 1, _mx = 0, _my = 0, _hover = noone, _select = noone, _blend = c_white, _alpha = 1) {
var hover = noone;
var p0 = getPoint(0);
var p1 = getPoint(1);
p0.x = _x + p0.x * _s;
p0.y = _y + p0.y * _s;
p1.x = _x + p1.x * _s;
p1.y = _y + p1.y * _s;
control_x0 = p0.x; control_y0 = p0.y;
control_x1 = p1.x; control_y1 = p1.y;
control_x0 = _x + bone_head_pose.x * _s;
control_y0 = _y + bone_head_pose.y * _s;
control_x1 = _x + bone_tail_pose.x * _s;
control_y1 = _y + bone_tail_pose.y * _s;
if(parent != noone) {
if(selecting && selecting.ID == self.ID) {
var h = __drawBoneUI(attributes, edit, _x, _y, _s, _mx, _my, _hover, _select, _blend, _alpha);
if(h != noone) hover = h;
}
for( var i = 0, n = array_length(childs); i < n; i++ ) {
var h = childs[i]._drawBone(attributes, edit, _x, _y, _s, _mx, _my, _hover, _select, _blend, _alpha);
if(hover == noone && h != noone)
hover = h;
}
return hover;
}
static __drawBoneUI = function(attributes, edit = false, _x = 0, _y = 0, _s = 1, _mx = 0, _my = 0, _hover = noone, _select = noone, _blend = c_white, _alpha = 1) {
var hover = noone;
var p0x = _x + bone_head_pose.x * _s;
var p0y = _y + bone_head_pose.y * _s;
var p1x = _x + bone_tail_pose.x * _s;
var p1y = _y + bone_tail_pose.y * _s;
if(_select && _select.ID == self.ID) {
draw_set_color(COLORS._main_value_positive);
draw_set_alpha(0.75);
} else if(hovering != noone && hovering[0].ID == self.ID && hovering[1] == 2) {
draw_set_alpha(0.75 * _alpha);
} else if(_hover != noone && _hover[0].ID == self.ID && _hover[1] == 2) {
draw_set_color(c_white);
draw_set_alpha(1);
draw_set_alpha(1 * _alpha);
} else {
draw_set_color(COLORS._main_accent);
draw_set_alpha(0.75);
draw_set_alpha(0.75 * _alpha);
}
if(IKlength == 0) {
if(!parent_anchor && parent.parent != noone) {
var _p = parent.getPoint(0);
_p.x = _x + _p.x * _s;
_p.y = _y + _p.y * _s;
draw_line_dashed(_p.x, _p.y, p0.x, p0.y, 1);
var _p = parent.getHead();
var _px = _x + _p.x * _s;
var _py = _y + _p.y * _s;
draw_line_dashed(_px, _py, p0x, p0y, 1);
}
if(attributes.display_bone == 0) {
var _ppx = lerp(p0.x, p1.x, 0.2);
var _ppy = lerp(p0.y, p1.y, 0.2);
var _prr = point_direction(p0.x, p0.y, p1.x, p1.y) + 90;
var _ppx = lerp(p0x, p1x, 0.2);
var _ppy = lerp(p0y, p1y, 0.2);
var _prr = point_direction(p0x, p0y, p1x, p1y) + 90;
var _prx = lengthdir_x(6 * pose_scale, _prr);
var _pry = lengthdir_y(6 * pose_scale, _prr);
draw_primitive_begin(pr_trianglelist);
draw_vertex(p0.x, p0.y);
draw_vertex(p0x, p0y);
draw_vertex(_ppx, _ppy);
draw_vertex(_ppx + _prx, _ppy + _pry);
draw_vertex(p0.x, p0.y);
draw_vertex(p0x, p0y);
draw_vertex(_ppx, _ppy);
draw_vertex(_ppx - _prx, _ppy - _pry);
draw_vertex(p1.x, p1.y);
draw_vertex(p1x, p1y);
draw_vertex(_ppx, _ppy);
draw_vertex(_ppx + _prx, _ppy + _pry);
draw_vertex(p1.x, p1.y);
draw_vertex(p1x, p1y);
draw_vertex(_ppx, _ppy);
draw_vertex(_ppx - _prx, _ppy - _pry);
draw_primitive_end();
if((edit & 0b100) && distance_to_line(_mx, _my, p0.x, p0.y, p1.x, p1.y) <= 12) //drag bone
hover = [ self, 2, p0 ];
if((edit & 0b100) && distance_to_line(_mx, _my, p0x, p0y, p1x, p1y) <= 12) //drag bone
hover = [ self, 2, bone_head_pose ];
} else if(attributes.display_bone == 1) {
draw_line_width(p0.x, p0.y, p1.x, p1.y, 3);
draw_line_width(p0x, p0y, p1x, p1y, 3);
if((edit & 0b100) && distance_to_line(_mx, _my, p0.x, p0.y, p1.x, p1.y) <= 6) //drag bone
hover = [ self, 2, p0 ];
if((edit & 0b100) && distance_to_line(_mx, _my, p0x, p0y, p1x, p1y) <= 6) //drag bone
hover = [ self, 2, bone_head_pose ];
}
} else {
draw_set_color(c_white);
if(!parent_anchor && parent.parent != noone) {
var _p = parent.getPoint(1);
_p.x = _x + _p.x * _s;
_p.y = _y + _p.y * _s;
draw_line_dashed(_p.x, _p.y, p0.x, p0.y, 1);
var _p = parent.getTail();
var _px = _x + _p.x * _s;
var _py = _y + _p.y * _s;
draw_line_dashed(_px, _py, p0x, p0y, 1);
}
draw_sprite_ui(THEME.preview_bone_IK, 0, p0.x, p0.y,,,, c_white, draw_get_alpha());
draw_sprite_ui(THEME.preview_bone_IK, 0, p0x, p0y,,,, COLORS._main_accent, draw_get_alpha());
if((edit & 0b100) && point_in_circle(_mx, _my, p0.x, p0.y, 24))
hover = [ self, 2, p0 ];
if((edit & 0b100) && point_in_circle(_mx, _my, p0x, p0y, 24))
hover = [ self, 2, bone_head_pose ];
}
draw_set_alpha(1.00);
draw_set_alpha(1);
if(attributes.display_name && IKlength == 0) {
if(abs(p0.y - p1.y) < abs(p0.x - p1.x)) {
if(abs(p0y - p1y) < abs(p0x - p1x)) {
draw_set_text(f_p3, fa_center, fa_bottom, COLORS._main_accent);
draw_text_add((p0.x + p1.x) / 2, (p0.y + p1.y) / 2 - 4, name);
draw_text_add((p0x + p1x) / 2, (p0y + p1y) / 2 - 4, name);
} else {
draw_set_text(f_p3, fa_left, fa_center, COLORS._main_accent);
draw_text_add((p0.x + p1.x) / 2 + 4, (p0.y + p1.y) / 2, name);
draw_text_add((p0x + p1x) / 2 + 4, (p0y + p1y) / 2, name);
}
}
if(IKlength == 0) {
if(!parent_anchor) {
control_i0 = (hovering != noone && hovering[0] == self && hovering[1] == 0)? 0 : 2;
control_i0 = (_hover != noone && _hover[0] == self && _hover[1] == 0)? 0 : 2;
if((edit & 0b001) && point_in_circle(_mx, _my, p0.x, p0.y, ui(16))) //drag head
hover = [ self, 0, p0 ];
if((edit & 0b001) && point_in_circle(_mx, _my, p0x, p0y, ui(16))) //drag head
hover = [ self, 0, bone_head_pose ];
}
control_i1 = (hovering != noone && hovering[0] == self && hovering[1] == 1)? 0 : 2;
control_i1 = (_hover != noone && _hover[0] == self && _hover[1] == 1)? 0 : 2;
if((edit & 0b010) && point_in_circle(_mx, _my, p1.x, p1.y, ui(16))) //drag tail
hover = [ self, 1, p1 ];
}
}
for( var i = 0, n = array_length(childs); i < n; i++ ) {
var h = childs[i]._drawBone(attributes, edit, _x, _y, _s, _mx, _my, hovering, selecting);
if(hover == noone && h != noone)
hover = h;
if((edit & 0b010) && point_in_circle(_mx, _my, p1x, p1y, ui(16))) //drag tail
hover = [ self, 1, bone_tail_pose ];
}
return hover;
@ -266,13 +288,28 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length =
pose_scale = 1;
pose_posit = [ 0, 0 ];
init_direction = direction;
init_distance = distance;
for( var i = 0, n = array_length(childs); i < n; i++ )
childs[i].resetPose();
}
static setPose = function(_position = [ 0, 0 ], _angle = 0, _scale = 1) {
static setPosition = function() {
bone_head_init = getPoint(0, false);
bone_head_pose = getPoint(0, true);
bone_tail_init = getPoint(1, false);
bone_tail_pose = getPoint(1, true);
for( var i = 0, n = array_length(childs); i < n; i++ )
childs[i].setPosition();
}
static setPose = function(_position = [ 0, 0 ], _angle = 0, _scale = 1, _ik = true) {
setPosition();
setPoseTransform(_position, _angle, _scale);
setIKconstrain();
if(_ik) setIKconstrain();
setPosition();
}
static setPoseTransform = function(_position = [ 0, 0 ], _angle = 0, _scale = 1) {
@ -314,20 +351,14 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length =
var bn = IKTarget;
for( var i = IKlength; i > 0; i-- ) {
var _p = bn.getPoint(1);
var _p = bn.getTail();
bones[i - 1] = bn;
points[i] = {
x: _p.x,
y: _p.y
};
points[i] = { x: _p.x, y: _p.y };
bn = bn.parent;
}
_p = bn.getPoint(1);
points[0] = {
x: _p.x,
y: _p.y
};
_p = bn.getTail();
points[0] = { x: _p.x, y: _p.y };
for( var i = 0; i < IKlength; i++ ) {
var p0 = points[i];
@ -336,11 +367,11 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length =
lengths[i] = point_distance(p0.x, p0.y, p1.x, p1.y);
}
var p = parent.getPoint(0);
p.x += lengthdir_x(distance, direction);
p.y += lengthdir_y(distance, direction);
var p = parent.getHead();
var px = p.x + lengthdir_x(distance, direction);
var py = p.y + lengthdir_y(distance, direction);
FABRIK(bones, points, lengths, p.x, p.y);
FABRIK(bones, points, lengths, px, py);
}
for( var i = 0, n = array_length(childs); i < n; i++ )
@ -349,10 +380,12 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length =
FABRIK_result = [];
static FABRIK = function(bones, points, lengths, dx, dy) {
var threshold = 0.01;
var _bo = array_create(array_length(points));
for( var i = 0, n = array_length(points); i < n; i++ )
_bo[i] = { x: points[i].x, y: points[i].y };
var sx = points[0].x;
var sy = points[0].y;
var itr = 0;
@ -373,17 +406,24 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length =
} until(delta <= threshold);
for( var i = 0, n = array_length(points) - 1; i < n; i++ ) {
var bone = bones[i];
var _b = bones[i];
var p0 = points[i];
var p1 = points[i + 1];
var dir = point_direction(p0.x, p0.y, p1.x, p1.y);
bone.angle = dir;
var dis = point_distance( p0.x, p0.y, p1.x, p1.y);
// _b.pose_scale = dis / _b.init_length;
// _b.length = dis;
_b.pose_angle = dir - _b.init_angle;
_b.angle = dir;
FABRIK_result[i] = p0;
}
FABRIK_result[i] = p1;
}
static FABRIK_backward = function(points, lengths, dx, dy) {
@ -429,8 +469,8 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length =
}
static __getBBOX = function() {
var p0 = getPoint(0);
var p1 = getPoint(1);
var p0 = bone_head_pose;
var p1 = bone_tail_pose;
var x0 = min(p0.x, p1.x);
var y0 = min(p0.y, p1.y);
@ -542,7 +582,7 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length =
static toString = function() { return $"Bone {name} [{ID}]"; }
static toArray = function(arr = []) {
array_push(arr, self);
if(!is_main) array_push(arr, self);
for( var i = 0, n = array_length(childs); i < n; i++ )
childs[i].toArray(arr);

View file

@ -31,6 +31,8 @@ function dynaSurf() constructor {
onFree();
}
static getSurfacePreview = function() { return array_safe_get_fast(surfaces, 0); }
static clone = function() { return noone; }
static destroy = function() {}
}

View file

@ -40,9 +40,9 @@
globalvar HOTKEYS, HOTKEY_CONTEXT;
LATEST_VERSION = 1_18_00_0;
VERSION = 1_18_03_1;
VERSION = 1_18_04_0;
SAVE_VERSION = 1_18_02_0;
VERSION_STRING = MAC? "1.18.003m" : "1.18.4.001";
VERSION_STRING = MAC? "1.18.003m" : "1.18.4.003";
BUILD_NUMBER = 1_18_03_1;
HOTKEYS = ds_map_create();

View file

@ -0,0 +1,34 @@
function meshBox(_junction) : widget() constructor {
self.junction = _junction;
static trigger = function() { }
static drawParam = function(params) {
setParam(params);
return draw(params.x, params.y, params.w, params.data, params.m);
}
static draw = function(_x, _y, _w, _mesh, _m) {
x = _x;
y = _y;
w = _w;
h = TEXTBOX_HEIGHT;
var ic = s_node_armature_mesh;
var iw = ui(24);
var _s = (iw - ui(8)) / max(sprite_get_width(ic), sprite_get_height(ic));
var bi = 0;
draw_sprite_stretched_ext(THEME.button_def, bi, x, y, iw, h);
draw_sprite_stretched_ext(THEME.ui_panel_bg, 1, x + iw + ui(4), y, w - iw - ui(4), h, COLORS._main_icon_light);
draw_sprite_ext(ic, 1, x + iw / 2, y + h / 2, _s, _s);
draw_set_text(f_p2, fa_left, fa_center, COLORS._main_text_sub);
draw_text_add(x + iw + ui(4 + 8), y + h / 2, "Mesh");
return h;
}
static clone = function() { return new meshBox(); }
}

View file

@ -0,0 +1,13 @@
{
"$GMScript":"v1",
"%Name":"meshBox",
"isCompatibility":false,
"isDnD":false,
"name":"meshBox",
"parent":{
"name":"object",
"path":"folders/widgets/object.yy",
},
"resourceType":"GMScript",
"resourceVersion":"2.0",
}

View file

@ -385,8 +385,9 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover = false, _foc
}
break;
case VALUE_TYPE.d3Material :
case VALUE_TYPE.surface :
case VALUE_TYPE.d3Material :
case VALUE_TYPE.dynaSurface :
param.h = widExtend? ui(96) : ui(48);
break;

View file

@ -573,12 +573,12 @@ function Node_2D_light(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
applyLight(_data, _ind, _lightSurf);
}
surface_set_target(_outSurf);
DRAW_CLEAR
BLEND_OVERRIDE draw_surface_safe(_surf);
BLEND_ADD draw_surface_safe(_lightSurf);
BLEND_NORMAL
surface_reset_target();
surface_set_shader(_outSurf, sh_2d_light_apply, true, BLEND.over);
shader_set_surface("base", _surf);
shader_set_surface("light", _lightSurf);
draw_empty();
surface_reset_shader();
return [ _outSurf, _lightSurf ];
}

View file

@ -17,8 +17,6 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
ty += ui(28);
draw_sprite_stretched_ext(THEME.ui_panel_bg, 1, _x, ty, _w, bh - ui(32), COLORS.node_composite_bg_blend, 1);
// draw_set_color(COLORS.node_composite_separator);
// draw_line(_x + 16, ty + ui(8), _x + _w - 16, ty + ui(8));
ty += ui(8);
var hovering = noone;
@ -210,22 +208,24 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
builder_bone.direction = point_direction(0, 0, bx, by);
builder_bone.distance = point_distance( 0, 0, bx, by);
}
} else if(key_mod_press(ALT)) {
if(builder_type == 0) {
var bo = builder_bone.getPoint(1);
var bo = builder_bone.getTail();
builder_bone.direction = dir;
builder_bone.distance = dis;
var bn = builder_bone.getPoint(0);
var bn = builder_bone.getHead();
builder_bone.angle = point_direction(bn.x, bn.y, bo.x, bo.y);
builder_bone.length = point_distance( bn.x, bn.y, bo.x, bo.y);
} else if(builder_type == 1) {
var chs = [];
for( var i = 0, n = array_length(builder_bone.childs); i < n; i++ ) {
var ch = builder_bone.childs[i];
chs[i] = ch.getPoint(1);
chs[i] = ch.getTail();
}
builder_bone.angle = dir;
@ -233,7 +233,7 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
for( var i = 0, n = array_length(builder_bone.childs); i < n; i++ ) {
var ch = builder_bone.childs[i];
var c0 = ch.getPoint(0);
var c0 = ch.getHead();
ch.angle = point_direction(c0.x, c0.y, chs[i].x, chs[i].y);
ch.length = point_distance( c0.x, c0.y, chs[i].x, chs[i].y);
@ -245,11 +245,11 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
builder_bone.distance = dis;
if(builder_bone.parent) {
var par_anc = builder_bone.parent.getPoint(1);
par_anc.x = _x + par_anc.x * _s;
par_anc.y = _y + par_anc.y * _s;
var par_anc = builder_bone.parent.getTail();
var par_ancx = _x + par_anc.x * _s;
var par_ancy = _y + par_anc.y * _s;
var inRange = point_in_circle(_mx, _my, par_anc.x, par_anc.y, 16) && mouse_release(mb_left);
var inRange = point_in_circle(_mx, _my, par_ancx, par_ancy, 16) && mouse_release(mb_left);
if(!builder_bone.parent.is_main && builder_bone.IKlength > 0 && inRange)
builder_bone.parent_anchor = true;
}
@ -269,27 +269,34 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
} else if(ik_dragging != noone) {
anchor_selecting = _b.draw(attributes, active * 0b100, _x, _y, _s, _mx, _my, anchor_selecting, ik_dragging);
var _bone = ik_dragging.parent;
var p1 = ik_dragging.getTail();
var p1x = _x + p1.x * _s;
var p1y = _y + p1.y * _s;
if(anchor_selecting != noone && anchor_selecting[1] == 2) {
var anc = anchor_selecting[0];
var reachable = false;
var _bone = ik_dragging.parent;
var len = 0;
var _reach = false;
var _blen = 0;
while(_bone != noone) {
if(_bone == anc.parent) {
reachable = true;
_reach = true;
break;
}
len++;
_blen++;
_bone = _bone.parent;
}
if(reachable && mouse_release(mb_left)) {
var p1 = ik_dragging.getPoint(1);
var p0 = anc.getPoint(0);
if(_reach) {
var p0 = anc.getHead();
var p0t = anc.getTail();
var _px = _x + p0t.x * _s;
var _py = _y + p0t.y * _s;
draw_line_dashed(_px, _py, p1x, p1y, 1);
if(mouse_release(mb_left)) {
var _len = point_distance(p0.x, p0.y, p1.x, p1.y);
var _ang = point_direction(p0.x, p0.y, p1.x, p1.y);
@ -297,17 +304,25 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
var IKbone = new __Bone(anc, _len, _ang, ik_dragging.angle + 90, 0, self);
anc.addChild(IKbone);
IKbone.IKlength = len;
IKbone.IKlength = _blen;
IKbone.IKTargetID = ik_dragging.ID;
IKbone.name = "IK handle";
IKbone.parent_anchor = false;
bones.setPosition();
}
}
draw_sprite_ui(THEME.preview_bone_IK, 0, p1x, p1y, 1, 1, 0, _reach? COLORS._main_value_positive : COLORS._main_accent, 0.5);
} else
draw_sprite_ui(THEME.preview_bone_IK, 0, p1x, p1y, 1, 1, 0, COLORS._main_accent, 0.25);
if(mouse_release(mb_left)) {
ik_dragging = noone;
UNDO_HOLDING = false;
bones.setPosition();
}
triggerRender();
@ -439,6 +454,7 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
builder_sx = smx;
builder_sy = smy;
UNDO_HOLDING = true;
bones.setPosition();
} else if(anchor_selecting[1] == 1) {
builder_bone = createBone(anchor_selecting[0], 0, 0);
@ -446,6 +462,7 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
builder_sx = smx;
builder_sy = smy;
UNDO_HOLDING = true;
bones.setPosition();
} else if(anchor_selecting[1] == 2) {
var _pr = anchor_selecting[0];
@ -467,9 +484,11 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
if(anchor_selecting == noone)
draw_sprite_ext(THEME.bone_tool_add, 1, _mx + 16, _my + 16, 1, 1, 0, c_white, 1);
else if(anchor_selecting[1] == 1) {
draw_sprite_ext(THEME.bone_tool_add, 0, _mx + 24, _my + 24, 1, 1, 0, c_white, 1);
draw_sprite_ext(THEME.bone_tool_add, 1, _mx + 24, _my + 24, 1, 1, 0, c_white, 1);
} else if(anchor_selecting[1] == 2)
draw_sprite_ext(THEME.bone_tool_add, 0, _mx + 24, _my + 24, 1, 1, 0, c_white, 1);
@ -536,13 +555,15 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
recordAction(ACTION_TYPE.struct_modify, bones, bones.serialize());
if(builder_type == 0) {
var orig = builder_bone.parent.getPoint(0);
var orig = builder_bone.parent.getHead();
builder_sx = orig.x;
builder_sy = orig.y;
} else if(builder_type == 1) {
var orig = builder_bone.getPoint(0);
var orig = builder_bone.getHead();
builder_sx = orig.x;
builder_sy = orig.y;
} else if(builder_type == 2) {
if(builder_bone.parent_anchor) {
builder_bone = noone;
@ -564,6 +585,7 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
static step = function() {}
static update = function(frame = CURRENT_FRAME) {
bones.setPosition();
outputs[0].setValue(bones);
}
@ -581,8 +603,8 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
var __b = ds_stack_pop(_bst);
for( var i = 0, n = array_length(__b.childs); i < n; i++ ) {
var p0 = __b.childs[i].getPoint(0);
var p1 = __b.childs[i].getPoint(1);
var p0 = __b.childs[i].getHead();
var p1 = __b.childs[i].getTail();
minx = min(minx, p0.x); miny = min(miny, p0.y);
maxx = max(maxx, p0.x); maxy = max(maxy, p0.y);

View file

@ -39,14 +39,14 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
attribute_surface_depth();
attribute_interpolation();
anchor_selecting = noone;
attributes.layer_visible = [];
attributes.layer_selectable = [];
attributes.display_name = true;
attributes.display_bone = 0;
anchor_selecting = noone;
array_push(attributeEditors, "Display");
array_push(attributeEditors, ["Display name", function() /*=>*/ {return attributes.display_name}, new checkBox(function() /*=>*/ { attributes.display_name = !attributes.display_name; })]);
array_push(attributeEditors, ["Display bone", function() /*=>*/ {return attributes.display_bone}, new scrollBox(["Octahedral", "Stick"], function(ind) /*=>*/ { attributes.display_bone = ind; })]);
@ -75,7 +75,7 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
var _surfAmo = getInputAmount();
for(var i = 0; i < _surfAmo; i++) {
var _surf = current_data[input_fix_len + i * data_length];
var _surf = getInputData(input_fix_len + i * data_length);
var _id = array_safe_get(boneIDMap, i, "");
if(_id == "") continue;
@ -217,6 +217,10 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
var _ind = amo - i - 1;
var _inp = input_fix_len + _ind * data_length;
var _surf = current_data[_inp];
var _mesh = is(_surf, RiggedMeshedSurface);
if(_mesh) _surf = _surf.getSurface();
var binded = array_safe_get(boneIDMap, _ind, "") != "";
var _bx = _x + _w - 24;
@ -293,9 +297,21 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
var tc = _ins? COLORS._main_text_accent : COLORS._main_icon;
if(hov) tc = COLORS._main_text;
var _tx = _sx1 + 12;
var _ty = _cy + lh / 2;
if(_mesh) {
var _mshx = _tx + 6;
var _mshy = _ty;
draw_sprite_ext(s_node_armature_mesh, 0, _mshx, _mshy, 1, 1, 0, COLORS._main_icon, 1);
_tx += 22;
}
draw_set_text(f_p2, fa_left, fa_center, tc);
draw_set_alpha(aa);
draw_text_add(_sx1 + 12, _cy + lh / 2, inputs[_inp].name);
draw_text_add(_tx, _ty, inputs[_inp].name);
draw_set_alpha(1);
if(_hover && point_in_rectangle(_m[0], _m[1], _x, _cy, _x + _w, _cy + lh)) {
@ -479,7 +495,6 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
bone.draw(attributes, false, _x + _dpos[0] * _s, _y + _dpos[1] * _s, _s * _dsca, _mx, _my, anchor_selecting);
inputs[3].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
//inputs[4].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
var mx = (_mx - _x) / _s;
var my = (_my - _y) / _s;
@ -576,6 +591,14 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
for(var i = 0; i < amo; i++) {
var index = input_fix_len + i * data_length;
var _surf = array_safe_get_fast(current_data, index);
if(is(_surf, RiggedMeshedSurface)) {
var _mesh = _surf.mesh;
for(var j = 0; j < array_length(_mesh.links); j++)
_mesh.links[j].draw(_x, _y, _s);
continue;
}
if(!_surf || is_array(_surf)) continue;
var _bone = array_safe_get(boneIDMap, i, "");
@ -740,11 +763,69 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
inputs[2].setVisible(_dim_type == COMPOSE_OUTPUT_SCALING.constant);
for( var i = input_fix_len, n = array_length(inputs); i < n; i += data_length ) {
inputs[i + 3].setVisible(current_data[i + 2]);
inputs[i + 5].setVisible(current_data[i + 4]);
inputs[i + 3].setVisible(getInputData(i + 2));
inputs[i + 5].setVisible(getInputData(i + 4));
}
}
static meshBind = function(_s, _bg) {
_mesh = _s.mesh;
_rmap = _s.rigMap;
_surf = _s.getSurface();
if(!is_surface(_surf)) return;
_rbon = _s.boneMap == noone? boneMap : _s.boneMap;
_rbid = struct_get_names(_rmap);
_rbidL = array_length(_rbid);
_ar = [ 0, 0 ];
array_foreach(_mesh.points, function(_p, i) /*=>*/ {
if(!is(_p, MeshedPoint)) return;
var _px = _p.sx;
var _py = _p.sy;
for( var j = 0; j < _rbidL; j++ ) {
var _rBoneID = _rbid[j];
if(!ds_map_exists(boneMap, _rBoneID)) continue;
var _rmapp = _rmap[$ _rBoneID];
var _weight = array_safe_get_fast(_rmapp, i, 0);
if(_weight == 0) continue;
var _bm = _rbon[? _rBoneID];
var _b = boneMap[? _rBoneID];
var _ax = _p.sx - _bm.bone_head_pose.x;
var _ay = _p.sy - _bm.bone_head_pose.y;
point_rotate_origin(_ax, _ay, _b.pose_angle - _bm.pose_angle, _ar);
var _nx = _b.bone_head_pose.x + _ar[0] * _b.pose_scale / _bm.pose_scale;
var _ny = _b.bone_head_pose.y + _ar[1] * _b.pose_scale / _bm.pose_scale;
var _dx = _nx - _p.sx;
var _dy = _ny - _p.sy;
_px += _dx * _weight;
_py += _dy * _weight;
}
_p.x = _px;
_p.y = _py;
});
surface_set_shader(temp_surface[!_bg], sh_sample, false, BLEND.alphamulp);
draw_set_color(c_white);
draw_set_alpha(1);
array_foreach(_mesh.tris, function(_t) /*=>*/ { _t.drawSurface(_surf); });
surface_reset_shader();
surface_set_shader(temp_surface[_bg], noone, true, BLEND.over);
draw_surface(temp_surface[!_bg], 0, 0);
surface_reset_shader();
}
static processData = function(_outData, _data, _output_index, _array_index) {
var atlas_data = [];
var bind_data = [];
@ -772,26 +853,27 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
}
var use_data = _bind != noone;
var res_index = 0;
var bg = 0;
var imageAmo = use_data? array_length(_bind) : (array_length(inputs) - input_fix_len) / data_length;
var _vis = attributes.layer_visible;
var _bg = 0, _s;
var _bg = 0, _s, _i;
for(var i = 0; i < imageAmo; i++) {
var vis = array_safe_get_fast(_vis, i, true);
if(!vis) continue;
if(!array_safe_get_fast(_vis, i, true)) continue;
var datInd = input_fix_len + i * data_length;
_i = input_fix_len + i * data_length;
_s = noone;
if(use_data) {
var _bindData = array_safe_get(_bind, i);
if(is_instanceof(_bindData, __armature_bind_data))
_s = _bindData.surface.get();
var _bdat = array_safe_get_fast(_bind, i);
if(is(_bdat, __armature_bind_data))
_s = _bdat.surface.get();
} else {
_s = array_safe_get(_data, datInd);
} else
_s = array_safe_get_fast(_data, _i);
if(is(_s, RiggedMeshedSurface)) {
meshBind(_s, _bg);
continue;
}
if(!is_surface(_s)) continue;
@ -801,11 +883,11 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
_b = boneMap[? _b];
var _tran = use_data? _bind[i].transform : _data[datInd + 1];
var _aang = use_data? _bind[i].applyRot : _data[datInd + 2];
var _pang = use_data? _bind[i].applyRotl : _data[datInd + 3];
var _asca = use_data? _bind[i].applySca : _data[datInd + 4];
var _psca = use_data? _bind[i].applyScal : _data[datInd + 5];
var _tran = use_data? _bind[i].transform : _data[_i + 1];
var _aang = use_data? _bind[i].applyRot : _data[_i + 2];
var _pang = use_data? _bind[i].applyRotl : _data[_i + 3];
var _asca = use_data? _bind[i].applySca : _data[_i + 4];
var _psca = use_data? _bind[i].applyScal : _data[_i + 5];
var _rot = _aang * (_pang? _b.angle : _b.pose_local_angle) + _tran[TRANSFORM.rot];
var _anc = _b.getPoint(0.5);
@ -871,10 +953,7 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
}
static attributeSerialize = function() {
var att = {
boneIDMap,
};
var att = { boneIDMap };
return att;
}

View file

@ -1,8 +1,11 @@
function RiggedMeshedSurface() constructor {
function RiggedMeshedSurface() : dynaSurf() constructor {
mesh = noone;
bone = noone;
boneMap = noone;
rigMap = {};
static getSurface = function() { return mesh == noone? noone : mesh.surface; }
static getSurfacePreview = function() { return getSurface(); }
}
function Node_Armature_Mesh_Rig(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
@ -18,58 +21,354 @@ function Node_Armature_Mesh_Rig(_x, _y, _group = noone) : Node(_x, _y, _group) c
newInput(2, nodeValue_Trigger("Autoweight", self, false ))
.setDisplay(VALUE_DISPLAY.button, { name: "Auto weight", UI : true, onClick: function() /*=>*/ {return AutoWeightPaint()} });
newInput(3, nodeValue_Float("Radius", self, 8))
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
newOutput(0, nodeValue_Output("Rigged mesh", self, VALUE_TYPE.mesh, noone));
newOutput(0, nodeValue_Output("Rigged Surface", self, VALUE_TYPE.dynaSurface, noone));
rigdata = {};
bone_posed = noone;
rigdata = noone;
anchor_selecting = noone;
static AutoWeightPaint = function() {
attributes.bonePoseData = {};
attributes.rigBones = noone;
attributes.display_name = true;
attributes.display_bone = 0;
array_push(attributeEditors, "Display");
array_push(attributeEditors, ["Display name", function() /*=>*/ {return attributes.display_name}, new checkBox(function() /*=>*/ { attributes.display_name = !attributes.display_name; })]);
array_push(attributeEditors, ["Display bone", function() /*=>*/ {return attributes.display_bone}, new scrollBox(["Octahedral", "Stick"], function(ind) /*=>*/ { attributes.display_bone = ind; })]);
tools = [
new NodeTool( "Pose", THEME.bone_tool_pose )
];
layer_renderer = new Inspector_Custom_Renderer(function(_x, _y, _w, _m, _hover, _focus) {
var _b = inputs[0].getValue();
if(_b == noone) return 0;
var amo = _b.childCount();
var _hh = ui(28);
var bh = ui(32 + 16) + amo * _hh;
var ty = _y;
draw_set_text(f_p2, fa_left, fa_top, COLORS._main_text_sub);
draw_text_add(_x + ui(16), ty + ui(4), __txt("Bones"));
ty += ui(28);
draw_sprite_stretched_ext(THEME.ui_panel_bg, 1, _x, ty, _w, bh - ui(32), COLORS.node_composite_bg_blend, 1);
ty += ui(8);
var hovering = noone;
var _bst = ds_stack_create();
ds_stack_push(_bst, [ _b, _x, _w ]);
anchor_selecting = noone;
while(!ds_stack_empty(_bst)) {
var _st = ds_stack_pop(_bst);
var _bone = _st[0];
var __x = _st[1];
var __w = _st[2];
var _sel = attributes.rigBones == noone? true : array_exists(attributes.rigBones, _bone.ID);
for( var i = 0, n = array_length(_bone.childs); i < n; i++ )
ds_stack_push(_bst, [ _bone.childs[i], __x + 16, __w - 16 ]);
if(_bone.is_main) continue;
var _dx = __x + ui(24);
draw_sprite_stretched_ext(THEME.checkbox_def, 0, _x + ui(16), ty + ui(4), ui(20), ui(20), c_white);
if(_sel) draw_sprite_stretched_ext(THEME.checkbox_def, 2, _x + ui(16), ty + ui(4), ui(20), ui(20), COLORS._main_accent);
if(_bone.parent_anchor) draw_sprite_ui(THEME.bone, 1, _dx + 12, ty + 14,,,, COLORS._main_icon);
else if(_bone.IKlength) draw_sprite_ui(THEME.bone, 2, _dx + 12, ty + 14,,,, COLORS._main_icon);
else draw_sprite_ui(THEME.bone, 0, _dx + 12, ty + 14,,,, COLORS._main_icon);
draw_set_text(f_p2, fa_left, fa_center, COLORS._main_text);
draw_text_add(_dx + 24, ty + 12, _bone.name);
var _hov = _hover && point_in_rectangle(_m[0], _m[1], _x, ty, _x + _w, ty + _hh - 1);
if(_hov) {
anchor_selecting = [ _bone, 2 ];
if(mouse_press(mb_left, _focus)) {
if(attributes.rigBones == noone)
attributes.rigBones = [ _bone.ID ];
else {
if(array_exists(attributes.rigBones, _bone.ID))
array_remove(attributes.rigBones, _bone.ID);
else
array_push(attributes.rigBones, _bone.ID);
}
}
}
ty += _hh;
if(!ds_stack_empty(_bst)) {
draw_set_color(COLORS.node_composite_separator);
draw_line(_x + 16, ty, _x + _w - 16, ty);
}
}
ds_stack_destroy(_bst);
layer_renderer.h = bh;
return layer_renderer.h;
});
input_display_list = [ 0, 1,
["Autoweight", false], 2, 3,
["Armature", false], layer_renderer,
];
anchor_selecting = noone;
posing_bone = noone;
posing_input = 0;
posing_type = 0;
posing_sx = 0;
posing_sy = 0;
posing_sz = 0;
posing_mx = 0;
posing_my = 0;
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
var _bones = inputs[0].getValue();
var _mesh = inputs[1].getValue();
if(!is(_bones, __Bone)) return;
if(_mesh != noone) {
__weights = anchor_selecting == noone? noone : struct_try_get(rigdata, anchor_selecting[0].ID, noone);
__x = _x;
__y = _y;
__s = _s;
draw_set_circle_precision(4);
if(__weights == noone) {
array_foreach(_mesh.points, function(_p) /*=>*/ {
if(!is(_p, MeshedPoint)) return;
_p.drx = __x + _p.x * __s;
_p.dry = __y + _p.y * __s;
_p.color = COLORS._main_accent;
draw_set_color(_p.color);
draw_circle(_p.drx, _p.dry, 2, false);
});
} else {
array_foreach(_mesh.points, function(_p, i) /*=>*/ {
if(!is(_p, MeshedPoint)) return;
_p.drx = __x + _p.x * __s;
_p.dry = __y + _p.y * __s;
var _w = array_safe_get_fast(__weights, i);
_p.color = merge_color(COLORS._main_accent, c_white, _w);
draw_set_color(_p.color);
draw_circle(_p.drx, _p.dry, 2, false);
});
}
draw_set_alpha(.5);
array_foreach(_mesh.links, function(_l) /*=>*/ {
var _p0 = _l.p0;
var _p1 = _l.p1;
var _c0 = _p0.color;
var _c1 = _p1.color;
draw_line_color(_p0.drx, _p0.dry, _p1.drx, _p1.dry, _c0, _c1);
});
draw_set_alpha(1);
}
if(bone_posed == noone) return;
if(isUsingTool("Pose")) {
anchor_selecting = bone_posed.draw(attributes, active * 0b111, _x, _y, _s, _mx, _my, anchor_selecting, posing_bone);
var mx = (_mx - _x) / _s;
var my = (_my - _y) / _s;
var smx = value_snap(mx, _snx);
var smy = value_snap(my, _sny);
if(posing_bone) {
if(posing_type == 0 && posing_bone.parent) { //move
var ang = posing_bone.parent.pose_angle;
var pp = point_rotate(smx - posing_mx, smy - posing_my, 0, 0, -ang);
var bx = posing_sx + pp[0];
var by = posing_sy + pp[1];
posing_input[TRANSFORM.pos_x] = bx;
posing_input[TRANSFORM.pos_y] = by;
triggerRender();
} else if(posing_type == 1) { //scale
var ss = point_distance(posing_mx, posing_my, smx, smy) / posing_sx;
var ori = posing_bone.getHead();
var ang = point_direction(ori.x, ori.y, smx, smy);
var rot = ang - posing_sy - posing_bone.parent.pose_angle;
posing_input[TRANSFORM.sca_x] = ss;
posing_input[TRANSFORM.rot] = rot;
triggerRender();
} else if(posing_type == 2) { //rotate
var ori = posing_bone.getHead();
var ang = point_direction(ori.x, ori.y, mx, my);
var rot = angle_difference(ang, posing_sy);
posing_sy = ang;
posing_sx += rot;
posing_input[TRANSFORM.rot] = posing_sx;
triggerRender();
}
if(mouse_release(mb_left)) {
posing_bone = noone;
posing_type = noone;
UNDO_HOLDING = false;
}
}
if(anchor_selecting != noone && mouse_press(mb_left, active)) {
posing_bone = anchor_selecting[0];
if(!struct_has(attributes.bonePoseData, posing_bone.ID))
attributes.bonePoseData[$ posing_bone.ID] = [ 0, 0, 0, 1, 1 ];
posing_input = attributes.bonePoseData[$ posing_bone.ID];
if(anchor_selecting[1] == 0 || anchor_selecting[0].IKlength) { // move
posing_type = 0;
posing_sx = posing_input[TRANSFORM.pos_x];
posing_sy = posing_input[TRANSFORM.pos_y];
var _p = anchor_selecting[2];
posing_mx = _p.x;
posing_my = _p.y;
} else if(anchor_selecting[1] == 1) { // scale
posing_type = 1;
var ori = posing_bone.getHead();
posing_sx = posing_bone.length / posing_bone.pose_scale * posing_bone.parent.pose_scale;
posing_sy = posing_bone.angle - posing_bone.pose_local_angle;
posing_sz = point_direction(ori.x, ori.y, smx, smy);
var pnt = posing_bone.getHead();
posing_mx = pnt.x;
posing_my = pnt.y;
} else if(anchor_selecting[1] == 2) { // rotate
posing_type = 2;
var ori = posing_bone.getHead();
posing_sx = posing_input[TRANSFORM.rot];
posing_sy = point_direction(ori.x, ori.y, mx, my);
posing_mx = mx;
posing_my = my;
}
}
return;
}
var _boneArr = bone_posed.toArray();
for( var i = 0, n = array_length(_boneArr); i < n; i++ ) {
var _b = _boneArr[i];
var _l = attributes.rigBones == noone || array_exists(attributes.rigBones, _b.ID);
_b.__drawBoneUI(attributes, false, _x, _y, _s, _mx, _my, anchor_selecting, noone, c_white, 0.25 + _l * 0.75);
}
}
static AutoWeightPaint = function(_render = true) {
var _mesh = inputs[1].getValue();
var _rad = inputs[3].getValue();
if(!is(bone_posed, __Bone)) return;
if(!is(_mesh, MeshedSurface)) return;
rigdata = {};
var _boneArr = _bones.toArray();
var _boneDat = array_create(array_length(_boneArr));
var _pnts = _mesh.points;
var _plen = array_length(_pnts);
var _boneArr = bone_posed.toArray();
var _boneDat = [];
for( var i = 0, n = array_length(_boneArr); i < n; i++ ) {
var _b = _boneArr[i];
if(attributes.rigBones != noone && !array_exists(attributes.rigBones, _b.ID)) continue;
_boneDat[i] = {
array_push(_boneDat, {
b : _b,
ID : _b.ID,
p0 : _b.getPoint(0),
p1 : _b.getPoint(1),
};
}
p0 : _b.getHead(),
p1 : _b.getTail(),
});
var _pnts = _mesh.points;
rigdata[$ _b.ID] = array_create(_plen, 0);
}
for( var i = 0, n = array_length(_pnts); i < n; i++ ) {
var _p = _pnts[i];
if(!is(_p, MeshedPoint)) continue;
var _px = _p.x;
var _py = _p.y;
var _minDist = 9999;
var _minBone = noone;
var _boneWi = array_create(array_length(_boneDat), 0);
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);
_boneWi[j] = _dist;
if(_dist < _minDist) {
_minDist = _dist;
_minBone = _b;
_minBone = _b.ID;
}
}
if(_minBone == noone) continue;
if(_minDist >= _rad) {
rigdata[$ _minBone][i] = 1;
continue;
}
var _totalWeight = 0;
for( var j = 0, m = array_length(_boneDat); j < m; j++ ) {
_boneWi[j] = max(_rad - _boneWi[j], 0);
_totalWeight += _boneWi[j];
}
for( var j = 0, m = array_length(_boneDat); j < m; j++ ) {
_boneWi[j] /= _totalWeight;
var _b = _boneDat[j];
rigdata[$ _b.ID][i] = _boneWi[j];
}
}
if(_render) triggerRender();
}
current_bone = noone;
static update = function() {
var _bones = inputs[0].getValue();
var _mesh = inputs[1].getValue();
@ -77,10 +376,49 @@ function Node_Armature_Mesh_Rig(_x, _y, _group = noone) : Node(_x, _y, _group) c
if(!is(_bones, __Bone)) return;
if(!is(_mesh, MeshedSurface)) return;
var _map = ds_map_create();
bone_posed = _bones.clone();
current_bone = _bones;
bone_posed.connect();
bone_posed.resetPose();
var _barr = bone_posed.toArray();
for( var i = 0, n = array_length(_barr); i < n; i++ ) {
var _b = _barr[i];
_map[? _b.ID] = _b;
if(!struct_has(attributes.bonePoseData, _b.ID)) continue;
var _trn = attributes.bonePoseData[$ _b.ID];
_b.pose_posit = [ _trn[TRANSFORM.pos_x], _trn[TRANSFORM.pos_y] ];
_b.pose_angle = _trn[TRANSFORM.rot];
_b.pose_scale = _trn[TRANSFORM.sca_x];
}
bone_posed.setPose(,,, false);
if(rigdata == noone) AutoWeightPaint(false);
var _meshRigged = new RiggedMeshedSurface();
_meshRigged.mesh = _mesh;
_meshRigged.rigMap = rigdata;
_meshRigged.mesh = _mesh.clone();
_meshRigged.bone = bone_posed;
_meshRigged.boneMap = _map;
outputs[0].setValue(_meshRigged);
}
static getGraphPreviewSurface = function() { return noone; }
static getPreviewValues = function() {
var _mesh = inputs[1].getValue();
return is(_mesh, MeshedSurface)? _mesh.surface : noone;
}
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
var bbox = drawGetBbox(xx, yy, _s);
draw_sprite_fit(s_node_armature_mesh_rig, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
}
}

View file

@ -84,8 +84,8 @@ function Node_Armature_Path(_x, _y, _group = noone) : Node(_x, _y, _group) const
if(bone.IKlength) continue;
if(!bone.is_main) {
var _p0 = bone.getPoint(0);
var _p1 = bone.getPoint(1);
var _p0 = bone.getHead();
var _p1 = bone.getTail();
array_push(lines, [
[_p0.x, _p0.y, 1],

View file

@ -129,7 +129,7 @@ function Node_Armature_Pose(_x, _y, _group = noone) : Node(_x, _y, _group) const
} else if(posing_type == 1) { //scale
var ss = point_distance(posing_mx, posing_my, smx, smy) / posing_sx;
var ori = posing_bone.getPoint(0);
var ori = posing_bone.getHead();
var ang = point_direction(ori.x, ori.y, smx, smy);
var rot = ang - posing_sy - posing_bone.parent.pose_angle;
@ -141,7 +141,7 @@ function Node_Armature_Pose(_x, _y, _group = noone) : Node(_x, _y, _group) const
UNDO_HOLDING = true;
} else if(posing_type == 2) { //rotate
var ori = posing_bone.getPoint(0);
var ori = posing_bone.getHead();
var ang = point_direction(ori.x, ori.y, mx, my);
var rot = angle_difference(ang, posing_sy);
posing_sy = ang;
@ -162,11 +162,12 @@ function Node_Armature_Pose(_x, _y, _group = noone) : Node(_x, _y, _group) const
}
if(anchor_selecting != noone && mouse_press(mb_left, active)) {
if(anchor_selecting[1] == 0 || anchor_selecting[0].IKlength) { // move
posing_bone = anchor_selecting[0];
if(!ds_map_exists(boneMap, posing_bone.ID))
setBone();
if(!ds_map_exists(boneMap, posing_bone.ID)) setBone();
posing_input = boneMap[? posing_bone.ID];
if(anchor_selecting[1] == 0 || anchor_selecting[0].IKlength) { // move
posing_type = 0;
var val = posing_input.getValue();
@ -174,34 +175,28 @@ function Node_Armature_Pose(_x, _y, _group = noone) : Node(_x, _y, _group) const
posing_sy = val[TRANSFORM.pos_y];
var _p = anchor_selecting[2];
posing_mx = (_p.x - _x) / _s;
posing_my = (_p.y - _y) / _s;
posing_mx = _p.x;
posing_my = _p.y;
} else if(anchor_selecting[1] == 1) { // scale
posing_bone = anchor_selecting[0];
if(!ds_map_exists(boneMap, posing_bone.ID))
setBone();
posing_input = boneMap[? posing_bone.ID];
posing_type = 1;
var ori = posing_bone.getPoint(0);
var ori = posing_bone.getHead();
var val = posing_input.getValue();
posing_sx = posing_bone.length / posing_bone.pose_scale * posing_bone.parent.pose_scale;
posing_sy = posing_bone.angle - posing_bone.pose_local_angle;
posing_sz = point_direction(ori.x, ori.y, smx, smy);
var pnt = posing_bone.getPoint(0);
var pnt = posing_bone.getHead();
posing_mx = pnt.x;
posing_my = pnt.y;
} else if(anchor_selecting[1] == 2) { // rotate
posing_bone = anchor_selecting[0];
if(!ds_map_exists(boneMap, posing_bone.ID))
setBone();
posing_input = boneMap[? posing_bone.ID];
posing_type = 2;
var ori = posing_bone.getPoint(0);
var ori = posing_bone.getHead();
var val = posing_input.getValue();
posing_sx = val[TRANSFORM.rot];
posing_sy = point_direction(ori.x, ori.y, mx, my);
@ -232,8 +227,8 @@ function Node_Armature_Pose(_x, _y, _group = noone) : Node(_x, _y, _group) const
var _bone_pose = _b.clone();
_bone_pose.connect();
_bone_pose.resetPose();
var _bst = ds_stack_create();
ds_stack_push(_bst, _bone_pose);
@ -257,6 +252,7 @@ function Node_Armature_Pose(_x, _y, _group = noone) : Node(_x, _y, _group) const
}
ds_stack_destroy(_bst);
_bone_pose.setPose();
outputs[0].setValue(_bone_pose);
@ -278,8 +274,8 @@ function Node_Armature_Pose(_x, _y, _group = noone) : Node(_x, _y, _group) const
var __b = ds_stack_pop(_bst);
for( var i = 0, n = array_length(__b.childs); i < n; i++ ) {
var p0 = __b.childs[i].getPoint(0);
var p1 = __b.childs[i].getPoint(1);
var p0 = __b.childs[i].getHead();
var p1 = __b.childs[i].getTail();
minx = min(minx, p0.x); miny = min(miny, p0.y);
maxx = max(maxx, p0.x); maxy = max(maxy, p0.y);

View file

@ -1101,8 +1101,12 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
static isRenderable = function(log = false) { //Check if every input is ready (updated)
if(!active || !isRenderActive()) return false;
for(var j = 0; j < array_length(inputs); j++)
if(!inputs[j].isRendered()) return false;
for(var j = 0; j < array_length(inputs); j++) {
if(!inputs[j].isRendered()) {
LOG_IF(global.FLAG.render == 1, $"→→ x Node {internalName} {inputs[j]} not rendered.");
return false;
}
}
return true;
}
@ -1201,8 +1205,6 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
}
}
LOG_IF(global.FLAG.render == 1, $"→→ Push {nodeNames} to queue.");
LOG_BLOCK_END();
return nodes;
}
@ -1453,11 +1455,6 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
var tx = xx + 6 * _s;
var tw = w * _s - 8 * _s;
if(!previewable) {
tx += _s * 4;
tw -= _s * 4;
}
if(_panel && _panel.is_searching && _panel.search_string != "" && search_match == -9999)
aa *= .15;
@ -1482,8 +1479,6 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
BLEND_NORMAL
draw_set_alpha(1);
// draw_line_width(_tx, _ty, _tx + tw, _ty, 4);
}
static drawJunctionWidget = function(_x, _y, _mx, _my, _s, _hover, _focus) {

View file

@ -4,18 +4,33 @@ function MeshedSurface() constructor {
tris = [];
links = [];
controls = [];
static clone = function() {
var n = new MeshedSurface();
n.surface = surface;
n.controls = controls;
p = array_create_ext(array_length(points), function(i) /*=>*/ { return is(points[i], MeshedPoint)? points[i].clone() : points[i]; });
n.points = p;
var l = array_create_ext(array_length(links), function(i) /*=>*/ {return links[i].clone(p)});
n.links = l;
var t = array_create_ext(array_length(tris), function(i) /*=>*/ {return tris[i].clone(p)});
n.tris = t;
return n;
}
}
function MeshedPoint(node, index, _x, _y) constructor {
function MeshedPoint(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;
@ -26,6 +41,12 @@ function MeshedPoint(node, index, _x, _y) constructor {
u = 0;
v = 0;
drx = 0;
dry = 0;
weight = 0;
color = c_white;
controlWeights = [];
static reset = function(_mesh_data) {
@ -49,6 +70,8 @@ function MeshedPoint(node, index, _x, _y) constructor {
}
static draw = function(_x, _y, _s) {
draw_set_circle_precision(4);
if(pin) {
draw_set_color(COLORS._main_accent);
draw_circle_prec(_x + x * _s, _y + y * _s, 3, false);
@ -67,6 +90,14 @@ function MeshedPoint(node, index, _x, _y) constructor {
static setPin = function(pin) { self.pin = pin; }
static equal = function(point) { return x == point.x && y == point.y; }
static clone = function() {
var p = new MeshedPoint(index, x, y);
p.u = u;
p.v = v;
return p;
}
}
function MeshedLink(_p0, _p1, _k = 1) constructor {
@ -94,9 +125,15 @@ function MeshedLink(_p0, _p1, _k = 1) constructor {
static draw = function(_x, _y, _s) {
INLINE
draw_set_color(c_red);
draw_set_color(COLORS._main_accent);
draw_line(_x + p0.x * _s, _y + p0.y * _s, _x + p1.x * _s, _y + p1.y * _s);
}
static clone = function(pointArr) {
var _p0 = pointArr[p0.index];
var _p1 = pointArr[p1.index];
return new MeshedLink(_p0, _p1, k);
}
}
function MeshedTriangle(_p0, _p1, _p2) constructor {
@ -143,9 +180,16 @@ function MeshedTriangle(_p0, _p1, _p2) constructor {
static contain = function(p) {
INLINE
return p == p0 || p == p1 || p == p2;
}
static clone = function(pointArr) {
var _p0 = pointArr[p0.index];
var _p1 = pointArr[p1.index];
var _p2 = pointArr[p2.index];
return new MeshedTriangle(_p0, _p1, _p2);
}
}
function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
@ -497,7 +541,7 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
var px = min(j * gw, ww);
var py = min(i * gh, hh);
mesh_data.points[i * _sam + j] = new MeshedPoint(self, ind++, px, py);
mesh_data.points[i * _sam + j] = new MeshedPoint(i * _sam + j, px, py);
if(i == 0) continue;
if(j && mesh_data.points[(i - 1) * _sam + j] != 0 && mesh_data.points[i * _sam + j - 1] != 0)
@ -583,9 +627,10 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
mesh_data.points = array_create(_mb + array_length(_p));
for( var i = 0, n = _mb; i < n; i++ )
mesh_data.points[i] = new MeshedPoint(self, ind++, _m[i][0], _m[i][1]);
mesh_data.points[i] = new MeshedPoint(i, _m[i][0], _m[i][1]);
for( var i = 0, n = array_length(_p); i < n; i++ )
mesh_data.points[_mb + i] = new MeshedPoint(self, ind++, _p[i][0], _p[i][1]);
mesh_data.points[_mb + i] = new MeshedPoint(_mb + i, _p[i][0], _p[i][1]);
var _t = delaunay_triangulation(mesh_data.points);
@ -599,7 +644,7 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
}
}
static Mesh_build = function() {
static Mesh_build = function(_render = true) {
var _inSurf = getInputData(0);
var _type = getInputData(8);
@ -614,7 +659,7 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
for(var i = 0; i < array_length(mesh_data.tris); i++)
mesh_data.tris[i].initSurface(is_array(_inSurf)? _inSurf[0] : _inSurf);
triggerRender();
if(_render) triggerRender();
if(loadPin != noone) {
for( var i = 0, n = array_length(loadPin); i < n; i++ ) {
@ -709,7 +754,7 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
static processData = function(_outData, _data, _output_index, _array_index) {
if(will_triangluate) {
Mesh_build();
Mesh_build(false);
will_triangluate = false;
}

View file

@ -79,6 +79,7 @@ function Node_Pin(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
var jhov = hover.drawJunction(_s, _mx, _my);
if(!isHovering) return noone;
if(!jhov) draw_sprite_ext(THEME.view_pan, 0, _mx + ui(16), _my + ui(24), 1, 1, 0, COLORS._main_accent);
hover_junction = jhov? hover : noone;
hover_scale_to = 1;

View file

@ -865,6 +865,7 @@ function __initNodes() {
addNodeObject(compose, "Armature Pose", s_node_armature_pose, "Node_Armature_Pose", [1, Node_Armature_Pose], ["rigging", "bone"], "Pose armature system.").setVersion(1146);
addNodeObject(compose, "Armature Bind", s_node_armature_bind, "Node_Armature_Bind", [1, Node_Armature_Bind], ["rigging", "bone"], "Bind and render image to an armature system.").setVersion(1146);
addNodeObject(compose, "Armature Path", s_node_armature_path, "Node_Armature_Path", [1, Node_Armature_Path], ["rigging", "bone"], "Generate path from armature system.").setVersion(1146);
addNodeObject(compose, "Armature Mesh Rig", s_node_armature_mesh_rig, "Node_Armature_Mesh_Rig", [1, Node_Armature_Mesh_Rig], ["rigging", "bone"], "Rig mesh to armature system.").setVersion(1_18_04_0);
addNodeObject(compose, "Armature Sample", s_node_armature_sample, "Node_Armature_Sample", [1, Node_Armature_Sample], ["rigging", "bone"], "Sample point from armature system.").setVersion(1147);
if(!DEMO) {

View file

@ -201,9 +201,12 @@ function Node_Tunnel_In(_x, _y, _group = noone) : Node(_x, _y, _group) construct
isHovering = point_in_circle(_mx, _my, xx, yy, _s * 24);
junction_hover = inputs[1].drawJunction(_s, _mx, _my);
if(!isHovering) return noone;
if(!junction_hover) draw_sprite_ext(THEME.view_pan, 0, _mx + ui(16), _my + ui(24), 1, 1, 0, COLORS._main_accent);
hover_scale_to = 1;
return junction_hover? inputs[1] : noone;
}

View file

@ -126,7 +126,9 @@ function Node_Tunnel_Out(_x, _y, _group = noone) : Node(_x, _y, _group) construc
isHovering = point_in_circle(_mx, _my, xx, yy, _s * 24);
junction_hover = outputs[0].drawJunction(_s, _mx, _my);
if(!isHovering) return noone;
if(!junction_hover) draw_sprite_ext(THEME.view_pan, 0, _mx + ui(16), _my + ui(24), 1, 1, 0, COLORS._main_accent);
hover_scale_to = 1;
return junction_hover? outputs[0] : noone;

View file

@ -993,9 +993,11 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
extract_node = "Node_Canvas";
break;
case VALUE_TYPE.dynaSurface : editWidget = new surfaceDynaBox(); break;
case VALUE_TYPE.pathnode : editWidget = new pathnodeBox(self); extract_node = "Node_Path"; break;
case VALUE_TYPE.tileset : editWidget = new tilesetBox(self); extract_node = "Node_Tile_Tileset"; break;
case VALUE_TYPE.armature : editWidget = new armatureBox(self); break;
case VALUE_TYPE.mesh : editWidget = new meshBox(self); break;
case VALUE_TYPE.struct : editWidget = new outputStructBox(); break;
case VALUE_TYPE.particle : editWidget = noone; break;
@ -1022,7 +1024,6 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
static isRendered = function() {
if(type == VALUE_TYPE.node) return true;
if(value_from == noone) return true;
var controlNode = value_from.from? value_from.from : value_from.node;
@ -2464,7 +2465,7 @@ function drawJuncConnection(from, to, params) {
switch(PREFERENCES.curve_connection_line) {
case 0 :
if(downDirection) _hdist = distance_to_line(mx, my, jx, jy, frx, fry);
else _hdist = distance_to_linear_connection(mx, my, jx, jy, frx, fry, _s, _drawParam);
else _hdist = distance_to_linear_connection(mx, my, frx, fry, jx, jy, _s, _drawParam);
break;
case 1 :

View file

@ -4,24 +4,33 @@ function point_rotate(px, py, ox, oy, a, p = undefined) {
p ??= [ px, py ];
a = angle_difference(a, 0);
if(a == 0) {
p[0] = px;
p[1] = py;
return p;
}
if(a == 180) {
p[0] = ox + (ox - px);
p[1] = oy + (oy - py);
return p;
}
if(a == 0) { p[0] = px; p[1] = py; return p; }
else if(a == 180) { p[0] = ox + (ox - px); p[1] = oy + (oy - py); return p; }
var cx = px - ox;
var cy = py - oy;
var d = -degtorad(a);
p[0] = ox + cx * cos(d) - cy * sin(d);
p[1] = oy + cx * sin(d) + cy * cos(d);
var dc = dcos(-a);
var ds = dsin(-a);
p[0] = ox + cx * dc - cy * ds;
p[1] = oy + cx * ds + cy * dc;
return p;
}
function point_rotate_origin(px, py, a, p) {
INLINE
a = angle_difference(a, 0);
if(a == 0) { p[0] = px; p[1] = py; return p; }
else if(a == 180) { p[0] = -px; p[1] = -py; return p; }
var dc = dcos(-a);
var ds = dsin(-a);
p[0] = px * dc - py * ds;
p[1] = px * ds + py * dc;
return p;
}

View file

@ -243,6 +243,7 @@ function Render(partial = false, runAction = false) { #region
if(!is_instanceof(nextNode, __Node_Base)) continue;
if(!nextNode.isRenderable()) continue;
LOG_IF(global.FLAG.render == 1, $"→→ Push {nextNode.internalName} to queue.");
RENDER_QUEUE.enqueue(nextNode);
}

View file

@ -0,0 +1,51 @@
function surfaceDynaBox() : widget() constructor {
static trigger = function() {}
static setInteract = function(interactable) { }
static drawParam = function(params) {
return draw(params.x, params.y, params.w, params.h, params.data);
}
static draw = function(_x, _y, _w, _h, _surface) {
x = _x;
y = _y;
w = _w;
h = _h;
draw_sprite_stretched(THEME.textbox, 3, _x, _y, _w, _h);
if(!is(_surface, dynaSurf)) return h;
_surface = _surface.getSurfacePreview();
var pad = ui(12);
var sw = min(_w - pad, _h - pad);
var sh = sw;
var sx0 = _x + _w / 2 - sw / 2;
var sx1 = sx0 + sw;
var sy0 = _y + _h / 2 - sh / 2;
var sy1 = sy0 + sh;
ui_rect(sx0, sy0, sx1, sy1, COLORS.widget_surface_frame);
if(surface_exists(_surface)) {
var sfw = surface_get_width(_surface);
var sfh = surface_get_height(_surface);
var ss = min(sw / sfw, sh / sfh);
var _sx = sx0 + sw / 2 - ss * sfw / 2;
var _sy = sy0 + sh / 2 - ss * sfh / 2;
draw_surface_ext_safe(_surface, _sx, _sy, ss, ss, 0, c_white, 1);
}
resetFocus();
return h;
}
static clone = function() {
return new surfaceDynaBox();
}
}

View file

@ -0,0 +1,13 @@
{
"$GMScript":"v1",
"%Name":"surfaceDynaBox",
"isCompatibility":false,
"isDnD":false,
"name":"surfaceDynaBox",
"parent":{
"name":"widgets",
"path":"folders/widgets.yy",
},
"resourceType":"GMScript",
"resourceVersion":"2.0",
}

View file

@ -0,0 +1,12 @@
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform sampler2D base;
uniform sampler2D light;
void main() {
vec4 b = texture2D( base, v_vTexcoord );
vec4 l = texture2D( light, v_vTexcoord );
gl_FragColor = vec4(b.rgb + l.rgb, b.a);
}

View file

@ -0,0 +1,19 @@
//
// Simple passthrough vertex shader
//
attribute vec3 in_Position; // (x,y,z)
//attribute vec3 in_Normal; // (x,y,z) unused in this shader.
attribute vec4 in_Colour; // (r,g,b,a)
attribute vec2 in_TextureCoord; // (u,v)
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main()
{
vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0);
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos;
v_vColour = in_Colour;
v_vTexcoord = in_TextureCoord;
}

View file

@ -0,0 +1,12 @@
{
"$GMShader":"",
"%Name":"sh_2d_light_apply",
"name":"sh_2d_light_apply",
"parent":{
"name":"generator",
"path":"folders/shader/generator.yy",
},
"resourceType":"GMShader",
"resourceVersion":"2.0",
"type":1,
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 964 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 875 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 875 B

View file

@ -2,24 +2,24 @@
"$GMSprite":"",
"%Name":"s_bone_IK",
"bboxMode":0,
"bbox_bottom":47,
"bbox_left":0,
"bbox_right":47,
"bbox_top":0,
"bbox_bottom":45,
"bbox_left":2,
"bbox_right":45,
"bbox_top":2,
"collisionKind":1,
"collisionTolerance":0,
"DynamicTexturePage":false,
"edgeFiltering":false,
"For3D":false,
"frames":[
{"$GMSpriteFrame":"","%Name":"31c83e1e-8539-4edf-a5f1-82ed6726abb6","name":"31c83e1e-8539-4edf-a5f1-82ed6726abb6","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
{"$GMSpriteFrame":"","%Name":"8fdfbcea-ea77-48fd-ba17-e77e525adfc6","name":"8fdfbcea-ea77-48fd-ba17-e77e525adfc6","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
],
"gridX":0,
"gridY":0,
"height":48,
"HTile":false,
"layers":[
{"$GMImageLayer":"","%Name":"c522ca13-4db7-451f-8192-17561ae92385","blendMode":0,"displayName":"default","isLocked":false,"name":"c522ca13-4db7-451f-8192-17561ae92385","opacity":100.0,"resourceType":"GMImageLayer","resourceVersion":"2.0","visible":true,},
{"$GMImageLayer":"","%Name":"8d65c061-a3b2-4290-98d8-2d158525536d","blendMode":0,"displayName":"default","isLocked":false,"name":"8d65c061-a3b2-4290-98d8-2d158525536d","opacity":100.0,"resourceType":"GMImageLayer","resourceVersion":"2.0","visible":true,},
],
"name":"s_bone_IK",
"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":"31c83e1e-8539-4edf-a5f1-82ed6726abb6","path":"sprites/s_bone_IK/s_bone_IK.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",},
},"Disabled":false,"id":"3a2d3c50-7975-4295-b363-cad98cd4e44e","IsCreationKey":false,"Key":0.0,"Length":1.0,"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"2.0","Stretch":false,},
"0":{"$SpriteFrameKeyframe":"","Id":{"name":"8fdfbcea-ea77-48fd-ba17-e77e525adfc6","path":"sprites/s_bone_IK/s_bone_IK.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",},
},"Disabled":false,"id":"b67cb8f4-299a-4324-84ec-f9ee0a802602","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,

Binary file not shown.

After

Width:  |  Height:  |  Size: 471 B

View file

@ -0,0 +1,90 @@
{
"$GMSprite":"",
"%Name":"s_node_armature_mesh",
"bboxMode":0,
"bbox_bottom":15,
"bbox_left":0,
"bbox_right":15,
"bbox_top":0,
"collisionKind":1,
"collisionTolerance":0,
"DynamicTexturePage":false,
"edgeFiltering":false,
"For3D":false,
"frames":[
{"$GMSpriteFrame":"","%Name":"4c4d464f-55b1-43f1-83f6-9e5cb7313927","name":"4c4d464f-55b1-43f1-83f6-9e5cb7313927","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
],
"gridX":0,
"gridY":0,
"height":16,
"HTile":false,
"layers":[
{"$GMImageLayer":"","%Name":"184ef4b6-61c4-4d63-ab62-a234177c7aed","blendMode":0,"displayName":"default","isLocked":false,"name":"184ef4b6-61c4-4d63-ab62-a234177c7aed","opacity":100.0,"resourceType":"GMImageLayer","resourceVersion":"2.0","visible":true,},
],
"name":"s_node_armature_mesh",
"nineSlice":null,
"origin":4,
"parent":{
"name":"nodes",
"path":"folders/sprites/nodes.yy",
},
"preMultiplyAlpha":false,
"resourceType":"GMSprite",
"resourceVersion":"2.0",
"sequence":{
"$GMSequence":"",
"%Name":"s_node_armature_mesh",
"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_armature_mesh",
"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":"4c4d464f-55b1-43f1-83f6-9e5cb7313927","path":"sprites/s_node_armature_mesh/s_node_armature_mesh.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",},
},"Disabled":false,"id":"13f8b5ba-8fba-4554-875b-7b57ecd738a7","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":8,
"yorigin":8,
},
"swatchColours":null,
"swfPrecision":0.5,
"textureGroupId":{
"name":"Default",
"path":"texturegroups/Default",
},
"type":0,
"VTile":false,
"width":16,
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View file

@ -0,0 +1,90 @@
{
"$GMSprite":"",
"%Name":"s_node_armature_mesh_rig",
"bboxMode":0,
"bbox_bottom":57,
"bbox_left":3,
"bbox_right":60,
"bbox_top":6,
"collisionKind":1,
"collisionTolerance":0,
"DynamicTexturePage":false,
"edgeFiltering":false,
"For3D":false,
"frames":[
{"$GMSpriteFrame":"","%Name":"cada5ad0-5cc6-4a4f-9e92-a41fdaa5bfea","name":"cada5ad0-5cc6-4a4f-9e92-a41fdaa5bfea","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
],
"gridX":0,
"gridY":0,
"height":64,
"HTile":false,
"layers":[
{"$GMImageLayer":"","%Name":"4c6f6f4a-829e-4a0f-896e-f2402548b091","blendMode":0,"displayName":"default","isLocked":false,"name":"4c6f6f4a-829e-4a0f-896e-f2402548b091","opacity":100.0,"resourceType":"GMImageLayer","resourceVersion":"2.0","visible":true,},
],
"name":"s_node_armature_mesh_rig",
"nineSlice":null,
"origin":4,
"parent":{
"name":"transform",
"path":"folders/nodes/icons/transform.yy",
},
"preMultiplyAlpha":false,
"resourceType":"GMSprite",
"resourceVersion":"2.0",
"sequence":{
"$GMSequence":"",
"%Name":"s_node_armature_mesh_rig",
"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_armature_mesh_rig",
"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":"cada5ad0-5cc6-4a4f-9e92-a41fdaa5bfea","path":"sprites/s_node_armature_mesh_rig/s_node_armature_mesh_rig.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",},
},"Disabled":false,"id":"02143a61-9a30-4973-8167-8a8223d0d4d2","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,
}