3D camera positioning modes

This commit is contained in:
Tanasart 2023-08-19 12:42:50 +02:00
parent bf0eabc189
commit 66351fa767
28 changed files with 1170 additions and 800 deletions

View file

@ -21,6 +21,11 @@
{"name":"widget","order":9,"path":"folders/dialog/widget.yy",},
{"name":"font","order":7,"path":"folders/font.yy",},
{"name":"functions","order":6,"path":"folders/functions.yy",},
{"name":"camera","order":7,"path":"folders/functions/3d/camera.yy",},
{"name":"gizmo","order":11,"path":"folders/functions/3d/gizmo.yy",},
{"name":"light","order":6,"path":"folders/functions/3d/light.yy",},
{"name":"mesh","order":8,"path":"folders/functions/3d/mesh.yy",},
{"name":"util","order":5,"path":"folders/functions/3d/util.yy",},
{"name":"action","order":40,"path":"folders/functions/action.yy",},
{"name":"animation","order":19,"path":"folders/functions/animation.yy",},
{"name":"async","order":36,"path":"folders/functions/async.yy",},
@ -186,10 +191,6 @@
{"name":"biterator","order":2,"path":"folders/VCT/biterator.yy",},
{"name":"widget","order":3,"path":"folders/VCT/widget.yy",},
{"name":"widgets","order":5,"path":"folders/widgets.yy",},
{"name":"util","order":17,"path":"folders/functions/3d/util.yy",},
{"name":"light","order":18,"path":"folders/functions/3d/light.yy",},
{"name":"camera","order":19,"path":"folders/functions/3d/camera.yy",},
{"name":"mesh","order":20,"path":"folders/functions/3d/mesh.yy",},
],
"ResourceOrderSettings": [
{"name":"s_node_corner","order":16,"path":"sprites/s_node_corner/s_node_corner.yy",},
@ -290,7 +291,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":"d3d_scene","order":4,"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",},
@ -588,6 +589,7 @@
{"name":"sh_warp_4points_pers","order":10,"path":"shaders/sh_warp_4points_pers/sh_warp_4points_pers.yy",},
{"name":"node_mirror","order":3,"path":"scripts/node_mirror/node_mirror.yy",},
{"name":"node_corner","order":6,"path":"scripts/node_corner/node_corner.yy",},
{"name":"__vertex_function","order":1,"path":"scripts/__vertex_function/__vertex_function.yy",},
{"name":"node_path_anchor","order":13,"path":"scripts/node_path_anchor/node_path_anchor.yy",},
{"name":"s_node_path_wave","order":7,"path":"sprites/s_node_path_wave/s_node_path_wave.yy",},
{"name":"string_function","order":6,"path":"scripts/string_function/string_function.yy",},
@ -1121,7 +1123,7 @@
{"name":"s_node_atlas","order":5,"path":"sprites/s_node_atlas/s_node_atlas.yy",},
{"name":"node_fluid_add","order":4,"path":"scripts/node_fluid_add/node_fluid_add.yy",},
{"name":"BBMOD_Quaternion","order":3,"path":"scripts/BBMOD_Quaternion/BBMOD_Quaternion.yy",},
{"name":"d3d_group","order":21,"path":"scripts/d3d_group/d3d_group.yy",},
{"name":"d3d_group","order":9,"path":"scripts/d3d_group/d3d_group.yy",},
{"name":"o_dialog_output_visibility","order":2,"path":"objects/o_dialog_output_visibility/o_dialog_output_visibility.yy",},
{"name":"node_normal","order":1,"path":"scripts/node_normal/node_normal.yy",},
{"name":"s_node_glow","order":24,"path":"sprites/s_node_glow/s_node_glow.yy",},
@ -1250,7 +1252,7 @@
{"name":"__view_get","order":1,"path":"scripts/__view_get/__view_get.yy",},
{"name":"s_node_texture_map","order":38,"path":"sprites/s_node_texture_map/s_node_texture_map.yy",},
{"name":"fd_rectangle_create","order":7,"path":"scripts/fd_rectangle_create/fd_rectangle_create.yy",},
{"name":"d3d_gizmo","order":4,"path":"scripts/d3d_gizmo/d3d_gizmo.yy",},
{"name":"d3d_gizmo","order":3,"path":"scripts/d3d_gizmo/d3d_gizmo.yy",},
{"name":"s_node_level_selector","order":29,"path":"sprites/s_node_level_selector/s_node_level_selector.yy",},
{"name":"random_function","order":3,"path":"scripts/random_function/random_function.yy",},
{"name":"s_node_input","order":6,"path":"sprites/s_node_input/s_node_input.yy",},

View file

@ -42,6 +42,11 @@
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"font","folderPath":"folders/font.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"functions","folderPath":"folders/functions.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"3d","folderPath":"folders/functions/3d.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"camera","folderPath":"folders/functions/3d/camera.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"gizmo","folderPath":"folders/functions/3d/gizmo.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"light","folderPath":"folders/functions/3d/light.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"mesh","folderPath":"folders/functions/3d/mesh.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"util","folderPath":"folders/functions/3d/util.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"action","folderPath":"folders/functions/action.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"animation","folderPath":"folders/functions/animation.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"async","folderPath":"folders/functions/async.yy",},
@ -224,10 +229,6 @@
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"biterator","folderPath":"folders/VCT/biterator.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"widget","folderPath":"folders/VCT/widget.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"widgets","folderPath":"folders/widgets.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"util","folderPath":"folders/functions/3d/util.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"light","folderPath":"folders/functions/3d/light.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"camera","folderPath":"folders/functions/3d/camera.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"mesh","folderPath":"folders/functions/3d/mesh.yy",},
],
"IncludedFiles": [
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"ApolloHelp.html","ConfigValues":{"Itch":{"CopyToMask":"0",},},"CopyToMask":-1,"filePath":"datafiles",},
@ -524,6 +525,7 @@
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"graphics x2.ai","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/tool",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_3d_tool_rotate.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/tool",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_3d_tool_scale.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/tool",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_3d_tool_transform_object.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/tool",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_3d_tool_transform.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/tool",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_bone_tool_add.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/tool",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_bone_tool_detach.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/tool",},
@ -1152,6 +1154,7 @@
{"id":{"name":"s_node_random","path":"sprites/s_node_random/s_node_random.yy",},},
{"id":{"name":"sh_3d_extrude_filler","path":"shaders/sh_3d_extrude_filler/sh_3d_extrude_filler.yy",},},
{"id":{"name":"s_window_exit","path":"sprites/s_window_exit/s_window_exit.yy",},},
{"id":{"name":"d3d_gizmo_sphere","path":"scripts/d3d_gizmo_sphere/d3d_gizmo_sphere.yy",},},
{"id":{"name":"s_node_color_remove","path":"sprites/s_node_color_remove/s_node_color_remove.yy",},},
{"id":{"name":"sh_average","path":"shaders/sh_average/sh_average.yy",},},
{"id":{"name":"sh_warp_4points_pers","path":"shaders/sh_warp_4points_pers/sh_warp_4points_pers.yy",},},

Binary file not shown.

View file

