mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-23 21:46:17 +01:00
ik
This commit is contained in:
parent
d3f1636077
commit
3952101495
16 changed files with 246 additions and 122 deletions
|
@ -21,6 +21,8 @@ function __Bone(_parent = noone, distance = 0, direction = 0, angle = 0, length
|
|||
pose_local_scale = 1;
|
||||
pose_local_posit = [ 0, 0 ];
|
||||
|
||||
angular_constrain = -1;
|
||||
|
||||
bone_head_init = new __vec2();
|
||||
bone_head_pose = new __vec2();
|
||||
bone_tail_init = new __vec2();
|
||||
|
@ -179,11 +181,38 @@ function __Bone(_parent = noone, distance = 0, direction = 0, angle = 0, length
|
|||
}
|
||||
|
||||
if(IKlength == 0) {
|
||||
if(angular_constrain != -1) {
|
||||
var _a0 = init_angle - angular_constrain;
|
||||
var _a1 = init_angle + angular_constrain;
|
||||
var ox, oy, nx, ny;
|
||||
|
||||
for( var i = 0; i <= 32; i++ ) {
|
||||
var _t = lerp(_a0, _a1, i / 32);
|
||||
|
||||
nx = p0x + lengthdir_x(32 * _s, _t);
|
||||
ny = p0y + lengthdir_y(32 * _s, _t);
|
||||
|
||||
if(i == 0) draw_line(p0x, p0y, nx, ny);
|
||||
if(i == 32) draw_line(p0x, p0y, nx, ny);
|
||||
if(i) draw_line(ox, oy, nx, ny);
|
||||
|
||||
ox = nx;
|
||||
oy = ny;
|
||||
}
|
||||
}
|
||||
|
||||
if(pose_angle != 0) {
|
||||
var nx = p0x + lengthdir_x(16, angle + pose_angle);
|
||||
var ny = p0y + lengthdir_y(16, angle + pose_angle);
|
||||
|
||||
draw_line_width(p0x, p0y, nx, ny, 2);
|
||||
}
|
||||
|
||||
if(!parent_anchor && parent.parent != noone) {
|
||||
var _p = parent.getHead();
|
||||
var _px = _x + _p.x * _s;
|
||||
var _py = _y + _p.y * _s;
|
||||
draw_line_dashed(_px, _py, p0x, p0y, 1);
|
||||
draw_line_dashed(_px, _py, p0x, p0y, 2, 8);
|
||||
}
|
||||
|
||||
if(attributes.display_bone == 0) {
|
||||
|
@ -308,7 +337,10 @@ function __Bone(_parent = noone, distance = 0, direction = 0, angle = 0, length
|
|||
static setPose = function(_position = [ 0, 0 ], _angle = 0, _scale = 1, _ik = true) {
|
||||
setPosition();
|
||||
setPoseTransform(_position, _angle, _scale);
|
||||
if(_ik) setIKconstrain();
|
||||
if(_ik) {
|
||||
setPosition();
|
||||
setIKconstrain();
|
||||
}
|
||||
setPosition();
|
||||
}
|
||||
|
||||
|
@ -324,6 +356,8 @@ function __Bone(_parent = noone, distance = 0, direction = 0, angle = 0, length
|
|||
if(apply_rotation) pose_angle += _angle;
|
||||
if(apply_scale) pose_scale *= _scale;
|
||||
|
||||
if(angular_constrain != -1) pose_angle = clamp(pose_angle, -angular_constrain, angular_constrain);
|
||||
|
||||
pose_local_angle = pose_angle;
|
||||
pose_local_scale = pose_scale;
|
||||
pose_local_posit = pose_posit;
|
||||
|
@ -391,8 +425,8 @@ function __Bone(_parent = noone, distance = 0, direction = 0, angle = 0, length
|
|||
var itr = 0;
|
||||
|
||||
do {
|
||||
FABRIK_backward(points, lengths, dx, dy);
|
||||
FABRIK_forward(points, lengths, sx, sy);
|
||||
FABRIK_backward(bones, points, lengths, dx, dy);
|
||||
FABRIK_forward(bones, points, lengths, sx, sy);
|
||||
|
||||
var delta = 0;
|
||||
var _bn = array_create(array_length(points));
|
||||
|
@ -416,8 +450,10 @@ function __Bone(_parent = noone, distance = 0, direction = 0, angle = 0, length
|
|||
// _b.pose_scale = dis / _b.init_length;
|
||||
// _b.length = dis;
|
||||
|
||||
_b.pose_angle = dir - _b.init_angle;
|
||||
_b.angle = dir;
|
||||
// _b.pose_angle = dir - _b.init_angle;
|
||||
// _b.angle = _b.init_angle + _b.pose_angle;
|
||||
|
||||
_b.angle = dir;
|
||||
|
||||
FABRIK_result[i] = p0;
|
||||
}
|
||||
|
@ -426,7 +462,7 @@ function __Bone(_parent = noone, distance = 0, direction = 0, angle = 0, length
|
|||
|
||||
}
|
||||
|
||||
static FABRIK_backward = function(points, lengths, dx, dy) {
|
||||
static FABRIK_backward = function(bones, points, lengths, dx, dy) {
|
||||
var tx = dx;
|
||||
var ty = dy;
|
||||
|
||||
|
@ -447,16 +483,19 @@ function __Bone(_parent = noone, distance = 0, direction = 0, angle = 0, length
|
|||
}
|
||||
}
|
||||
|
||||
static FABRIK_forward = function(points, lengths, sx, sy) {
|
||||
static FABRIK_forward = function(bones, points, lengths, sx, sy) {
|
||||
var tx = sx;
|
||||
var ty = sy;
|
||||
|
||||
for( var i = 0, n = array_length(points) - 1; i < n; i++ ) {
|
||||
var _b = bones[i];
|
||||
var p0 = points[i];
|
||||
var p1 = points[i + 1];
|
||||
var len = lengths[i];
|
||||
var dir = point_direction(tx, ty, p1.x, p1.y);
|
||||
|
||||
if(_b.angular_constrain != -1) dir = clamp(dir, _b.init_angle - _b.angular_constrain, _b.init_angle + _b.angular_constrain);
|
||||
|
||||
p0.x = tx;
|
||||
p0.y = ty;
|
||||
|
||||
|
@ -516,6 +555,8 @@ function __Bone(_parent = noone, distance = 0, direction = 0, angle = 0, length
|
|||
bone.apply_rotation = apply_rotation;
|
||||
bone.apply_scale = apply_scale;
|
||||
|
||||
bone.angular_constrain = angular_constrain;
|
||||
|
||||
bone.childs = [];
|
||||
for( var i = 0, n = array_length(childs); i < n; i++ )
|
||||
bone.childs[i] = childs[i].serialize();
|
||||
|
@ -534,7 +575,7 @@ function __Bone(_parent = noone, distance = 0, direction = 0, angle = 0, length
|
|||
is_main = bone.is_main;
|
||||
parent_anchor = bone.parent_anchor;
|
||||
|
||||
self.node = node;
|
||||
self.node = node;
|
||||
|
||||
IKlength = bone.IKlength;
|
||||
IKTargetID = struct_try_get(bone, "IKTargetID", "");
|
||||
|
@ -542,6 +583,9 @@ function __Bone(_parent = noone, distance = 0, direction = 0, angle = 0, length
|
|||
apply_rotation = bone.apply_rotation;
|
||||
apply_scale = bone.apply_scale;
|
||||
|
||||
angular_constrain = struct_try_get(bone, "angular_constrain", -1);
|
||||
angular_constrain = -1;
|
||||
|
||||
childs = [];
|
||||
for( var i = 0, n = array_length(bone.childs); i < n; i++ ) {
|
||||
var _b = new __Bone().deserialize(bone.childs[i], node);
|
||||
|
@ -570,8 +614,9 @@ function __Bone(_parent = noone, distance = 0, direction = 0, angle = 0, length
|
|||
_b.IKlength = IKlength;
|
||||
_b.IKTargetID = IKTargetID;
|
||||
|
||||
_b.apply_rotation = apply_rotation;
|
||||
_b.apply_scale = apply_scale;
|
||||
_b.apply_rotation = apply_rotation;
|
||||
_b.apply_scale = apply_scale;
|
||||
_b.angular_constrain = angular_constrain;
|
||||
|
||||
for( var i = 0, n = array_length(childs); i < n; i++ )
|
||||
_b.addChild(childs[i].clone());
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
LATEST_VERSION = 1_18_00_0;
|
||||
VERSION = 1_18_04_0;
|
||||
SAVE_VERSION = 1_18_02_0;
|
||||
VERSION_STRING = MAC? "1.18.003m" : "1.18.4.003";
|
||||
VERSION_STRING = MAC? "1.18.003m" : "1.18.4.004";
|
||||
BUILD_NUMBER = 1_18_03_1;
|
||||
|
||||
HOTKEYS = ds_map_create();
|
||||
|
|
|
@ -294,7 +294,8 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
|
|||
var p0t = anc.getTail();
|
||||
var _px = _x + p0t.x * _s;
|
||||
var _py = _y + p0t.y * _s;
|
||||
draw_line_dashed(_px, _py, p1x, p1y, 1);
|
||||
draw_line_dashed(_px, _py, p1x, p1y, 2, 8);
|
||||
draw_sprite_ui(THEME.preview_bone_IK, 1, _px, _py, 1, 1, 0, COLORS._main_accent, 1);
|
||||
|
||||
if(mouse_release(mb_left)) {
|
||||
var _len = point_distance(p0.x, p0.y, p1.x, p1.y);
|
||||
|
@ -314,10 +315,10 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
|
|||
}
|
||||
}
|
||||
|
||||
draw_sprite_ui(THEME.preview_bone_IK, 0, p1x, p1y, 1, 1, 0, _reach? COLORS._main_value_positive : COLORS._main_accent, 0.5);
|
||||
draw_sprite_ui(THEME.preview_bone_IK, 0, p1x, p1y, 1, 1, 0, _reach? COLORS._main_value_positive : COLORS._main_accent, 1);
|
||||
|
||||
} else
|
||||
draw_sprite_ui(THEME.preview_bone_IK, 0, p1x, p1y, 1, 1, 0, COLORS._main_accent, 0.25);
|
||||
draw_sprite_ui(THEME.preview_bone_IK, 0, p1x, p1y, 1, 1, 0, COLORS._main_accent, 0.5);
|
||||
|
||||
if(mouse_release(mb_left)) {
|
||||
ik_dragging = noone;
|
||||
|
|
|
@ -55,8 +55,8 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
new NodeTool( "Pose", THEME.bone_tool_pose )
|
||||
];
|
||||
|
||||
boneMap = ds_map_create();
|
||||
surfMap = ds_map_create();
|
||||
boneMap = {};
|
||||
surfMap = {};
|
||||
boneIDMap = [];
|
||||
|
||||
hold_visibility = true;
|
||||
|
@ -66,8 +66,10 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
layer_dragging = noone;
|
||||
layer_remove = -1;
|
||||
|
||||
hoverIndex = noone;
|
||||
|
||||
layer_renderer = new Inspector_Custom_Renderer(function(_x, _y, _w, _m, _hover, _focus) {
|
||||
ds_map_clear(surfMap);
|
||||
surfMap = {};
|
||||
|
||||
var amo = min(array_length(inputs) - data_length, array_length(current_data));
|
||||
var _bind = getSingleValue(2);
|
||||
|
@ -79,8 +81,8 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
var _id = array_safe_get(boneIDMap, i, "");
|
||||
if(_id == "") continue;
|
||||
|
||||
if(!ds_map_exists(surfMap, _id)) surfMap[? _id] = [];
|
||||
array_push(surfMap[? _id], [ i, _surf ]);
|
||||
if(!struct_exists(surfMap, _id)) surfMap[$ _id] = [];
|
||||
array_push(surfMap[$ _id], [ i, _surf ]);
|
||||
}
|
||||
|
||||
#region draw bones
|
||||
|
@ -124,8 +126,8 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
draw_set_text(f_p2, fa_left, fa_center, COLORS._main_text);
|
||||
draw_text_add(__x + 24, ty + 12, _bone.name);
|
||||
|
||||
if(ds_map_exists(surfMap, _bone.ID)) {
|
||||
var _sdata = surfMap[? _bone.ID];
|
||||
if(struct_exists(surfMap, _bone.ID)) {
|
||||
var _sdata = surfMap[$ _bone.ID];
|
||||
|
||||
var _sx = __x + 24 + string_width(_bone.name) + 8;
|
||||
var _sy = ty + 4;
|
||||
|
@ -209,7 +211,7 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
var _sel = attributes.layer_selectable;
|
||||
var ly = ty + 6;
|
||||
var ssh = lh - 6;
|
||||
var hoverIndex = noone;
|
||||
hoverIndex = noone;
|
||||
|
||||
layer_remove = -1;
|
||||
|
||||
|
@ -317,7 +319,7 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
if(_hover && point_in_rectangle(_m[0], _m[1], _x, _cy, _x + _w, _cy + lh)) {
|
||||
hoverIndex = _ind;
|
||||
|
||||
if(mouse_press(mb_left, _focus)) {
|
||||
if(!_mesh && mouse_press(mb_left, _focus)) {
|
||||
_layer_dragging = _ind;
|
||||
_layer_drag_y = _m[1];
|
||||
|
||||
|
@ -455,7 +457,7 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
}
|
||||
|
||||
static setBone = function() {
|
||||
ds_map_clear(boneMap);
|
||||
boneMap = {};
|
||||
|
||||
var _b = getInputData(1);
|
||||
bone = _b;
|
||||
|
@ -469,7 +471,7 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
|
||||
for( var i = 0, n = array_length(_bone.childs); i < n; i++ ) {
|
||||
var child_bone = _bone.childs[i];
|
||||
boneMap[? child_bone.ID] = child_bone;
|
||||
boneMap[$ child_bone.ID] = child_bone;
|
||||
ds_stack_push(_bst, child_bone);
|
||||
}
|
||||
}
|
||||
|
@ -524,7 +526,7 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
_tran = array_clone(_tran);
|
||||
|
||||
var _bone = array_safe_get(boneIDMap, (surf_dragging - input_fix_len) / data_length, "");
|
||||
_bone = boneMap[? _bone];
|
||||
_bone = boneMap[$ _bone];
|
||||
|
||||
if(drag_type == NODE_COMPOSE_DRAG.move) {
|
||||
var _dx = smx - dragging_mx;
|
||||
|
@ -593,6 +595,8 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
var _surf = array_safe_get_fast(current_data, index);
|
||||
|
||||
if(is(_surf, RiggedMeshedSurface)) {
|
||||
if(i != hoverIndex) continue;
|
||||
|
||||
var _mesh = _surf.mesh;
|
||||
for(var j = 0; j < array_length(_mesh.links); j++)
|
||||
_mesh.links[j].draw(_x, _y, _s);
|
||||
|
@ -602,9 +606,9 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
if(!_surf || is_array(_surf)) continue;
|
||||
|
||||
var _bone = array_safe_get(boneIDMap, i, "");
|
||||
if(!ds_map_exists(boneMap, _bone)) continue;
|
||||
if(!struct_exists(boneMap, _bone)) continue;
|
||||
|
||||
_bone = boneMap[? _bone];
|
||||
_bone = boneMap[$ _bone];
|
||||
|
||||
var _tran = current_data[index + 1];
|
||||
var _aang = current_data[index + 2];
|
||||
|
@ -665,7 +669,7 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
if(!_surf || is_array(_surf)) continue;
|
||||
|
||||
var _bone = array_safe_get(boneIDMap, i, "");
|
||||
if(!ds_map_exists(boneMap, _bone)) continue;
|
||||
if(!struct_exists(boneMap, _bone)) continue;
|
||||
|
||||
var a = anchors[index];
|
||||
|
||||
|
@ -677,9 +681,11 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
hovering = index;
|
||||
hovering_type = NODE_COMPOSE_DRAG.scale;
|
||||
_si = 1;
|
||||
|
||||
} else if(point_in_rectangle_points(_mx, _my, a.d0[0], a.d0[1], a.d1[0], a.d1[1], a.d2[0], a.d2[1], a.d3[0], a.d3[1])) {
|
||||
hovering = index;
|
||||
hovering_type = NODE_COMPOSE_DRAG.move;
|
||||
|
||||
} else if(point_in_circle(_mx, _my, a.rr[0], a.rr[1], 12)) {
|
||||
hovering = index;
|
||||
hovering_type = NODE_COMPOSE_DRAG.rotate;
|
||||
|
@ -688,6 +694,7 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
|
||||
draw_sprite_colored(THEME.anchor_rotate, _ri, a.rr[0], a.rr[1],, a.rot);
|
||||
draw_sprite_colored(THEME.anchor_scale, _si, a.d3[0], a.d3[1],, a.rot);
|
||||
|
||||
} else if(point_in_rectangle_points(_mx, _my, a.d0[0], a.d0[1], a.d1[0], a.d1[1], a.d2[0], a.d2[1], a.d3[0], a.d3[1]) &&
|
||||
(surface_selecting != hovering || surface_selecting == noone)) {
|
||||
|
||||
|
@ -787,14 +794,14 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
|
||||
for( var j = 0; j < _rbidL; j++ ) {
|
||||
var _rBoneID = _rbid[j];
|
||||
if(!ds_map_exists(boneMap, _rBoneID)) continue;
|
||||
if(!struct_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 _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;
|
||||
|
@ -879,9 +886,9 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
if(!is_surface(_s)) continue;
|
||||
|
||||
var _b = use_data? _bind[i].bone : array_safe_get(boneIDMap, i, "");
|
||||
if(!ds_map_exists(boneMap, _b)) continue;
|
||||
if(!struct_exists(boneMap, _b)) continue;
|
||||
|
||||
_b = boneMap[? _b];
|
||||
_b = boneMap[$ _b];
|
||||
|
||||
var _tran = use_data? _bind[i].transform : _data[_i + 1];
|
||||
var _aang = use_data? _bind[i].applyRot : _data[_i + 2];
|
||||
|
@ -938,9 +945,9 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
var _arot = getInputData(surfIndex + 2);
|
||||
|
||||
var _b = use_data? _bind[i].bone : array_safe_get(boneIDMap, (surfIndex - input_fix_len) / data_length, "");
|
||||
if(!ds_map_exists(boneMap, _b)) return;
|
||||
if(!struct_exists(boneMap, _b)) return;
|
||||
|
||||
_b = boneMap[? _b];
|
||||
_b = boneMap[$ _b];
|
||||
|
||||
var _cx = surface_get_width_safe(_surf) / 2;
|
||||
var _cy = surface_get_height_safe(_surf) / 2;
|
||||
|
|
|
@ -376,7 +376,7 @@ 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();
|
||||
var _map = {};
|
||||
|
||||
bone_posed = _bones.clone();
|
||||
current_bone = _bones;
|
||||
|
@ -388,7 +388,7 @@ function Node_Armature_Mesh_Rig(_x, _y, _group = noone) : Node(_x, _y, _group) c
|
|||
for( var i = 0, n = array_length(_barr); i < n; i++ ) {
|
||||
var _b = _barr[i];
|
||||
|
||||
_map[? _b.ID] = _b;
|
||||
_map[$ _b.ID] = _b;
|
||||
if(!struct_has(attributes.bonePoseData, _b.ID)) continue;
|
||||
|
||||
var _trn = attributes.bonePoseData[$ _b.ID];
|
||||
|
|
|
@ -11,7 +11,7 @@ function Node_Armature_Pose(_x, _y, _group = noone) : Node(_x, _y, _group) const
|
|||
|
||||
newOutput(0, nodeValue_Output("Armature", self, VALUE_TYPE.armature, noone));
|
||||
|
||||
boneMap = ds_map_create();
|
||||
boneMap = {};
|
||||
|
||||
attributes.display_name = true;
|
||||
attributes.display_bone = 0;
|
||||
|
@ -31,7 +31,7 @@ function Node_Armature_Pose(_x, _y, _group = noone) : Node(_x, _y, _group) const
|
|||
.setDisplay(VALUE_DISPLAY.transform);
|
||||
inputs[index].display_data.bone_id = bone != noone? bone.ID : noone;
|
||||
|
||||
if(bone != noone) boneMap[? bone.ID] = inputs[index];
|
||||
if(bone != noone) boneMap[$ bone.ID] = inputs[index];
|
||||
|
||||
array_push(input_display_list, index);
|
||||
|
||||
|
@ -72,8 +72,8 @@ function Node_Armature_Pose(_x, _y, _group = noone) : Node(_x, _y, _group) const
|
|||
array_push(_input_display_list, _idx);
|
||||
//print($" > Adding bone ID: {bone.ID}");
|
||||
|
||||
if(ds_map_exists(boneMap, bone.ID)) {
|
||||
var _inp = boneMap[? bone.ID];
|
||||
if(struct_exists(boneMap, bone.ID)) {
|
||||
var _inp = boneMap[$ bone.ID];
|
||||
|
||||
_inp.index = _idx;
|
||||
array_push(_inputs, _inp);
|
||||
|
@ -163,8 +163,8 @@ function Node_Armature_Pose(_x, _y, _group = noone) : Node(_x, _y, _group) const
|
|||
|
||||
if(anchor_selecting != noone && mouse_press(mb_left, active)) {
|
||||
posing_bone = anchor_selecting[0];
|
||||
if(!ds_map_exists(boneMap, posing_bone.ID)) setBone();
|
||||
posing_input = boneMap[? posing_bone.ID];
|
||||
if(!struct_exists(boneMap, posing_bone.ID)) setBone();
|
||||
posing_input = boneMap[$ posing_bone.ID];
|
||||
|
||||
if(anchor_selecting[1] == 0 || anchor_selecting[0].IKlength) { // move
|
||||
|
||||
|
@ -236,8 +236,8 @@ function Node_Armature_Pose(_x, _y, _group = noone) : Node(_x, _y, _group) const
|
|||
var bone = ds_stack_pop(_bst);
|
||||
var _id = bone.ID;
|
||||
|
||||
if(ds_map_exists(boneMap, _id)) {
|
||||
var _inp = boneMap[? _id];
|
||||
if(struct_exists(boneMap, _id)) {
|
||||
var _inp = boneMap[$ _id];
|
||||
_inp.updateName(bone.name);
|
||||
|
||||
var _trn = _inp.getValue();
|
||||
|
@ -298,7 +298,7 @@ function Node_Armature_Pose(_x, _y, _group = noone) : Node(_x, _y, _group) const
|
|||
var inp = inputs[i];
|
||||
var idx = struct_try_get(inp.display_data, "bone_id");
|
||||
|
||||
boneMap[? idx] = inp;
|
||||
boneMap[$ idx] = inp;
|
||||
}
|
||||
|
||||
setBone();
|
||||
|
|
|
@ -867,7 +867,7 @@ function __initNodes() {
|
|||
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) {
|
||||
ds_list_add(compose, "Export");
|
||||
addNodeObject(compose, "Export", s_node_export, "Node_Export", [0, Node_create_Export],, "Export image/animation to file(s).");
|
||||
|
|
|
@ -81,6 +81,8 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
|
|||
.setSetting(tool_size)
|
||||
.setToolObject(tool_brush);
|
||||
|
||||
tool_tile_picker = false;
|
||||
|
||||
tools = [
|
||||
tool_pencil,
|
||||
|
||||
|
@ -163,51 +165,88 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
|
|||
_tool.drawing_surface = drawing_surface;
|
||||
_tool.tile_size = _tileSiz;
|
||||
|
||||
_tool.step(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
|
||||
if(!tool_tile_picker) {
|
||||
_tool.step(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
|
||||
|
||||
surface_set_target(preview_draw_overlay);
|
||||
DRAW_CLEAR
|
||||
_tool.drawPreview(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
|
||||
surface_reset_target();
|
||||
|
||||
surface_set_target(_preview_draw_mask);
|
||||
DRAW_CLEAR
|
||||
_tool.drawMask(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
|
||||
surface_reset_target();
|
||||
|
||||
surface_set_target(preview_draw_mask);
|
||||
DRAW_CLEAR
|
||||
draw_surface_ext(_preview_draw_mask, _x, _y, _s * _tileSiz[0], _s * _tileSiz[1], 0, c_white, 1);
|
||||
surface_reset_target();
|
||||
|
||||
if(_tool.brush_resizable) {
|
||||
if(hover && key_mod_press(CTRL)) {
|
||||
if(mouse_wheel_down()) tool_attribute.size = max( 1, tool_attribute.size - 1);
|
||||
if(mouse_wheel_up()) tool_attribute.size = min(64, tool_attribute.size + 1);
|
||||
}
|
||||
surface_set_target(preview_draw_overlay);
|
||||
DRAW_CLEAR
|
||||
_tool.drawPreview(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
|
||||
surface_reset_target();
|
||||
|
||||
brush.sizing(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
|
||||
surface_set_target(_preview_draw_mask);
|
||||
DRAW_CLEAR
|
||||
_tool.drawMask(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
|
||||
surface_reset_target();
|
||||
|
||||
surface_set_target(preview_draw_mask);
|
||||
DRAW_CLEAR
|
||||
draw_surface_ext(_preview_draw_mask, _x, _y, _s * _tileSiz[0], _s * _tileSiz[1], 0, c_white, 1);
|
||||
surface_reset_target();
|
||||
|
||||
if(_tool.brush_resizable) {
|
||||
if(hover && key_mod_press(CTRL)) {
|
||||
if(mouse_wheel_down()) tool_attribute.size = max( 1, tool_attribute.size - 1);
|
||||
if(mouse_wheel_up()) tool_attribute.size = min(64, tool_attribute.size + 1);
|
||||
}
|
||||
|
||||
brush.sizing(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
|
||||
}
|
||||
|
||||
surface_set_shader(preview_draw_overlay_tile, sh_draw_tile_map, true, BLEND.over);
|
||||
shader_set_2("dimension", _outDim);
|
||||
|
||||
shader_set_surface("indexTexture", preview_draw_overlay);
|
||||
shader_set_2("indexTextureDim", surface_get_dimension(preview_draw_overlay));
|
||||
|
||||
tileset.shader_submit();
|
||||
|
||||
draw_empty();
|
||||
surface_reset_shader();
|
||||
|
||||
draw_surface_ext(preview_draw_overlay_tile, _x, _y, _s, _s, 0, c_white, 1);
|
||||
|
||||
params.panel.drawNodeGrid();
|
||||
|
||||
shader_set(sh_brush_outline);
|
||||
shader_set_f("dimension", _sw, _sh);
|
||||
draw_surface(preview_draw_mask, 0, 0);
|
||||
shader_reset();
|
||||
}
|
||||
|
||||
surface_set_shader(preview_draw_overlay_tile, sh_draw_tile_map, true, BLEND.over);
|
||||
shader_set_2("dimension", _outDim);
|
||||
|
||||
shader_set_surface("indexTexture", preview_draw_overlay);
|
||||
shader_set_2("indexTextureDim", surface_get_dimension(preview_draw_overlay));
|
||||
|
||||
tileset.shader_submit();
|
||||
if(tool_tile_picker) {
|
||||
var _mtx = floor(round((_mx - _x) / _s - 0.5) / _tileSiz[0]);
|
||||
var _mty = floor(round((_my - _y) / _s - 0.5) / _tileSiz[1]);
|
||||
|
||||
draw_empty();
|
||||
surface_reset_shader();
|
||||
|
||||
draw_surface_ext(preview_draw_overlay_tile, _x, _y, _s, _s, 0, c_white, 1);
|
||||
|
||||
params.panel.drawNodeGrid();
|
||||
|
||||
shader_set(sh_brush_outline);
|
||||
shader_set_f("dimension", _sw, _sh);
|
||||
draw_surface(preview_draw_mask, 0, 0);
|
||||
shader_reset();
|
||||
var _mrx = _x + _mtx * _s * _tileSiz[0];
|
||||
var _mry = _y + _mty * _s * _tileSiz[1];
|
||||
|
||||
draw_set_color(COLORS._main_accent);
|
||||
draw_rectangle(_mrx, _mry, _mrx + _s * _tileSiz[0], _mry + _s * _tileSiz[0], true);
|
||||
|
||||
var _cc = surface_getpixel_ext(canvas_surface, _mtx, _mty);
|
||||
|
||||
if(is_array(_cc)) {
|
||||
params.panel.sample_data = {
|
||||
type: "tileset",
|
||||
drawFn: tileset.drawTile,
|
||||
index: _cc[0] - 1,
|
||||
};
|
||||
|
||||
if(mouse_click(mb_left, active)) {
|
||||
brush.brush_indices = [[[ _cc[0] - 1, _cc[1] ]]];
|
||||
brush.brush_width = 1;
|
||||
brush.brush_height = 1;
|
||||
|
||||
tool_tile_picker = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!key_mod_press(ALT))
|
||||
tool_tile_picker = false;
|
||||
}
|
||||
|
||||
if(hover && key_mod_press(ALT))
|
||||
tool_tile_picker = true;
|
||||
}
|
||||
|
||||
// if(!array_empty(tileset.autoterrain)) {
|
||||
|
|
|
@ -20,7 +20,7 @@ function Node_Tile_Tileset(_x, _y, _group = noone) : Node(_x, _y, _group) constr
|
|||
|
||||
newOutput(0, nodeValue_Output("Tileset", self, VALUE_TYPE.tileset, self));
|
||||
|
||||
static drawTile = function(index, _x, _y, _w, _h) {
|
||||
function drawTile(index, _x, _y, _w, _h) {
|
||||
if(index < -1) { // animated
|
||||
var _an = -index - 2;
|
||||
var _at = array_safe_get(animatedTiles, _an, noone);
|
||||
|
|
|
@ -180,6 +180,7 @@ function Panel_Preview() : PanelContent() constructor {
|
|||
view_pan_tool = false;
|
||||
view_zoom_tool = false;
|
||||
|
||||
sample_data = noone;
|
||||
sample_color_raw = noone;
|
||||
sample_color = noone;
|
||||
sample_x = noone;
|
||||
|
@ -1077,6 +1078,12 @@ function Panel_Preview() : PanelContent() constructor {
|
|||
clamp(sample_color_raw[1] * 255, 0, 255),
|
||||
clamp(sample_color_raw[2] * 255, 0, 255),
|
||||
clamp(sample_color_raw[3] * 255, 0, 255)) : sample_color_raw;
|
||||
|
||||
sample_data = {
|
||||
type: "color",
|
||||
data: sample_color_raw,
|
||||
color: sample_color,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2014,7 +2021,51 @@ function Panel_Preview() : PanelContent() constructor {
|
|||
draw_sprite_stretched_ext(THEME.toolbar, 1, 0, 0, w, topbar_height, c_white, aa);
|
||||
draw_sprite_stretched_ext(THEME.toolbar, 0, 0, ty, w, toolbar_height, c_white, aa);
|
||||
|
||||
if(_tool && tool_current != noone) { // tool settings
|
||||
if(sample_data != noone) {
|
||||
var cx = ui(6);
|
||||
var cy = ui(6);
|
||||
var cw = ui(32);
|
||||
var ch = topbar_height - ui(10);
|
||||
|
||||
var _ty = sample_data.type;
|
||||
|
||||
if(_ty == "color") {
|
||||
var _da = sample_data.data;
|
||||
var _cc = sample_data.color;
|
||||
drawColor(_cc, cx, cy, cw, ch);
|
||||
draw_sprite_stretched_add(THEME.s_box_r2, 1, cx, cy, cw, ch, c_white, 0.3);
|
||||
|
||||
var tx = cx + cw + ui(8);
|
||||
draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text);
|
||||
|
||||
if(is_array(_da)) {
|
||||
draw_text(tx, cy + ch / 2, _da);
|
||||
|
||||
} else {
|
||||
var hx = color_get_hex(_cc);
|
||||
draw_text(tx, cy + ch / 2, hx);
|
||||
|
||||
tx += string_width(hx) + ui(8);
|
||||
draw_set_color(COLORS._main_text_sub);
|
||||
draw_text(tx, cy + ch / 2, $"({color_get_alpha(_cc)})");
|
||||
}
|
||||
|
||||
} else if(_ty == "tileset") {
|
||||
cw = ch;
|
||||
|
||||
var _dr = sample_data.drawFn;
|
||||
var _in = sample_data.index;
|
||||
|
||||
_dr(_in, cx, cy, cw, ch);
|
||||
draw_sprite_stretched_add(THEME.s_box_r2, 1, cx, cy, cw, ch, c_white, 0.3);
|
||||
|
||||
var tx = cx + cw + ui(8);
|
||||
draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text);
|
||||
|
||||
draw_text(tx, cy + ch / 2, $"Tile {_in}");
|
||||
}
|
||||
|
||||
} else if(_tool && tool_current != noone) { // tool settings
|
||||
var settings = array_merge(_tool.getToolSettings(), tool_current.settings);
|
||||
|
||||
tool_x = lerp_float(tool_x, tool_x_to, 5);
|
||||
|
@ -2086,33 +2137,10 @@ function Panel_Preview() : PanelContent() constructor {
|
|||
if(mouse_wheel_up()) tool_x_to = clamp(tool_x_to + ui(64) * SCROLL_SPEED, -tol_max_w, 0);
|
||||
if(mouse_wheel_down()) tool_x_to = clamp(tool_x_to - ui(64) * SCROLL_SPEED, -tol_max_w, 0);
|
||||
}
|
||||
|
||||
} else { // color sampler
|
||||
var cx = ui(6);
|
||||
var cy = ui(6);
|
||||
var cw = ui(32);
|
||||
var ch = topbar_height - ui(10);
|
||||
|
||||
if(sample_color != noone) {
|
||||
drawColor(sample_color, cx, cy, cw, ch);
|
||||
|
||||
var tx = cx + cw + ui(8);
|
||||
draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text);
|
||||
|
||||
if(is_array(sample_color_raw)) {
|
||||
draw_text(tx, cy + ch / 2, sample_color_raw);
|
||||
|
||||
} else {
|
||||
var hx = color_get_hex(sample_color);
|
||||
draw_text(tx, cy + ch / 2, hx);
|
||||
|
||||
tx += string_width(hx) + ui(8);
|
||||
draw_set_color(COLORS._main_text_sub);
|
||||
draw_text(tx, cy + ch / 2, $"({color_get_alpha(sample_color)})");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sample_data = noone;
|
||||
|
||||
var tbx = toolbar_height / 2;
|
||||
var tby = ty + toolbar_height / 2;
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@
|
|||
}
|
||||
],
|
||||
|
||||
// [ "Gamemaker Link", "bind_gamemaker_path", gamemaker_editWidget, noone ],
|
||||
[ "Gamemaker Link", "bind_gamemaker_path", gamemaker_editWidget, noone ],
|
||||
];
|
||||
|
||||
static setPalette = function(pal = noone) {
|
||||
|
|
BIN
sprites/s_bone_IK/d0370ade-8599-4155-9318-c2d7f3093323.png
Normal file
BIN
sprites/s_bone_IK/d0370ade-8599-4155-9318-c2d7f3093323.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 612 B |
Binary file not shown.
Before Width: | Height: | Size: 875 B After Width: | Height: | Size: 875 B |
Binary file not shown.
After Width: | Height: | Size: 612 B |
Binary file not shown.
Before Width: | Height: | Size: 875 B After Width: | Height: | Size: 875 B |
|
@ -12,14 +12,15 @@
|
|||
"edgeFiltering":false,
|
||||
"For3D":false,
|
||||
"frames":[
|
||||
{"$GMSpriteFrame":"","%Name":"8fdfbcea-ea77-48fd-ba17-e77e525adfc6","name":"8fdfbcea-ea77-48fd-ba17-e77e525adfc6","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
|
||||
{"$GMSpriteFrame":"","%Name":"ff23c0fb-a981-4cd9-bb33-aa7c9b24473b","name":"ff23c0fb-a981-4cd9-bb33-aa7c9b24473b","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
|
||||
{"$GMSpriteFrame":"","%Name":"d0370ade-8599-4155-9318-c2d7f3093323","name":"d0370ade-8599-4155-9318-c2d7f3093323","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
|
||||
],
|
||||
"gridX":0,
|
||||
"gridY":0,
|
||||
"height":48,
|
||||
"HTile":false,
|
||||
"layers":[
|
||||
{"$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,},
|
||||
{"$GMImageLayer":"","%Name":"a26b5cff-5172-4a89-b2c8-77679c7b6afb","blendMode":0,"displayName":"default","isLocked":false,"name":"a26b5cff-5172-4a89-b2c8-77679c7b6afb","opacity":100.0,"resourceType":"GMImageLayer","resourceVersion":"2.0","visible":true,},
|
||||
],
|
||||
"name":"s_bone_IK",
|
||||
"nineSlice":null,
|
||||
|
@ -49,7 +50,7 @@
|
|||
},
|
||||
"eventStubScript":null,
|
||||
"eventToFunction":{},
|
||||
"length":1.0,
|
||||
"length":2.0,
|
||||
"lockOrigin":false,
|
||||
"moments":{
|
||||
"$KeyframeStore<MomentsEventKeyframe>":"",
|
||||
|
@ -69,8 +70,11 @@
|
|||
"tracks":[
|
||||
{"$GMSpriteFramesTrack":"","builtinName":0,"events":[],"inheritsTrackColour":true,"interpolation":1,"isCreationTrack":false,"keyframes":{"$KeyframeStore<SpriteFrameKeyframe>":"","Keyframes":[
|
||||
{"$Keyframe<SpriteFrameKeyframe>":"","Channels":{
|
||||
"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,},
|
||||
"0":{"$SpriteFrameKeyframe":"","Id":{"name":"ff23c0fb-a981-4cd9-bb33-aa7c9b24473b","path":"sprites/s_bone_IK/s_bone_IK.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",},
|
||||
},"Disabled":false,"id":"4a26cb96-661e-4919-a885-99da307f9298","IsCreationKey":false,"Key":0.0,"Length":1.0,"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"2.0","Stretch":false,},
|
||||
{"$Keyframe<SpriteFrameKeyframe>":"","Channels":{
|
||||
"0":{"$SpriteFrameKeyframe":"","Id":{"name":"d0370ade-8599-4155-9318-c2d7f3093323","path":"sprites/s_bone_IK/s_bone_IK.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",},
|
||||
},"Disabled":false,"id":"953568eb-430d-4fa1-b0e2-411f290f1941","IsCreationKey":false,"Key":1.0,"Length":1.0,"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"2.0","Stretch":false,},
|
||||
],"resourceType":"KeyframeStore<SpriteFrameKeyframe>","resourceVersion":"2.0",},"modifiers":[],"name":"frames","resourceType":"GMSpriteFramesTrack","resourceVersion":"2.0","spriteId":null,"trackColour":0,"tracks":[],"traits":0,},
|
||||
],
|
||||
"visibleRange":null,
|
||||
|
|
Loading…
Reference in a new issue