3d camera

This commit is contained in:
Tanasart 2023-08-16 20:16:31 +02:00
parent da48f8b24a
commit 34b594f482
41 changed files with 1410 additions and 867 deletions

View file

@ -197,7 +197,8 @@
{"name":"sh_normal_light","order":1,"path":"shaders/sh_normal_light/sh_normal_light.yy",},
{"name":"node_tool","order":9,"path":"scripts/node_tool/node_tool.yy",},
{"name":"sh_find_pixel","order":3,"path":"shaders/sh_find_pixel/sh_find_pixel.yy",},
{"name":"__node_3d_camera","order":10,"path":"scripts/__node_3d_camera/__node_3d_camera.yy",},
{"name":"d3d_light_point","order":16,"path":"scripts/d3d_light_point/d3d_light_point.yy",},
{"name":"node_3d_camera","order":10,"path":"scripts/node_3d_camera/node_3d_camera.yy",},
{"name":"panel_preview_window","order":1,"path":"scripts/panel_preview_window/panel_preview_window.yy",},
{"name":"sh_scale3x","order":29,"path":"shaders/sh_scale3x/sh_scale3x.yy",},
{"name":"__node_3d","order":8,"path":"scripts/__node_3d/__node_3d.yy",},
@ -286,6 +287,7 @@
{"name":"s_node_armature_sample","order":18,"path":"sprites/s_node_armature_sample/s_node_armature_sample.yy",},
{"name":"o_dialog_notifications","order":6,"path":"objects/o_dialog_notifications/o_dialog_notifications.yy",},
{"name":"sh_draw_color","order":8,"path":"shaders/sh_draw_color/sh_draw_color.yy",},
{"name":"d3d_scene","order":15,"path":"scripts/d3d_scene/d3d_scene.yy",},
{"name":"s_node_array_find","order":2,"path":"sprites/s_node_array_find/s_node_array_find.yy",},
{"name":"fd_rectangle_set_velocity_time_step","order":17,"path":"scripts/fd_rectangle_set_velocity_time_step/fd_rectangle_set_velocity_time_step.yy",},
{"name":"fd_rectangle_set_collision_mask_sprite","order":1,"path":"scripts/fd_rectangle_set_collision_mask_sprite/fd_rectangle_set_collision_mask_sprite.yy",},
@ -1070,6 +1072,7 @@
{"name":"s_node_text_length","order":9,"path":"sprites/s_node_text_length/s_node_text_length.yy",},
{"name":"s_node_grid_hex","order":4,"path":"sprites/s_node_grid_hex/s_node_grid_hex.yy",},
{"name":"sh_fd_visualize_colorize_glsl","order":13,"path":"shaders/sh_fd_visualize_colorize_glsl/sh_fd_visualize_colorize_glsl.yy",},
{"name":"node_3d_light_point","order":2,"path":"scripts/node_3d_light_point/node_3d_light_point.yy",},
{"name":"s_node_pb_draw_fill","order":14,"path":"sprites/s_node_pb_draw_fill/s_node_pb_draw_fill.yy",},
{"name":"s_node_rate_remap","order":4,"path":"sprites/s_node_rate_remap/s_node_rate_remap.yy",},
{"name":"node_pb_draw_semi_ellipse","order":6,"path":"scripts/node_pb_draw_semi_ellipse/node_pb_draw_semi_ellipse.yy",},

View file

@ -708,7 +708,8 @@
{"id":{"name":"sh_normal_light","path":"shaders/sh_normal_light/sh_normal_light.yy",},},
{"id":{"name":"node_tool","path":"scripts/node_tool/node_tool.yy",},},
{"id":{"name":"sh_find_pixel","path":"shaders/sh_find_pixel/sh_find_pixel.yy",},},
{"id":{"name":"__node_3d_camera","path":"scripts/__node_3d_camera/__node_3d_camera.yy",},},
{"id":{"name":"d3d_light_point","path":"scripts/d3d_light_point/d3d_light_point.yy",},},
{"id":{"name":"node_3d_camera","path":"scripts/node_3d_camera/node_3d_camera.yy",},},
{"id":{"name":"panel_preview_window","path":"scripts/panel_preview_window/panel_preview_window.yy",},},
{"id":{"name":"sh_scale3x","path":"shaders/sh_scale3x/sh_scale3x.yy",},},
{"id":{"name":"__node_3d","path":"scripts/__node_3d/__node_3d.yy",},},
@ -806,6 +807,7 @@
{"id":{"name":"s_node_armature_sample","path":"sprites/s_node_armature_sample/s_node_armature_sample.yy",},},
{"id":{"name":"o_dialog_notifications","path":"objects/o_dialog_notifications/o_dialog_notifications.yy",},},
{"id":{"name":"sh_draw_color","path":"shaders/sh_draw_color/sh_draw_color.yy",},},
{"id":{"name":"d3d_scene","path":"scripts/d3d_scene/d3d_scene.yy",},},
{"id":{"name":"s_node_array_find","path":"sprites/s_node_array_find/s_node_array_find.yy",},},
{"id":{"name":"fd_rectangle_set_velocity_time_step","path":"scripts/fd_rectangle_set_velocity_time_step/fd_rectangle_set_velocity_time_step.yy",},},
{"id":{"name":"fd_rectangle_set_collision_mask_sprite","path":"scripts/fd_rectangle_set_collision_mask_sprite/fd_rectangle_set_collision_mask_sprite.yy",},},
@ -1700,6 +1702,7 @@
{"id":{"name":"s_node_text_length","path":"sprites/s_node_text_length/s_node_text_length.yy",},},
{"id":{"name":"s_node_grid_hex","path":"sprites/s_node_grid_hex/s_node_grid_hex.yy",},},
{"id":{"name":"sh_fd_visualize_colorize_glsl","path":"shaders/sh_fd_visualize_colorize_glsl/sh_fd_visualize_colorize_glsl.yy",},},
{"id":{"name":"node_3d_light_point","path":"scripts/node_3d_light_point/node_3d_light_point.yy",},},
{"id":{"name":"s_node_pb_draw_fill","path":"sprites/s_node_pb_draw_fill/s_node_pb_draw_fill.yy",},},
{"id":{"name":"s_node_rate_remap","path":"sprites/s_node_rate_remap/s_node_rate_remap.yy",},},
{"id":{"name":"s_node_3d_cube","path":"sprites/s_node_3d_cube/s_node_3d_cube.yy",},},

View file

@ -2,22 +2,40 @@
event_inherited();
#region data
dialog_w = ui(280);
dialog_h = ui(60 + 40 * 3);
dialog_w = ui(320);
destroy_on_click_out = true;
display_parameter = {};
#endregion
#region data
cb_grid = new checkBox(function() {
PANEL_GRAPH.show_grid = !PANEL_GRAPH.show_grid;
})
properties = [
[
new checkBox(function() { display_parameter.show_grid = !display_parameter.show_grid; }),
__txt("Grid"),
function() { return display_parameter.show_grid },
],
[
new checkBox(function() { display_parameter.show_dimension = !display_parameter.show_dimension; }),
__txtx("graph_visibility_dim", "Dimension"),
function() { return display_parameter.show_dimension },
],
[
new checkBox(function() { display_parameter.show_compute = !display_parameter.show_compute; }),
__txtx("graph_visibility_compute", "Compute time"),
function() { return display_parameter.show_compute },
],
[
new checkBox(function() { display_parameter.avoid_label = !display_parameter.avoid_label; }),
__txtx("graph_visibility_avoid_label", "Avoid Label"),
function() { return display_parameter.avoid_label },
],
[
new slider(50, 100, 1, function(val) { display_parameter.preview_scale = val; }),
__txtx("graph_visibility_preview_scale", "Preview Scale"),
function() { return display_parameter.preview_scale },
],
]
cb_dim = new checkBox(function() {
PANEL_GRAPH.show_dimension = !PANEL_GRAPH.show_dimension;
})
cb_com = new checkBox(function() {
PANEL_GRAPH.show_compute = !PANEL_GRAPH.show_compute;
})
dialog_h = ui(60 + 40 * array_length(properties));
#endregion

View file

@ -12,24 +12,28 @@ if !ready exit;
#region draw
var yy = dialog_y + ui(64);
var ww = ui(128);
var wh = TEXTBOX_HEIGHT;
cb_grid.setFocusHover(sFOCUS, sHOVER);
cb_grid.register();
draw_set_text(f_p1, fa_left, fa_center, COLORS._main_text);
draw_text(dialog_x + ui(32), yy, __txt("Grid"));
cb_grid.draw(dialog_x + dialog_w - ui(48), yy, PANEL_GRAPH.show_grid, mouse_ui,, fa_center, fa_center);
yy += ui(40);
cb_dim.setFocusHover(sFOCUS, sHOVER);
cb_dim.register();
draw_set_text(f_p1, fa_left, fa_center, COLORS._main_text);
draw_text(dialog_x + ui(32), yy, __txtx("graph_visibility_dim", "Dimension"));
cb_dim.draw(dialog_x + dialog_w - ui(48), yy, PANEL_GRAPH.show_dimension, mouse_ui,, fa_center, fa_center);
yy += ui(40);
cb_com.setFocusHover(sFOCUS, sHOVER);
cb_com.register();
draw_set_text(f_p1, fa_left, fa_center, COLORS._main_text);
draw_text(dialog_x + ui(32), yy, __txtx("graph_visibility_compute", "Compute time"));
cb_com.draw(dialog_x + dialog_w - ui(48), yy, PANEL_GRAPH.show_compute, mouse_ui,, fa_center, fa_center);
for( var i = 0, n = array_length(properties); i < n; i++ ) {
var _prop = properties[i];
var _widg = _prop[0];
var _text = _prop[1];
var _data = _prop[2]();
_widg.setFocusHover(sFOCUS, sHOVER);
_widg.register();
draw_set_text(f_p1, fa_left, fa_center, COLORS._main_text);
draw_text(dialog_x + ui(32), yy, _text);
var params = new widgetParam(dialog_x + dialog_w - ui(16) - ww, yy - wh / 2, ww, wh, _data);
if(is_instanceof(_widg, checkBox))
params.halign = fa_center;
_widg.drawParam(params);
yy += ui(40);
}
#endregion

View file