@ -240,9 +240,9 @@ function BBMOD_Quaternion(_x=0.0, _y=0.0, _z=0.0, _w=1.0) constructor
/// @return {Struct.BBMOD_Quaternion} Returns `self`.
static FromLookRotation = function (_forward, _up) {
gml_pragma("forceinline");
_forward = _forward.Clone();
_up = _up.Clone();
_forward = new BBMOD_Vec3(_forward);
_up = new BBMOD_Vec3(_up);
if (!_forward.Orthonormalize(_up))
{
@ -268,9 +268,9 @@ function BBMOD_Quaternion(_x=0.0, _y=0.0, _z=0.0, _w=1.0) constructor
gml_pragma("forceinline");
W = sqrt(1 + rotMatrix[0] + rotMatrix[5] + rotMatrix[10]) / 2;
X = (rotMatrix[9] - rotMatrix[6]) / (4 * W);
Y = (rotMatrix[2] - rotMatrix[8]) / (4 * W);
Z = (rotMatrix[4] - rotMatrix[1]) / (4 * W);
X = (rotMatrix[9] - rotMatrix[6]) / (4 * W);
Y = (rotMatrix[2] - rotMatrix[8]) / (4 * W);
Z = (rotMatrix[4] - rotMatrix[1]) / (4 * W);
return self;
}
@ -427,10 +427,19 @@ function BBMOD_Quaternion(_x=0.0, _y=0.0, _z=0.0, _w=1.0) constructor
/// @return {Struct.BBMOD_Vec3} The created vector.
static Rotate = function (_v) {
gml_pragma("forceinline");
var _tovec = is_instanceof(_v, __vec3);
if(_tovec) _v = new BBMOD_Vec3(_v.x, _v.y, _v.z);
var _q = Normalize();
var _V = new BBMOD_Quaternion(_v.X, _v.Y, _v.Z, 0.0);
var _rot = _q.Mul(_V).Mul(_q.Conjugate());
return new BBMOD_Vec3(_rot.X, _rot.Y, _rot.Z);
var res;
if(_tovec) res = new __vec3(_rot.X, _rot.Y, _rot.Z);
else res = new BBMOD_Vec3(_rot.X, _rot.Y, _rot.Z);
return res;
};
/// @func Scale(_s)

View file

@ -26,16 +26,24 @@
///
/// @see BBMOD_Vec2
/// @see BBMOD_Vec4
function BBMOD_Vec3(_x=0.0, _y=_x, _z=_x) constructor
{
/// @var {Real} The first component of the vector.
X = _x;
/// @var {Real} The second component of the vector.
Y = _y;
/// @var {Real} The third component of the vector.
Z = _z;
function BBMOD_Vec3(_x=0.0, _y=_x, _z=_x) constructor {
if(is_instanceof(_x, __vec3)) {
X = _x.x;
Y = _x.y;
Z = _x.z;
} else if(is_instanceof(_x, BBMOD_Vec3)) {
X = _x.X;
Y = _x.Y;
Z = _x.Z;
} else if(is_array(_x)) {
X = _x[0];
Y = _x[1];
Z = _x[2];
} else {
X = _x;
Y = _y;
Z = _z;
}
/// @func Abs()
///

View file

@ -7,7 +7,7 @@ function Node_3D(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constr
static processData = function(_outSurf, _data, _output_index, _array_index) {}
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {}
static getPreviewObject = function() {
static getPreviewObject = function() { #region
if(ds_list_empty(outputs)) return [];
switch(outputs[| preview_channel].type) {
case VALUE_TYPE.d3Mesh :
@ -23,7 +23,7 @@ function Node_3D(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constr
_obj = array_safe_get(_obj, preview_index, noone);
return [ _obj ];
}
} #endregion
static getPreviewObjectOutline = function() { return getPreviewObject() }
}

View file

@ -4,20 +4,20 @@ function Node_3D_Light(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group)
if(!LOADING && !APPENDING)
inputs[| 0].setValue([ 0, 0, 1 ]);
inputs[| input_d3d_index + 0] = nodeValue("Color", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_white);
inputs[| in_d3d + 0] = nodeValue("Color", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_white);
inputs[| input_d3d_index + 1] = nodeValue("Intensity", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
inputs[| in_d3d + 1] = nodeValue("Intensity", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
.setDisplay(VALUE_DISPLAY.slider, [ 0, 1, 0.01 ]);
input_light_index = ds_list_size(inputs);
in_light = ds_list_size(inputs);
outputs[| 0] = nodeValue("Light", self, JUNCTION_CONNECT.output, VALUE_TYPE.d3Light, noone);
#macro __d3d_input_list_light ["Light", false], input_d3d_index + 0, input_d3d_index + 1
#macro __d3d_input_list_light ["Light", false], in_d3d + 0, in_d3d + 1
static setLight = function(light, _data) {
var _col = _data[input_d3d_index + 0];
var _int = _data[input_d3d_index + 1];
var _col = _data[in_d3d + 0];
var _int = _data[in_d3d + 1];
light.color = _col;
light.intensity = _int;

View file

@ -1,7 +1,7 @@
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);
in_mesh = ds_list_size(inputs);
outputs[| 0] = nodeValue("Mesh", self, JUNCTION_CONNECT.output, VALUE_TYPE.d3Mesh, noone);

View file

@ -14,7 +14,7 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr
inputs[| 2] = nodeValue("Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 1, 1, 1 ])
.setDisplay(VALUE_DISPLAY.vector);
input_d3d_index = ds_list_size(inputs);
in_d3d = ds_list_size(inputs);
#macro __d3d_input_list_transform ["Transform", false], 0, 1, 2
@ -34,63 +34,96 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr
drag_original = 0;
axis_hover = noone;
tools = [
new NodeTool( "Transform", THEME.tools_3d_transform ),
new NodeTool( "Rotate", THEME.tools_3d_rotate ),
new NodeTool( "Scale", THEME.tools_3d_scale ),
];
#endregion
static drawOverlay3D = function(active, params, _mx, _my, _snx, _sny, _panel) { #region
var _pos = inputs[| 0].getValue(,,, true);
var _rot = inputs[| 1].getValue(,,, true);
var _sca = inputs[| 2].getValue(,,, true);
#region ---- tools ----
tool_pos = new NodeTool( "Transform", THEME.tools_3d_transform );
tool_rot = new NodeTool( "Rotate", THEME.tools_3d_rotate );
tool_sca = new NodeTool( "Scale", THEME.tools_3d_scale );
tools = [ tool_pos, tool_rot, tool_sca ];
var _camera = params.camera;
var _camPos = _camera.position;
var _camTar = _camera.focus;
var _camDis = _camera.focus_dist;
var _camAx = _camera.focus_angle_x;
var _camAy = _camera.focus_angle_y;
tool_axis_edit = new scrollBox([ "local", "global" ], function(val) { tool_attribute.context = val; });
tool_axis_edit.font = f_p2;
tool_axis_edit.arrow_spr = THEME.arrow;
tool_axis_edit.arrow_ind = 3;
tool_attribute.context = 0;
tool_settings = [
[ "Axis", tool_axis_edit, "context", tool_attribute ],
];
var _qview = new BBMOD_Quaternion().FromEuler(_camAy, -_camAx, 0);
static getToolSettings = function() {
if(isUsingTool("Transform") || isUsingTool("Rotate"))
return tool_settings;
return [];
}
#endregion
static drawGizmoPosition = function(index, object, _vpos, active, params, _mx, _my, _snx, _sny, _panel) { #region
#region ---- main ----
var _pos = inputs[| index].getValue(,,, true);
var _qrot = object == noone? new BBMOD_Quaternion() : object.rotation;
var _qinv = new BBMOD_Quaternion().FromAxisAngle(new BBMOD_Vec3(1, 0, 0), 90);
var _vpos = new __vec3( _pos[0], _pos[1], _pos[2] );
var _posView = _camera.worldPointToViewPoint(_vpos);
var _camera = params.camera;
var _qview = new BBMOD_Quaternion().FromEuler(_camera.focus_angle_y, -_camera.focus_angle_x, 0);
var cx = _posView.x;
var cy = _posView.y;
var _axis = tool_attribute.context;
var _hover = noone;
var _hoverDist = 10;
var th;
var _hover = noone;
var _hoverDist = 10;
var th;
var _posView = _camera.worldPointToViewPoint(_vpos);
var cx = _posView.x;
var cy = _posView.y;
if(isUsingTool(0)) { #region move
var ga = [];
var size = 64;
var hs = size / 2;
var sq = 8;
#endregion
#region display
ga[0] = new BBMOD_Vec3(-size, 0, 0);
ga[1] = new BBMOD_Vec3(0, 0, size);
ga[2] = new BBMOD_Vec3(0, -size, 0);
ga[3] = [ new BBMOD_Vec3(-hs + sq, 0, hs - sq),
new BBMOD_Vec3(-hs - sq, 0, hs - sq),
new BBMOD_Vec3(-hs - sq, 0, hs + sq),
new BBMOD_Vec3(-hs + sq, 0, hs + sq), ];
new BBMOD_Vec3(-hs - sq, 0, hs - sq),
new BBMOD_Vec3(-hs - sq, 0, hs + sq),
new BBMOD_Vec3(-hs + sq, 0, hs + sq), ];
ga[4] = [ new BBMOD_Vec3( 0, -hs + sq, hs - sq),
new BBMOD_Vec3( 0, -hs - sq, hs - sq),
new BBMOD_Vec3( 0, -hs - sq, hs + sq),
new BBMOD_Vec3( 0, -hs + sq, hs + sq), ];
new BBMOD_Vec3( 0, -hs - sq, hs - sq),
new BBMOD_Vec3( 0, -hs - sq, hs + sq),
new BBMOD_Vec3( 0, -hs + sq, hs + sq), ];
ga[5] = [ new BBMOD_Vec3(-hs + sq, -hs - sq, 0),
new BBMOD_Vec3(-hs - sq, -hs - sq, 0),
new BBMOD_Vec3(-hs - sq, -hs + sq, 0),
new BBMOD_Vec3(-hs + sq, -hs + sq, 0), ];
new BBMOD_Vec3(-hs - sq, -hs - sq, 0),
new BBMOD_Vec3(-hs - sq, -hs + sq, 0),
new BBMOD_Vec3(-hs + sq, -hs + sq, 0), ];
ga[0] = new BBMOD_Vec3(-size, 0, 0);
ga[1] = new BBMOD_Vec3(0, -size, 0);
ga[2] = new BBMOD_Vec3(0, 0, -size);
ga[3] = [ new BBMOD_Vec3(-hs + sq, -hs - sq, 0),
new BBMOD_Vec3(-hs - sq, -hs - sq, 0),
new BBMOD_Vec3(-hs - sq, -hs + sq, 0),
new BBMOD_Vec3(-hs + sq, -hs + sq, 0), ];
ga[4] = [ new BBMOD_Vec3( 0, -hs + sq, -hs - sq),
new BBMOD_Vec3( 0, -hs - sq, -hs - sq),
new BBMOD_Vec3( 0, -hs - sq, -hs + sq),
new BBMOD_Vec3( 0, -hs + sq, -hs + sq), ];
ga[5] = [ new BBMOD_Vec3(-hs + sq, 0, -hs - sq),
new BBMOD_Vec3(-hs - sq, 0, -hs - sq),
new BBMOD_Vec3(-hs - sq, 0, -hs + sq),
new BBMOD_Vec3(-hs + sq, 0, -hs + sq), ];
for( var i = 0; i < 3; i++ ) {
ga[i] = _qview.Rotate(ga[i]);
if(_axis == 0)
ga[i] = _qview.Rotate(_qinv.Rotate(_qrot.Rotate(ga[i])));
else if(_axis == 1)
ga[i] = _qview.Rotate(_qinv.Rotate(ga[i]));
th = 2 + (axis_hover == i || drag_axis == i);
if(drag_axis != noone && drag_axis != i)
@ -110,8 +143,12 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr
}
for( var i = 3; i < 6; i++ ) {
for( var j = 0; j < 4; j++ )
ga[i][j] = _qview.Rotate(ga[i][j]);
for( var j = 0; j < 4; j++ ) {
if(_axis == 0)
ga[i][j] = _qview.Rotate(_qinv.Rotate(_qrot.Rotate(ga[i][j])));
else if(_axis == 1)
ga[i][j] = _qview.Rotate(_qinv.Rotate(ga[i][j]));
}
th = 1;
@ -149,82 +186,116 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr
}
axis_hover = _hover;
if(drag_axis != noone) {
if(!MOUSE_WRAPPING) {
drag_mx += _mx - drag_px;
drag_my += _my - drag_py;
#endregion display
if(drag_axis != noone) { #region editing
if(!MOUSE_WRAPPING) {
drag_mx += _mx - drag_px;
drag_my += _my - drag_py;
var _mmx = drag_mx - drag_cx;
var _mmy = drag_my - drag_cy;
var mAdj, nor;
var mAdj, nor, prj;
var ray = _camera.viewPointToWorldRay(_mx, _my);
var ray = _camera.viewPointToWorldRay(drag_mx, drag_my);
if(drag_axis < 3) {
switch(drag_axis) {
case 0 : nor = new __vec3(0, 0, 1); break;
case 1 : nor = new __vec3(1, 0, 0); break;
case 2 : nor = new __vec3(0, 1, 0); break;
}
var pln = new __plane(drag_original, nor);
mAdj = d3d_intersect_ray_plane(ray, pln);
if(drag_prev != undefined) {
var _diff = mAdj.subtract(drag_prev);
_pos[drag_axis] += _diff.getIndex(drag_axis);
if(inputs[| 0].setValue(_pos))
UNDO_HOLDING = true;
}
} else {
switch(drag_axis) {
case 3 : nor = new __vec3(0, 0, 1); break;
case 4 : nor = new __vec3(1, 0, 0); break;
case 5 : nor = new __vec3(0, 1, 0); break;
}
var pln = new __plane(drag_original, nor);
mAdj = d3d_intersect_ray_plane(ray, pln);
if(drag_prev != undefined) {
var _diff = mAdj.subtract(drag_prev);
_pos[0] += _diff.x;
_pos[1] += _diff.y;
_pos[2] += _diff.z;
if(inputs[| 0].setValue(_pos))
UNDO_HOLDING = true;
}
if(drag_axis < 3) {
switch(drag_axis) {
case 0 : nor = new __vec3(0, 1, 0); prj = new __vec3(1, 0, 0); break;
case 1 : nor = new __vec3(0, 0, 1); prj = new __vec3(0, 1, 0); break;
case 2 : nor = new __vec3(1, 0, 0); prj = new __vec3(0, 0, 1); break;
}
if(_axis == 0) {
nor = _qrot.Rotate(nor);
prj = _qrot.Rotate(prj);
}
var pln = new __plane(drag_original, nor);
mAdj = d3d_intersect_ray_plane(ray, pln);
if(drag_prev != undefined) {
var _diff = mAdj.subtract(drag_prev);
var _dist = _diff.dot(prj);
for( var i = 0; i < 3; i++ )
_pos[i] += prj.getIndex(i) * _dist;
if(inputs[| index].setValue(_pos))
UNDO_HOLDING = true;
}
} else {
switch(drag_axis) {
case 3 : nor = new __vec3(0, 0, 1); break;
case 4 : nor = new __vec3(1, 0, 0); break;
case 5 : nor = new __vec3(0, 1, 0); break;
}
if(_axis == 0)
nor = _qrot.Rotate(nor);
var pln = new __plane(drag_original, nor);
mAdj = d3d_intersect_ray_plane(ray, pln);
if(drag_prev != undefined) {
var _diff = mAdj.subtract(drag_prev);
for( var i = 0; i < 3; i++ )
_pos[i] += _diff.getIndex(i);
if(inputs[| index].setValue(_pos))
UNDO_HOLDING = true;
}
drag_prev = mAdj;
}
setMouseWrap();
drag_px = _mx;
drag_py = _my;
drag_prev = mAdj;
}
setMouseWrap();
drag_px = _mx;
drag_py = _my;
} #endregion
if(_hover != noone && mouse_press(mb_left, active)) {
drag_axis = _hover;
drag_prev = undefined;
drag_mx = _mx;
drag_my = _my;
drag_px = _mx;
drag_py = _my;
drag_cx = cx;
drag_cy = cy;
if(_hover != noone && mouse_press(mb_left, active)) { #region
drag_axis = _hover;
drag_prev = undefined;
drag_mx = _mx;
drag_my = _my;
drag_px = _mx;
drag_py = _my;
drag_cx = cx;
drag_cy = cy;
drag_original = new __vec3(_pos);
}
#endregion
} else if(isUsingTool(1)) { #region rotate
var size = 64;
var _qrot = object.rotation;
drag_original = new __vec3(_pos);
} #endregion
} #endregion
static drawGizmoRotation = function(index, object, _vpos, active, params, _mx, _my, _snx, _sny, _panel) { #region
#region ---- main ----
var _rot = inputs[| index].getValue(,,, true);
var _qrot = object == noone? new BBMOD_Quaternion() : object.rotation;
var _qinv = new BBMOD_Quaternion().FromAxisAngle(new BBMOD_Vec3(1, 0, 0), 90);
var _camera = params.camera;
var _qview = new BBMOD_Quaternion().FromEuler(_camera.focus_angle_y, -_camera.focus_angle_x, 0);
var _axis = tool_attribute.context;
var _hover = noone;
var _hoverDist = 10;
var th;
var _posView = _camera.worldPointToViewPoint(_vpos);
var cx = _posView.x;
var cy = _posView.y;
var ga = [];
var size = 64;
var hs = size / 2;
var sq = 8;
#endregion
#region display
var size = 64;
for( var i = 0; i < 3; i++ ) {
var op, np;
@ -242,7 +313,10 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr
case 2 : np = new BBMOD_Vec3(lengthdir_x(size, ang), 0, lengthdir_y(size, ang)); break;
}
np = _qview.Rotate(_qinv.Rotate(_qrot.Rotate(np)));
if(_axis == 0)
np = _qview.Rotate(_qinv.Rotate(_qrot.Rotate(np)));
else if(_axis == 1)
np = _qview.Rotate(_qinv.Rotate(np));
if(j && (op.Z > 0 && np.Z > 0 || drag_axis == i)) {
draw_line_round(cx + op.X, cy + op.Y, cx + np.X, cy + np.Y, th);
@ -256,70 +330,96 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr
op = np;
}
}
axis_hover = _hover;
#endregion
if(drag_axis != noone) {
var mAng = point_direction(cx, cy, _mx, _my);
var _n = BBMOD_VEC3_FORWARD;
switch(drag_axis) {
case 0 : _n = new BBMOD_Vec3(-1, 0, 0); break;
case 1 : _n = new BBMOD_Vec3( 0, 0, -1); break;
case 2 : _n = new BBMOD_Vec3( 0, -1, 0); break;
}
if(drag_axis != noone) { #region
var mAng = point_direction(cx, cy, _mx, _my);
var _n = BBMOD_VEC3_FORWARD;
switch(drag_axis) {
case 0 : _n = new BBMOD_Vec3(-1, 0, 0); break;
case 1 : _n = new BBMOD_Vec3( 0, 0, -1); break;
case 2 : _n = new BBMOD_Vec3( 0, -1, 0); break;
}
if(_axis == 0)
_n = _qrot.Rotate(_n).Normalize();
var _nv = _qview.Rotate(_qinv.Rotate(_n));
draw_line_round(cx, cy, cx + _nv.X * 100, cy + _nv.Y * 100, 2);
var _nv = _qview.Rotate(_qinv.Rotate(_n));
draw_line_round(cx, cy, cx + _nv.X * 100, cy + _nv.Y * 100, 2);
if(drag_prev != undefined) {
var _rd = (mAng - drag_prev) * (_nv.Z > 0? 1 : -1);
if(drag_prev != undefined) {
var _rd = (mAng - drag_prev) * (_nv.Z > 0? 1 : -1);
var _currR = new BBMOD_Quaternion().FromAxisAngle(_n, _rd);
var _mulp = _currR.Mul(_qrot);
var _Nrot = _mulp.ToArray();
var _currR = new BBMOD_Quaternion().FromAxisAngle(_n, _rd);
var _mulp = _currR.Mul(_qrot);
var _Nrot = _mulp.ToArray();
if(inputs[| 1].setValue(_Nrot))
UNDO_HOLDING = true;
}
draw_set_color(COLORS._main_accent);
draw_line_dashed(cx, cy, _mx, _my, 1, 4);
drag_prev = mAng;
if(inputs[| index].setValue(_Nrot))
UNDO_HOLDING = true;
}
draw_set_color(COLORS._main_accent);
draw_line_dashed(cx, cy, _mx, _my, 1, 4);
drag_prev = mAng;
} #endregion
if(_hover != noone && mouse_press(mb_left, active)) {
drag_axis = _hover;
drag_prev = undefined;
}
#endregion
} else if(isUsingTool(2)) { #region scale
if(_hover != noone && mouse_press(mb_left, active)) { #region
drag_axis = _hover;
drag_prev = undefined;
} #endregion
} #endregion
static drawGizmoScale = function(index, object, _vpos, active, params, _mx, _my, _snx, _sny, _panel) { #region
#region ---- main ----
var _sca = inputs[| index].getValue(,,, true);
var _qrot = object == noone? new BBMOD_Quaternion() : object.rotation;
var _qinv = new BBMOD_Quaternion().FromAxisAngle(new BBMOD_Vec3(1, 0, 0), 90);
var _camera = params.camera;
var _qview = new BBMOD_Quaternion().FromEuler(_camera.focus_angle_y, -_camera.focus_angle_x, 0);
var _axis = tool_attribute.context;
var _hover = noone;
var _hoverDist = 10;
var th;
var _posView = _camera.worldPointToViewPoint(_vpos);
var cx = _posView.x;
var cy = _posView.y;
var ga = [];
var size = 64;
var hs = size / 2;
var sq = 8;
var _qrot = object.rotation;
var _qinv = new BBMOD_Quaternion().FromAxisAngle(new BBMOD_Vec3(1, 0, 0), 90);
#endregion
#region display
var ga = [];
var size = 64;
var hs = size / 2;
var sq = 8;
ga[0] = new BBMOD_Vec3(-size, 0, 0);
ga[1] = new BBMOD_Vec3(0, -size, 0);
ga[2] = new BBMOD_Vec3(0, 0, -size);
ga[3] = [ new BBMOD_Vec3(-hs + sq, -hs - sq, 0),
new BBMOD_Vec3(-hs - sq, -hs - sq, 0),
new BBMOD_Vec3(-hs - sq, -hs + sq, 0),
new BBMOD_Vec3(-hs + sq, -hs + sq, 0), ];
new BBMOD_Vec3(-hs - sq, -hs - sq, 0),
new BBMOD_Vec3(-hs - sq, -hs + sq, 0),
new BBMOD_Vec3(-hs + sq, -hs + sq, 0), ];
ga[4] = [ new BBMOD_Vec3( 0, -hs + sq, -hs - sq),
new BBMOD_Vec3( 0, -hs - sq, -hs - sq),
new BBMOD_Vec3( 0, -hs - sq, -hs + sq),
new BBMOD_Vec3( 0, -hs + sq, -hs + sq), ];
new BBMOD_Vec3( 0, -hs - sq, -hs - sq),
new BBMOD_Vec3( 0, -hs - sq, -hs + sq),
new BBMOD_Vec3( 0, -hs + sq, -hs + sq), ];
ga[5] = [ new BBMOD_Vec3(-hs + sq, 0, -hs - sq),
new BBMOD_Vec3(-hs - sq, 0, -hs - sq),
new BBMOD_Vec3(-hs - sq, 0, -hs + sq),
new BBMOD_Vec3(-hs + sq, 0, -hs + sq), ];
new BBMOD_Vec3(-hs - sq, 0, -hs - sq),
new BBMOD_Vec3(-hs - sq, 0, -hs + sq),
new BBMOD_Vec3(-hs + sq, 0, -hs + sq), ];
for( var i = 0; i < 3; i++ ) {
ga[i] = _qview.Rotate(_qinv.Rotate(_qrot.Rotate(ga[i])));
@ -342,8 +442,12 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr
}
for( var i = 3; i < 6; i++ ) {
for( var j = 0; j < 4; j++ )
ga[i][j] = _qview.Rotate(_qinv.Rotate(_qrot.Rotate(ga[i][j])));
for( var j = 0; j < 4; j++ ) {
if(_axis == 0)
ga[i][j] = _qview.Rotate(_qinv.Rotate(_qrot.Rotate(ga[i][j])));
else
ga[i][j] = _qview.Rotate(_qinv.Rotate(ga[i][j]));
}
th = 1;
@ -381,78 +485,96 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr
}
axis_hover = _hover;
#endregion
if(drag_axis != noone) {
if(!MOUSE_WRAPPING) {
drag_mx += _mx - drag_px;
drag_my += _my - drag_py;
if(drag_axis != noone) { #region editing
if(!MOUSE_WRAPPING) {
drag_mx += _mx - drag_px;
drag_my += _my - drag_py;
var _mmx = drag_mx - drag_cx;
var _mmy = drag_my - drag_cy;
var mAdj, nor;
var mAdj, nor;
var ray = _camera.viewPointToWorldRay(_mx, _my);
var ray = _camera.viewPointToWorldRay(drag_mx, drag_my);
if(drag_axis < 3) {
switch(drag_axis) {
case 0 : nor = new __vec3(0, 0, 1); break;
case 1 : nor = new __vec3(1, 0, 0); break;
case 2 : nor = new __vec3(0, 1, 0); break;
}
var pln = new __plane(drag_original, nor);
mAdj = d3d_intersect_ray_plane(ray, pln);
if(drag_prev != undefined) {
var _diff = mAdj.subtract(drag_prev);
_sca[drag_axis] += _diff.getIndex(drag_axis);
if(inputs[| 2].setValue(_sca))
UNDO_HOLDING = true;
}
} else {
switch(drag_axis) {
case 3 : nor = new __vec3(0, 0, 1); break;
case 4 : nor = new __vec3(1, 0, 0); break;
case 5 : nor = new __vec3(0, 1, 0); break;
}
var pln = new __plane(drag_original, nor);
mAdj = d3d_intersect_ray_plane(ray, pln);
if(drag_prev != undefined) {
var _diff = mAdj.subtract(drag_prev);
_sca[0] += _diff.x;
_sca[1] += _diff.y;
_sca[2] += _diff.z;
if(inputs[| 2].setValue(_sca))
UNDO_HOLDING = true;
}
if(drag_axis < 3) {
switch(drag_axis) {
case 0 : nor = new __vec3(0, 1, 0); prj = new __vec3(1, 0, 0); break;
case 1 : nor = new __vec3(0, 0, 1); prj = new __vec3(0, 1, 0); break;
case 2 : nor = new __vec3(1, 0, 0); prj = new __vec3(0, 0, 1); break;
}
nor = _qrot.Rotate(nor);
prj = _qrot.Rotate(prj);
var pln = new __plane(drag_original, nor);
mAdj = d3d_intersect_ray_plane(ray, pln);
if(drag_prev != undefined) {
var _diff = mAdj.subtract(drag_prev);
var _dist = _diff.dot(prj);
for( var i = 0; i < 3; i++ )
_sca[i] += prj.getIndex(i) * _dist;
if(inputs[| index].setValue(_sca))
UNDO_HOLDING = true;
}
} else {
switch(drag_axis) {
case 3 : nor = new __vec3(0, 0, 1); break;
case 4 : nor = new __vec3(1, 0, 0); break;
case 5 : nor = new __vec3(0, 1, 0); break;
}
nor = _qrot.Rotate(nor);
var pln = new __plane(drag_original, nor);
mAdj = d3d_intersect_ray_plane(ray, pln);
if(drag_prev != undefined) {
var _diff = mAdj.subtract(drag_prev);
for( var i = 0; i < 3; i++ )
_sca[i] += _diff.getIndex(i);
if(inputs[| index].setValue(_sca))
UNDO_HOLDING = true;
}
drag_prev = mAdj;
}
setMouseWrap();
drag_px = _mx;
drag_py = _my;
drag_prev = mAdj;
}
setMouseWrap();
drag_px = _mx;
drag_py = _my;
} #endregion
if(_hover != noone && mouse_press(mb_left, active)) {
drag_axis = _hover;
drag_prev = undefined;
drag_mx = _mx;
drag_my = _my;
drag_px = _mx;
drag_py = _my;
drag_cx = cx;
drag_cy = cy;
if(_hover != noone && mouse_press(mb_left, active)) { #region
drag_axis = _hover;
drag_prev = undefined;
drag_mx = _mx;
drag_my = _my;
drag_px = _mx;
drag_py = _my;
drag_cx = cx;
drag_cy = cy;
drag_original = new __vec3(_sca);
}
#endregion
}
drag_original = new __vec3(_sca);
} #endregion
} #endregion
static drawOverlay3D = function(active, params, _mx, _my, _snx, _sny, _panel) { #region
var object = getPreviewObject();
if(array_empty(object)) return;
object = object[0];
var _pos = inputs[| 0].getValue(,,, true);
var _vpos = new __vec3( _pos[0], _pos[1], _pos[2] );
if(isUsingTool("Transform")) drawGizmoPosition(0, object, _vpos, active, params, _mx, _my, _snx, _sny, _panel);
else if(isUsingTool("Rotate")) drawGizmoRotation(1, object, _vpos, active, params, _mx, _my, _snx, _sny, _panel);
else if(isUsingTool("Scale")) drawGizmoScale(2, object, _vpos, active, params, _mx, _my, _snx, _sny, _panel);
if(drag_axis != noone && mouse_release(mb_left)) {
drag_axis = noone;

View file

@ -27,15 +27,15 @@ function __3dCamera() constructor {
viewMat = new __mat4();
projMat = new __mat4();
static getUp = function() {
var upVector = new __vec3(0, 0, 0);
static getUp = function(_x = 1, _y = 1, _z = 1) {
var upVector = new __vec3(0, 0, -1);
var hRad = degtorad(focus_angle_x);
var vRad = degtorad(focus_angle_y);
upVector.x = -sin(hRad) * sin(vRad);
upVector.y = cos(hRad) * -sin(vRad);
upVector.z = cos(vRad);
upVector.x = -sin(hRad) * sin(vRad) * _x;
upVector.y = cos(hRad) * -sin(vRad) * _y;
upVector.z = cos(vRad) * _z;
return upVector._normalize();
}
@ -91,6 +91,11 @@ function __3dCamera() constructor {
return self;
}
static setCameraLookRotate = function() {
var _fPos = calculate_3d_position(focus.x, focus.y, focus.z, focus_angle_x, focus_angle_y, focus_dist);
position.set(_fPos);
}
static worldPointToViewPoint = function(vec3) {
var _vec4 = new __vec4().set(vec3, 1);
var _view = viewMat.transpose().multiplyVector(_vec4);

View file

@ -0,0 +1,30 @@
function __3dGizmoSphere(radius = 0.5, color = c_white, alpha = 1) : __3dObject() constructor {
vertex = array_create(33 * 3);
var _i = 0;
for( var i = 0; i <= 32; i++ ) {
var a0 = (i + 0) / 32 * 360;
var a1 = (i + 1) / 32 * 360;
var x0 = lengthdir_x(radius, a0);
var y0 = lengthdir_y(radius, a0);
var x1 = lengthdir_x(radius, a1);
var y1 = lengthdir_y(radius, a1);
vertex[_i++] = [ 0, x0, y0, color, alpha ];
vertex[_i++] = [ 0, x1, y1, color, alpha ];
vertex[_i++] = [ x0, 0, y0, color, alpha ];
vertex[_i++] = [ x1, 0, y1, color, alpha ];
vertex[_i++] = [ x0, y0, 0, color, alpha ];
vertex[_i++] = [ x1, y1, 0, color, alpha ];
}
VF = global.VF_POS_COL;
render_type = pr_linelist;
VB = build();
static submitSel = function(params = {}) {
shader_set(sh_d3d_wireframe);
submitVertex(params);
shader_reset();
}
}

View file

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

View file

@ -30,7 +30,12 @@ function __vec3(_x = 0, _y = 0, _z = 0) constructor {
z = _z;
return self;
} set(_x, _y, _z);
static isZero = function() {
gml_pragma("forceinline");
return x == 0 && y == 0 && z == 0;
}
static setIndex = function(index, value) {
gml_pragma("forceinline");
switch(index) {

View file

@ -157,7 +157,7 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover = false, _foc
draw_line(bx - ui(20), by - lhf, bx - ui(20), by + lhf);
bx -= ui(26 + 12);
if(buttonInstant(THEME.button_hide, bx - ui(12), by - ui(12), ui(24), ui(24), _m, _focus, _hover, __txtx("panel_animation_looping_mode", "Looping mode") + " " + ON_END_NAME[jun.on_end], THEME.prop_on_end, jun.on_end) == 2)
if(buttonInstant(THEME.button_hide, bx - ui(12), by - ui(12), ui(24), ui(24), _m, _focus, _hover, __txtx("panel_animation_looping_mode", "Looping mode") + " " + global.junctionEndName[jun.on_end], THEME.prop_on_end, jun.on_end) == 2)
jun.on_end = safe_mod(jun.on_end + 1, sprite_get_number(THEME.prop_on_end));
}
#endregion

View file

@ -2,73 +2,197 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group)
name = "3D Camera";
object = new __3dCamera_object();
camera = new __3dCamera();
camera.useFocus = false;
lookat = new __3dGizmoSphere(0.5, c_ltgray, 1);
scene = new __3dScene(camera);
scene.name = "Camera";
inputs[| input_d3d_index + 0] = nodeValue("FOV", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 60)
inputs[| in_d3d + 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 ])
inputs[| in_d3d + 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 )
inputs[| in_d3d + 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 )
inputs[| in_d3d + 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 )
inputs[| in_d3d + 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[| in_d3d + 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[| in_d3d + 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)
inputs[| in_d3d + 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)
inputs[| in_d3d + 8] = nodeValue("Orthographic Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
.setDisplay(VALUE_DISPLAY.slider, [ 0.01, 4, 0.01 ]);
inputs[| in_d3d + 9] = nodeValue("Postioning Mode", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "Position + Rotation", "Position + Lookat", "Lookat + Rotation" ]);
inputs[| in_d3d + 10] = nodeValue("Lookat Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0, 0 ])
.setDisplay(VALUE_DISPLAY.vector);
inputs[| in_d3d + 11] = nodeValue("Roll", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setDisplay(VALUE_DISPLAY.rotation);
inputs[| in_d3d + 12] = nodeValue("Horizontal Angle", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setDisplay(VALUE_DISPLAY.rotation);
inputs[| in_d3d + 13] = nodeValue("Vertical Angle", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 45)
.setDisplay(VALUE_DISPLAY.slider, [0, 90, 1]);
inputs[| in_d3d + 14] = nodeValue("Distance", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 4);
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,
input_display_list = [ in_d3d + 4,
["Output", false], in_d3d + 2,
["Transform", false], in_d3d + 9, 0, 1, in_d3d + 10, in_d3d + 11, in_d3d + 12, in_d3d + 13, in_d3d + 14,
["Camera", false], in_d3d + 3, in_d3d + 0, in_d3d + 1, in_d3d + 8,
["Render", false], in_d3d + 5, in_d3d + 6, in_d3d + 7,
];
static step = function() {
var _proj = inputs[| input_d3d_index + 3].getValue();
tool_lookat = new NodeTool( "Move Target", THEME.tools_3d_transform_object );
static getToolSettings = function() { #region
var _posm = inputs[| in_d3d + 9].getValue();
inputs[| input_d3d_index + 0].setVisible(_proj == 0);
inputs[| input_d3d_index + 8].setVisible(_proj == 1);
switch(_posm) {
case 0 : return tool_settings;
case 1 :
case 2 : return [];
}
return [];
} #endregion
static drawOverlay3D = function(active, params, _mx, _my, _snx, _sny, _panel) { #region
var object = getPreviewObject();
if(array_empty(object)) return;
object = object[0];
var _pos = inputs[| 0].getValue(,,, true);
var _vpos = new __vec3( _pos[0], _pos[1], _pos[2] );
if(isUsingTool("Transform")) drawGizmoPosition(0, object, _vpos, active, params, _mx, _my, _snx, _sny, _panel);
else if(isUsingTool("Rotate")) drawGizmoRotation(1, object, _vpos, active, params, _mx, _my, _snx, _sny, _panel);
else if(isUsingTool("Move Target")) {
var _lkpos = inputs[| in_d3d + 10].getValue(,,, true);
var _lkvpos = new __vec3( _lkpos[0], _lkpos[1], _lkpos[2] );
drawGizmoPosition(in_d3d + 10, noone, _lkvpos, active, params, _mx, _my, _snx, _sny, _panel);
}
if(drag_axis != noone && mouse_release(mb_left)) {
drag_axis = noone;
UNDO_HOLDING = false;
}
} #endregion
static onValueUpdate = function(index) {
if(index == in_d3d + 9) PANEL_PREVIEW.tool_current = noone;
}
static step = function() { #region
var _proj = inputs[| in_d3d + 3].getValue();
var _posm = inputs[| in_d3d + 9].getValue();
inputs[| in_d3d + 0].setVisible(_proj == 0);
inputs[| in_d3d + 8].setVisible(_proj == 1);
inputs[| 0].setVisible(_posm == 0 || _posm == 1);
inputs[| 1].setVisible(_posm == 0);
inputs[| in_d3d + 10].setVisible(_posm == 1 || _posm == 2);
inputs[| in_d3d + 11].setVisible(_posm == 1);
inputs[| in_d3d + 12].setVisible(_posm == 2);
inputs[| in_d3d + 13].setVisible(_posm == 2);
inputs[| in_d3d + 14].setVisible(_posm == 2);
switch(_posm) {
case 0 :
tools = [ tool_pos, tool_rot ];
break;
case 1 :
tools = [ tool_pos, tool_lookat ];
tool_attribute.context = 1;
break;
case 2 :
tools = [ tool_lookat ];
tool_attribute.context = 1;
break;
}
} #endregion
static processData = function(_output, _data, _output_index, _array_index = 0) { #region
var _pos = _data[0];
var _rot = _data[1];
var _fov = _data[input_d3d_index + 0];
var _clip = _data[input_d3d_index + 1];
var _dim = _data[input_d3d_index + 2];
var _proj = _data[input_d3d_index + 3];
var _scne = _data[input_d3d_index + 4];
var _ambt = _data[input_d3d_index + 5];
var _dbg = _data[input_d3d_index + 6];
var _back = _data[input_d3d_index + 7];
var _orts = _data[input_d3d_index + 8];
var _fov = _data[in_d3d + 0];
var _clip = _data[in_d3d + 1];
var _dim = _data[in_d3d + 2];
var _proj = _data[in_d3d + 3];
var _scne = _data[in_d3d + 4];
var _ambt = _data[in_d3d + 5];
var _dbg = _data[in_d3d + 6];
var _back = _data[in_d3d + 7];
var _orts = _data[in_d3d + 8];
var _posm = _data[in_d3d + 9];
var _look = _data[in_d3d + 10];
var _roll = _data[in_d3d + 11];
var _hAng = _data[in_d3d + 12];
var _vAng = _data[in_d3d + 13];
var _dist = _data[in_d3d + 14];
var _qi1 = new BBMOD_Quaternion().FromAxisAngle(new BBMOD_Vec3(0, 1, 0), 90);
var _qi2 = new BBMOD_Quaternion().FromAxisAngle(new BBMOD_Vec3(1, 0, 0), -90);
var _qi3 = new BBMOD_Quaternion().FromAxisAngle(new BBMOD_Vec3(1, 0, 0), 90);
switch(_posm) {
case 0 :
camera.useFocus = false;
camera.position.set(_pos);
camera.rotation.set(_rot[0], _rot[1], _rot[2], _rot[3]);
break;
case 1 :
camera.useFocus = true;
camera.position.set(_pos);
camera.focus.set(_look);
camera.up.set(0, 0, -1);
var _for = camera.focus.subtract(camera.position);
if(!_for.isZero())
camera.rotation = new BBMOD_Quaternion().FromLookRotation(_for, camera.up).Mul(_qi1).Mul(_qi2);
lookat.position.set(_look);
break;
case 2 :
camera.useFocus = true;
camera.focus.set(_look);
camera.setFocusAngle(_hAng, _vAng, _dist);
camera.setCameraLookRotate();
camera.up = camera.getUp();
var _for = camera.focus.subtract(camera.position);
if(!_for.isZero())
camera.rotation = new BBMOD_Quaternion().FromLookRotation(_for, camera.up).Mul(_qi1).Mul(_qi3);
lookat.position.set(_look);
break;
}
object.position.set(camera.position);
object.rotation = camera.rotation.Clone();
setTransform(object, _data);
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(1 / _orts, _dim[0] / _dim[1] / _orts);
@ -106,12 +230,21 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group)
}
static getPreviewObject = function() {
var _scene = array_safe_get(all_inputs, input_d3d_index + 4, []);
_scene = array_safe_get(_scene, preview_index);
static getPreviewObject = function() { #region
var _posm = inputs[| in_d3d + 9].getValue();
var _scene = array_safe_get(all_inputs, in_d3d + 4, []);
if(is_array(_scene))
_scene = array_safe_get(_scene, preview_index, noone);
switch(_posm) {
case 0 : return [ object, _scene ];
case 1 : return [ object, lookat, _scene ];
case 2 : return [ object, lookat, _scene ];
}
return [ object, _scene ];
}
} #endregion
static getPreviewObjectOutline = function() { return [ object ]; }
static getPreviewObjectOutline = function() { return isUsingTool("Move Target")? [ lookat ] : [ object ]; }
}

View file

@ -1,11 +1,11 @@
function Node_3D_Light_Point(_x, _y, _group = noone) : Node_3D_Light(_x, _y, _group) constructor {
name = "Point Light";
inputs[| input_light_index + 0] = nodeValue("Radius", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 4)
inputs[| in_light + 0] = nodeValue("Radius", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 4)
input_display_list = [
["Transform", false], 0,
__d3d_input_list_light, input_light_index,
__d3d_input_list_light, in_light,
]
static processData = function(_output, _data, _output_index, _array_index = 0) {
@ -14,7 +14,7 @@ function Node_3D_Light_Point(_x, _y, _group = noone) : Node_3D_Light(_x, _y, _gr
setTransform(object, _data);
setLight(object, _data);
var _rad = inputs[| input_light_index + 0].getValue();
var _rad = inputs[| in_light + 0].getValue();
object.radius = _rad;
return object;

View file

@ -1,47 +1,47 @@
function Node_3D_Mesh_Cube(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _group) constructor {
name = "3D Cube";
inputs[| input_mesh_index + 0] = nodeValue("Texture per side", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false );
inputs[| in_mesh + 0] = nodeValue("Texture per side", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false );
inputs[| input_mesh_index + 1] = nodeValue("Texture", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone );
inputs[| in_mesh + 1] = nodeValue("Texture", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone );
inputs[| input_mesh_index + 2] = nodeValue("Texture 2", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone );
inputs[| in_mesh + 2] = nodeValue("Texture 2", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone );
inputs[| input_mesh_index + 3] = nodeValue("Texture 3", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone );
inputs[| in_mesh + 3] = nodeValue("Texture 3", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone );
inputs[| input_mesh_index + 4] = nodeValue("Texture 4", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone );
inputs[| in_mesh + 4] = nodeValue("Texture 4", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone );
inputs[| input_mesh_index + 5] = nodeValue("Texture 5", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone );
inputs[| in_mesh + 5] = nodeValue("Texture 5", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone );
inputs[| input_mesh_index + 6] = nodeValue("Texture 6", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone );
inputs[| in_mesh + 6] = nodeValue("Texture 6", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone );
input_display_list = [
__d3d_input_list_mesh,
__d3d_input_list_transform,
["Texture", false], input_mesh_index + 0, input_mesh_index + 1, input_mesh_index + 2, input_mesh_index + 3,
input_mesh_index + 4, input_mesh_index + 5, input_mesh_index + 6,
["Texture", false], in_mesh + 0, in_mesh + 1, in_mesh + 2, in_mesh + 3,
in_mesh + 4, in_mesh + 5, in_mesh + 6,
]
static step = function() { #region
var _tex_side = inputs[| input_mesh_index + 0].getValue();
var _tex_side = inputs[| in_mesh + 0].getValue();
inputs[| input_mesh_index + 1].name = _tex_side? "Texture 1" : "Texture";
inputs[| input_mesh_index + 1].setVisible(true, true);
inputs[| input_mesh_index + 2].setVisible(_tex_side, _tex_side);
inputs[| input_mesh_index + 3].setVisible(_tex_side, _tex_side);
inputs[| input_mesh_index + 4].setVisible(_tex_side, _tex_side);
inputs[| input_mesh_index + 5].setVisible(_tex_side, _tex_side);
inputs[| input_mesh_index + 6].setVisible(_tex_side, _tex_side);
inputs[| in_mesh + 1].name = _tex_side? "Texture 1" : "Texture";
inputs[| in_mesh + 1].setVisible(true, true);
inputs[| in_mesh + 2].setVisible(_tex_side, _tex_side);
inputs[| in_mesh + 3].setVisible(_tex_side, _tex_side);
inputs[| in_mesh + 4].setVisible(_tex_side, _tex_side);
inputs[| in_mesh + 5].setVisible(_tex_side, _tex_side);
inputs[| in_mesh + 6].setVisible(_tex_side, _tex_side);
} #endregion
static processData = function(_output, _data, _output_index, _array_index = 0) { #region
var _tex_side = _data[input_mesh_index + 0];
var _tex_1 = _data[input_mesh_index + 1];
var _tex_2 = _data[input_mesh_index + 2];
var _tex_3 = _data[input_mesh_index + 3];
var _tex_4 = _data[input_mesh_index + 4];
var _tex_5 = _data[input_mesh_index + 5];
var _tex_6 = _data[input_mesh_index + 6];
var _tex_side = _data[in_mesh + 0];
var _tex_1 = _data[in_mesh + 1];
var _tex_2 = _data[in_mesh + 2];
var _tex_3 = _data[in_mesh + 3];
var _tex_4 = _data[in_mesh + 4];
var _tex_5 = _data[in_mesh + 5];
var _tex_6 = _data[in_mesh + 6];
var object;
if(_tex_side) {
@ -59,5 +59,5 @@ function Node_3D_Mesh_Cube(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _group
return object;
} #endregion
static getPreviewValues = function() { return array_safe_get(all_inputs, input_mesh_index + 1, noone); }
static getPreviewValues = function() { return array_safe_get(all_inputs, in_mesh + 1, noone); }
}

View file

@ -66,7 +66,7 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
selection_mx = 0;
selection_my = 0;
tool_channel_edit = new checkBoxGroup(THEME.tools_canvas_channel, function(ind, val) { tool_attribute.channel[ind] = val; });
tool_channel_edit = new checkBoxGroup(THEME.tools_canvas_channel, function(ind, val) { tool_attribute.channel[ind] = val; });
tool_attribute.channel = [ true, true, true, true ];
tool_settings = [
[ "Channel", tool_channel_edit, "channel", tool_attribute ],

View file

@ -371,7 +371,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
if(hasInspector1Update()) {
var trig = inspectInput1.getValue();
if(trig) {
inspectInput1.editWidget.onClick();
onInspector1Update();
inspectInput1.setValue(false);
}
}
@ -379,7 +379,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
if(hasInspector2Update()) {
var trig = inspectInput2.getValue();
if(trig) {
inspectInput2.editWidget.onClick();
onInspector2Update();
inspectInput2.setValue(false);
}
}
@ -1277,6 +1277,8 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
static getTool = function() { return self; }
static getToolSettings = function() { return tool_settings; }
static setTool = function(tool) { #region
if(!tool) {
isTool = false;

View file

@ -1,30 +1,33 @@
enum CURVE_TYPE {
none,
linear,
bezier,
cut,
}
function valueKey(_time, _value, _anim = noone, _in = 0, _ot = 0) constructor {
time = _time;
ratio = time / (PROJECT.animator.frames_total - 1);
value = _value;
anim = _anim;
#region ---- main ----
time = _time;
ratio = time / (PROJECT.animator.frames_total - 1);
value = _value;
anim = _anim;
ease_y_lock = true;
ease_in = is_array(_in)? _in : [_in, 1];
ease_out = is_array(_ot)? _ot : [_ot, 0];
ease_y_lock = true;
ease_in = is_array(_in)? _in : [_in, 1];
ease_out = is_array(_ot)? _ot : [_ot, 0];
var _int = anim? anim.prop.key_inter : CURVE_TYPE.linear;
ease_in_type = _int;
ease_out_type = _int;
ease_in_type = CURVE_TYPE.none;
ease_out_type = CURVE_TYPE.none;
dopesheet_x = 0;
#endregion
dopesheet_x = 0;
static setTime = function(time) {
static setTime = function(time) { #region
self.time = time;
ratio = time / (PROJECT.animator.frames_total - 1);
}
} #endregion
static clone = function(target = noone) {
static clone = function(target = noone) { #region
var key = new valueKey(time, value, target);
key.ease_in = ease_in;
key.ease_out = ease_out;
@ -32,9 +35,9 @@ function valueKey(_time, _value, _anim = noone, _in = 0, _ot = 0) constructor {
key.ease_out_type = ease_out_type;
return key;
}
} #endregion
static cloneAnimator = function(shift = 0, anim = noone, removeDup = true) {
static cloneAnimator = function(shift = 0, anim = noone, removeDup = true) { #region
if(anim != noone) { //check value compat between animator
if(value_bit(self.anim.prop.type) & value_bit(anim.prop.type) == 0) {
noti_warning("Type incompatible");
@ -58,26 +61,28 @@ function valueKey(_time, _value, _anim = noone, _in = 0, _ot = 0) constructor {
anim.setKeyTime(key, time + shift, removeDup);
return key;
}
} #endregion
}
function valueAnimator(_val, _prop, _sep_axis = false) constructor {
suffix = "";
values = ds_list_create();
sep_axis = _sep_axis;
if(_prop.type != VALUE_TYPE.trigger)
ds_list_add(values, new valueKey(0, _val, self));
//print(_prop.name + ": " + string(_val));
#region ---- main ----
suffix = "";
values = ds_list_create();
sep_axis = _sep_axis;
index = 0;
prop = _prop;
dopesheet_y = 0;
if(_prop.type != VALUE_TYPE.trigger)
ds_list_add(values, new valueKey(0, _val, self));
#endregion
index = 0;
prop = _prop;
dopesheet_y = 0;
static interpolate = function(from, to, rat) {
static interpolate = function(from, to, rat) { #region
if(prop.type == VALUE_TYPE.boolean)
return 0;
if(to.ease_in_type == CURVE_TYPE.none && from.ease_out_type == CURVE_TYPE.none)
if(to.ease_in_type == CURVE_TYPE.linear && from.ease_out_type == CURVE_TYPE.linear)
return rat;
if(to.ease_in_type == CURVE_TYPE.cut)
return 0;
@ -93,9 +98,9 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor {
var bz = [0, eox, eoy, 1. - eix, eiy, 1];
return eval_curve_segment_x(bz, rat);
}
} #endregion
static lerpValue = function(from, to, _lrp) {
static lerpValue = function(from, to, _lrp) { #region
var _f = from.value;
var _t = to.value;
@ -138,11 +143,11 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor {
return processType(_f);
return processType(lerp(_f, _t, _lrp));
}
} #endregion
static getName = function() { return prop.name + suffix; }
static getValue = function(_time = PROJECT.animator.current_frame) {
static getValue = function(_time = PROJECT.animator.current_frame) { #region
if(prop.type == VALUE_TYPE.trigger) {
if(ds_list_size(values) == 0)
return false;
@ -239,14 +244,14 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor {
}
return processType(values[| ds_list_size(values) - 1].value); //Last frame
}
} #endregion
static processTypeDefault = function() {
static processTypeDefault = function() { #region
if(!sep_axis && typeArray(prop.display_type)) return [];
return 0;
}
static processType = function(_val) {
} #endregion
static processType = function(_val) { #region
if(!sep_axis && typeArray(prop.display_type) && is_array(_val)) {
for(var i = 0; i < array_length(_val); i++)
_val[i] = processValue(_val[i]);
@ -254,9 +259,9 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor {
return _val;
}
return processValue(_val);
}
} #endregion
static processValue = function(_val) {
static processValue = function(_val) { #region
if(is_array(_val)) return _val;
if(is_struct(_val)) return _val;
if(is_undefined(_val)) return 0;
@ -275,9 +280,9 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor {
}
return _val;
}
} #endregion
static setKeyTime = function(_key, _time, _replace = true) {
static setKeyTime = function(_key, _time, _replace = true) { #region
if(!ds_list_exist(values, _key)) return 0;
if(!LOADING) PROJECT.modified = true;
@ -303,9 +308,9 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor {
ds_list_add(values, _key);
return 1;
}
} #endregion
static setValue = function(_val = 0, _record = true, _time = PROJECT.animator.current_frame, ease_in = 0, ease_out = 0) {
static setValue = function(_val = 0, _record = true, _time = PROJECT.animator.current_frame, ease_in = 0, ease_out = 0) { #region
if(prop.type == VALUE_TYPE.trigger) {
if(!prop.is_anim) {
values[| 0] = new valueKey(0, _val, self);
@ -370,16 +375,16 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor {
if(_record) recordAction(ACTION_TYPE.list_insert, values, [ k, ds_list_size(values), "add " + string(prop.name) + " keyframe" ]);
ds_list_add(values, k);
return true;
}
} #endregion
static removeKey = function(key) {
static removeKey = function(key) { #region
if(ds_list_size(values) > 1)
ds_list_remove(values, key);
else
prop.is_anim = false;
}
} #endregion
static serialize = function(scale = false) {
static serialize = function(scale = false) { #region
var _data = [];
for(var i = 0; i < ds_list_size(values); i++) {
@ -417,9 +422,9 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor {
}
return _data;
}
} #endregion
static deserialize = function(_data, scale = false) {
static deserialize = function(_data, scale = false) { #region
ds_list_clear(values);
if(prop.type == VALUE_TYPE.gradient && PROJECT.version < 1340 && !CLONING) { //backward compat: Gradient
@ -482,9 +487,9 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor {
vk.ease_y_lock = ease_y_lock;
ds_list_add(values, vk);
}
}
} #endregion
static cleanUp = function() {
static cleanUp = function() { #region
ds_list_destroy(values);
}
} #endregion
}

View file

@ -64,7 +64,8 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct
}
static preProcess = function(outIndex) {
var _out = outputs[| outIndex].getValue();
var _out = outputs[| outIndex].getValue();
all_inputs = array_create(ds_list_size(inputs));
if(process_amount == 0) { #region render single data
if(outputs[| outIndex].type == VALUE_TYPE.d3object) //passing 3D vertex call
@ -101,6 +102,7 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct
return inputs_data[0]
}
all_inputs = inputs_data;
var data = processData(_out, inputs_data, outIndex, 0); /// Process data
return data;
} #endregion
@ -117,7 +119,6 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct
array_resize(_out, process_amount);
var _data = array_create(ds_list_size(inputs));
all_inputs = array_create(ds_list_size(inputs));
for(var i = 0; i < ds_list_size(inputs); i++)
all_inputs[i] = array_create(process_amount);

View file

@ -103,6 +103,8 @@ function Node_Render_Sprite_Sheet(_x, _y, _group = noone) : Node(_x, _y, _group)
amo = _ed - _st;
for(var i = 0; i < array_length(inpt); i++) {
_atl[i] = [];
if(!is_surface(inpt[i])) continue;
var sw = surface_get_width(inpt[i]);
var sh = surface_get_height(inpt[i]);
@ -133,8 +135,6 @@ function Node_Render_Sprite_Sheet(_x, _y, _group = noone) : Node(_x, _y, _group)
surface_reset_target();
refreshSurface = true;
_atl[i] = [];
}
if(!arr) _surf = array_safe_get(_surf, 0);

View file

@ -35,7 +35,7 @@ function Node_Trigger_Bool(_x, _y, _group = noone) : Node(_x, _y, _group) constr
switch(con) {
case 0 : doTrigger = val; break;
case 1 : doTrigger = !prevVal && val; break;
case 2 : doTrigger = prevVal && !val; break;
case 2 : doTrigger = prevVal && !val; break;
case 3 : doTrigger = prevVal != val; break;
}

File diff suppressed because it is too large Load diff

View file

@ -264,7 +264,7 @@ function Panel_Animation() : PanelContent() constructor {
[ [THEME.timeline_ease, 0], function() {
for( var i = 0, n = array_length(keyframe_selecting); i < n; i++ ) {
var k = keyframe_selecting[i];
k.ease_in_type = CURVE_TYPE.none;
k.ease_in_type = CURVE_TYPE.linear;
k.ease_in = [0, 1];
}
}, __txtx("panel_animation_ease_linear", "Linear") ],
@ -301,7 +301,7 @@ function Panel_Animation() : PanelContent() constructor {
[ [THEME.timeline_ease, 0], function() {
for( var i = 0, n = array_length(keyframe_selecting); i < n; i++ ) {
var k = keyframe_selecting[i];
k.ease_out_type = CURVE_TYPE.none;
k.ease_out_type = CURVE_TYPE.linear;
k.ease_out = [0, 0];
}
}, __txtx("panel_animation_ease_linear", "Linear") ],
@ -637,7 +637,7 @@ function Panel_Animation() : PanelContent() constructor {
var key_next = animator.values[| k + 1];
var dx = key_next.time - key.time;
if(key.ease_out_type == CURVE_TYPE.none && key_next.ease_in_type == CURVE_TYPE.none) { //linear draw
if(key.ease_out_type == CURVE_TYPE.linear && key_next.ease_in_type == CURVE_TYPE.linear) { //linear draw
nx = (key_next.time + 1) * ui(timeline_scale) + timeline_shift;
if(valArray) {
for( var ki = 0; ki < array_length(key.value); ki++ ) {
@ -1011,7 +1011,7 @@ function Panel_Animation() : PanelContent() constructor {
tx = tool_width - ui(20 + 16 * 4.5);
if(pHOVER && point_in_circle(msx, msy, tx, ty, ui(6))) {
draw_sprite_ui_uniform(THEME.prop_on_end, animator.prop.on_end, tx, ty, 1, COLORS._main_icon_on_inner, 1);
TOOLTIP = __txtx("panel_animation_looping_mode", "Looping mode") + ": " + ON_END_NAME[animator.prop.on_end];
TOOLTIP = __txtx("panel_animation_looping_mode", "Looping mode") + ": " + global.junctionEndName[animator.prop.on_end];
if(mouse_release(mb_left, pFOCUS))
animator.prop.on_end = safe_mod(animator.prop.on_end + 1, sprite_get_number(THEME.prop_on_end));
@ -1099,7 +1099,7 @@ function Panel_Animation() : PanelContent() constructor {
draw_sprite_ui_uniform(THEME.arrow, _node.anim_show? 3 : 0, ui(10), _node_y, 1, COLORS._main_icon, 0.75);
draw_set_font(f_p3);
var nodeName = "[" + _node.name + "] ";
var nodeName = $"[{_node.name}] ";
var tw = string_width(nodeName);
draw_set_color(node_ordering == _node? COLORS._main_text_accent : COLORS._main_text);
@ -1199,7 +1199,8 @@ function Panel_Animation() : PanelContent() constructor {
var s_bar_y = scr_y + scr_prog_s;
if(is_scrolling) {
dope_sheet_y_to = clamp((my - scr_y - scr_scale_s / 2) / (scr_s - scr_scale_s), 0, 1) * -dope_sheet_y_max;
if(scr_s - scr_scale_s != 0)
dope_sheet_y_to = clamp((my - scr_y - scr_scale_s / 2) / (scr_s - scr_scale_s), 0, 1) * -dope_sheet_y_max;
if(mouse_release(mb_left)) is_scrolling = false;
}
@ -1399,7 +1400,7 @@ function Panel_Animation() : PanelContent() constructor {
case KEYFRAME_DRAG_TYPE.ease_in :
for( var i = 0, n = array_length(keyframe_selecting); i < n; i++ ) {
var k = keyframe_selecting[i];
k.ease_in_type = keyframe_dragout? CURVE_TYPE.bezier : CURVE_TYPE.none;
k.ease_in_type = keyframe_dragout? CURVE_TYPE.bezier : CURVE_TYPE.linear;
k.ease_in[0] = dx;
if(!k.ease_y_lock)
@ -1410,7 +1411,7 @@ function Panel_Animation() : PanelContent() constructor {
case KEYFRAME_DRAG_TYPE.ease_out :
for( var i = 0, n = array_length(keyframe_selecting); i < n; i++ ) {
var k = keyframe_selecting[i];
k.ease_out_type = keyframe_dragout? CURVE_TYPE.bezier : CURVE_TYPE.none;
k.ease_out_type = keyframe_dragout? CURVE_TYPE.bezier : CURVE_TYPE.linear;
k.ease_out[0] = dx;
if(!k.ease_y_lock)
@ -1420,8 +1421,8 @@ function Panel_Animation() : PanelContent() constructor {
case KEYFRAME_DRAG_TYPE.ease_both :
for( var i = 0, n = array_length(keyframe_selecting); i < n; i++ ) {
var k = keyframe_selecting[i];
k.ease_in_type = keyframe_dragout? CURVE_TYPE.bezier : CURVE_TYPE.none;
k.ease_out_type = keyframe_dragout? CURVE_TYPE.bezier : CURVE_TYPE.none;
k.ease_in_type = keyframe_dragout? CURVE_TYPE.bezier : CURVE_TYPE.linear;
k.ease_out_type = keyframe_dragout? CURVE_TYPE.bezier : CURVE_TYPE.linear;
k.ease_in[0] = dx;
if(!k.ease_y_lock)

View file

@ -17,7 +17,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
show_dimension : true,
show_compute : true,
avoid_label : false,
avoid_label : true,
preview_scale : 100,
}
#endregion

View file

@ -72,7 +72,7 @@ function Panel_Preview() : PanelContent() constructor {
tileMode = 0;
bg_color = COLORS.panel_3d_bg;
bg_color = COLORS.panel_bg_clear;
#endregion
#region ---- tool ----
@ -877,7 +877,7 @@ function Panel_Preview() : PanelContent() constructor {
}
preview_x_max = 0;
var _xx = (_node.tools != -1) * ui(40);
var _xx = tool_side_drawing * ui(40);
var xx = _xx + preview_x + ui(8);
var yy = h - toolbar_height - prev_size - ui(8);
if(my > yy) mouse_on_preview = false;
@ -979,84 +979,88 @@ function Panel_Preview() : PanelContent() constructor {
var _tool = tool_hovering;
tool_hovering = noone;
if(_node.tools != -1) {
var aa = d3_active? 0.5 : 1;
draw_sprite_stretched_ext(THEME.tool_side, 1, 0, ui(32), tool_width, h - toolbar_height - ui(32), c_white, aa);
if(_node.tools == -1) {
tool_current = noone;
return;
}
var aa = d3_active? 0.5 : 1;
draw_sprite_stretched_ext(THEME.tool_side, 1, 0, ui(32), tool_width, h - toolbar_height - ui(32), c_white, aa);
var xx = ui(1) + tool_width / 2;
var yy = ui(34) + tool_size / 2;
var pd = 2;
var xx = ui(1) + tool_width / 2;
var yy = ui(34) + tool_size / 2;
var pd = 2;
for(var i = 0; i < array_length(_node.tools); i++) {
var tool = _node.tools[i];
var _x0 = xx - tool_size / 2;
var _y0 = yy - tool_size / 2;
var _x1 = xx + tool_size / 2;
var _y1 = yy + tool_size / 2;
for(var i = 0; i < array_length(_node.tools); i++) { #region iterate each tools
var tool = _node.tools[i];
var _x0 = xx - tool_size / 2;
var _y0 = yy - tool_size / 2;
var _x1 = xx + tool_size / 2;
var _y1 = yy + tool_size / 2;
if(point_in_rectangle(_mx, _my, _x0, _y0 + 1, _x1, _y1 - 1)) {
tool_hovering = tool;
}
if(point_in_rectangle(_mx, _my, _x0, _y0 + 1, _x1, _y1 - 1)) {
tool_hovering = tool;
}
if(tool.subtools > 0 && _tool == tool) {
var s_ww = tool_size * tool.subtools;
var s_hh = tool_size;
draw_sprite_stretched(THEME.menu_bg, 0, _x0 - pd, _y0 - pd, s_ww + pd * 2, s_hh + pd * 2);
if(tool.subtools > 0 && _tool == tool) { #region subtools
var s_ww = tool_size * tool.subtools;
var s_hh = tool_size;
draw_sprite_stretched(THEME.menu_bg, 0, _x0 - pd, _y0 - pd, s_ww + pd * 2, s_hh + pd * 2);
var stool = tool.spr;
var stool = tool.spr;
for( var j = 0; j < array_length(stool); j++ ) {
var _sxx = xx + j * tool_size;
var _syy = yy;
for( var j = 0; j < array_length(stool); j++ ) {
var _sxx = xx + j * tool_size;
var _syy = yy;
var _sx0 = _sxx - tool_size / 2;
var _sy0 = _syy - tool_size / 2;
var _sx1 = _sxx + tool_size / 2;
var _sy1 = _syy + tool_size / 2;
var _sx0 = _sxx - tool_size / 2;
var _sy0 = _syy - tool_size / 2;
var _sx1 = _sxx + tool_size / 2;
var _sy1 = _syy + tool_size / 2;
if(point_in_rectangle(_mx, _my, _sx0, _sy0 + 1, _sx1, _sy1 - 1)) {
TOOLTIP = tool.getName(j);
draw_sprite_stretched(THEME.button_hide, 1, _sx0 + pd, _sy0 + pd, tool_size - pd * 2, tool_size - pd * 2);
if(point_in_rectangle(_mx, _my, _sx0, _sy0 + 1, _sx1, _sy1 - 1)) {
TOOLTIP = tool.getName(j);
draw_sprite_stretched(THEME.button_hide, 1, _sx0 + pd, _sy0 + pd, tool_size - pd * 2, tool_size - pd * 2);
if(mouse_press(mb_left, pFOCUS))
tool.toggle(j);
}
if(tool_current == tool && tool.selecting == j) {
draw_sprite_stretched_ext(THEME.button_hide, 2, _sx0 + pd, _sy0 + pd, tool_size - pd * 2, tool_size - pd * 2, COLORS.panel_preview_grid, 1);
draw_sprite_stretched_ext(THEME.button_hide, 3, _sx0 + pd, _sy0 + pd, tool_size - pd * 2, tool_size - pd * 2, COLORS._main_accent, 1);
}
draw_sprite_colored(stool[j], 0, _sxx, _syy);
}
if(point_in_rectangle(_mx, _my, _x0, _y0 + 1, _x0 + s_ww, _y1 - 1))
tool_hovering = tool;
} else {
if(tool_hovering == tool) {
draw_sprite_stretched(THEME.button_hide, 1, _x0 + pd, _y0 + pd, tool_size - pd * 2, tool_size - pd * 2);
TOOLTIP = tool.getName();
if(mouse_press(mb_left, pFOCUS))
tool.toggle();
tool.toggle(j);
}
if(tool_current == tool && tool.selecting == j) {
draw_sprite_stretched_ext(THEME.button_hide, 2, _sx0 + pd, _sy0 + pd, tool_size - pd * 2, tool_size - pd * 2, COLORS.panel_preview_grid, 1);
draw_sprite_stretched_ext(THEME.button_hide, 3, _sx0 + pd, _sy0 + pd, tool_size - pd * 2, tool_size - pd * 2, COLORS._main_accent, 1);
}
if(pFOCUS && WIDGET_CURRENT == noone && keyboard_check_pressed(ord(string(i + 1))))
draw_sprite_colored(stool[j], 0, _sxx, _syy);
}
if(point_in_rectangle(_mx, _my, _x0, _y0 + 1, _x0 + s_ww, _y1 - 1))
tool_hovering = tool;
#endregion
} else { #region single tools
if(tool_hovering == tool) {
draw_sprite_stretched(THEME.button_hide, 1, _x0 + pd, _y0 + pd, tool_size - pd * 2, tool_size - pd * 2);
TOOLTIP = tool.getName();
if(mouse_press(mb_left, pFOCUS))
tool.toggle();
}
if(pFOCUS && WIDGET_CURRENT == noone && keyboard_check_pressed(ord(string(i + 1))))
tool.toggle();
if(tool_current == tool) {
draw_sprite_stretched_ext(THEME.button_hide, 2, _x0 + pd, _y0 + pd, tool_size - pd * 2, tool_size - pd * 2, COLORS.panel_preview_grid, 1);
draw_sprite_stretched_ext(THEME.button_hide, 3, _x0 + pd, _y0 + pd, tool_size - pd * 2, tool_size - pd * 2, COLORS._main_accent, 1);
}
if(tool.subtools > 0) draw_sprite_colored(tool.spr[tool.selecting], 0, xx, yy);
else draw_sprite_colored(tool.spr, 0, xx, yy);
if(tool_current == tool) {
draw_sprite_stretched_ext(THEME.button_hide, 2, _x0 + pd, _y0 + pd, tool_size - pd * 2, tool_size - pd * 2, COLORS.panel_preview_grid, 1);
draw_sprite_stretched_ext(THEME.button_hide, 3, _x0 + pd, _y0 + pd, tool_size - pd * 2, tool_size - pd * 2, COLORS._main_accent, 1);
}
yy += tool_size;
if(tool.subtools > 0) draw_sprite_colored(tool.spr[tool.selecting], 0, xx, yy);
else draw_sprite_colored(tool.spr, 0, xx, yy);
#endregion
}
} else
tool_current = noone;
yy += tool_size;
} #endregion
} #endregion
function drawToolBar(_node) { #region
@ -1072,8 +1076,8 @@ function Panel_Preview() : PanelContent() constructor {
if(!_node) return;
if(tool_current != noone) { //tool settings
var settings = _node.tool_settings;
if(tool_current != noone) { #region tool settings
var settings = _node.getToolSettings();
var len = array_length(settings);
for( var i = 0, n = array_length(tool_current.settings); i < n; i++ )
settings[len + i] = tool_current.settings[i];
@ -1098,20 +1102,16 @@ function Panel_Preview() : PanelContent() constructor {
tol_max_w += string_width(nme) + ui(8);
wdg.setFocusHover(pFOCUS, pHOVER);
switch(instanceof(wdg)) {
case "textBox" :
wdg.draw(tolx, toly, tolw, tolh, atr[$ key], [ mx, my ]);
break;
case "checkBoxGroup" :
tolw = tolh * wdg.size;
wdg.draw(tolx, toly, atr[$ key], [ mx, my ], tolh);
break;
case "checkBox" :
tolw = tolh;
wdg.draw(tolx, toly, atr[$ key], [ mx, my ], tolh);
break;
case "checkBoxGroup" : tolw = tolh * wdg.size; break;
case "checkBox" : tolw = tolh; break;
case "scrollBox" : tolw = ui(96); break;
}
var params = new widgetParam(tolx, toly, tolw, tolh, atr[$ key],, [ mx, my ])
wdg.drawParam(params);
tolx += tolw + ui(16);
tol_max_w += tolw + ui(16);
}
@ -1121,7 +1121,8 @@ 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
#endregion
} else { #region color sampler
var cx = ui(10);
var cy = ui(10);
var cw = ui(32);
@ -1145,6 +1146,7 @@ function Panel_Preview() : PanelContent() constructor {
draw_set_color(COLORS._main_text_sub);
draw_text(tx, cy + ch / 2, "(" + string(color_get_alpha(sample_color)) + ")");
}
#endregion
}
var tbx = toolbar_height / 2;

View file

@ -5,6 +5,10 @@ function scrollBox(_data, _onModify, update_hover = true) : widget() constructor
data = [];
curr_text = 0;
font = f_p0;
arrow_spr = THEME.scroll_box_arrow;
arrow_ind = 0;
open = false;
open_rx = 0;
open_ry = 0;
@ -78,15 +82,17 @@ function scrollBox(_data, _onModify, update_hover = true) : widget() constructor
if(mouse_press(mb_left)) deactivate();
}
draw_set_text(f_p0, align, fa_center, COLORS._main_text);
var _arw = sprite_get_width(arrow_spr) + ui(8);
draw_set_text(font, align, fa_center, COLORS._main_text);
draw_set_alpha(0.5 + 0.5 * interactable);
if(align == fa_center)
draw_text(_x + w / 2, _y + _h / 2 - ui(2), _text);
draw_text(_x + (w - _arw) / 2, _y + _h / 2 - ui(2), _text);
else if(align == fa_left)
draw_text(_x + ui(8), _y + _h / 2 - ui(2), _text);
draw_set_alpha(1);
draw_sprite_ui_uniform(THEME.scroll_box_arrow, 0, _x + w - 20, _y + _h / 2, 1, COLORS._main_icon, 0.5 + 0.5 * interactable);
draw_sprite_ui_uniform(arrow_spr, arrow_ind, _x + w - _arw / 2, _y + _h / 2, 1, COLORS._main_icon, 0.5 + 0.5 * interactable);
if(WIDGET_CURRENT == self)
draw_sprite_stretched_ext(THEME.widget_selecting, 0, _x - ui(3), _y - ui(3), _w + ui(6), _h + ui(6), COLORS._main_accent, 1);