mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-11-10 20:45:35 +01:00
sdf control gizmo
This commit is contained in:
parent
c9f3b8d46e
commit
af9235f4ba
@ -180,7 +180,8 @@ function Node_RM_Primitive(_x, _y, _group = noone) : Node_RM(_x, _y, _group) con
|
|||||||
drag_axis = noone;
|
drag_axis = noone;
|
||||||
drag_sv = 0;
|
drag_sv = 0;
|
||||||
drag_delta = 0;
|
drag_delta = 0;
|
||||||
drag_prev = 0;
|
drag_pre0 = 0;
|
||||||
|
drag_pre1 = 0;
|
||||||
drag_dist = 0;
|
drag_dist = 0;
|
||||||
drag_val = 0;
|
drag_val = 0;
|
||||||
|
|
||||||
@ -200,6 +201,7 @@ function Node_RM_Primitive(_x, _y, _group = noone) : Node_RM(_x, _y, _group) con
|
|||||||
static drawGizmoPosition = function(index, _vpos, active, params, _mx, _my, _snx, _sny, _panel) { #region
|
static drawGizmoPosition = function(index, _vpos, active, params, _mx, _my, _snx, _sny, _panel) { #region
|
||||||
#region ---- main ----
|
#region ---- main ----
|
||||||
var _pos = inputs[| index].getValue(,,, true);
|
var _pos = inputs[| index].getValue(,,, true);
|
||||||
|
// _pos = [ -_pos[0], _pos[2], -_pos[1] ];
|
||||||
var _qinv = new BBMOD_Quaternion().FromAxisAngle(new BBMOD_Vec3(1, 0, 0), 90);
|
var _qinv = new BBMOD_Quaternion().FromAxisAngle(new BBMOD_Vec3(1, 0, 0), 90);
|
||||||
|
|
||||||
var _camera = params.camera;
|
var _camera = params.camera;
|
||||||
@ -275,45 +277,45 @@ function Node_RM_Primitive(_x, _y, _group = noone) : Node_RM(_x, _y, _group) con
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for( var i = 3; i < 6; i++ ) {
|
// for( var i = 3; i < 6; i++ ) {
|
||||||
for( var j = 0; j < 4; j++ )
|
// for( var j = 0; j < 4; j++ )
|
||||||
ga[i][j] = _qview.Rotate(_qinv.Rotate(ga[i][j]));
|
// ga[i][j] = _qview.Rotate(_qinv.Rotate(ga[i][j]));
|
||||||
|
|
||||||
th = 1;
|
// th = 1;
|
||||||
|
|
||||||
var p0x = cx + ga[i][0].X, p0y = cy + ga[i][0].Y;
|
// var p0x = cx + ga[i][0].X, p0y = cy + ga[i][0].Y;
|
||||||
var p1x = cx + ga[i][1].X, p1y = cy + ga[i][1].Y;
|
// var p1x = cx + ga[i][1].X, p1y = cy + ga[i][1].Y;
|
||||||
var p2x = cx + ga[i][2].X, p2y = cy + ga[i][2].Y;
|
// var p2x = cx + ga[i][2].X, p2y = cy + ga[i][2].Y;
|
||||||
var p3x = cx + ga[i][3].X, p3y = cy + ga[i][3].Y;
|
// var p3x = cx + ga[i][3].X, p3y = cy + ga[i][3].Y;
|
||||||
|
|
||||||
var _pax = (p0x + p1x + p2x + p3x) / 4;
|
// var _pax = (p0x + p1x + p2x + p3x) / 4;
|
||||||
var _pay = (p0y + p1y + p2y + p3y) / 4;
|
// var _pay = (p0y + p1y + p2y + p3y) / 4;
|
||||||
|
|
||||||
if((abs(p0x - _pax) + abs(p1x - _pax) + abs(p2x - _pax) + abs(p3x - _pax)) / 4 < 1)
|
// if((abs(p0x - _pax) + abs(p1x - _pax) + abs(p2x - _pax) + abs(p3x - _pax)) / 4 < 1)
|
||||||
continue;
|
// continue;
|
||||||
if((abs(p0y - _pay) + abs(p1y - _pay) + abs(p2y - _pay) + abs(p3y - _pay)) / 4 < 1)
|
// if((abs(p0y - _pay) + abs(p1y - _pay) + abs(p2y - _pay) + abs(p3y - _pay)) / 4 < 1)
|
||||||
continue;
|
// continue;
|
||||||
|
|
||||||
draw_set_color(COLORS.axis[(i - 3 - 1 + 3) % 3]);
|
// draw_set_color(COLORS.axis[(i - 3 - 1 + 3) % 3]);
|
||||||
if(axis_hover == i || drag_axis == i) {
|
// if(axis_hover == i || drag_axis == i) {
|
||||||
draw_primitive_begin(pr_trianglestrip);
|
// draw_primitive_begin(pr_trianglestrip);
|
||||||
draw_vertex(p0x, p0y);
|
// draw_vertex(p0x, p0y);
|
||||||
draw_vertex(p1x, p1y);
|
// draw_vertex(p1x, p1y);
|
||||||
draw_vertex(p3x, p3y);
|
// draw_vertex(p3x, p3y);
|
||||||
draw_vertex(p2x, p2y);
|
// draw_vertex(p2x, p2y);
|
||||||
draw_primitive_end();
|
// draw_primitive_end();
|
||||||
|
|
||||||
} else if (drag_axis == noone) {
|
// } else if (drag_axis == noone) {
|
||||||
draw_line(p0x, p0y, p1x, p1y);
|
// draw_line(p0x, p0y, p1x, p1y);
|
||||||
draw_line(p1x, p1y, p2x, p2y);
|
// draw_line(p1x, p1y, p2x, p2y);
|
||||||
draw_line(p2x, p2y, p3x, p3y);
|
// draw_line(p2x, p2y, p3x, p3y);
|
||||||
draw_line(p3x, p3y, p0x, p0y);
|
// draw_line(p3x, p3y, p0x, p0y);
|
||||||
} else
|
// } else
|
||||||
continue;
|
// continue;
|
||||||
|
|
||||||
if(point_in_rectangle_points(_mx, _my, p0x, p0y, p1x, p1y, p3x, p3y, p2x, p2y))
|
// if(point_in_rectangle_points(_mx, _my, p0x, p0y, p1x, p1y, p3x, p3y, p2x, p2y))
|
||||||
_hover = i;
|
// _hover = i;
|
||||||
}
|
// }
|
||||||
|
|
||||||
axis_hover = _hover;
|
axis_hover = _hover;
|
||||||
#endregion display
|
#endregion display
|
||||||
@ -323,54 +325,36 @@ function Node_RM_Primitive(_x, _y, _group = noone) : Node_RM(_x, _y, _group) con
|
|||||||
drag_mx += _mx - drag_px;
|
drag_mx += _mx - drag_px;
|
||||||
drag_my += _my - drag_py;
|
drag_my += _my - drag_py;
|
||||||
|
|
||||||
var mAdj, nor, prj;
|
var mAdj, nor, prj, app;
|
||||||
|
|
||||||
var ray = _camera.viewPointToWorldRay(drag_mx, drag_my);
|
var ray = _camera.viewPointToWorldRay(drag_mx, drag_my);
|
||||||
var val = [ drag_val[0], drag_val[1], drag_val[2] ];
|
var val = [ drag_val[0], drag_val[1], drag_val[2] ];
|
||||||
|
|
||||||
if(drag_axis < 3) {
|
switch(drag_axis) {
|
||||||
switch(drag_axis) {
|
case 0 :
|
||||||
case 0 : nor = new __vec3(0, 1, 0); prj = new __vec3(1, 0, 0); break;
|
case 3 : nor = new __vec3(0, 1, 0); prj = new __vec3(1, 0, 0); app = 0; break;
|
||||||
case 1 : nor = new __vec3(0, 0, 1); prj = new __vec3(0, 1, 0); break;
|
case 1 :
|
||||||
case 2 : nor = new __vec3(1, 0, 0); prj = new __vec3(0, 0, 1); break;
|
case 4 : nor = new __vec3(0, 0, 1); prj = new __vec3(0, 1, 0); app = -2; break;
|
||||||
}
|
case 2 :
|
||||||
|
case 5 : nor = new __vec3(1, 0, 0); prj = new __vec3(0, 0, 1); app = 1; 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);
|
|
||||||
var _dist = _diff.dot(prj);
|
|
||||||
|
|
||||||
for( var i = 0; i < 3; i++ )
|
|
||||||
val[i] += prj.getIndex(i) * _dist;
|
|
||||||
|
|
||||||
if(inputs[| index].setValue(value_snap(val, _snx)))
|
|
||||||
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);
|
|
||||||
|
|
||||||
for( var i = 0; i < 3; i++ )
|
|
||||||
val[i] += _diff.getIndex(i);
|
|
||||||
|
|
||||||
if(inputs[| index].setValue(value_snap(val, _snx)))
|
|
||||||
UNDO_HOLDING = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var pln = new __plane(drag_original, nor);
|
||||||
|
mAdj = d3d_intersect_ray_plane(ray, pln);
|
||||||
|
|
||||||
|
if(drag_pre0 != undefined) {
|
||||||
|
var _diff = mAdj.subtract(drag_pre0);
|
||||||
|
var _dist = _diff.dot(prj);
|
||||||
|
|
||||||
|
val[abs(app)] -= _dist * (app >= 0? 1 : -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
drag_pre0 = mAdj;
|
||||||
|
|
||||||
|
if(inputs[| index].setValue(value_snap(val, _snx)))
|
||||||
|
UNDO_HOLDING = true;
|
||||||
|
|
||||||
drag_val = [ val[0], val[1], val[2] ];
|
drag_val = [ val[0], val[1], val[2] ];
|
||||||
drag_prev = mAdj;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setMouseWrap();
|
setMouseWrap();
|
||||||
@ -380,7 +364,8 @@ function Node_RM_Primitive(_x, _y, _group = noone) : Node_RM(_x, _y, _group) con
|
|||||||
|
|
||||||
if(_hover != noone && mouse_press(mb_left, active)) { #region
|
if(_hover != noone && mouse_press(mb_left, active)) { #region
|
||||||
drag_axis = _hover;
|
drag_axis = _hover;
|
||||||
drag_prev = undefined;
|
drag_pre0 = undefined;
|
||||||
|
drag_pre1 = undefined;
|
||||||
drag_mx = _mx;
|
drag_mx = _mx;
|
||||||
drag_my = _my;
|
drag_my = _my;
|
||||||
drag_px = _mx;
|
drag_px = _mx;
|
||||||
@ -394,8 +379,9 @@ function Node_RM_Primitive(_x, _y, _group = noone) : Node_RM(_x, _y, _group) con
|
|||||||
} #endregion
|
} #endregion
|
||||||
|
|
||||||
static drawOverlay3D = function(active, params, _mx, _my, _snx, _sny, _panel) {
|
static drawOverlay3D = function(active, params, _mx, _my, _snx, _sny, _panel) {
|
||||||
var _pos = getSingleValue(2);
|
var _pos = getSingleValue(2);
|
||||||
var _vpos = new __vec3( _pos[0], _pos[1], _pos[2] );
|
var _camera = params.camera;
|
||||||
|
var _vpos = new __vec3( -_pos[0], _pos[2], -_pos[1] );
|
||||||
|
|
||||||
if(isUsingTool("Transform")) drawGizmoPosition(2, _vpos, active, params, _mx, _my, _snx, _sny, _panel);
|
if(isUsingTool("Transform")) drawGizmoPosition(2, _vpos, active, params, _mx, _my, _snx, _sny, _panel);
|
||||||
|
|
||||||
|
@ -1133,10 +1133,14 @@ function Panel_Preview() : PanelContent() constructor {
|
|||||||
function draw3DSdf(_node) { #region
|
function draw3DSdf(_node) { #region
|
||||||
_node.previewing = 1;
|
_node.previewing = 1;
|
||||||
|
|
||||||
|
var _env = _node.environ;
|
||||||
|
var _obj = _node.object;
|
||||||
|
|
||||||
d3_scene_preview = d3_scene;
|
d3_scene_preview = d3_scene;
|
||||||
d3_scene_preview.camera = d3_view_camera;
|
d3_scene_preview.camera = d3_view_camera;
|
||||||
|
|
||||||
#region view
|
#region view
|
||||||
|
d3_view_camera.fov = max(1, _env.fov * 1.23);
|
||||||
var _pos, targ, _blend = 1;
|
var _pos, targ, _blend = 1;
|
||||||
|
|
||||||
targ = d3_camTarget;
|
targ = d3_camTarget;
|
||||||
@ -1174,9 +1178,6 @@ function Panel_Preview() : PanelContent() constructor {
|
|||||||
d3_view_camera.setMatrix();
|
d3_view_camera.setMatrix();
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
var _env = _node.environ;
|
|
||||||
var _obj = _node.object;
|
|
||||||
|
|
||||||
draw_clear(bg_color);
|
draw_clear(bg_color);
|
||||||
|
|
||||||
gpu_set_texfilter(true);
|
gpu_set_texfilter(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user