This commit is contained in:
Tanasart 2023-06-25 20:12:17 +02:00
parent 979c9b28a0
commit 95384584ab
19 changed files with 506 additions and 281 deletions

View file

@ -100,6 +100,7 @@
{"name":"transform","order":8,"path":"folders/nodes/data/transform.yy",},
{"name":"value","order":3,"path":"folders/nodes/data/value.yy",},
{"name":"atlas","order":9,"path":"folders/nodes/data/value/atlas.yy",},
{"name":"buffer","order":11,"path":"folders/nodes/data/value/buffer.yy",},
{"name":"mesh","order":7,"path":"folders/nodes/data/value/mesh.yy",},
{"name":"struct","order":6,"path":"folders/nodes/data/value/struct.yy",},
{"name":"surface","order":10,"path":"folders/nodes/data/value/surface.yy",},
@ -126,6 +127,7 @@
{"name":"number","order":47,"path":"folders/nodes/icons/value/number.yy",},
{"name":"path","order":48,"path":"folders/nodes/icons/value/path.yy",},
{"name":"struct","order":50,"path":"folders/nodes/icons/value/struct.yy",},
{"name":"surface","order":53,"path":"folders/nodes/icons/value/surface.yy",},
{"name":"texts","order":49,"path":"folders/nodes/icons/value/texts.yy",},
{"name":"VFX","order":134,"path":"folders/nodes/icons/VFX.yy",},
{"name":"panels","order":2,"path":"folders/panels.yy",},
@ -161,8 +163,6 @@
{"name":"gameframe","order":2,"path":"folders/sprites/gameframe.yy",},
{"name":"misc","order":3,"path":"folders/sprites/misc.yy",},
{"name":"widgets","order":5,"path":"folders/widgets.yy",},
{"name":"surface","order":53,"path":"folders/nodes/icons/value/surface.yy",},
{"name":"buffer","order":11,"path":"folders/nodes/data/value/buffer.yy",},
],
"ResourceOrderSettings": [
{"name":"s_node_corner","order":16,"path":"sprites/s_node_corner/s_node_corner.yy",},
@ -1032,6 +1032,7 @@
{"name":"node_websocket_sender","order":1,"path":"scripts/node_websocket_sender/node_websocket_sender.yy",},
{"name":"fd_rectangle_get_acceleration_b","order":1,"path":"scripts/fd_rectangle_get_acceleration_b/fd_rectangle_get_acceleration_b.yy",},
{"name":"surface_draw_functions","order":7,"path":"scripts/surface_draw_functions/surface_draw_functions.yy",},
{"name":"sh_default","order":6,"path":"shaders/sh_default/sh_default.yy",},
{"name":"BBMOD_Matrix","order":2,"path":"scripts/BBMOD_Matrix/BBMOD_Matrix.yy",},
{"name":"pack_shelf","order":1,"path":"scripts/pack_shelf/pack_shelf.yy",},
{"name":"s_node_path_trim","order":6,"path":"sprites/s_node_path_trim/s_node_path_trim.yy",},

View file

@ -128,6 +128,7 @@
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"array","folderPath":"folders/nodes/data/value/array.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"atlas","folderPath":"folders/nodes/data/value/atlas.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"bool","folderPath":"folders/nodes/data/value/bool.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"buffer","folderPath":"folders/nodes/data/value/buffer.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"color","folderPath":"folders/nodes/data/value/color.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"mesh","folderPath":"folders/nodes/data/value/mesh.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"number","folderPath":"folders/nodes/data/value/number.yy",},
@ -158,6 +159,7 @@
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"number","folderPath":"folders/nodes/icons/value/number.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"path","folderPath":"folders/nodes/icons/value/path.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"struct","folderPath":"folders/nodes/icons/value/struct.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"surface","folderPath":"folders/nodes/icons/value/surface.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"texts","folderPath":"folders/nodes/icons/value/texts.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"VFX","folderPath":"folders/nodes/icons/VFX.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"panels","folderPath":"folders/panels.yy",},
@ -197,8 +199,6 @@
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"Steamworks","folderPath":"folders/Steamworks.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"UGC","folderPath":"folders/Steamworks/UGC.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"widgets","folderPath":"folders/widgets.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"surface","folderPath":"folders/nodes/icons/value/surface.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"buffer","folderPath":"folders/nodes/data/value/buffer.yy",},
],
"IncludedFiles": [
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"ApolloHelp.html","ConfigValues":{"Itch":{"CopyToMask":"0",},},"CopyToMask":-1,"filePath":"datafiles",},
@ -217,6 +217,7 @@
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"UI.json","CopyToMask":-1,"filePath":"datafiles/data/locale/en",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"words.json","CopyToMask":-1,"filePath":"datafiles/data/locale/en",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"nodes.json","CopyToMask":-1,"filePath":"datafiles/data",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"default x2.zip","CopyToMask":-1,"filePath":"datafiles/data/themes",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"default.zip","CopyToMask":-1,"filePath":"datafiles/data/themes",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"FiraCode-Medium.ttf","CopyToMask":-1,"filePath":"datafiles/data/themes/default/fonts",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"fonts.json","CopyToMask":-1,"filePath":"datafiles/data/themes/default/fonts",},
@ -351,6 +352,7 @@
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_slider.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_sort_24.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_star.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_steam_1.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_steam_creator.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_steam.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_strandSim.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
@ -375,6 +377,8 @@
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_workshop_download.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_workshop_update.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_workshop_upload.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_workspace_0.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_workspace_1.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_youtube.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"graphics x2.ai","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/inspector",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_inspector_area_strip2.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/inspector",},
@ -1616,6 +1620,7 @@
{"id":{"name":"node_websocket_sender","path":"scripts/node_websocket_sender/node_websocket_sender.yy",},},
{"id":{"name":"fd_rectangle_get_acceleration_b","path":"scripts/fd_rectangle_get_acceleration_b/fd_rectangle_get_acceleration_b.yy",},},
{"id":{"name":"surface_draw_functions","path":"scripts/surface_draw_functions/surface_draw_functions.yy",},},
{"id":{"name":"sh_default","path":"shaders/sh_default/sh_default.yy",},},
{"id":{"name":"BBMOD_Matrix","path":"scripts/BBMOD_Matrix/BBMOD_Matrix.yy",},},
{"id":{"name":"pack_shelf","path":"scripts/pack_shelf/pack_shelf.yy",},},
{"id":{"name":"s_node_path_trim","path":"sprites/s_node_path_trim/s_node_path_trim.yy",},},

Binary file not shown.

Binary file not shown.

View file