@ -8,76 +8,96 @@ event_inherited();
note = "";
var link = "https://gist.githubusercontent.com/Ttanasart-pt/e7ab670299ce6b00cfd632646f3ac9a8/raw/1.0.0";
note_get = http_get(link);
var _link = $"https://gist.githubusercontent.com/Ttanasart-pt/f21a140906a60c6e12c99ebfecec1645/raw/{VERSION_STRING}";
note_get = http_get(_link);
sp_note = new scrollPane(dialog_w - ui(80), dialog_h - ui(88), function(_y, _m) {
draw_clear_alpha(COLORS.panel_bg_clear, 0);
BLEND_OVERRIDE
var yy = 0;
BLEND_ALPHA_MULP
var xx = ui(8);
var yy = ui(8);
var ww = sp_note.surface_w - ui(16);
var txt = note;
while(string_length(txt) > 0) {
var nl = string_pos("\n", txt);
var line = string_copy(txt, 1, nl - 1);
var tab = 1;
while(string_char_at(line, tab) == " " && tab < string_length(line)) tab++;
line = string_copy(line, tab, string_length(line) - tab + 1);
var lines = string_split(txt, "\n");
for( var i = 0, n = array_length(lines); i < n; i++ ) {
var line = lines[i];
var _stx = string_split(string_trim(line), " ");
var _line = line;
if(nl == 0) {
line = txt;
txt = "";
if(array_length(_stx) <= 1) {
draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text);
draw_text_line(xx + 0, _y + yy, line, -1, ww);
yy += string_height_ext(_line, -1, ww);
} else {
txt = string_copy(txt, nl + 1, string_length(txt) - nl);
}
var sp = string_pos(" ", line);
var md = string_copy(line, 1, sp - 1);
var ww = dialog_w - ui(128);
var xx = (tab - 1) * ui(8);
switch(md) {
case "#" :
draw_set_text(f_h3, fa_left, fa_top, COLORS._main_text_on_accent);
line = string_copy(line, sp + 1, string_length(line) - sp);
yy += ui(16);
draw_text_line(xx, _y + yy, line, -1, ww);
var _cont = array_create(array_length(_stx) - 1);
for( var j = 1, m = array_length(_stx); j < m; j++ )
_cont[j - 1] = _stx[j];
_line = string_join_ext(" ", _cont);
switch(_stx[0]) {
case "#" :
draw_set_text(f_h3, fa_left, fa_top, COLORS._main_text_sub);
yy += (!!i) * ui(16);
draw_text_line(xx, _y + yy, _line, -1, ww);
yy += ui(4);
break;
case "##" :
draw_set_text(f_h5, fa_left, fa_top, COLORS._main_text_on_accent);
line = string_copy(line, sp + 1, string_length(line) - sp);
yy += ui(8);
draw_text_line(xx + ui(16), _y + yy, line, -1, ww);
yy += ui(4);
break;
case "###" :
draw_set_text(f_p0b, fa_left, fa_top, COLORS._main_accent);
line = string_copy(line, sp + 1, string_length(line) - sp);
yy += ui(8);
draw_text_line(xx + ui(16), _y + yy, line, -1, ww);
yy += ui(4);
break;
case "-" :
draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text);
line = string_copy(line, sp + 1, string_length(line) - sp);
draw_sprite_ui_uniform(THEME.text_bullet, 0, xx + ui(16), _y + yy + ui(10), 1, COLORS._main_icon);
draw_text_line(xx + ui(28), _y + yy, line, -1, ww);
break;
case "+" :
draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text);
line = string_copy(line, sp + 1, string_length(line) - sp);
draw_sprite_ui_uniform(THEME.text_bullet, 1, xx + ui(16), _y + yy + ui(10), 1, COLORS._main_value_positive);
draw_text_line(xx + ui(28), _y + yy, line, -1, ww);
break;
default :
draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text);
draw_text_line(xx + 0, _y + yy, line, -1, ww);
break;
yy += ui(4);
break;
case "##" :
draw_set_text(f_h5, fa_left, fa_top, COLORS._main_text_sub);
var _h = string_height_ext(_line, -1, ww);
yy += (!!i) * ui(16);
draw_sprite_stretched_ext(THEME.group_label, 1, xx, yy - ui(4), ww, _h + ui(8), COLORS._main_icon, 1);
draw_text_line(xx + ui(16), _y + yy, _line, -1, ww);
yy += ui(8);
break;
case "###" :
draw_set_text(f_p0b, fa_left, fa_top, COLORS._main_accent);
yy += (!!i) * ui(8);
draw_text_line(xx + ui(16), _y + yy, _line, -1, ww);
yy += ui(4);
break;
case "-" :
var _x = xx + ui(28);
if(string_char_at(line, 1) == "\t")
_x += ui(16);
draw_sprite_ui_uniform(THEME.text_bullet, 0, _x - ui(12), _y + yy + ui(18), 1, COLORS._main_icon);
var _lx = _x;
draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text);
for( var j = 1, m = array_length(_stx); j < m; j++ ) {
var _word = (j > 1? " " : "") + _stx[j];
if(_x + string_width(_word) > ww) {
yy += line_get_height();
_x = _lx;
}
if(string_char_at(_word, 1) == "[")
draw_set_color(COLORS._main_text_accent);
else
draw_set_color(COLORS._main_text);
draw_text(_x, _y + yy, _word);
_x += string_width(_word);
}
yy += line_get_height();
break;
default :
draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text);
draw_text_line(xx + 0, _y + yy, _line, -1, ww);
break;
}
if(_stx[0] != "-")
yy += string_height_ext(_line, -1, ww);
}
yy += string_height_ext(line, -1, ww);
}
BLEND_NORMAL

View file

@ -24,18 +24,16 @@ function __part(_node) constructor {
turning = 0;
turnSpd = 0
ac = 0;
wig = 0;
spVec = [ 0, 0 ];
accel = 0;
wig = 0;
spVec = [ 0, 0 ];
boundary_data = -1;
g = 0;
gDir = -90;
_gx = 0;
_gy = 0;
gx = 0;
gy = 0;
grav = 0;
gravDir = -90;
gravX = 0;
gravY = 0;
scx = 1;
scy = 1;
@ -69,8 +67,6 @@ function __part(_node) constructor {
surf = _surf;
x = _x;
y = _y;
gx = 0;
gy = 0;
prevx = undefined;
prevy = undefined;
@ -81,13 +77,13 @@ function __part(_node) constructor {
}
static setPhysic = function(_sx, _sy, _ac, _g, _gDir, _wig, _turn, _turnSpd) {
speedx = _sx;
speedy = _sy;
ac = _ac;
g = _g;
gDir = _gDir;
_gx = lengthdir_x(g, gDir);
_gy = lengthdir_y(g, gDir);
speedx = _sx;
speedy = _sy;
accel = _ac;
grav = _g;
gravDir = _gDir;
gravX = lengthdir_x(grav, gravDir);
gravY = lengthdir_y(grav, gravDir);
turning = _turn;
turnSpd = _turnSpd;
@ -139,7 +135,7 @@ function __part(_node) constructor {
var dirr = point_direction(0, 0, speedx, speedy);
var diss = point_distance(0, 0, speedx, speedy);
diss += ac;
diss = max(0, diss + accel);
if(speedx != 0 || speedy != 0) {
if(wig != 0)
@ -151,15 +147,8 @@ function __part(_node) constructor {
}
}
speedx = lengthdir_x(diss, dirr) + _gx;
speedy = lengthdir_y(diss, dirr) + _gy;
//if(_gx != 0 || _gy != 0) {
// gx += _gx;
// gy += _gy;
// x += gx;
// y += gy;
//}
speedx = lengthdir_x(diss, dirr) + gravX;
speedy = lengthdir_y(diss, dirr) + gravY;
if(follow) rot = spVec[1];
else rot += rot_s;

View file

@ -1,11 +0,0 @@
function Node_3D_Camera(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constructor {
name = "3D Camera";
static update = function(frame = PROJECT.animator.current_frame) {
}
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
}
}

View file

@ -1,4 +1,4 @@
function Node_3D_Light(_x, _y, _group = noone) : Node_3DObject(_x, _y, _group) constructor {
function Node_3D_Light(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group) constructor {
name = "3D Light";
object = new __3dLight();
@ -21,8 +21,8 @@ function Node_3D_Light(_x, _y, _group = noone) : Node_3DObject(_x, _y, _group) c
var _col = inputs[| input_d3d_index + 0].getValue();
var _int = inputs[| input_d3d_index + 1].getValue();
object.color = _col;
object.intensity = _int;
object.color = _col;
object.intensity = _int;
outputs[| 0].setValue(object);
}

View file

@ -1,4 +1,4 @@
function Node_3D_Mesh(_x, _y, _group = noone) : Node_3DObject(_x, _y, _group) constructor {
function Node_3D_Mesh(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group) constructor {
name = "3D Mesh";
input_mesh_index = ds_list_size(inputs);

View file

@ -1,4 +1,4 @@
function Node_3DObject(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constructor {
function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constructor {
name = "3D Object";
h = 64;
min_h = h;
@ -472,9 +472,9 @@ function Node_3DObject(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constru
outputs[| 0].setValue(object);
}
static submitShader = function(params = {}, shader = noone) { object.submitShader(params, shader); }
static submitUI = function(params = {}, shader = noone) { object.submitUI(params, shader); }
static submit = function(params = {}, shader = noone) { object.submit(params, shader); }
static submitSel = function(params = {}, shader = noone) { object.submitSel(params, shader); }
static update = function(frame = PROJECT.animator.current_frame) {}
}

View file

@ -1,12 +1,21 @@
enum CAMERA_PROJECTION {
perspective,
orthograph
}
function __3dCamera() constructor {
position = new __vec3();
rotation = new BBMOD_Quaternion();
focus = new __vec3();
up = new __vec3(0, 0, -1);
useFocus = true;
focus_angle_x = 0;
focus_angle_y = 0;
focus_dist = 1;
projection = CAMERA_PROJECTION.perspective;
fov = 60;
view_near = 1;
view_far = 32000;
@ -39,8 +48,21 @@ function __3dCamera() constructor {
}
static setMatrix = function() {
projMat.setRaw(matrix_build_projection_perspective_fov(fov, view_aspect, view_near, view_far));
viewMat.setRaw(matrix_build_lookat(position.x, position.y, position.z, focus.x, focus.y, focus.z, up.x, up.y, up.z));
if(projection == CAMERA_PROJECTION.perspective)
projMat.setRaw(matrix_build_projection_perspective_fov(fov, view_aspect, view_near, view_far));
else
projMat.setRaw(matrix_build_projection_ortho(view_w, view_h, view_near, view_far));
if(useFocus)
viewMat.setRaw(matrix_build_lookat(position.x, position.y, position.z, focus.x, focus.y, focus.z, up.x, up.y, up.z));
else {
var _for = rotation.Rotate(new BBMOD_Vec3( 1.0, 0.0, 0.0));
var _up = rotation.Rotate(new BBMOD_Vec3( 0.0, 0.0, -1.0));
viewMat.setRaw(matrix_build_lookat(position.x, position.y, position.z,
position.x + _for.X, position.y + _for.Y, position.z + _for.Z,
_up.X, _up.Y, _up.Z));
}
return self;
}

View file

@ -6,24 +6,24 @@ function __3dCamera_object() : __3dObject() constructor {
len = 0.5; //cameraLength
vertex = [
[ len, -ivw, ivh ], [ len, ivw, ivh ],
[ len, ivw, ivh ], [ len, ivw, -ivh ],
[ len, ivw, -ivh ], [ len, -ivw, -ivh ],
[ len, -ivw, -ivh ], [ len, -ivw, ivh ],
[ -len, -ivw, ivh ], [ -len, ivw, ivh ],
[ -len, ivw, ivh ], [ -len, ivw, -ivh ],
[ -len, ivw, -ivh ], [ -len, -ivw, -ivh ],
[ -len, -ivw, -ivh ], [ -len, -ivw, ivh ],
[ -len, -ovw, ovh ], [ -len, ovw, ovh ],
[ -len, ovw, ovh ], [ -len, ovw, -ovh ],
[ -len, ovw, -ovh ], [ -len, -ovw, -ovh ],
[ -len, -ovw, -ovh ], [ -len, -ovw, ovh ],
[ len, -ivw, ivh ], [ -len, -ovw, ovh ],
[ len, ivw, ivh ], [ -len, ovw, ovh ],
[ len, ivw, -ivh ], [ -len, ovw, -ovh ],
[ len, -ivw, -ivh ], [ -len, -ovw, -ovh ],
[ len, -ovw, ovh ], [ len, ovw, ovh ],
[ len, ovw, ovh ], [ len, ovw, -ovh ],
[ len, ovw, -ovh ], [ len, -ovw, -ovh ],
[ len, -ovw, -ovh ], [ len, -ovw, ovh ],
[ -len, -ivw, ivh ], [ len, -ovw, ovh ],
[ -len, ivw, ivh ], [ len, ovw, ovh ],
[ -len, ivw, -ivh ], [ len, ovw, -ovh ],
[ -len, -ivw, -ivh ], [ len, -ovw, -ovh ],
[ -len, -ovw * 0.5, ovh + 0.2 ], [ -len, ovw * 0.5, ovh + 0.2 ],
[ -len, 0, ovh + 0.6 ], [ -len, ovw * 0.5, ovh + 0.2 ],
[ -len, -ovw * 0.5, ovh + 0.2 ], [ -len, 0, ovh + 0.6 ],
[ len, -ovw * 0.5, ovh + 0.2 ], [ len, ovw * 0.5, ovh + 0.2 ],
[ len, 0, ovh + 0.6 ], [ len, ovw * 0.5, ovh + 0.2 ],
[ len, -ovw * 0.5, ovh + 0.2 ], [ len, 0, ovh + 0.6 ],
];
VF = global.VF_POS_COL;
@ -33,6 +33,12 @@ function __3dCamera_object() : __3dObject() constructor {
position.set(-5, -5, 5);
rotation.set(0, 30, 135);
scale.set(1, room_width / room_height, 1);
static submitSel = function(params = {}) {
shader_set(sh_d3d_wireframe);
submitVertex(params);
shader_reset();
}
}
function calculate_3d_position(camFx, camFy, camFz, camAx, camAy, camDist) {

View file

@ -1,39 +1,10 @@
function __3dLight() : __3dObject() constructor {
UI_vertex = [];
for( var i = 0; i <= 32; i++ )
UI_vertex[i] = [ 0, lengthdir_x(0.5, i / 32 * 360), lengthdir_y(0.5, i / 32 * 360), c_yellow, 0.8 ];
for( var i = 0; i <= 32; i++ ) UI_vertex[i] = [ 0, lengthdir_x(0.5, i / 32 * 360), lengthdir_y(0.5, i / 32 * 360), c_yellow, 0.8 ];
VB_UI = build(noone, UI_vertex);
color = c_white;
intensity = 1;
static presubmit = function(params = {}) {
var _rot = new __rot3(0, 0, 0).lookAt(position, params.camera.position);
var rot = matrix_build(0, 0, 0,
_rot.x, _rot.y, _rot.z,
1, 1, 1);
var sca = matrix_build(0, 0, 0,
0, 0, 0,
0.6, 0.6, 0.6);
var pos = matrix_build(position.x, position.y, position.z,
0, 0, 0,
1, 1, 1);
matrix_stack_clear();
matrix_stack_push(pos);
matrix_stack_push(rot);
matrix_set(matrix_world, matrix_stack_top());
vertex_submit(VB_UI, pr_linestrip, -1);
matrix_stack_push(sca);
matrix_set(matrix_world, matrix_stack_top());
vertex_submit(VB_UI, pr_linestrip, -1);
matrix_stack_clear();
matrix_set(matrix_world, matrix_build_identity());
}
static shine = function(params = {}) {}
static submit = function(params = {}, shader = noone) {}
}

View file

@ -1,30 +1,46 @@
function __3dLightDirectional() : __3dLight() constructor {
vertex = [
[ 1, 0, 0, c_yellow, 0.8 ], [ 3, 0, 0, c_yellow, 0.8 ]
];
VF = global.VF_POS_COL;
vertex = [ [ 1, 0, 0, c_yellow, 0.8 ], [ 3, 0, 0, c_yellow, 0.8 ] ];
VF = global.VF_POS_COL;
render_type = pr_linelist;
VB = build();
VB = build();
color = c_white;
color = c_white;
intensity = 1;
position.set(1, 0, 0);
position.set(4, 0, 0);
static submit = function(params = {}, shader = noone) { shine(params); }
static submitUI = function(params = {}, shader = noone) { shine(params); submitVertex(params, shader); }
static submitSel = function(params = {}) {
shader_set(sh_d3d_wireframe);
presubmit(params);
preSubmitVertex(params);
shader_reset();
}
static shine = function(params = {}) {
shader_set(sh_d3d_default);
static submitShader = function(params = {}) { params.addLightDirectional(self); }
static preSubmitVertex = function(params = {}) {
var _rot = new __rot3(0, 0, 0).lookAt(position, params.camera.position);
shader_set_f("light_dir_direction", position.x, position.y, position.z);
shader_set_f("light_dir_color", colToVec4(color));
shader_set_f("light_dir_intensity", intensity);
var rot = matrix_build(0, 0, 0,
_rot.x, _rot.y, _rot.z,
1, 1, 1);
var sca = matrix_build(0, 0, 0,
0, 0, 0,
0.6, 0.6, 0.6);
var pos = matrix_build(position.x, position.y, position.z,
0, 0, 0,
1, 1, 1);
shader_reset();
matrix_stack_clear();
matrix_stack_push(pos);
matrix_stack_push(rot);
matrix_set(matrix_world, matrix_stack_top());
vertex_submit(VB_UI, pr_linestrip, -1);
matrix_stack_push(sca);
matrix_set(matrix_world, matrix_stack_top());
vertex_submit(VB_UI, pr_linestrip, -1);
matrix_stack_clear();
matrix_set(matrix_world, matrix_build_identity());
}
}

View file

@ -0,0 +1,50 @@
function __3dLightPoint() : __3dLight() constructor {
color = c_white;
intensity = 1;
radius = 10;
static submitSel = function(params = {}) {
shader_set(sh_d3d_wireframe);
preSubmitVertex(params);
shader_reset();
}
static submitShader = function(params = {}) { params.addLightPoint(self); }
static preSubmitVertex = function(params = {}) {
var _rot = new __rot3(0, 0, 0).lookAt(position, params.camera.position);
var rot = matrix_build(0, 0, 0,
_rot.x, _rot.y, _rot.z,
1, 1, 1);
var sca = matrix_build(0, 0, 0,
0, 0, 0,
0.6, 0.6, 0.6);
var ran = matrix_build(0, 0, 0,
0, 0, 0,
radius * 2, radius * 2, radius * 2);
var pos = matrix_build(position.x, position.y, position.z,
0, 0, 0,
1, 1, 1);
matrix_stack_clear();
matrix_stack_push(pos);
matrix_stack_push(rot);
matrix_set(matrix_world, matrix_stack_top());
vertex_submit(VB_UI, pr_linestrip, -1);
matrix_stack_push(sca);
matrix_set(matrix_world, matrix_stack_top());
vertex_submit(VB_UI, pr_linestrip, -1);
matrix_stack_pop();
matrix_stack_push(ran);
matrix_set(matrix_world, matrix_stack_top());
vertex_submit(VB_UI, pr_linestrip, -1);
matrix_stack_pop();
matrix_stack_clear();
matrix_set(matrix_world, matrix_build_identity());
}
}

View file

@ -0,0 +1,11 @@
{
"resourceType": "GMScript",
"resourceVersion": "1.0",
"name": "d3d_light_point",
"isCompatibility": false,
"isDnD": false,
"parent": {
"name": "3d",
"path": "folders/functions/3d.yy",
},
}

View file

@ -26,7 +26,7 @@ function __3dObject() constructor {
rotation = new BBMOD_Quaternion();
scale = new __vec3(1, 1, 1);
static build = function(_buffer = VB, _vertex = vertex, _normal = normals) {
static build = function(_buffer = VB, _vertex = vertex, _normal = normals) { #region
if(_buffer != noone) vertex_delete_buffer(_buffer);
_buffer = vertex_create_buffer();
@ -57,16 +57,18 @@ function __3dObject() constructor {
vertex_end(_buffer);
return _buffer;
}
} #endregion
static presubmit = function(params = {}) {}
static postsubmit = function(params = {}) {}
static preSubmitVertex = function(params = {}) {}
static postSubmitVertex = function(params = {}) {}
static submitShader = function(params = {}, shader = noone) {}
static submit = function(params = {}, shader = noone) { submitVertex(params, shader); }
static submitUI = function(params = {}, shader = noone) { submitVertex(params, shader); }
static submitSel = function(params = {}) { submitVertex(params, sh_d3d_silhouette); }
static submitVertex = function(params = {}, shader = noone) {
static submitVertex = function(params = {}, shader = noone) { #region
if(shader != noone)
shader_set(shader);
else if(custom_shader != noone)
@ -78,7 +80,7 @@ function __3dObject() constructor {
}
}
presubmit(params);
preSubmitVertex(params);
if(VB != noone) {
var pos = matrix_build(position.x, position.y, position.z,
@ -101,12 +103,8 @@ function __3dObject() constructor {
matrix_set(matrix_world, matrix_build_identity());
}
postsubmit(params);
postSubmitVertex(params);
shader_reset();
}
}
function __3dObjectParameters(camera) constructor {
self.camera = camera;
} #endregion
}

View file

@ -15,7 +15,7 @@ function __plane(origin, normal) constructor {
#region functions
function d3d_intersect_ray_plane(ray, plane) {
print($"Intersect {ray}\n\tto {plane}");
//print($"Intersect {ray}\n\tto {plane}");
var det = plane.normal.dot(ray.direction);
if(det == 0) return new __vec3();

View file

@ -0,0 +1,67 @@
function __3dScene(camera) constructor {
self.camera = camera;
name = "New scene";
lightAmbient = c_black;
lightDir_count = 0;
lightDir_direction = [];
lightDir_color = [];
lightDir_intensity = [];
lightPnt_count = 0;
lightPnt_position = [];
lightPnt_color = [];
lightPnt_intensity = [];
lightPnt_radius = [];
static reset = function() {
lightDir_count = 0;
lightDir_direction = [];
lightDir_color = [];
lightDir_intensity = [];
lightPnt_count = 0;
lightPnt_position = [];
lightPnt_color = [];
lightPnt_intensity = [];
lightPnt_radius = [];
}
static apply = function() {
shader_set(sh_d3d_default);
shader_set_f("light_ambient", colToVec4(lightAmbient));
shader_set_i("light_dir_count", lightDir_count);
shader_set_f("light_dir_direction", lightDir_direction);
shader_set_f("light_dir_color", lightDir_color);
shader_set_f("light_dir_intensity", lightDir_intensity);
shader_set_i("light_pnt_count", lightPnt_count);
shader_set_f("light_pnt_position", lightPnt_position);
shader_set_f("light_pnt_color", lightPnt_color);
shader_set_f("light_pnt_intensity", lightPnt_intensity);
shader_set_f("light_pnt_radius", lightPnt_radius);
//print($"Scene {name} submit {lightPnt_position} point lights");
shader_reset();
}
static addLightDirectional = function(light) {
array_append(lightDir_direction, [ light.position.x, light.position.y, light.position.z ]);
array_append(lightDir_color, colToVec4(light.color));
array_append(lightDir_intensity, [ light.intensity ]);
lightDir_count++;
return self;
}
static addLightPoint = function(light) {
array_append(lightPnt_position, [ light.position.x, light.position.y, light.position.z ]);
array_append(lightPnt_color, colToVec4(light.color));
array_append(lightPnt_intensity, [ light.intensity ]);
array_append(lightPnt_radius, [ light.radius ]);
lightPnt_count++;
return self;
}
}

View file

@ -0,0 +1,11 @@
{
"resourceType": "GMScript",
"resourceVersion": "1.0",
"name": "d3d_scene",
"isCompatibility": false,
"isDnD": false,
"parent": {
"name": "3d",
"path": "folders/functions/3d.yy",
},
}

View file

@ -26,6 +26,7 @@ enum ACTION_TYPE {
collection_loaded,
struct_modify,
custom,
}
enum DS_TYPE {
@ -39,6 +40,8 @@ function Action(_type, _object, _data) constructor {
data = _data;
extra_data = 0;
clear_action = noone;
static undo = function() {
var _n;
@ -104,6 +107,9 @@ function Action(_type, _object, _data) constructor {
obj.deserialize(data);
data = _data;
break;
case ACTION_TYPE.custom :
data = obj(data);
break;
}
}
@ -171,6 +177,9 @@ function Action(_type, _object, _data) constructor {
obj.deserialize(data);
data = _data;
break;
case ACTION_TYPE.custom :
data = obj(data);
break;
}
}
@ -225,9 +234,17 @@ function Action(_type, _object, _data) constructor {
case ACTION_TYPE.struct_modify :
ss = $"modify {struct_try_get(obj, "name", "value")}";
break;
case ACTION_TYPE.custom :
ss = struct_try_get(data, "tooltip", "action");
break;
}
return ss;
}
static destroy = function() {
if(clear_action == noone) return;
clear_action(data);
}
}
function recordAction(_type, _object, _data = -1) {
@ -237,7 +254,12 @@ function recordAction(_type, _object, _data = -1) {
var act = new Action(_type, _object, _data);
array_push(o_main.action_last_frame, act);
ds_stack_clear(REDO_STACK);
while(!ds_stack_empty(REDO_STACK)) {
var actions = ds_stack_pop(REDO_STACK);
for( var i = 0, n = array_length(actions); i < n; i++ )
actions[i].destroy();
}
return act;
}

View file

@ -101,10 +101,10 @@
globalvar VERSION, SAVE_VERSION, VERSION_STRING, BUILD_NUMBER;
VERSION = 11505;
VERSION = 11506;
SAVE_VERSION = 11500;
VERSION_STRING = "1.15.0.5";
BUILD_NUMBER = 11505;
VERSION_STRING = "1.15.0.6";
BUILD_NUMBER = 11506;
globalvar APPEND_MAP;
APPEND_MAP = ds_map_create();

View file

@ -0,0 +1,138 @@
function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group) constructor {
name = "3D Camera";
object = new __3dCamera_object();
camera = new __3dCamera();
camera.useFocus = false;
scene = new __3dScene(camera);
scene.name = "Camera";
inputs[| input_d3d_index + 0] = nodeValue("FOV", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 60)
.setDisplay(VALUE_DISPLAY.slider, [ 10, 90, 1 ]);
inputs[| input_d3d_index + 1] = nodeValue("Clipping Distance", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, [ 1, 32000 ])
.setDisplay(VALUE_DISPLAY.vector);
inputs[| input_d3d_index + 2] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF )
.setDisplay(VALUE_DISPLAY.vector);
inputs[| input_d3d_index + 3] = nodeValue("Projection", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0 )
.setDisplay(VALUE_DISPLAY.enum_button, [ "Perspective", "Orthographic" ]);
inputs[| input_d3d_index + 4] = nodeValue("Scene", self, JUNCTION_CONNECT.input, VALUE_TYPE.d3Scene, noone )
.setVisible(true, true);
inputs[| input_d3d_index + 5] = nodeValue("Ambient Light", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_black );
inputs[| input_d3d_index + 6] = nodeValue("Show Background", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false );
inputs[| input_d3d_index + 7] = nodeValue("Backface Culling", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
.setDisplay(VALUE_DISPLAY.enum_button, [ "None", "CW", "CCW" ]);
inputs[| input_d3d_index + 8] = nodeValue("Orthographic Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
.setDisplay(VALUE_DISPLAY.slider, [ 0.01, 4, 0.01 ]);
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
input_display_list = [ input_d3d_index + 4,
["Output", false], input_d3d_index + 2,
["Transform", false], 0, 1,
["Camera", false], input_d3d_index + 3, input_d3d_index + 0, input_d3d_index + 1, input_d3d_index + 8,
["Render", false], input_d3d_index + 5, input_d3d_index + 6, input_d3d_index + 7,
];
static step = function() {
var _proj = inputs[| input_d3d_index + 3].getValue();
inputs[| input_d3d_index + 8].setVisible(_proj == 1);
}
static update = function(frame = PROJECT.animator.current_frame) {
setTransform();
var _pos = inputs[| 0].getValue();
var _rot = inputs[| 1].getValue();
var _fov = inputs[| input_d3d_index + 0].getValue();
var _clip = inputs[| input_d3d_index + 1].getValue();
var _dim = inputs[| input_d3d_index + 2].getValue();
var _proj = inputs[| input_d3d_index + 3].getValue();
var _scne = inputs[| input_d3d_index + 4].getValue();
var _ambt = inputs[| input_d3d_index + 5].getValue();
var _dbg = inputs[| input_d3d_index + 6].getValue();
var _back = inputs[| input_d3d_index + 7].getValue();
var _orts = inputs[| input_d3d_index + 8].getValue();
if(_scne == noone) return;
camera.position.set(_pos[0], _pos[1], _pos[2]);
camera.rotation.set(_rot[0], _rot[1], _rot[2], _rot[3]);
camera.projection = _proj;
camera.setViewFov(_fov, _clip[0], _clip[1]);
if(_proj == 0) camera.setViewSize(_dim[0], _dim[1]);
else if(_proj == 1) camera.setViewSize(_dim[0] / _orts, _dim[1] / _orts);
scene.lightAmbient = _ambt;
var _outSurf = outputs[| 0].getValue();
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1]);
outputs[| 0].setValue(_outSurf);
camera.setMatrix();
surface_set_target(_outSurf);
if(_dbg) draw_clear(_ambt);
else DRAW_CLEAR
gpu_set_zwriteenable(true);
gpu_set_ztestenable(true);
gpu_set_cullmode(_back);
var cam = camera_get_active();
camera.applyCamera(cam);
scene.reset();
_scne.submitShader(scene);
scene.apply();
_scne.submit(scene); //////////////// SUBMIT ////////////////
surface_reset_target();
gpu_set_cullmode(cull_noculling);
}
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
}
static submitShader = function(params = {}, shader = noone) {
object.submitShader(params, shader);
var _scne = inputs[| input_d3d_index + 4].getValue();
if(_scne == noone) return;
_scne.submitShader(params, shader);
}
static submitUI = function(params = {}, shader = noone) {
object.submitUI(params, shader);
var _scne = inputs[| input_d3d_index + 4].getValue();
if(_scne == noone) return;
_scne.submitUI(params, shader);
}
static submit = function(params = {}, shader = noone) {
object.submit(params, shader);
var _scne = inputs[| input_d3d_index + 4].getValue();
if(_scne == noone) return;
_scne.submit(params, shader);
}
static submitSel = function(params = {}, shader = noone) {
object.submitSel(params, shader);
}
}

View file

@ -1,7 +1,7 @@
{
"resourceType": "GMScript",
"resourceVersion": "1.0",
"name": "__node_3d_camera",
"name": "node_3d_camera",
"isCompatibility": false,
"isDnD": false,
"parent": {

View file

@ -0,0 +1,19 @@
function Node_3D_Light_Point(_x, _y, _group = noone) : Node_3D_Light(_x, _y, _group) constructor {
name = "Point Light";
object = new __3dLightPoint();
inputs[| input_light_index + 0] = nodeValue("Radius", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 4)
input_display_list = [
["Transform", false], 0,
__d3d_input_list_light, input_light_index,
]
static update = function(frame = PROJECT.animator.current_frame) {
setTransform();
setLight();
var _rad = inputs[| input_light_index + 0].getValue();
object.radius = _rad;
}
}

View file

@ -0,0 +1,11 @@
{
"resourceType": "GMScript",
"resourceVersion": "1.0",
"name": "node_3d_light_point",
"isCompatibility": false,
"isDnD": false,
"parent": {
"name": "d3d light",
"path": "folders/nodes/data/3D/d3d light.yy",
},
}

View file

@ -0,0 +1,12 @@
{
"isDnD": false,
"isCompatibility": false,
"parent": {
"name": "variable",
"path": "folders/nodes/data/variable.yy",
},
"resourceVersion": "1.0",
"name": "node_counter",
"tags": [],
"resourceType": "GMScript",
}

View file

@ -8,6 +8,8 @@ function Node_3D_Scene(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constru
setIsDynamicInput(1);
object_lists = [];
static createNewInput = function() {
var index = ds_list_size(inputs);
inputs[| index] = nodeValue("Object", self, JUNCTION_CONNECT.input, VALUE_TYPE.d3Mesh, noone )
@ -40,36 +42,26 @@ function Node_3D_Scene(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constru
refreshDynamicInput();
}
static submitSel = function(params = {}) {
for( var i = input_fix_len, n = ds_list_size(inputs); i < n; i += data_length ) {
var _obj = inputs[| i].getValue();
if(_obj == noone) continue;
_obj.submitSel(params);
}
}
static submitUI = function(params = {}, shader = noone) {
for( var i = input_fix_len, n = ds_list_size(inputs); i < n; i += data_length ) {
var _obj = inputs[| i].getValue();
if(_obj == noone) continue;
_obj.submitUI(params, shader);
}
}
static submit = function(params = {}, shader = noone) {
for( var i = input_fix_len, n = ds_list_size(inputs); i < n; i += data_length ) {
var _obj = inputs[| i].getValue();
if(_obj == noone) continue;
_obj.submit(params, shader);
}
}
static update = function(frame = PROJECT.animator.current_frame) {
object_lists = [];
for( var i = input_fix_len, n = ds_list_size(inputs); i < n; i += data_length ) {
var _obj = inputs[| i].getValue();
if(_obj == noone) continue;
array_push(object_lists, _obj);
}
}
static _submit = function(callback, params = {}, shader = noone) {
for( var i = 0, n = array_length(object_lists); i < n; i++ )
callback(object_lists[i], params, shader);
}
static submitShader = function(params = {}) { _submit(function(_obj, params) { _obj.submitShader(params); }, params); }
static submitSel = function(params = {}) { _submit(function(_obj, params) { _obj.submitSel(params); }, params); }
static submitUI = function(params = {}, shader = noone) { _submit(function(_obj, params, shader) { _obj.submitUI(params, shader); }, params); }
static submit = function(params = {}, shader = noone) { _submit(function(_obj, params, shader) { _obj.submit(params, shader); }, params); }
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {}
}

View file

@ -44,8 +44,9 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
attribute_surface_depth();
canvas_surface = surface_create_empty(1, 1);
drawing_surface = surface_create_empty(1, 1);
canvas_surface = surface_create_empty(1, 1);
drawing_surface = surface_create_empty(1, 1);
_drawing_surface = surface_create_empty(1, 1);
canvas_buffer = buffer_create(1 * 1 * 4, buffer_fixed, 2);
surface_w = 1;
surface_h = 1;
@ -82,30 +83,21 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
draw_stack = ds_list_create();
function apply_draw_surface() {
var _alp = inputs[| 11].getValue();
function storeAction() {
var action = recordAction(ACTION_TYPE.custom, function(data) {
is_selected = false;
var _canvas = surface_clone(canvas_surface);
if(is_surface(data.surface))
canvas_surface = surface_clone(data.surface);
surface_store_buffer();
surface_free(data.surface);
return { surface: _canvas, tooltip: data.tooltip }
}, { surface: surface_clone(canvas_surface), tooltip: "Modify canvas" });
BLEND_ALPHA;
if(isUsingTool("Eraser"))
gpu_set_blendmode(bm_subtract);
draw_surface_ext_safe(drawing_surface, 0, 0, 1, 1, 0, c_white, _alp);
surface_clear(drawing_surface);
BLEND_NORMAL;
surface_store_buffer();
}
function surface_store_buffer() {
buffer_delete(canvas_buffer);
surface_w = surface_get_width(canvas_surface);
surface_h = surface_get_height(canvas_surface);
canvas_buffer = buffer_create(surface_w * surface_h * 4, buffer_fixed, 4);
buffer_get_surface(canvas_buffer, canvas_surface, 0);
triggerRender();
apply_surface();
action.clear_action = function(data) { surface_free_safe(data.surface); };
}
function apply_surface() {
@ -124,6 +116,35 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
surface_clear(drawing_surface);
}
function surface_store_buffer() {
buffer_delete(canvas_buffer);
surface_w = surface_get_width(canvas_surface);
surface_h = surface_get_height(canvas_surface);
canvas_buffer = buffer_create(surface_w * surface_h * 4, buffer_fixed, 4);
buffer_get_surface(canvas_buffer, canvas_surface, 0);
triggerRender();
apply_surface();
}
function apply_draw_surface() {
var _alp = inputs[| 11].getValue();
storeAction();
surface_set_target(canvas_surface);
if(isUsingTool("Eraser")) gpu_set_blendmode(bm_subtract);
else BLEND_ALPHA
draw_surface_ext_safe(drawing_surface, 0, 0, 1, 1, 0, c_white, _alp);
surface_reset_target();
surface_clear(drawing_surface);
BLEND_NORMAL;
surface_store_buffer();
}
function draw_point_size(_x, _y, _siz, _brush) { #region
if(!is_surface(_brush)) {
if(_siz <= 1)
@ -401,13 +422,23 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
var _prev = inputs[| 5].getValue();
var _brush = inputs[| 6].getValue();
if(key_mod_press(ALT)) return;
if(!surface_exists(canvas_surface))
surface_store_buffer();
var _surf_w = surface_get_width(canvas_surface);
var _surf_h = surface_get_height(canvas_surface);
if(!isUsingTool("Selection") && is_surface(selection_surface)) {
#region drawing surface review
_drawing_surface = surface_verify(_drawing_surface, _surf_w, _surf_h);
surface_set_target(_drawing_surface);
DRAW_CLEAR
draw_surface_safe(drawing_surface);
surface_reset_target();
#endregion
if(!isUsingTool("Selection") && is_surface(selection_surface)) { #region
var pos_x = selection_position[0];
var pos_y = selection_position[1];
@ -419,15 +450,14 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
surface_store_buffer();
surface_free(selection_surface);
}
} #endregion
surface_set_target(canvas_surface);
draw_set_color(_col);
if(!isUsingTool("Selection"))
gpu_set_colorwriteenable(tool_attribute.channel[0], tool_attribute.channel[1], tool_attribute.channel[2], tool_attribute.channel[3]);
if(isUsingTool("Selection")) {
if(isUsingTool("Selection")) { #region
if(is_selected) {
if(!is_surface(selection_surface)) {
is_selected = false;
@ -507,7 +537,8 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
draw_surface(selection_mask, 0, 0);
BLEND_NORMAL
surface_reset_target();
storeAction();
surface_set_target(canvas_surface);
gpu_set_blendmode(bm_subtract);
draw_surface(selection_surface, sel_x0, sel_y0);
@ -529,7 +560,8 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
}
}
}
} else if(isUsingTool("Pencil") || isUsingTool("Eraser")) {
#endregion
} else if(isUsingTool("Pencil") || isUsingTool("Eraser")) { #region
if(key_mod_press(SHIFT) && key_mod_press(CTRL)) {
var aa = point_direction(mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y);
var dd = point_distance(mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y);
@ -550,9 +582,7 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
mouse_holding = true;
if(key_mod_press(SHIFT)) {
surface_set_shader(drawing_surface, noone, true, BLEND.alpha);
//print($"===== DRAW LINE {mouse_pre_draw_x}, {mouse_pre_draw_y}, {mouse_cur_x}, {mouse_cur_y} =====");
draw_line_size(mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y, _siz, _brush);
//print($"===== DRAW LINE END =====");
surface_reset_shader();
mouse_holding = false;
@ -584,8 +614,8 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
mouse_pre_x = mouse_cur_x;
mouse_pre_y = mouse_cur_y;
} else if(isUsingTool("Rectangle") || isUsingTool("Ellipse")) {
#endregion
} else if(isUsingTool("Rectangle") || isUsingTool("Ellipse")) { #region
if(mouse_holding && key_mod_press(SHIFT)) {
var ww = mouse_cur_x - mouse_pre_x;
var hh = mouse_cur_y - mouse_pre_y;
@ -617,33 +647,33 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
mouse_holding = false;
}
}
} else if(isUsingTool("Fill") || (DRAGGING && DRAGGING.type == "Color")) {
if(point_in_rectangle(mouse_cur_x, mouse_cur_y, 0, 0, _surf_w - 1, _surf_h - 1)) {
var fill = DRAGGING? mouse_release(mb_left) : mouse_press(mb_left);
if(fill) {
if(DRAGGING) draw_set_color(DRAGGING.data);
switch(_fill_type) {
case 0 :
flood_fill_scanline(mouse_cur_x, mouse_cur_y, canvas_surface, _thr, false);
break;
case 1 :
flood_fill_scanline(mouse_cur_x, mouse_cur_y, canvas_surface, _thr, true);
break;
case 2 :
canvas_fill(mouse_cur_x, mouse_cur_y, canvas_surface, _thr);
break;
}
surface_store_buffer();
}
#endregion
} else if(isUsingTool("Fill") || (DRAGGING && DRAGGING.type == "Color")) { #region
var fill = DRAGGING? mouse_release(mb_left) : mouse_press(mb_left);
if(fill && point_in_rectangle(mouse_cur_x, mouse_cur_y, 0, 0, _surf_w - 1, _surf_h - 1)) {
storeAction();
surface_set_target(canvas_surface);
if(DRAGGING) draw_set_color(DRAGGING.data);
switch(_fill_type) {
case 0 :
flood_fill_scanline(mouse_cur_x, mouse_cur_y, canvas_surface, _thr, false);
break;
case 1 :
flood_fill_scanline(mouse_cur_x, mouse_cur_y, canvas_surface, _thr, true);
break;
case 2 :
canvas_fill(mouse_cur_x, mouse_cur_y, canvas_surface, _thr);
break;
}
surface_store_buffer();
surface_reset_target();
}
#endregion
}
draw_set_alpha(1);
gpu_set_colorwriteenable(true, true, true, true);
surface_reset_target();
if(key_mod_press(ALT)) return;
#region preview
var _bg = inputs[| 8].getValue();
@ -658,7 +688,7 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
_preview_draw_surface = surface_verify(_preview_draw_surface, surface_get_width(__s), surface_get_height(__s));
surface_set_shader(preview_draw_surface, noone,, BLEND.alpha);
draw_surface_safe(drawing_surface, 0, 0);
draw_surface_safe(_drawing_surface, 0, 0);
draw_set_color(_col);
if(isUsingTool("Selection")) {
@ -690,7 +720,7 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
}
surface_reset_shader();
if(!isNotUsingTool()) {
if(isUsingTool()) {
if(isUsingTool("Selection")) {
if(is_selected) {
var pos_x = _x + selection_position[0] * _s;

File diff suppressed because it is too large Load diff

View file

@ -193,8 +193,17 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor {
if(prop.on_end == KEYFRAME_END.wrap) {
var from = values[| ds_list_size(values) - 1];
var to = values[| 0];
var prog = PROJECT.animator.frames_total - from.time + _time;
var totl = PROJECT.animator.frames_total - from.time + to.time;
var fTime = from.time;
var tTime = to.time;
//if(from > PROJECT.animator.frames_total) {
// fTime = fTime % PROJECT.animator.frames_total;
// tTime = tTime - PROJECT.animator.frames_total;
//}
var prog = PROJECT.animator.frames_total - fTime + _time;
var totl = PROJECT.animator.frames_total - fTime + tTime;
var rat = prog / totl;
var _lrp = interpolate(from, to, rat);

View file

@ -350,13 +350,15 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor {
///**/ addNodeObject(threeD, "Depth 3D", s_node_stack, "Node_3D_Depth", [1, Node_3D_Depth],, "Create 3D looking image from depth map.").setVersion(1447);
ds_list_add(threeD, "3D");
addNodeObject(threeD, "3D Scene", s_node_3d_cube, "Node_3D_Scene", [1, Node_3D_Scene]);
addNodeObject(threeD, "3D Scene", s_node_3d_cube, "Node_3D_Scene", [1, Node_3D_Scene]);
addNodeObject(threeD, "3D Camera", s_node_3d_cube, "Node_3D_Camera", [1, Node_3D_Camera]);
ds_list_add(threeD, "Mesh");
addNodeObject(threeD, "3D Cube", s_node_3d_cube, "Node_3D_Mesh_Cube", [1, Node_3D_Mesh_Cube]);
addNodeObject(threeD, "3D Cube", s_node_3d_cube, "Node_3D_Mesh_Cube", [1, Node_3D_Mesh_Cube]);
ds_list_add(threeD, "Light");
addNodeObject(threeD, "Directional Light", s_node_3d_cube, "Node_3D_Light_Directional", [1, Node_3D_Light_Directional]);
addNodeObject(threeD, "Point Light", s_node_3d_cube, "Node_3D_Light_Point", [1, Node_3D_Light_Point]);
ds_list_add(threeD, "Legacy");
addNodeObject(threeD, "3D Object", s_node_3d_obj, "Node_3D_Obj", [0, Node_create_3D_Obj],, "Load .obj file from your computer as a 3D object.");

View file

@ -10,12 +10,14 @@ function Panel_Animation() : PanelContent() constructor {
context_str = "Animation";
icon = THEME.panel_animation;
timeline_h = ui(28);
min_w = ui(40);
min_h = ui(48);
tool_width = ui(224);
#region ---- dimension ----
timeline_h = ui(28);
min_w = ui(40);
min_h = ui(48);
tool_width = ui(224);
#endregion
static initSize = function() {
static initSize = function() { #region
timeline_w = w - tool_width - ui(80);
timeline_surface = surface_create_valid(timeline_w, timeline_h);
timeline_mask = surface_create_valid(timeline_w, timeline_h);
@ -24,79 +26,99 @@ function Panel_Animation() : PanelContent() constructor {
dope_sheet_h = h - timeline_h - ui(20);
dope_sheet_surface = surface_create_valid(dope_sheet_w, 1);
dope_sheet_mask = surface_create_valid(dope_sheet_w, 1);
}
} #endregion
initSize();
dope_sheet_y = 0;
dope_sheet_y_to = 0;
dope_sheet_y_max = 0;
is_scrolling = false;
#region ---- position ----
dope_sheet_y = 0;
dope_sheet_y_to = 0;
dope_sheet_y_max = 0;
is_scrolling = false;
dopesheet_dragging = noone;
dopesheet_drag_mx = 0;
dopesheet_dragging = noone;
dopesheet_drag_mx = 0;
dope_sheet_node_padding = ui(2);
dope_sheet_node_padding = ui(2);
#endregion
ds_name_surface = surface_create_valid(tool_width - ui(16), 1);
timeline_scubbing = false;
timeline_scub_st = 0;
timeline_scale = 20;
timeline_separate = 5;
timeline_sep_line = 1;
_scrub_frame = -1;
#region ---- timeline ----
timeline_scubbing = false;
timeline_scub_st = 0;
timeline_scale = 20;
timeline_separate = 5;
timeline_sep_line = 1;
_scrub_frame = -1;
timeline_shift = 0;
timeline_shift_to = 0;
timeline_dragging = false;
timeline_drag_sx = 0;
timeline_drag_sy = 0;
timeline_drag_mx = 0;
timeline_drag_my = 0;
timeline_draggable = true;
timeline_shift = 0;
timeline_shift_to = 0;
timeline_dragging = false;
timeline_drag_sx = 0;
timeline_drag_sy = 0;
timeline_drag_mx = 0;
timeline_drag_my = 0;
timeline_draggable = true;
timeline_stretch = 0;
timeline_stretch_sx = 0;
timeline_stretch_mx = 0;
timeline_stretch = 0;
timeline_stretch_sx = 0;
timeline_stretch_mx = 0;
timeline_show_time = -1;
timeline_preview = noone;
timeline_show_time = -1;
timeline_preview = noone;
#endregion
keyframe_dragging = noone;
keyframe_drag_type = -1;
keyframe_dragout = false;
keyframe_drag_mx = 0;
keyframe_drag_my = 0;
keyframe_selecting = [];
#region ---- keyframes ----
keyframe_dragging = noone;
keyframe_drag_type = -1;
keyframe_dragout = false;
keyframe_drag_mx = 0;
keyframe_drag_my = 0;
keyframe_selecting = [];
keyframe_boxable = true;
keyframe_boxing = false;
keyframe_box_sx = -1;
keyframe_box_sy = -1;
keyframe_boxable = true;
keyframe_boxing = false;
keyframe_box_sx = -1;
keyframe_box_sy = -1;
#endregion
value_hovering = noone;
value_focusing = noone;
#region ---- values ----
value_hovering = noone;
value_focusing = noone;
#endregion
show_node_outside_context = true;
node_ordering = noone;
node_name_type = 0;
#region ---- display ----
show_node_outside_context = true;
#endregion
stagger_mode = 0;
stagger_index = 0;
#region ---- nodes ----
node_ordering = noone;
node_name_type = 0;
#endregion
#region ---- stagger ----
stagger_mode = 0;
stagger_index = 0;
#endregion
#region ---- tools ----
tool_width_drag = false;
tool_width_start = 0;
tool_width_mx = 0;
#endregion
anim_properties = ds_list_create();
tool_width_drag = false;
tool_width_start = 0;
tool_width_mx = 0;
on_end_dragging_anim = noone;
onion_dragging = noone;
prev_cache = array_create(PROJECT.animator.frames_total);
control_buttons = [
copy_clipboard = ds_list_create();
#region ++++ control_buttons ++++
control_buttons = [
[ function() { return __txt("Stop"); },
function() { return 4; },
function() { return PROJECT.animator.is_playing? COLORS._main_accent : COLORS._main_icon; },
@ -129,7 +151,9 @@ function Panel_Animation() : PanelContent() constructor {
function() { PROJECT.animator.setFrame(PROJECT.animator.real_frame + 1); }
],
];
#endregion
#region ++++ hotkeys ++++
addHotkey("", "Play/Pause", vk_space, MOD_KEY.none, function() { if(PROJECT.animator.is_playing) PROJECT.animator.pause() else PROJECT.animator.play(); });
addHotkey("", "Resume/Pause", vk_space, MOD_KEY.shift, function() { if(PROJECT.animator.is_playing) PROJECT.animator.pause() else PROJECT.animator.resume(); });
@ -146,17 +170,18 @@ function Panel_Animation() : PanelContent() constructor {
addHotkey("Animation", "Duplicate", "D", MOD_KEY.ctrl, function() { PANEL_ANIMATION.doDuplicate(); });
addHotkey("Animation", "Copy", "C", MOD_KEY.ctrl, function() { PANEL_ANIMATION.doCopy(); });
addHotkey("Animation", "Paste", "V", MOD_KEY.ctrl, function() { PANEL_ANIMATION.doPaste(PANEL_ANIMATION.value_focusing); });
#endregion
function deleteKeys() {
function deleteKeys() { #region
for( var i = 0, n = array_length(keyframe_selecting); i < n; i++ ) {
var k = keyframe_selecting[i];
k.anim.removeKey(k);
}
keyframe_selecting = [];
updatePropertyList();
}
} #endregion
function alignKeys(halign = fa_left) {
function alignKeys(halign = fa_left) { #region
if(array_empty(keyframe_selecting)) return;
var tt = 0;
@ -184,9 +209,9 @@ function Panel_Animation() : PanelContent() constructor {
var k = keyframe_selecting[i];
k.anim.setKeyTime(k, tt);
}
}
} #endregion
function arrangeKeys() {
function arrangeKeys() { #region
var l = [];
for( var i = 0; i < ds_list_size(anim_properties); i++ ) {
var node = anim_properties[| i];
@ -216,9 +241,9 @@ function Panel_Animation() : PanelContent() constructor {
}
keyframe_selecting = l;
}
} #endregion
function staggerKeys(_index, _stag) {
function staggerKeys(_index, _stag) { #region
var t = keyframe_selecting[_index].time;
for( var i = 0, n = array_length(keyframe_selecting); i < n; i++ ) {
var k = keyframe_selecting[i];
@ -226,8 +251,9 @@ function Panel_Animation() : PanelContent() constructor {
k.anim.setKeyTime(k, _t);
}
}
} #endregion
#region ++++ keyframe_menu ++++
keyframe_menu = [
menuItem(__txtx("panel_animation_lock_y", "Lock/Unlock Y easing"), function() {
for( var i = 0, n = array_length(keyframe_selecting); i < n; i++ ) {
@ -318,10 +344,11 @@ function Panel_Animation() : PanelContent() constructor {
keyframe_menu_empty = [
menuItem(__txt("Paste"), function() { doPaste(value_focusing); }, THEME.paste, [ "Animation", "Paste" ]),
];
#endregion
function onFocusBegin() { PANEL_ANIMATION = self; }
function onResize() {
function onResize() { #region
initSize();
if(w - tool_width > 1) {
@ -344,9 +371,9 @@ function Panel_Animation() : PanelContent() constructor {
ds_name_surface = surface_verify(ds_name_surface, tool_width - ui(0), dope_sheet_h);
}
resetTimelineMask();
}
} #endregion
function resetTimelineMask() {
function resetTimelineMask() { #region
if(!surface_exists(timeline_mask))
timeline_mask = surface_create_valid(timeline_w, timeline_h);
@ -368,10 +395,10 @@ function Panel_Animation() : PanelContent() constructor {
gpu_set_blendmode(bm_normal);
surface_reset_target();
}
}
} #endregion
resetTimelineMask();
function updatePropertyNode(pr, _node) {
function updatePropertyNode(pr, _node) { #region
var is_anim = false;
for(var j = 0; j < ds_list_size(_node.inputs); j++) {
var jun = _node.inputs[| j];
@ -380,9 +407,9 @@ function Panel_Animation() : PanelContent() constructor {
if(!is_anim) return;
ds_priority_add(pr, _node, _node.anim_priority);
}
} #endregion
function updatePropertyList() {
function updatePropertyList() { #region
ds_list_destroy(anim_properties);
var amo = ds_map_size(PROJECT.nodeMap);
var k = ds_map_find_first(PROJECT.nodeMap);
@ -400,9 +427,9 @@ function Panel_Animation() : PanelContent() constructor {
anim_properties = ds_priority_to_list(pr);
ds_priority_destroy(pr);
}
} #endregion
function drawTimeline() { //draw summary
function drawTimeline() { #region //draw summary
var bar_x = tool_width + ui(16);
var bar_y = h - timeline_h - ui(10);
var bar_w = timeline_w;
@ -577,9 +604,9 @@ function Panel_Animation() : PanelContent() constructor {
surface_reset_target();
draw_surface_safe(timeline_surface, bar_x, bar_y);
}
} #endregion
function drawDopesheetLine(animator, key_y, msx, msy, _gy_val_min = 999999, _gy_val_max = -999999) {
function drawDopesheetLine(animator, key_y, msx, msy, _gy_val_min = 999999, _gy_val_max = -999999) { #region
var bar_total_w = PROJECT.animator.frames_total * ui(timeline_scale);
var bar_show_w = timeline_shift + bar_total_w;
var hovering = noone;
@ -719,9 +746,9 @@ function Panel_Animation() : PanelContent() constructor {
}
}
}
}
} #endregion
function drawDopesheetGraph(prop, key_y, msx, msy) {
function drawDopesheetGraph(prop, key_y, msx, msy) { #region
var bar_total_w = PROJECT.animator.frames_total * ui(timeline_scale);
var bar_show_w = timeline_shift + bar_total_w;
var _gy_top = key_y + ui(16);
@ -787,9 +814,9 @@ function Panel_Animation() : PanelContent() constructor {
drawDopesheetLine(prop.animators[i], key_y, msx, msy, _min, _max);
} else
drawDopesheetLine(prop.animator, key_y, msx, msy);
}
} #endregion
function drawDopesheetAnimatorKeysBG(animator, msx, msy) {
function drawDopesheetAnimatorKeysBG(animator, msx, msy) { #region
var prop_dope_y = animator.dopesheet_y;
var key_hover = noone;
var key_list = animator.values;
@ -845,9 +872,9 @@ function Panel_Animation() : PanelContent() constructor {
}
return key_hover;
}
} #endregion
function drawDopesheetAnimatorKeys(_node, animator, msx, msy) {
function drawDopesheetAnimatorKeys(_node, animator, msx, msy) { #region
var prop_y = animator.dopesheet_y;
var key_hover = noone;
var node_y = _node.dopesheet_y + dope_sheet_node_padding;
@ -917,10 +944,9 @@ function Panel_Animation() : PanelContent() constructor {
}
return key_hover;
}
} #endregion
#region label
function drawDopesheetLabelAnimator(_node, animator, msx, msy) {
function drawDopesheetLabelAnimator(_node, animator, msx, msy) { #region
var aa = _node.group == PANEL_GRAPH.getCurrentContext()? 1 : 0.9;
var tx = tool_width;
var ty = animator.dopesheet_y - 1;
@ -1018,9 +1044,9 @@ function Panel_Animation() : PanelContent() constructor {
draw_set_alpha(aa);
draw_text_add(ui(32), ty - 2, animator.getName());
draw_set_alpha(1);
}
} #endregion
function drawDopesheetLabel() {
function drawDopesheetLabel() { #region
surface_set_target(ds_name_surface);
draw_clear_alpha(COLORS.panel_bg_clear, 0);
var msx = mx - ui(8);
@ -1133,10 +1159,9 @@ function Panel_Animation() : PanelContent() constructor {
}
surface_reset_target();
}
#endregion
} #endregion
function drawDopesheet() {
function drawDopesheet() { #region
var bar_x = tool_width + ui(16);
var bar_y = h - timeline_h - ui(10);
var bar_w = timeline_w;
@ -1700,9 +1725,9 @@ function Panel_Animation() : PanelContent() constructor {
draw_surface_safe(dope_sheet_surface, bar_x, ui(8));
draw_sprite_stretched(THEME.ui_panel_bg_cover, 1, bar_x, ui(8), bar_w, dope_sheet_h);
}
} #endregion
function drawAnimationControl() {
function drawAnimationControl() { #region
var bx = ui(8);
var by = h - ui(40);
var mini = w < ui(348);
@ -1812,9 +1837,9 @@ function Panel_Animation() : PanelContent() constructor {
txt = __txt("Onion skin");
if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(24), [mx, my], pFOCUS, pHOVER, txt, THEME.onion_skin,, PROJECT.onion_skin.enabled? c_white : COLORS._main_icon) == 2)
PROJECT.onion_skin.enabled = !PROJECT.onion_skin.enabled;
}
} #endregion
function drawContent(panel) {
function drawContent(panel) { #region
draw_clear_alpha(COLORS.panel_bg_clear, 0);
if(!PROJECT.active) return;
@ -1851,9 +1876,9 @@ function Panel_Animation() : PanelContent() constructor {
TOOLTIP = __txt("Frame") + " " + string(timeline_show_time + 1) + "/" + string(PROJECT.animator.frames_total);
timeline_show_time = -1;
}
}
} #endregion
function doDuplicate() {
function doDuplicate() { #region
if(array_empty(keyframe_selecting)) return;
var clones = [];
@ -1868,16 +1893,15 @@ function Panel_Animation() : PanelContent() constructor {
keyframe_drag_type = KEYFRAME_DRAG_TYPE.move;
keyframe_drag_mx = mx;
keyframe_drag_my = my;
}
} #endregion
copy_clipboard = ds_list_create();
function doCopy() {
function doCopy() { #region
ds_list_clear(copy_clipboard);
for( var i = 0, n = array_length(keyframe_selecting); i < n; i++ )
ds_list_add(copy_clipboard, keyframe_selecting[i]);
}
} #endregion
function doPaste(val = noone) {
function doPaste(val = noone) { #region
if(ds_list_empty(copy_clipboard)) return;
var shf = 0;
@ -1915,5 +1939,5 @@ function Panel_Animation() : PanelContent() constructor {
for( var i = 0; i < ds_list_size(copy_clipboard); i++ )
copy_clipboard[| i].cloneAnimator(shf, (multiVal || val == noone)? noone : val.animator);
}
}
} #endregion
}

View file

@ -11,94 +11,111 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
}
setProject(project);
scale = [ 0.01, 0.02, 0.05, 0.10, 0.15, 0.20, 0.25, 0.33, 0.5, 0.65, 0.8, 1, 1.2, 1.35, 1.5, 2.0];
graph_s = 1;
graph_s_to = graph_s;
#region ---- display ----
display_parameter = {
show_grid : true,
show_dimension : true,
show_compute : true,
avoid_label : false,
preview_scale : 100,
}
#endregion
graph_dragging_key = false;
graph_zooming_key = false;
#region ---- position ----
scale = [ 0.01, 0.02, 0.05, 0.10, 0.15, 0.20, 0.25, 0.33, 0.5, 0.65, 0.8, 1, 1.2, 1.35, 1.5, 2.0];
graph_s = 1;
graph_s_to = graph_s;
graph_dragging_key = false;
graph_zooming_key = false;
graph_draggable= true;
graph_dragging = false;
graph_drag_mx = 0;
graph_drag_my = 0;
graph_drag_sx = 0;
graph_drag_sy = 0;
graph_zooming = false;
graph_zoom_mx = 0;
graph_zoom_my = 0;
graph_zoom_m = 0;
graph_zoom_s = 0;
drag_key = mb_middle;
drag_locking = false;
#endregion
graph_draggable= true;
graph_dragging = false;
graph_drag_mx = 0;
graph_drag_my = 0;
graph_drag_sx = 0;
graph_drag_sy = 0;
#region ---- mouse ----
mouse_graph_x = 0;
mouse_graph_y = 0;
mouse_grid_x = 0;
mouse_grid_y = 0;
mouse_on_graph = false;
#endregion
graph_zooming = false;
graph_zoom_mx = 0;
graph_zoom_my = 0;
graph_zoom_m = 0;
graph_zoom_s = 0;
#region ---- nodes ----
node_context = ds_list_create();
drag_key = mb_middle;
drag_locking = false;
node_dragging = noone;
node_drag_mx = 0;
node_drag_my = 0;
node_drag_sx = 0;
node_drag_sy = 0;
node_drag_ox = 0;
node_drag_oy = 0;
mouse_graph_x = 0;
mouse_graph_y = 0;
mouse_grid_x = 0;
mouse_grid_y = 0;
mouse_on_graph = false;
selection_block = 0;
nodes_select_list = ds_list_create();
nodes_select_drag = false;
nodes_select_mx = 0;
nodes_select_my = 0;
node_context = ds_list_create();
nodes_junction_d = noone;
nodes_junction_dx = 0;
nodes_junction_dy = 0;
node_dragging = noone;
node_drag_mx = 0;
node_drag_my = 0;
node_drag_sx = 0;
node_drag_sy = 0;
node_drag_ox = 0;
node_drag_oy = 0;
node_hovering = noone;
node_hover = noone;
node_focus = noone;
junction_hovering = noone;
add_node_draw_junc = false;
add_node_draw_x_fix = 0;
add_node_draw_y_fix = 0;
add_node_draw_x = 0;
add_node_draw_y = 0;
connection_aa = 2;
connection_surface = surface_create(1, 1);
selection_block = 0;
nodes_select_list = ds_list_create();
nodes_select_drag = false;
nodes_select_mx = 0;
nodes_select_my = 0;
value_focus = noone;
value_dragging = noone;
value_draggings = [];
#endregion
nodes_junction_d = noone;
nodes_junction_dx = 0;
nodes_junction_dy = 0;
#region ---- minimap ----
minimap_show = false;
minimap_w = ui(160);
minimap_h = ui(160);
minimap_surface = -1;
node_hovering = noone;
node_hover = noone;
node_focus = noone;
minimap_panning = false;
minimap_dragging = false;
minimap_drag_sx = 0;
minimap_drag_sy = 0;
minimap_drag_mx = 0;
minimap_drag_my = 0;
#endregion
junction_hovering = noone;
add_node_draw_junc = false;
add_node_draw_x_fix = 0;
add_node_draw_y_fix = 0;
add_node_draw_x = 0;
add_node_draw_y = 0;
value_focus = noone;
value_dragging = noone;
value_draggings = [];
minimap_show = false;
minimap_w = ui(160);
minimap_h = ui(160);
minimap_surface = -1;
minimap_panning = false;
minimap_dragging = false;
minimap_drag_sx = 0;
minimap_drag_sy = 0;
minimap_drag_mx = 0;
minimap_drag_my = 0;
context_framing = false;
context_frame_progress = 0;
context_frame_direct = 0;
context_frame_sx = 0; context_frame_ex = 0;
context_frame_sy = 0; context_frame_ey = 0;
show_grid = true;
show_dimension = true;
show_compute = true;
connection_aa = 2;
connection_surface = surface_create(1, 1);
#region ---- context frame ----
context_framing = false;
context_frame_progress = 0;
context_frame_direct = 0;
context_frame_sx = 0; context_frame_ex = 0;
context_frame_sy = 0; context_frame_ey = 0;
#endregion
toolbar_height = ui(40);
@ -182,7 +199,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
function() { return 0; },
function() { return __txtx("graph_visibility_title", "Visibility settings"); },
function(param) {
var gs = dialogCall(o_dialog_graph_view, param.x, param.y);
var gs = dialogCall(o_dialog_graph_view, param.x, param.y, { display_parameter });
gs.anchor = ANCHOR.bottom | ANCHOR.left;
}
],
@ -209,7 +226,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
}
});
addHotkey("Graph", "Toggle grid", "G", MOD_KEY.none, function() { PANEL_GRAPH.show_grid = !PANEL_GRAPH.show_grid; });
addHotkey("Graph", "Toggle grid", "G", MOD_KEY.none, function() { display_parameter.show_grid = !display_parameter.show_grid; });
addHotkey("Graph", "Toggle preview", "H", MOD_KEY.none, function() { PANEL_GRAPH.setTriggerPreview(); });
addHotkey("Graph", "Toggle render", "R", MOD_KEY.none, function() { PANEL_GRAPH.setTriggerRender(); });
@ -530,7 +547,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
} #endregion
function drawGrid() { #region
if(!show_grid) return;
if(!display_parameter.show_grid) return;
var gls = project.graphGrid.size;
if(graph_s <= 0.15) gls *= 10;
@ -577,7 +594,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
#region draw frame
for(var i = 0; i < ds_list_size(nodes_list); i++) {
if(instanceof(nodes_list[| i]) != "Node_Frame") continue;
nodes_list[| i].drawNode(gr_x, gr_y, mx, my, graph_s);
nodes_list[| i].drawNode(gr_x, gr_y, mx, my, graph_s, display_parameter);
}
#endregion
printIf(log, "Frame draw time: " + string(current_time - t)); t = current_time;
@ -881,7 +898,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
for(var i = 0; i < ds_list_size(nodes_list); i++) {
var _node = nodes_list[| i];
if(instanceof(_node) == "Node_Frame") continue;
var val = _node.drawNode(gr_x, gr_y, mx, my, graph_s);
var val = _node.drawNode(gr_x, gr_y, mx, my, graph_s, display_parameter);
if(val) {
if(key_mod_press(SHIFT))

View file

@ -7,6 +7,8 @@ function Panel_Menu() : PanelContent() constructor {
noti_icon_show = 0;
noti_icon_time = 0;
version_name_copy = 0;
if(PREF_MAP[? "panel_menu_right_control"])
action_buttons = ["exit", "maximize", "minimize", "fullscreen"];
else
@ -572,8 +574,12 @@ function Panel_Menu() : PanelContent() constructor {
var txt = "v. " + string(VERSION_STRING);
if(STEAM_ENABLED) txt += " Steam";
version_name_copy = lerp_float(version_name_copy, 0, 10);
var tc = merge_color(COLORS._main_text_sub, COLORS._main_value_positive, min(1, version_name_copy));
var sc = merge_color(c_white, COLORS._main_value_positive, min(1, version_name_copy));
if(hori) {
draw_set_text(f_p0, fa_center, fa_center, COLORS._main_text_sub);
draw_set_text(f_p0, fa_center, fa_center, tc);
var ww = string_width(txt) + ui(12);
if(h > ui(76)) {
@ -590,25 +596,34 @@ function Panel_Menu() : PanelContent() constructor {
}
if(pHOVER && point_in_rectangle(mx, my, _x0, _y0, _x1, _y1)) {
draw_sprite_stretched(THEME.button_hide_fill, 1, _x0, _y0, _x1 - _x0, _y1 - _y0);
draw_sprite_stretched_ext(THEME.button_hide_fill, 1, _x0, _y0, _x1 - _x0, _y1 - _y0, sc, 1);
if(mouse_press(mb_left, pFOCUS)) {
if(mouse_press(mb_left, pFOCUS))
dialogCall(o_dialog_release_note);
if(mouse_press(mb_right, pFOCUS)) {
clipboard_set_text(VERSION_STRING);
version_name_copy = 3;
}
}
draw_text((_x0 + _x1) / 2, (_y0 + _y1) / 2, txt);
} else {
var x1 = ui(40);
var y1 = h - ui(20);
draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text_sub);
draw_set_text(f_p0, fa_left, fa_center, tc);
var ww = string_width(txt) + ui(12);
if(pHOVER && point_in_rectangle(mx, my, x1, y1 - ui(16), x1 + ww, y1 + ui(16))) {
draw_sprite_stretched(THEME.button_hide_fill, 1, x1, y1 - ui(16), ww, ui(32));
draw_sprite_stretched_ext(THEME.button_hide_fill, 1, x1, y1 - ui(16), ww, ui(32), sc, 1);
if(mouse_press(mb_left, pFOCUS))
dialogCall(o_dialog_release_note);
if(mouse_press(mb_right, pFOCUS)) {
clipboard_set_text(VERSION_STRING);
version_name_copy = 3;
}
}
draw_text(x1 + ui(6), y1, txt);
}
#endregion

View file

@ -101,8 +101,16 @@ function Panel_Preview() : PanelContent() constructor {
d3_zoom_speed = 0.2;
d3_pan_speed = 2;
d3_preview_params = new __3dObjectParameters(d3_view_camera);
d3_light_ambient = $303030;
d3_scene = new __3dScene(d3_view_camera);
d3_scene.lightAmbient = $202020;
d3_scene_light0 = new __3dLightDirectional();
d3_scene_light0.position.set(-1, -2, 3);
d3_scene_light0.color = $303030;
d3_scene_light1 = new __3dLightDirectional();
d3_scene_light1.position.set(1, 2, 3);
d3_scene_light1.color = $404040;
#endregion
tb_framerate = new textBox(TEXTBOX_INPUT.number, function(val) { preview_rate = real(val); });
@ -360,6 +368,72 @@ function Panel_Preview() : PanelContent() constructor {
canvas_hover = point_in_rectangle(mx, my, 0, toolbar_height, w, h - toolbar_height);
} #endregion
function dragCanvas3D() { #region
if(d3_camPanning) {
if(!MOUSE_WRAPPING) {
var dx = mx - d3_camPan_mx;
var dy = my - d3_camPan_my;
d3_view_camera.focus_angle_x += dx * 0.2 * d3_pan_speed;
d3_view_camera.focus_angle_y += dy * 0.1 * d3_pan_speed;
}
d3_camPan_mx = mx;
d3_camPan_my = my;
setMouseWrap();
if(mouse_release(canvas_drag_key))
d3_camPanning = false;
}
if(canvas_zooming) {
if(!MOUSE_WRAPPING) {
var dy = -(my - canvas_zoom_m) / 200;
d3_view_camera.focus_dist = clamp(d3_view_camera.focus_dist + dy, 1, 1000);
}
canvas_zoom_m = my;
setMouseWrap();
if(mouse_release(canvas_drag_key))
canvas_zooming = false;
}
if(pFOCUS && pHOVER && canvas_hover) {
var _doDragging = false;
var _doZooming = false;
if(mouse_press(mb_middle)) {
_doDragging = true;
canvas_drag_key = mb_middle;
} else if(mouse_press(mb_left) && canvas_dragging_key) {
_doDragging = true;
canvas_drag_key = mb_left;
} else if(mouse_press(mb_left) && canvas_zooming_key) {
_doZooming = true;
canvas_drag_key = mb_left;
}
if(_doDragging) {
d3_camPanning = true;
d3_camPan_mx = mx;
d3_camPan_my = my;
}
if(_doZooming) {
canvas_zooming = true;
canvas_zoom_m = my;
}
if(mouse_wheel_up()) d3_view_camera.focus_dist = max( 1, d3_view_camera.focus_dist * (1 - d3_zoom_speed));
if(mouse_wheel_down()) d3_view_camera.focus_dist = min(1000, d3_view_camera.focus_dist * (1 + d3_zoom_speed));
}
canvas_dragging_key = false;
canvas_zooming_key = false;
canvas_hover = point_in_rectangle(mx, my, 0, toolbar_height, w, h - toolbar_height);
} #endregion
function fullView() { #region
var node = getNodePreview();
if(node == noone) {
@ -625,11 +699,7 @@ function Panel_Preview() : PanelContent() constructor {
var _prev_node = getNodePreview();
_prev_node.previewing = 1;
#region draw
d3_view_camera.setViewSize(w, h);
d3_surface = surface_verify(d3_surface, w, h);
d3_outline_surface = surface_verify(d3_outline_surface, w, h);
#region view
var cam = camera_get_active();
var _pos, targ;
@ -647,7 +717,13 @@ function Panel_Preview() : PanelContent() constructor {
d3_view_camera.focus.set(targ);
}
d3_view_camera.setViewSize(w, h);
d3_view_camera.setMatrix();
#endregion
#region draw
d3_surface = surface_verify(d3_surface, w, h);
d3_outline_surface = surface_verify(d3_outline_surface, w, h);
surface_set_target(d3_surface);
draw_clear(COLORS.panel_3d_bg);
@ -661,7 +737,7 @@ function Panel_Preview() : PanelContent() constructor {
var _tx = round(d3_view_camera.focus.x);
var _ty = round(d3_view_camera.focus.y);
var _scale = _dist;
var _scale = _dist * 2;
while(_scale > 32) _scale /= 2;
shader_set_f("scale", _scale);
@ -670,65 +746,35 @@ function Panel_Preview() : PanelContent() constructor {
shader_reset();
gpu_set_zwriteenable(true);
shader_set(sh_d3d_default);
shader_set_f("light_ambient", colToVec4(d3_light_ambient));
shader_set_f("light_dir_direction", 1, 2, 3);
shader_set_f("light_dir_color", colToVec4(c_white));
shader_set_f("light_dir_intensity", 0.5);
shader_reset();
d3_scene.reset();
d3_scene.addLightDirectional(d3_scene_light0);
d3_scene.addLightDirectional(d3_scene_light1);
_prev_node.submitShader(d3_scene);
d3_scene.apply();
_prev_node.submitUI(d3_preview_params);
_prev_node.submitUI(d3_scene); //////////////// SUBMIT ////////////////
surface_reset_target();
draw_surface(d3_surface, 0, 0);
#region outline
var inspect_node = PANEL_INSPECTOR.inspecting;
if(inspect_node) {
surface_set_target(d3_outline_surface);
draw_clear(c_black);
d3_view_camera.applyCamera(cam);
gpu_set_ztestenable(false);
inspect_node.submitSel(d3_preview_params);
surface_reset_target();
shader_set(sh_d3d_outline);
shader_set_dim("dimension", d3_outline_surface);
shader_set_color("outlineColor", COLORS._main_accent);
draw_surface(d3_outline_surface, 0, 0);
shader_reset();
}
#endregion
#endregion
#region camera
if(pHOVER) {
if(mouse_wheel_up()) d3_view_camera.focus_dist = max( 1, d3_view_camera.focus_dist * (1 - d3_zoom_speed));
if(mouse_wheel_down()) d3_view_camera.focus_dist = min(1000, d3_view_camera.focus_dist * (1 + d3_zoom_speed));
}
if(d3_camPanning) {
if(!MOUSE_WRAPPING) {
var dx = mx - d3_camPan_mx;
var dy = my - d3_camPan_my;
d3_view_camera.focus_angle_x += dx * 0.2 * d3_pan_speed;
d3_view_camera.focus_angle_y += dy * 0.1 * d3_pan_speed;
}
d3_camPan_mx = mx;
d3_camPan_my = my;
setMouseWrap();
if(mouse_release(mb_middle))
d3_camPanning = false;
} else if(mouse_press(mb_middle, pFOCUS)) {
d3_camPanning = true;
d3_camPan_mx = mx;
d3_camPan_my = my;
#region outline
var inspect_node = PANEL_INSPECTOR.inspecting;
if(inspect_node && inspect_node.is_3D) {
surface_set_target(d3_outline_surface);
draw_clear(c_black);
d3_view_camera.applyCamera(cam);
gpu_set_ztestenable(false);
inspect_node.submitSel(d3_scene);
surface_reset_target();
shader_set(sh_d3d_outline);
shader_set_dim("dimension", d3_outline_surface);
shader_set_color("outlineColor", COLORS._main_accent);
draw_surface(d3_outline_surface, 0, 0);
shader_reset();
}
#endregion
} #endregion
@ -882,7 +928,7 @@ function Panel_Preview() : PanelContent() constructor {
overlayHover &= point_in_rectangle(mx, my, 0, toolbar_height, w, h - toolbar_height);
overlayHover &= !key_mod_press(CTRL);
if(d3_active) _node.drawOverlay3D(overlayHover, d3_preview_params, _mx, _my, _snx, _sny, { w, h });
if(_node.is_3D) _node.drawOverlay3D(overlayHover, d3_scene, _mx, _my, _snx, _sny, { w, h });
else _node.drawOverlay(overlayHover, cx, cy, canvas_s, _mx, _my, _snx, _sny, { w, h });
var _tool = tool_hovering;
@ -1162,6 +1208,7 @@ function Panel_Preview() : PanelContent() constructor {
draw_clear(canvas_bg);
if(d3_active) {
dragCanvas3D();
draw3D();
} else {

View file

@ -38,7 +38,7 @@ function slider(_min, _max, _step, _onModify = noone, _onRelease = noone) : widg
return draw(params.x, params.y, params.w, params.h, params.data, params.m);
}
static draw = function(_x, _y, _w, _h, _data, _m, tb_w = 64, halign = fa_left, valign = fa_top) {
static draw = function(_x, _y, _w, _h, _data, _m, tb_w = 50, halign = fa_left, valign = fa_top) {
x = _x;
y = _y;
w = _w;

View file

@ -75,7 +75,7 @@ function widget() constructor {
static draw = function() {}
}
function widgetParam(x, y, w, h, data, extra_data, m, rx = 0, ry = 0) constructor {
function widgetParam(x, y, w, h, data, extra_data = 0, m = mouse_ui, rx = 0, ry = 0) constructor {
self.x = x;
self.y = y;

View file

@ -7,27 +7,58 @@ varying vec3 v_vNormal;
varying vec3 v_worldPosition;
uniform vec4 light_ambient;
uniform vec3 light_dir_direction;
uniform vec4 light_dir_color;
uniform float light_dir_intensity;
#region ---- light ----
uniform vec4 light_ambient;
#define LIGHT_DIR_LIMIT 16
uniform int light_dir_count;
uniform vec3 light_dir_direction[LIGHT_DIR_LIMIT];
uniform vec4 light_dir_color[LIGHT_DIR_LIMIT];
uniform float light_dir_intensity[LIGHT_DIR_LIMIT];
#define LIGHT_PNT_LIMIT 16
uniform int light_pnt_count;
uniform vec3 light_pnt_position[LIGHT_PNT_LIMIT];
uniform vec4 light_pnt_color[LIGHT_PNT_LIMIT];
uniform float light_pnt_intensity[LIGHT_PNT_LIMIT];
uniform float light_pnt_radius[LIGHT_PNT_LIMIT];
#endregion
void main() {
vec4 final_color = texture2D( gm_BaseTexture, v_vTexcoord );
final_color *= v_vColour;
gl_FragColor = vec4(0.);
///////////////// LIGHT /////////////////
#region ++++ light ++++
vec3 light_effect = light_ambient.rgb;
for(int i = 0; i < light_dir_count; i++) {
float light_dir_strength = dot(normalize(v_vNormal), normalize(light_dir_direction[i]));
if(light_dir_strength < 0.)
continue;
light_dir_strength = max(light_dir_strength * light_dir_intensity[i], 0.);
light_effect += light_dir_color[i].rgb * light_dir_strength;
}
for(int i = 0; i < light_pnt_count; i++) {
float light_pnt_strength = dot(normalize(v_vNormal), normalize(light_pnt_position[i] - v_worldPosition));
if(light_pnt_strength < 0.)
continue;
float light_distance = distance(light_pnt_position[i], v_worldPosition);
if(light_distance > light_pnt_radius[i])
continue;
float light_attenuation = 1. - pow(light_distance / light_pnt_radius[i], 2.);
light_pnt_strength = max(light_pnt_strength * light_pnt_intensity[i] * light_attenuation, 0.);
light_effect += light_pnt_color[i].rgb * light_pnt_strength;
}
vec3 light_effect = light_ambient.rgb * light_ambient.a;
float light_dir_strength = dot(normalize(v_vNormal), normalize(light_dir_direction));
light_dir_strength = max(light_dir_strength * light_dir_intensity, 0.);
light_effect += light_dir_color.rgb * light_dir_color.a * light_dir_strength;
light_effect = max(light_effect, 0.);
final_color.rgb *= light_effect;
///////////////// FINAL /////////////////
light_effect = max(light_effect, 0.);
final_color.rgb *= light_effect;
#endregion
gl_FragColor = final_color;
}

View file

@ -17,9 +17,9 @@ 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_worldPosition = (gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos).xyz;
v_vColour = in_Colour;
v_vTexcoord = in_TextureCoord;
v_worldPosition = (gm_Matrices[MATRIX_WORLD] * object_space_pos).xyz;
v_vColour = in_Colour;
v_vTexcoord = in_TextureCoord;
vec3 worldNormal = normalize(gm_Matrices[MATRIX_WORLD] * vec4(in_Normal, 0.)).xyz;
v_vNormal = worldNormal;