@ -380,7 +380,7 @@ event_inherited();
var spr_y = yy + grid_size / 2;
if(variable_struct_exists(_node, "getSpr")) _node.getSpr();
if(sprite_exists(_node.spr)) draw_sprite_ui_uniform(_node.spr, 0, spr_x, spr_y);
if(sprite_exists(_node.spr)) draw_sprite_ui_uniform(_node.spr, 0, spr_x, spr_y, 0.5);
if(_node.getTooltip() != "") {
if(point_in_rectangle(_m[0], _m[1], _boxx, yy, _boxx + ui(16), yy + ui(16))) {

View file

@ -32,7 +32,7 @@ event_inherited();
x1 = dialog_x + dialog_w - ui(16);
sp_sample.resize(x1 - x0 - ui(12), y1 - y0);
sp_contest.resize(x1 - x0 - ui(12), y1 - y0);
sp_contest.resize(x1 - x0 - ui(12), y1 - y0 - 2);
}
var x0 = dialog_x + ui(16);
@ -167,7 +167,7 @@ event_inherited();
var sw = sprite_get_width(spr);
var sh = sprite_get_height(spr);
var s = min(gw / sw, gh / sh) * 2;
var s = min(gw / sw, gh / sh);
var ox = (sprite_get_xoffset(spr) - sw / 2) * s / 2;
var oy = (sprite_get_yoffset(spr) - sh / 2) * s / 2;
@ -224,7 +224,7 @@ event_inherited();
contest_viewing = noone;
sp_contest = new scrollPane(x1 - x0 - ui(12), y1 - y0, function(_y, _m) {
sp_contest = new scrollPane(x1 - x0 - ui(12), y1 - y0 - 2, function(_y, _m) {
draw_clear_alpha(COLORS.panel_bg_clear_inner, 0);
var hh = 0;

View file

@ -159,13 +159,13 @@ if !ready exit;
if(!expand) {
draw_set_text(f_p1, fa_right, fa_bottom, COLORS._main_text_sub);
draw_text(x1 - ui(82), y0 - ui(4), __txt("Art by") + " ");
draw_sprite_ui_uniform(s_kenney, 0, x1, y0 - ui(4), 2, c_white, 0.5);
draw_sprite_ui_uniform(s_kenney, 0, x1, y0 - ui(4),, c_white, 0.5);
}
break;
case "Workshop" :
sp_sample.setFocusHover(sFOCUS, sHOVER);
sp_sample.draw(x0 + ui(6), y0);
var bx = x1 - ui(32);
var by = y0 - ui(32);
@ -178,7 +178,7 @@ if !ready exit;
break;
case "Contests" :
sp_contest.setFocusHover(sFOCUS, sHOVER);
sp_contest.draw(x0 + ui(6), y0);
sp_contest.draw(x0 + ui(6), y0 + 1);
break;
}

View file

@ -1,5 +1,5 @@
/// @description
if(async_load[? "id"] == contest_req) {
if(async_load[? "id"] == contest_req) { //get contests
var r_str = async_load[? "result"];
if(is_undefined(r_str)) return;
@ -10,8 +10,10 @@ if(async_load[? "id"] == contest_req) {
for( var i = 0; i < array_length(thrs); i++ ) {
var thr = thrs[i];
if(thr.parent_id != "1113080578351312906") continue;
if(struct_has(thr, "applied_tags") && array_exists(thr.applied_tags, "1113145223938326658")) continue;
if(thr.parent_id != "1113080578351312906") continue; //not in contest channel
if(struct_has(thr, "flags") && thr.flags & 2) continue;
if(struct_has(thr, "applied_tags") && array_exists(thr.applied_tags, "1113145223938326658")) continue; //has announcement tag
thr.messages = [];
array_push(contests, thr);

View file

@ -1,10 +1,11 @@
function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length = 0, attributes = {}) constructor {
function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length = 0, attributes = {}, node = noone) constructor {
id = UUID_generate();
self.name = "New bone";
self.distance = distance;
self.direction = direction;
self.angle = angle;
self.length = length;
self.node = node;
pose_angle = 0;
pose_scale = 1;
@ -14,13 +15,19 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length =
self.parent_anchor = true;
self.childs = [];
tb_name = new textBox(TEXTBOX_INPUT.text, function(_name) { name = _name; });
tb_name = new textBox(TEXTBOX_INPUT.text,
function(_name) {
name = _name;
if(node) node.triggerRender();
});
tb_name.font = f_p2;
tb_name.hide = true;
self.attributes = attributes;
updated = false;
IKlength = 0;
freeze_data = {};
self.parent = parent;
@ -54,25 +61,30 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length =
childs[i].freeze();
}
static getPoint = function(distance, direction) {
static getPoint = function(progress) {
var len = length * progress;
if(parent == noone)
return new Point(lengthdir_x(self.distance, self.direction), lengthdir_y(self.distance, self.direction))
.add(lengthdir_x( distance, direction), lengthdir_y( distance, direction));
return new Point(lengthdir_x(distance, direction), lengthdir_y(distance, direction))
.add(lengthdir_x(len, angle), lengthdir_y(len, angle));
if(parent_anchor) {
var p = parent.getPoint(parent.length, parent.angle);
return p.add(lengthdir_x(distance, direction), lengthdir_y(distance, direction));
var p = parent.getPoint(1)
.add(lengthdir_x(len, angle), lengthdir_y(len, angle))
return p;
}
var p = parent.getPoint(self.distance, self.direction);
return p.add(lengthdir_x(distance, direction), lengthdir_y(distance, direction));
var p = parent.getPoint(0)
.add(lengthdir_x(distance, direction), lengthdir_y(distance, direction))
.add(lengthdir_x(len, angle), lengthdir_y(len, angle))
return p;
}
static draw = function(edit = false, _x = 0, _y = 0, _s = 1, _mx = 0, _my = 0, child = true, hovering = noone) {
var hover = noone;
var p0 = getPoint(0, 0);
var p1 = getPoint(length, angle);
var p0 = getPoint(0);
var p1 = getPoint(1);
p0.x = _x + p0.x * _s;
p0.y = _y + p0.y * _s;
@ -80,26 +92,30 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length =
p1.y = _y + p1.y * _s;
if(parent != noone) {
var aa = (hovering != noone && hovering[0] == self && hovering[1] == 2)? 1 : 0.75;
draw_set_color(COLORS._main_accent);
var _boneHover = hovering != noone && hovering[0] == self && hovering[1] == 2;
var aa = _boneHover? 1 : 0.75;
draw_set_color(_boneHover? c_white : COLORS._main_accent);
if(!parent_anchor && parent.parent != noone) {
var _p = parent.getPoint(0, 0);
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);
}
draw_set_alpha(aa);
draw_line_width2(p0.x, p0.y, p1.x, p1.y, 6, 2);
var _ppx = lerp(p0.x, p1.x, 0.2);
var _ppy = lerp(p0.y, p1.y, 0.2);
draw_line_width2(p0.x, p0.y, _ppx, _ppy, 2, 12);
draw_line_width2(_ppx, _ppy, p1.x, p1.y, 12, 2);
draw_set_alpha(1.00);
if(attributes.display_name) {
if(abs(p0.y - p1.y) < abs(p0.x - p1.x)) {
draw_set_text(f_p2, fa_center, fa_bottom, COLORS._main_accent);
draw_text((p0.x + p1.x) / 2, (p0.y + p1.y) / 2 - 4, name);
draw_text_add((p0.x + p1.x) / 2, (p0.y + p1.y) / 2 - 4, name);
} else {
draw_set_text(f_p2, fa_left, fa_center, COLORS._main_accent);
draw_text((p0.x + p1.x) / 2 + 4, (p0.y + p1.y) / 2, name);
draw_text_add((p0.x + p1.x) / 2 + 4, (p0.y + p1.y) / 2, name);
}
}
@ -107,20 +123,26 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length =
hover = [ self, 2 ];
if(!parent_anchor) {
if(edit && point_in_circle(_mx, _my, p0.x, p0.y, ui(20))) { //drag head
if(edit && point_in_circle(_mx, _my, p0.x, p0.y, ui(16))) { //drag head
draw_sprite_colored(THEME.anchor_selector, 0, p0.x, p0.y);
hover = [ self, 0 ];
} else
draw_sprite_colored(THEME.anchor_selector, 2, p0.x, p0.y);
}
if(edit && point_in_circle(_mx, _my, p1.x, p1.y, ui(20))) { //drag tail
if(edit && point_in_circle(_mx, _my, p1.x, p1.y, ui(16))) { //drag tail
draw_sprite_colored(THEME.anchor_selector, 0, p1.x, p1.y);
hover = [ self, 1 ];
} else
draw_sprite_colored(THEME.anchor_selector, 2, p1.x, p1.y);
}
//var ph = getPoint(0.5);
//ph.x = _x + ph.x * _s;
//ph.y = _y + ph.y * _s;
//draw_set_color(COLORS._main_accent);
//draw_circle(ph.x, ph.y, 4, false);
if(child)
for( var i = 0; i < array_length(childs); i++ ) {
var h = childs[i].draw(edit, _x, _y, _s, _mx, _my, true, hovering);
@ -131,25 +153,6 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length =
return hover;
}
static drawInspector = function(_x, _y, _w, _m, _hover, _focus) {
var _h = ui(28);
//draw_sprite_stretched(THEME.node_bg, 0, _x, _y, _w, _h);
draw_sprite_ui(THEME.bone, 0, _x + 12, _y + 12,,,, COLORS._main_icon);
tb_name.setFocusHover(_focus, _hover);
tb_name.draw(_x + 24, _y + 2, _w - 24 - 8, _h - 4, name, _m);
_y += _h;
draw_set_color(COLORS.node_composite_separator);
draw_line(_x + 16, _y, _x + _w - 16, _y);
for( var i = 0; i < array_length(childs); i++ )
_y = childs[i].drawInspector(_x + ui(16), _y, _w - ui(16), _m, _hover, _focus);
return _y;
}
static resetPose = function() {
pose_angle = 0;
pose_scale = 1;
@ -160,16 +163,21 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length =
}
static setPose = function(_position = [ 0, 0 ], _angle = 0, _scale = 1) {
setPoseTransform(_position, _angle, _scale);
setIKconstrain();
}
static setPoseTransform = function(_position = [ 0, 0 ], _angle = 0, _scale = 1) {
if(is_main) {
for( var i = 0; i < array_length(childs); i++ )
childs[i].setPose(_position, _angle, _scale);
childs[i].setPoseTransform(_position, _angle, _scale);
return;
}
pose_posit[0] += _position[0];
pose_posit[1] += _position[1];
pose_angle += _angle;
//pose_scale = _scale;
pose_scale *= _scale;
var _x = lengthdir_x(distance, direction) + pose_posit[0];
var _y = lengthdir_y(distance, direction) + pose_posit[1];
@ -180,8 +188,16 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length =
angle += pose_angle;
length *= pose_scale;
for( var i = 0; i < array_length(childs); i++ )
childs[i].setPose(_position, _angle, _scale);
for( var i = 0; i < array_length(childs); i++ ) {
if(childs[i].parent_anchor)
childs[i].setPoseTransform(_position, pose_angle, pose_scale);
else
childs[i].setPoseTransform(_position, pose_angle, pose_scale);
}
}
static setIKconstrain = function() {
}
static serialize = function() {
@ -204,22 +220,23 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length =
return bone;
}
static deserialize = function(bone, attributes) {
static deserialize = function(bone, attributes, node) {
id = bone.id;
name = bone.name;
distance = bone.distance;
direction = bone.direction;
angle = bone.angle;
length = bone.length;
is_main = bone.is_main;
parent_anchor = bone.parent_anchor;
self.attributes = attributes;
self.node = node;
childs = [];
for( var i = 0; i < array_length(bone.childs); i++ ) {
var _b = new __Bone().deserialize(bone.childs[i], attributes);
var _b = new __Bone().deserialize(bone.childs[i], attributes, node);
addChild(_b);
}
@ -232,6 +249,7 @@ function __Bone(parent = noone, distance = 0, direction = 0, angle = 0, length =
_b.name = name;
_b.is_main = is_main;
_b.parent_anchor = parent_anchor;
_b.IKlength = IKlength;
for( var i = 0; i < array_length(childs); i++ )
_b.addChild(childs[i].clone(attributes));

View file

@ -38,7 +38,7 @@ function draw_sprite_uniform(spr, ind, _x, _y, scale, color = c_white) {
}
function draw_sprite_ui(spr, ind, _x, _y, xscale = 1, yscale = 1, rot = 0, color = c_white, alpha = 1) {
var UI_SPRITE_SCALE = 2;
static UI_SPRITE_SCALE = 1;
var xscale_ui = ui(xscale) / UI_SPRITE_SCALE;
var yscale_ui = ui(yscale) / UI_SPRITE_SCALE;

View file

@ -33,8 +33,8 @@
VERSION = 1146;
SAVEFILE_VERSION = 1440;
VERSION_STRING = "1.14.5n3";
BUILD_NUMBER = 114503;
VERSION_STRING = "1.14.5n4";
BUILD_NUMBER = 114504;
globalvar NODES, NODE_MAP, APPEND_MAP, NODE_NAME_MAP;
globalvar HOTKEYS, HOTKEY_CONTEXT, NODE_INSTANCES;

View file

@ -1,30 +1,76 @@
function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Armature Create";
w = 96;
h = 72;
min_h = h;
//inputs[| 0] = nodeValue("Axis", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0);
bone_renderer = new Inspector_Custom_Renderer(function(_x, _y, _w, _m, _hover, _focus) {
var _b = attributes.bones;
if(_b == noone) return 0;
var amo = _b.childCount();
var _h = ui(32 + 16) + amo * ui(28);
var __y = _y;
var _hh = ui(28);
var bh = ui(32 + 16) + amo * _hh;
var ty = _y;
draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text);
draw_text_add(_x + ui(16), _y + ui(4), "Bones");
draw_text_add(_x + ui(16), ty + ui(4), "Bones");
ty += ui(32);
_y += ui(32);
draw_sprite_stretched_ext(THEME.ui_panel_bg, 1, _x, _y, _w, _h - ui(32), COLORS.node_composite_bg_blend, 1);
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, _y + ui(8), _x + _w - 16, _y + ui(8));
draw_line(_x + 16, ty + ui(8), _x + _w - 16, ty + ui(8));
_y += ui(8);
ty += ui(8);
for( var i = 0; i < array_length(_b.childs); i++ ) {
_y = _b.childs[i].drawInspector(_x + ui(8), _y, _w - ui(16), _m, _hover, _focus);
var hovering = noone;
var _bst = ds_stack_create();
ds_stack_push(_bst, [ _b, _x, _w ]);
while(!ds_stack_empty(_bst)) {
var _st = ds_stack_pop(_bst);
var bone = _st[0];
var __x = _st[1];
var __w = _st[2];
if(!bone.is_main) {
if(bone.parent_anchor)
draw_sprite_ui(THEME.bone, 1, __x + 12, ty + 12,,,, COLORS._main_icon);
else {
if(_hover && point_in_circle(_m[0], _m[1], __x + 12, ty + 12, 12)) {
draw_sprite_ui(THEME.bone, 0, __x + 12, ty + 12,,,, COLORS._main_icon_light);
if(mouse_press(mb_left, _focus))
bone_dragging = bone;
} else
draw_sprite_ui(THEME.bone, 0, __x + 12, ty + 12,,,, COLORS._main_icon);
}
draw_set_text(f_p2, fa_left, fa_center, COLORS._main_text);
draw_text(__x + 24, ty + 12, bone.name);
//if(bone_dragging != noone && point_in_rectangle(_m[0], _m[1], _x, ty, _x + _w, ty + _hh - 1)) {
// draw_sprite_stretched_ext(THEME.ui_panel_active, 0, _x, ty, _w, _hh, COLORS._main_accent, 1);
// hovering = bone;
//}
ty += _hh;
draw_set_color(COLORS.node_composite_separator);
draw_line(_x + 16, ty, _x + _w - 16, ty);
}
for( var i = 0; i < array_length(bone.childs); i++ )
ds_stack_push(_bst, [ bone.childs[i], __x + 16, __w - 16 ]);
}
return _h;
ds_stack_destroy(_bst);
if(bone_dragging && mouse_release(mb_left))
bone_dragging = noone;
return bh;
})
input_display_list = [
@ -35,7 +81,7 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
data_length = 1;
static createBone = function(parent, distance, direction) {
var bone = new __Bone(parent, distance, direction,,, attributes);
var bone = new __Bone(parent, distance, direction,,, attributes, self);
parent.addChild(bone);
if(parent == attributes.bones)
@ -45,10 +91,10 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
outputs[| 0] = nodeValue("Armature", self, JUNCTION_CONNECT.output, VALUE_TYPE.armature, noone);
attributes.bones = new __Bone(,,,,, attributes);
attributes.bones = new __Bone(,,,,, attributes, self);
attributes.bones.name = "Main";
attributes.bones.is_main = true;
bone_update = false;
attributes.bones.node = self;
attributes.display_name = true;
array_push(attributeEditors, ["Display name", "display_name",
@ -61,6 +107,7 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
new NodeTool( "Add bones", THEME.bone_tool_add ),
new NodeTool( "Remove bones", THEME.bone_tool_remove ),
new NodeTool( "Detach bones", THEME.bone_tool_detach ),
new NodeTool( "IK", THEME.bone_tool_detach ),
];
anchor_selecting = noone;
@ -71,6 +118,8 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
builder_mx = 0;
builder_my = 0;
bone_dragging = noone;
moving = false;
scaling = false;
@ -81,7 +130,7 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
var _b = attributes.bones;
if(isUsingTool(0)) { //transform
attributes.bones.draw(active, _x, _y, _s, _mx, _my);
attributes.bones.draw(false, _x, _y, _s, _mx, _my);
var _bst = ds_stack_create();
ds_stack_push(_bst, _b);
@ -95,8 +144,8 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
var __b = ds_stack_pop(_bst);
if(!__b.is_main) {
var p0 = __b.getPoint(0, 0);
var p1 = __b.getPoint(__b.length, __b.angle);
var p0 = __b.getPoint(0);
var p1 = __b.getPoint(1);
minx = min(minx, p0.x);
miny = min(miny, p0.y);
@ -187,6 +236,8 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
draw_set_color(COLORS._main_accent);
draw_rectangle_border(minx, miny, maxx, maxy, hvMv);
triggerRender();
return;
}
@ -201,8 +252,8 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
var dis = point_distance(builder_sx, builder_sy, mx, my);
if(builder_type == 2) {
var bx = builder_sx + (mx - builder_mx) / _s;
var by = builder_sy + (my - builder_my) / _s;
var bx = builder_sx + (mx - builder_mx);
var by = builder_sy + (my - builder_my);
if(!builder_bone.parent_anchor) {
builder_bone.direction = point_direction(0, 0, bx, by);
@ -210,12 +261,12 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
}
} else if(key_mod_press(ALT)) {
if(builder_type == 0) {
var bo = builder_bone.getPoint(builder_bone.length, builder_bone.angle);
var bo = builder_bone.getPoint(1);
builder_bone.direction = dir;
builder_bone.distance = dis;
var bn = builder_bone.getPoint(0, 0);
var bn = builder_bone.getPoint(0);
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);
@ -223,7 +274,7 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
var chs = [];
for( var i = 0; i < array_length(builder_bone.childs); i++ ) {
var ch = builder_bone.childs[i];
chs[i] = ch.getPoint(ch.length, ch.angle);
chs[i] = ch.getPoint(1);
}
builder_bone.angle = dir;
@ -231,7 +282,7 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
for( var i = 0; i < array_length(builder_bone.childs); i++ ) {
var ch = builder_bone.childs[i];
var c0 = ch.getPoint(0, 0);
var c0 = ch.getPoint(0);
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);
@ -241,6 +292,15 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
if(builder_type == 0) {
builder_bone.direction = dir;
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;
if(!builder_bone.parent.is_main && point_in_circle(_mx, _my, par_anc.x, par_anc.y, 16) && mouse_release(mb_left))
builder_bone.parent_anchor = true;
}
} else if(builder_type == 1) {
builder_bone.angle = dir;
builder_bone.length = dis;
@ -251,6 +311,8 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
builder_bone = noone;
UNDO_HOLDING = false;
}
triggerRender();
}
if(isUsingTool(1)) { // builder
@ -269,7 +331,7 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
UNDO_HOLDING = true;
} else if(anchor_selecting[1] == 2) {
var _pr = anchor_selecting[0];
var _md = new __Bone(noone, 0, 0, _pr.angle, _pr.length / 2, attributes);
var _md = new __Bone(noone, 0, 0, _pr.angle, _pr.length / 2, attributes, self);
_pr.length = _md.length;
for( var i = 0; i < array_length(_pr.childs); i++ )
@ -278,10 +340,17 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
_pr.childs = [];
_pr.addChild(_md);
bone_update = true;
UNDO_HOLDING = true;
}
}
if(anchor_selecting == noone)
draw_sprite_ext(THEME.bone_tool_add, 1, _mx + 24, _my + 24, 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);
} else if(isUsingTool(2)) { //remover
if(anchor_selecting != noone && anchor_selecting[0].parent != noone && mouse_press(mb_left, active)) {
var _bone = anchor_selecting[0];
@ -293,38 +362,47 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
for( var i = 0; i < array_length(_bone.childs); i++ ) {
var _ch = _bone.childs[i];
_par.addChild(_ch);
_ch.parent_anchor = _bone.parent_anchor;
}
bone_update = true;
triggerRender();
}
}
} else if(isUsingTool(2)) { //detach
if(anchor_selecting != noone && anchor_selecting[0].parent_anchor && anchor_selecting[1] == 2 && mouse_press(mb_left, active)) {
if(anchor_selecting != noone)
draw_sprite_ext(THEME.bone_tool_remove, 1, _mx + 24, _my + 24, 1, 1, 0, c_white, 1);
} else if(isUsingTool(3)) { //detach
if(anchor_selecting != noone && anchor_selecting[1] == 2 && mouse_press(mb_left, active)) {
builder_bone = anchor_selecting[0];
builder_type = anchor_selecting[1];
var par = builder_bone.parent;
if(builder_bone.parent_anchor) {
builder_bone.distance = par.length;
builder_bone.direction = par.angle;
}
builder_bone.parent_anchor = false;
builder_bone.distance = par.length;
builder_bone.direction = par.angle;
builder_sx = lengthdir_x(par.length, par.angle);
builder_sy = lengthdir_y(par.length, par.angle);
builder_sx = lengthdir_x(builder_bone.distance, builder_bone.direction);
builder_sy = lengthdir_y(builder_bone.distance, builder_bone.direction);
builder_mx = mx;
builder_my = my;
UNDO_HOLDING = true;
}
} else if(isUsingTool(3) || isNotUsingTool()) { //mover
} else if(isUsingTool(4)) { //IK
} else if(isNotUsingTool()) { //mover
if(anchor_selecting != noone && mouse_press(mb_left, active)) {
builder_bone = anchor_selecting[0];
builder_type = anchor_selecting[1];
if(builder_type == 0) {
var orig = builder_bone.parent.getPoint(0, 0);
var orig = builder_bone.parent.getPoint(0);
builder_sx = orig.x;
builder_sy = orig.y;
} else if(builder_type == 1) {
var orig = builder_bone.getPoint(0, 0);
var orig = builder_bone.getPoint(0);
builder_sx = orig.x;
builder_sy = orig.y;
} else if(builder_type == 2) {
@ -352,14 +430,22 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
outputs[| 0].setValue(attributes.bones);
}
static attributeSerialize = function() { return {}; }
static attributeDeserialize = function(attr) {}
static doSerialize = function(_map) {
_map.bones = attributes.bones.serialize();
}
static postDeserialize = function() {
if(!struct_has(load_map, "bones")) return;
attributes.bones = new __Bone(,,,,, attributes);
attributes.bones.deserialize(load_map.bones, attributes);
attributes.bones = new __Bone(,,,,, attributes, self);
attributes.bones.deserialize(load_map.bones, attributes, self);
}
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
var bbox = drawGetBbox(xx, yy, _s);
draw_sprite_fit(s_node_armature_create, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
}
}

View file

@ -7,12 +7,19 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
inputs[| 1] = nodeValue("Armature", self, JUNCTION_CONNECT.input, VALUE_TYPE.armature, noone)
.setVisible(true, true)
.rejectArray();
inputs[| 2] = nodeValue("Bind data", self, JUNCTION_CONNECT.input, VALUE_TYPE.struct, noone)
.setVisible(true, true)
.setArrayDepth(1);
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
outputs[| 1] = nodeValue("Atlas data", self, JUNCTION_CONNECT.output, VALUE_TYPE.atlas, [])
.rejectArrayProcess();
outputs[| 2] = nodeValue("Bind data", self, JUNCTION_CONNECT.output, VALUE_TYPE.struct, [])
.setArrayDepth(1);
attribute_surface_depth();
attribute_interpolation();
@ -39,21 +46,24 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
layer_renderer = new Inspector_Custom_Renderer(function(_x, _y, _w, _m, _hover, _focus) { #region
ds_map_clear(surfMap);
var index = -1;
for(var i = input_fix_len; i < ds_list_size(inputs) - data_length; i += data_length) {
index++;
var _surf = current_data[i];
var _id = inputs[| i].extra_data[0];
if(_id == "") continue;
if(ds_map_exists(surfMap, _id))
array_push(surfMap[? _id], _surf);
array_push(surfMap[? _id], [ index, _surf ]);
else
surfMap[? _id] = [ _surf ];
surfMap[? _id] = [ [ index, _surf ] ];
print($"Add {_surf} to {_id}");
//print($"Add {_surf} to {_id}");
}
#region draw bones
var _b = inputs[| 1].getValue();
if(_b == noone) return 0;
var amo = _b.childCount();
var _hh = ui(28);
var bh = ui(32 + 16) + amo * _hh;
@ -81,23 +91,34 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
var __w = _st[2];
if(!bone.is_main) {
draw_sprite_ui(THEME.bone, 0, __x + 12, ty + 12,,,, COLORS._main_icon);
draw_sprite_ui(THEME.bone, bone.parent_anchor, __x + 12, ty + 12,,,, COLORS._main_icon);
draw_set_text(f_p2, fa_left, fa_center, COLORS._main_text);
draw_text(__x + 24, ty + 12, bone.name);
if(ds_map_exists(surfMap, bone.id)) {
var _surf = surfMap[? bone.id];
print($"{_id} has surface {_surf}");
var _sdata = surfMap[? bone.id];
var _sx = __x + 24 + string_width(bone.name) + 8;
var _sy = ty + 4;
for( var i = 0; i < array_length(_surf); i++ ) {
var _sw = surface_get_width(_surf[i]);
var _sh = surface_get_height(_surf[i]);
for( var i = 0; i < array_length(_sdata); i++ ) {
var _sid = _sdata[i][0];
var _surf = _sdata[i][1];
var _sw = surface_get_width(_surf);
var _sh = surface_get_height(_surf);
var _ss = (_hh - 8) / _sh;
draw_surface_ext_safe(_surf[i], _sx, _sy, _ss, _ss, 0, c_white, 1);
draw_set_color(COLORS.node_composite_bg);
draw_surface_ext_safe(_surf, _sx, _sy, _ss, _ss, 0, c_white, 1);
if(_hover && point_in_rectangle(_m[0], _m[1], _sx, _sy, _sx + _sw * _ss, _sy + _sh * _ss)) {
if(mouse_press(mb_left, _focus)) {
layer_dragging = _sid;
inputs[| input_fix_len + _sid * data_length].extra_data[0] = "";
}
draw_set_color(COLORS._main_accent);
} else
draw_set_color(COLORS.node_composite_bg);
draw_rectangle(_sx, _sy, _sx + _sw * _ss, _sy + _sh * _ss, true);
_sy += _sh * _ss + 4;
@ -142,110 +163,112 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
ty += ui(32);
var lh = 32;
var sh = 8 + max(1, amo) * (lh + 4) + 8;
draw_sprite_stretched_ext(THEME.ui_panel_bg, 1, _x, ty, _w, sh, COLORS.node_composite_bg_blend, 1);
#region draw surface
var lh = 32;
var sh = 8 + max(1, amo) * (lh + 4) + 8;
draw_sprite_stretched_ext(THEME.ui_panel_bg, 1, _x, ty, _w, sh, COLORS.node_composite_bg_blend, 1);
var _vis = attributes.layer_visible;
var _sel = attributes.layer_selectable;
var ly = ty + 8;
var ssh = lh - 6;
var hoverIndex = noone;
draw_set_color(COLORS.node_composite_separator);
draw_line(_x + 16, ly, _x + _w - 16, ly);
layer_remove = -1;
var index = -1;
for(var i = input_fix_len; i < ds_list_size(inputs) - data_length; i += data_length) {
var _surf = current_data[i];
index++;
var _bx = _x + _w - 24;
var _cy = ly + index * (lh + 4);
if(point_in_circle(_m[0], _m[1], _bx, _cy + lh / 2, 16)) {
draw_sprite_ui_uniform(THEME.icon_delete, 3, _bx, _cy + lh / 2, 1, COLORS._main_value_negative);
if(mouse_press(mb_left, _focus))
layer_remove = index;
} else
draw_sprite_ui_uniform(THEME.icon_delete, 3, _bx, _cy + lh / 2, 1, COLORS._main_icon);
if(!is_surface(_surf)) continue;
var aa = (index != layer_dragging || layer_dragging == noone)? 1 : 0.5;
var vis = _vis[index];
var sel = _sel[index];
var hover = point_in_rectangle(_m[0], _m[1], _x, _cy, _x + _w, _cy + lh);
var _vis = attributes.layer_visible;
var _sel = attributes.layer_selectable;
var ly = ty + 8;
var ssh = lh - 6;
var hoverIndex = noone;
draw_set_color(COLORS.node_composite_separator);
draw_line(_x + 16, _cy + lh + 2, _x + _w - 16, _cy + lh + 2);
draw_line(_x + 16, ly, _x + _w - 16, ly);
layer_remove = -1;
var index = -1;
for(var i = input_fix_len; i < ds_list_size(inputs) - data_length; i += data_length) {
var _surf = current_data[i];
var _bx = _x + 24 * 2 + 8;
if(point_in_circle(_m[0], _m[1], _bx, _cy + lh / 2, 12)) {
draw_sprite_ui_uniform(THEME.junc_visible, vis, _bx, _cy + lh / 2, 1, c_white);
if(mouse_press(mb_left, _focus))
hold_visibility = !_vis[index];
if(mouse_click(mb_left, _focus) && _vis[index] != hold_visibility) {
_vis[@ index] = hold_visibility;
doUpdate();
}
} else
draw_sprite_ui_uniform(THEME.junc_visible, vis, _bx, _cy + lh / 2, 1, COLORS._main_icon, 0.5 + 0.5 * vis);
index++;
var _bx = _x + _w - 24;
var _cy = ly + index * (lh + 4);
_bx += 24 + 8;
if(point_in_circle(_m[0], _m[1], _bx, _cy + lh / 2, 12)) {
draw_sprite_ui_uniform(THEME.cursor_select, sel, _bx, _cy + lh / 2, 1, c_white);
if(mouse_press(mb_left, _focus))
hold_select = !_sel[index];
if(mouse_click(mb_left, _focus) && _sel[index] != hold_select)
_sel[@ index] = hold_select;
} else
draw_sprite_ui_uniform(THEME.cursor_select, sel, _bx, _cy + lh / 2, 1, COLORS._main_icon, 0.5 + 0.5 * sel);
draw_set_color(COLORS.node_composite_bg);
var _sx0 = _bx + 24;
var _sx1 = _sx0 + ssh;
var _sy0 = _cy + 3;
var _sy1 = _sy0 + ssh;
draw_rectangle(_sx0, _sy0, _sx1, _sy1, true);
var _ssw = surface_get_width(_surf);
var _ssh = surface_get_height(_surf);
var _sss = min(ssh / _ssw, ssh / _ssh);
draw_surface_ext_safe(_surf, _sx0, _sy0, _sss, _sss, 0, c_white, 1);
draw_set_text(f_p1, fa_left, fa_center, hover? COLORS._main_text : COLORS._main_text);
draw_set_alpha(aa);
draw_text(_sx1 + 12, _cy + lh / 2, inputs[| i].name);
draw_set_alpha(1);
if(_hover && point_in_rectangle(_m[0], _m[1], _x, _cy, _x + _w, _cy + lh)) {
hoverIndex = index;
if(layer_dragging != noone) {
draw_set_color(COLORS._main_accent);
if(layer_dragging > index)
draw_line_width(_x + 16, _cy + lh + 2, _x + _w - 16, _cy + lh + 2, 2);
else if(layer_dragging < index)
draw_line_width(_x + 16, _cy - 2, _x + _w - 16, _cy - 2, 2);
}
}
if(layer_dragging == noone || layer_dragging == index) {
var _bx = _x + 24;
if(point_in_circle(_m[0], _m[1], _bx, _cy + lh / 2, 16)) {
draw_sprite_ui_uniform(THEME.hamburger, 3, _bx, _cy + lh / 2, .75, c_white);
draw_sprite_ui_uniform(THEME.icon_delete, 3, _bx, _cy + lh / 2, 1, COLORS._main_value_negative);
if(mouse_press(mb_left, _focus))
layer_dragging = index;
layer_remove = index;
} else
draw_sprite_ui_uniform(THEME.hamburger, 3, _bx, _cy + lh / 2, .75, COLORS._main_icon);
draw_sprite_ui_uniform(THEME.icon_delete, 3, _bx, _cy + lh / 2, 1, COLORS._main_icon);
if(!is_surface(_surf)) continue;
var aa = (index != layer_dragging || layer_dragging == noone)? 1 : 0.5;
var vis = _vis[index];
var sel = _sel[index];
var hover = point_in_rectangle(_m[0], _m[1], _x, _cy, _x + _w, _cy + lh);
draw_set_color(COLORS.node_composite_separator);
draw_line(_x + 16, _cy + lh + 2, _x + _w - 16, _cy + lh + 2);
var _bx = _x + 24 * 2 + 8;
if(point_in_circle(_m[0], _m[1], _bx, _cy + lh / 2, 12)) {
draw_sprite_ui_uniform(THEME.junc_visible, vis, _bx, _cy + lh / 2, 1, c_white);
if(mouse_press(mb_left, _focus))
hold_visibility = !_vis[index];
if(mouse_click(mb_left, _focus) && _vis[index] != hold_visibility) {
_vis[@ index] = hold_visibility;
doUpdate();
}
} else
draw_sprite_ui_uniform(THEME.junc_visible, vis, _bx, _cy + lh / 2, 1, COLORS._main_icon, 0.5 + 0.5 * vis);
_bx += 24 + 8;
if(point_in_circle(_m[0], _m[1], _bx, _cy + lh / 2, 12)) {
draw_sprite_ui_uniform(THEME.cursor_select, sel, _bx, _cy + lh / 2, 1, c_white);
if(mouse_press(mb_left, _focus))
hold_select = !_sel[index];
if(mouse_click(mb_left, _focus) && _sel[index] != hold_select)
_sel[@ index] = hold_select;
} else
draw_sprite_ui_uniform(THEME.cursor_select, sel, _bx, _cy + lh / 2, 1, COLORS._main_icon, 0.5 + 0.5 * sel);
draw_set_color(COLORS.node_composite_bg);
var _sx0 = _bx + 24;
var _sx1 = _sx0 + ssh;
var _sy0 = _cy + 3;
var _sy1 = _sy0 + ssh;
draw_rectangle(_sx0, _sy0, _sx1, _sy1, true);
var _ssw = surface_get_width(_surf);
var _ssh = surface_get_height(_surf);
var _sss = min(ssh / _ssw, ssh / _ssh);
draw_surface_ext_safe(_surf, _sx0, _sy0, _sss, _sss, 0, c_white, 1);
draw_set_text(f_p1, fa_left, fa_center, hover? COLORS._main_text : COLORS._main_text);
draw_set_alpha(aa);
draw_text(_sx1 + 12, _cy + lh / 2, inputs[| i].name);
draw_set_alpha(1);
if(_hover && point_in_rectangle(_m[0], _m[1], _x, _cy, _x + _w, _cy + lh)) {
hoverIndex = index;
if(layer_dragging != noone) {
draw_set_color(COLORS._main_accent);
if(layer_dragging > index)
draw_line_width(_x + 16, _cy + lh + 2, _x + _w - 16, _cy + lh + 2, 2);
else if(layer_dragging < index)
draw_line_width(_x + 16, _cy - 2, _x + _w - 16, _cy - 2, 2);
}
}
if(layer_dragging == noone || layer_dragging == index) {
var _bx = _x + 24;
if(point_in_circle(_m[0], _m[1], _bx, _cy + lh / 2, 16)) {
draw_sprite_ui_uniform(THEME.hamburger, 3, _bx, _cy + lh / 2, .75, c_white);
if(mouse_press(mb_left, _focus))
layer_dragging = index;
} else
draw_sprite_ui_uniform(THEME.hamburger, 3, _bx, _cy + lh / 2, .75, COLORS._main_icon);
}
}
}
#endregion
if(layer_dragging != noone && mouse_release(mb_left)) {
if(layer_dragging != hoverIndex && hoverIndex != noone) {
@ -283,7 +306,7 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
#endregion
});
input_display_list = [ 1,
input_display_list = [ 1, 2,
["Output", true], 0,
["Armature", false], layer_renderer,
["Surfaces", true],
@ -301,6 +324,9 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
if(input_display_list[i] > idx)
input_display_list[i] = input_display_list[i] - data_length;
}
if(ds_list_size(inputs) == input_fix_len)
createNewSurface();
doUpdate();
#endregion
}
@ -345,6 +371,7 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
overlay_h = 0;
atlas_data = [];
bind_data = [];
static getInputAmount = function() {
return input_fix_len + (ds_list_size(inputs) - input_fix_len) / data_length;
@ -388,11 +415,12 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
ds_stack_push(_bst, _b);
while(!ds_stack_empty(_bst)) {
var __b = ds_stack_pop(_bst);
var bone = ds_stack_pop(_bst);
for( var i = 0; i < array_length(__b.childs); i++ ) {
boneMap[? __b.id] = __b;
ds_stack_push(_bst, __b.childs[i]);
for( var i = 0; i < array_length(bone.childs); i++ ) {
var child_bone = bone.childs[i];
boneMap[? child_bone.id] = child_bone;
ds_stack_push(_bst, child_bone);
}
}
@ -401,11 +429,19 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
}
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
var dim = inputs[| 0].getValue();
var _b = inputs[| 1].getValue();
var dim = inputs[| 0].getValue();
var _b = inputs[| 1].getValue();
var _bind = inputs[| 2].getValue();
if(_b == noone) return;
if(_bind != noone) {
_b.draw(false, _x, _y, _s, _mx, _my);
return;
}
if(attributes.display_bone == 1)
_b.draw(active, _x, _y, _s, _mx, _my);
_b.draw(false, _x, _y, _s, _mx, _my);
var ww = dim[0];
var hh = dim[1];
@ -467,7 +503,7 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
UNDO_HOLDING = true;
if(mouse_release(mb_left)) {
input_dragging = -1;
surf_dragging = -1;
UNDO_HOLDING = false;
}
}
@ -478,42 +514,42 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
var _sel = attributes.layer_selectable;
var amo = (ds_list_size(inputs) - input_fix_len) / data_length;
if(array_length(current_data) < input_fix_len + amo * data_length)
return;
for(var i = 0; i < amo; i++) {
var vis = _vis[i];
var sel = _sel[i];
var vis = array_safe_get(_vis, i);
var sel = array_safe_get(_sel, i);
if(!vis) continue;
var index = input_fix_len + i * data_length;
var _surf = current_data[index + 0];
var _surf = array_safe_get(current_data, index);
if(!_surf || is_array(_surf)) continue;
var _bone = inputs[| index].extra_data[0];
if(!ds_map_exists(boneMap, _bone)) continue;
if(!ds_map_exists(boneMap, _bone)) {
//print($"Bone not found {_bone}");
continue;
}
_bone = boneMap[? _bone];
var _tran = current_data[index + 1];
var _rot = _bone.angle + _tran[TRANSFORM.rot];
var _anc = _bone.getPoint(_bone.length / 2, _bone.angle);
var _pos = point_rotate(_tran[TRANSFORM.pos_x], _tran[TRANSFORM.pos_y], _anc.x, _anc.y, _rot);
var _anc = _bone.getPoint(0.5);
var _mov = point_rotate(_tran[TRANSFORM.pos_x], _tran[TRANSFORM.pos_y], 0, 0, _bone.angle);
var _sca = [ _tran[TRANSFORM.sca_x], _tran[TRANSFORM.sca_y] ];
if(!_surf || is_array(_surf)) continue;
var _ww = surface_get_width(_surf);
var _hh = surface_get_height(_surf);
var _sw = _ww * _sca[0];
var _sh = _hh * _sca[1];
var cx = _pos[0] + _ww / 2;
var cy = _pos[1] + _hh / 2;
var cx = _anc.x + _mov[0];
var cy = _anc.y + _mov[1];
var _d0 = point_rotate(cx - _sw / 2, cy - _sh / 2, cx, cy, _rot);
var _d1 = point_rotate(cx - _sw / 2, cy + _sh / 2, cx, cy, _rot);
var _d2 = point_rotate(cx + _sw / 2, cy - _sh / 2, cx, cy, _rot);
var _d3 = point_rotate(cx + _sw / 2, cy + _sh / 2, cx, cy, _rot);
var _rr = point_rotate(cx, cy - _sh / 2 - 1, cx, cy, _rot);
var _rr = point_rotate(cx, cy - _sh / 2 - 4, cx, cy, _rot);
_d0[0] = overlay_x(_d0[0], _x, _s); _d0[1] = overlay_y(_d0[1], _y, _s);
_d1[0] = overlay_x(_d1[0], _x, _s); _d1[1] = overlay_y(_d1[1], _y, _s);
@ -558,22 +594,26 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
var _tran = current_data[hovering + 1];
var _rot = _bone.angle + _tran[TRANSFORM.rot];
var _anc = _bone.getPoint(_bone.length / 2, _bone.angle);
var _pos = point_rotate(_tran[TRANSFORM.pos_x], _tran[TRANSFORM.pos_y], _anc.x, _anc.y, _rot);
var _anc = _bone.getPoint(0.5);
var _mov = point_rotate(_tran[TRANSFORM.pos_x], _tran[TRANSFORM.pos_y], 0, 0, _bone.angle);
var _sca = [ _tran[TRANSFORM.sca_x], _tran[TRANSFORM.sca_y] ];
var _ww = surface_get_width(_surf);
var _hh = surface_get_height(_surf);
var _dx0 = _x + _pos[0] * _s;
var _dy0 = _y + _pos[1] * _s;
var _dx1 = _dx0 + _ww * _s;
var _dy1 = _dy0 + _hh * _s;
var _ww = surface_get_width(_surf);
var _hh = surface_get_height(_surf);
var _sw = _ww * _sca[0];
var _sh = _hh * _sca[1];
var cx = _pos[0] + _ww / 2;
var cy = _pos[1] + _hh / 2;
var _cen = point_rotate(-_sw / 2, -_sh / 2, 0, 0, _bone.angle);
var _pos = [
_anc.x + _cen[0] + _mov[0],
_anc.y + _cen[1] + _mov[1]
];
var _dx0 = _x + _pos[0] * _s;
var _dy0 = _y + _pos[1] * _s;
var cx = _anc.x + _mov[0];
var cy = _anc.y + _mov[1];
var _d0 = point_rotate(cx - _sw / 2, cy - _sh / 2, cx, cy, _rot);
var _d1 = point_rotate(cx - _sw / 2, cy + _sh / 2, cx, cy, _rot);
@ -595,8 +635,8 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
if(mouse_press(mb_left, active)) {
surf_dragging = hovering;
drag_type = hovering_type;
dragging_sx = _pos[0];
dragging_sy = _pos[1];
dragging_sx = _tran[TRANSFORM.pos_x];
dragging_sy = _tran[TRANSFORM.pos_y];
dragging_mx = _mx;
dragging_my = _my;
}
@ -604,19 +644,17 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
if(mouse_press(mb_left, active)) {
surf_dragging = hovering;
drag_type = hovering_type;
dragging_sx = _rot;
rot_anc_x = _dx0 + _ww / 2 * _s;
rot_anc_y = _dy0 + _hh / 2 * _s;
dragging_sx = _tran[TRANSFORM.rot];
rot_anc_x = overlay_x(cx, _x, _s);
rot_anc_y = overlay_y(cy, _y, _s);
dragging_mx = point_direction(rot_anc_x, rot_anc_y, _mx, _my);
}
} else if(hovering_type == NODE_COMPOSE_DRAG.scale) { //sca
if(mouse_press(mb_left, active)) {
surf_dragging = hovering;
drag_type = hovering_type;
dragging_sx = _sca[0];
dragging_sy = _sca[1];
dragging_mx = _dx0 + _ww / 2 * _s;
dragging_my = _dy0 + _hh / 2 * _s;
dragging_mx = (_d0[0] + _d3[0]) / 2;
dragging_my = (_d0[1] + _d3[1]) / 2;
}
}
}
@ -627,7 +665,7 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
}
if(attributes.display_bone == 0)
_b.draw(active, _x, _y, _s, _mx, _my);
_b.draw(false, _x, _y, _s, _mx, _my);
#endregion
}
@ -645,11 +683,21 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
static process_data = function(_outSurf, _data, _output_index, _array_index) {
if(_output_index == 1) return atlas_data;
if(_output_index == 0 && _array_index == 0) atlas_data = [];
if(_output_index == 2) return bind_data;
if(_output_index == 0 && _array_index == 0) {
atlas_data = [];
bind_data = [];
}
var _dim = _data[0];
var _bone = _data[1];
var cDep = attrDepth();
var _bind = _data[2];
var cDep = attrDepth();
if(_bone == noone) return _outSurf;
if(ds_map_size(boneMap) == 0)
setBone();
overlay_w = _dim[0];
overlay_h = _dim[1];
@ -664,46 +712,58 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
surface_reset_target();
}
var res_index = 0, bg = 0;
var imageAmo = (ds_list_size(inputs) - input_fix_len) / data_length;
var _vis = attributes.layer_visible;
var use_data = _bind != noone;
var res_index = 0;
var bg = 0;
var imageAmo = use_data? array_length(_bind) : (ds_list_size(inputs) - input_fix_len) / data_length;
var _vis = attributes.layer_visible;
surface_set_shader(_outSurf, sh_sample, true, BLEND.alphamulp);
for(var i = 0; i < imageAmo; i++) {
var vis = _vis[i];
var vis = array_safe_get(_vis, i, true);
if(!vis) continue;
var startDataIndex = input_fix_len + i * data_length;
var _s = _data[startDataIndex];
var _bone = inputs[| startDataIndex].extra_data[0];
var datInd = input_fix_len + i * data_length;
var _s = use_data? _bind[i].surface.get() : _data[datInd];
if(!is_surface(_s)) continue;
if(!ds_map_exists(boneMap, _bone)) continue;
var _bone = use_data? _bind[i].bone : inputs[| datInd].extra_data[0];
if(!ds_map_exists(boneMap, _bone)) {
//print($"Bone not exist {_bone} from map {ds_map_size(boneMap)}")
continue;
}
_bone = boneMap[? _bone];
var _tran = _data[startDataIndex + 1];
var _tran = use_data? _bind[i].transform : _data[datInd + 1];
var _rot = _bone.angle + _tran[TRANSFORM.rot];
var _anc = _bone.getPoint(_bone.length / 2, _bone.angle);
var _pos = point_rotate(_tran[TRANSFORM.pos_x], _tran[TRANSFORM.pos_y], _anc.x, _anc.y, _rot);
var _anc = _bone.getPoint(0.5);
var _mov = point_rotate(_tran[TRANSFORM.pos_x], _tran[TRANSFORM.pos_y], 0, 0, _bone.angle);
var _sca = [ _tran[TRANSFORM.sca_x], _tran[TRANSFORM.sca_y] ];
if(!is_surface(_s)) continue;
var _ww = surface_get_width(_s);
var _hh = surface_get_height(_s);
var _sw = _ww * _sca[0];
var _sh = _hh * _sca[1];
var cx = _pos[0];
var cy = _pos[1];
var _d0 = point_rotate(cx - _sw / 2, cy - _sh / 2, cx, cy, _rot);
var _cen = point_rotate(-_sw / 2, -_sh / 2, 0, 0, _rot);
var _pos = [
_anc.x + _cen[0] + _mov[0],
_anc.y + _cen[1] + _mov[1]
];
shader_set_interpolation(_s);
array_push(atlas_data, new SurfaceAtlas(_s, _d0, _rot, _sca));
draw_surface_ext_safe(_s, _d0[0], _d0[1], _sca[0], _sca[1], _rot);
array_push(atlas_data, new SurfaceAtlas(_s, _pos, _rot, _sca));
array_push(bind_data, {
surface: new Surface(_s),
bone: _bone.id,
transform: _tran
});
draw_surface_ext_safe(_s, _pos[0], _pos[1], _sca[0], _sca[1], _rot);
}
surface_reset_shader();
return _outSurf;
@ -731,5 +791,9 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
if(struct_has(attr, "layer_selectable"))
attributes.layer_selectable = attr.layer_selectable;
}
static doApplyDeserialize = function() {
setBone();
}
}

View file

@ -1,6 +1,10 @@
function Node_Armature_Pose(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Armature Pose";
w = 96;
h = 72;
min_h = h;
inputs[| 0] = nodeValue("Armature", self, JUNCTION_CONNECT.input, VALUE_TYPE.armature, noone)
.setVisible(true, true);
@ -134,7 +138,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, 0);
var ori = posing_bone.getPoint(0);
var ang = point_direction(ori.x, ori.y, mx, my);
var rot = angle_difference(ang, posing_sy);
posing_sy = ang;
@ -180,7 +184,7 @@ function Node_Armature_Pose(_x, _y, _group = noone) : Node(_x, _y, _group) const
posing_sx = posing_bone.length / posing_bone.pose_scale;
posing_sy = posing_bone.angle - posing_bone.pose_angle;
var pnt = posing_bone.getPoint(0, 0);
var pnt = posing_bone.getPoint(0);
posing_mx = pnt.x;
posing_my = pnt.y;
@ -191,7 +195,7 @@ function Node_Armature_Pose(_x, _y, _group = noone) : Node(_x, _y, _group) const
posing_input = boneMap[? posing_bone.id];
posing_type = 2;
var ori = posing_bone.getPoint(0, 0);
var ori = posing_bone.getPoint(0);
var val = posing_input.getValue();
posing_sx = val[TRANSFORM.rot];
posing_sy = point_direction(ori.x, ori.y, mx, my);
@ -266,6 +270,13 @@ function Node_Armature_Pose(_x, _y, _group = noone) : Node(_x, _y, _group) const
boneMap[? idx] = inp;
}
setBone();
}
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
var bbox = drawGetBbox(xx, yy, _s);
draw_sprite_fit(s_node_armature_pose, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
}
}

View file

@ -201,10 +201,14 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
ds_list_delete(inputs, idx);
array_remove(input_display_list, idx + i);
}
for( var i = input_display_list_len; i < array_length(input_display_list); i++ ) {
if(input_display_list[i] > idx)
input_display_list[i] = input_display_list[i] - data_length;
}
if(ds_list_size(inputs) == input_fix_len)
createNewSurface();
doUpdate();
}

View file

@ -260,11 +260,6 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor {
addNodeObject(transform, "Composite", s_node_compose, "Node_Composite", [1, Node_Composite], ["merge"], "Combine multiple images with controllable position, rotation, scale.");
addNodeObject(transform, "Nine Slice", s_node_9patch, "Node_9Slice", [1, Node_9Slice], ["9 slice", "splice"], "Cut image into 3x3 parts, and scale/repeat only the middle part.");
addNodeObject(transform, "Padding", s_node_padding, "Node_Padding", [1, Node_Padding],, "Make image bigger by adding space in 4 directions.");
ds_list_add(transform, "Armature");
addNodeObject(transform, "Armature Create", s_node_armature_create, "Node_Armature", [1, Node_Armature], ["rigging", "bone"]).setVersion(1145);
addNodeObject(transform, "Armature Pose", s_node_armature_pose, "Node_Armature_Pose", [1, Node_Armature_Pose], ["rigging", "bone"]).setVersion(1145);
addNodeObject(transform, "Armature Bind", s_node_armature_bind, "Node_Armature_Bind", [1, Node_Armature_Bind], ["rigging", "bone"]).setVersion(1145);
var filter = ds_list_create();
addNodeCatagory("Filter", filter);
@ -420,9 +415,9 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor {
addNodeObject(compose, "Pack Sprites", s_node_pack_sprite, "Node_Pack_Sprites", [1, Node_Pack_Sprites],, "Combine array of images with different dimension using different algorithms.").setVersion(1140);
ds_list_add(compose, "Armature");
addNodeObject(compose, "Armature Create", s_node_armature_create, "Node_Armature", [1, Node_Armature], ["rigging", "bone"]).setVersion(1145);
addNodeObject(compose, "Armature Pose", s_node_armature_pose, "Node_Armature_Pose", [1, Node_Armature_Pose], ["rigging", "bone"]).setVersion(1145);
addNodeObject(compose, "Armature Bind", s_node_armature_bind, "Node_Armature_Bind", [1, Node_Armature_Bind], ["rigging", "bone"]).setVersion(1145);
addNodeObject(compose, "Armature Create", s_node_armature_create, "Node_Armature", [1, Node_Armature], ["rigging", "bone"]).setVersion(1146);
addNodeObject(compose, "Armature Pose", s_node_armature_pose, "Node_Armature_Pose", [1, Node_Armature_Pose], ["rigging", "bone"]).setVersion(1146);
addNodeObject(compose, "Armature Bind", s_node_armature_bind, "Node_Armature_Bind", [1, Node_Armature_Bind], ["rigging", "bone"]).setVersion(1146);
if(!DEMO) {
ds_list_add(compose, "Export");

View file

@ -0,0 +1,10 @@
//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main()
{
gl_FragColor = v_vColour * texture2D( gm_BaseTexture, v_vTexcoord );
}

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,10 @@
{
"resourceType": "GMShader",
"resourceVersion": "1.0",
"name": "sh_default",
"parent": {
"name": "draw",
"path": "folders/shader/draw.yy",
},
"type": 1,
}