diff --git a/PixelComposer.resource_order b/PixelComposer.resource_order index 362346679..80fe5aef0 100644 --- a/PixelComposer.resource_order +++ b/PixelComposer.resource_order @@ -405,6 +405,7 @@ {"name":"d3d_cube","order":1,"path":"scripts/d3d_cube/d3d_cube.yy",}, {"name":"d3d_cylinder_nocaps","order":9,"path":"scripts/d3d_cylinder_nocaps/d3d_cylinder_nocaps.yy",}, {"name":"d3d_cylinder","order":2,"path":"scripts/d3d_cylinder/d3d_cylinder.yy",}, + {"name":"d3d_gizmo_axis","order":7,"path":"scripts/d3d_gizmo_axis/d3d_gizmo_axis.yy",}, {"name":"d3d_gizmo_circle_z","order":4,"path":"scripts/d3d_gizmo_circle_z/d3d_gizmo_circle_z.yy",}, {"name":"d3d_gizmo_line_dashed","order":3,"path":"scripts/d3d_gizmo_line_dashed/d3d_gizmo_line_dashed.yy",}, {"name":"d3d_gizmo_line","order":1,"path":"scripts/d3d_gizmo_line/d3d_gizmo_line.yy",}, diff --git a/PixelComposer.yyp b/PixelComposer.yyp index dbc030e36..12417286a 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -767,6 +767,7 @@ {"id":{"name":"d3d_cube","path":"scripts/d3d_cube/d3d_cube.yy",},}, {"id":{"name":"d3d_cylinder_nocaps","path":"scripts/d3d_cylinder_nocaps/d3d_cylinder_nocaps.yy",},}, {"id":{"name":"d3d_cylinder","path":"scripts/d3d_cylinder/d3d_cylinder.yy",},}, + {"id":{"name":"d3d_gizmo_axis","path":"scripts/d3d_gizmo_axis/d3d_gizmo_axis.yy",},}, {"id":{"name":"d3d_gizmo_circle_z","path":"scripts/d3d_gizmo_circle_z/d3d_gizmo_circle_z.yy",},}, {"id":{"name":"d3d_gizmo_line_dashed","path":"scripts/d3d_gizmo_line_dashed/d3d_gizmo_line_dashed.yy",},}, {"id":{"name":"d3d_gizmo_line","path":"scripts/d3d_gizmo_line/d3d_gizmo_line.yy",},}, diff --git a/datafiles/data/Theme.zip b/datafiles/data/Theme.zip index 1bd648088..80bcc3892 100644 Binary files a/datafiles/data/Theme.zip and b/datafiles/data/Theme.zip differ diff --git a/scripts/__node_3d_object/__node_3d_object.gml b/scripts/__node_3d_object/__node_3d_object.gml index b87dbe7d4..dc58b0c69 100644 --- a/scripts/__node_3d_object/__node_3d_object.gml +++ b/scripts/__node_3d_object/__node_3d_object.gml @@ -1,12 +1,15 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constructor { name = "3D Object"; + gizmo = new __3dGizmoAxis(.2, COLORS._main_accent); + cached_object = []; object_class = noone; preview_channel = 0; + apply_anchor = false; inputs[| 0] = nodeValue("Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0, 0 ]) - .setDisplay(VALUE_DISPLAY.vector); + .setDisplay(VALUE_DISPLAY.vector, { linkable: false }); inputs[| 1] = nodeValue("Rotation", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0, 0, 1 ]) .setDisplay(VALUE_DISPLAY.d3quarternion); @@ -15,7 +18,12 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr .setDisplay(VALUE_DISPLAY.vector); inputs[| 3] = nodeValue("Anchor", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0, 0 ]) - .setDisplay(VALUE_DISPLAY.vector); + .setDisplay(VALUE_DISPLAY.vector, { + linkable: false, + side_button : button(function() { apply_anchor = !apply_anchor; triggerRender(); }) + .setIcon(THEME.icon_3d_anchor, [ function() /*=>*/ {return apply_anchor} ], c_white) + .setTooltip("Apply Position") + }); in_d3d = ds_list_size(inputs); @@ -616,6 +624,15 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr var _sca = _data[2]; var _anc = _data[3]; + if(apply_anchor) + _pos = [ + _pos[0] + _anc[0], + _pos[1] + _anc[1], + _pos[2] + _anc[2], + ]; + + gizmo.transform.position.set( _pos[0], _pos[1], _pos[2]); + object.transform.position.set( _pos[0], _pos[1], _pos[2]); object.transform.anchor.set( _anc[0], _anc[1], _anc[2]); object.transform.rotation.set( _rot[0], _rot[1], _rot[2], _rot[3]); @@ -626,6 +643,7 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr static getObject = function(index, class = object_class) { #region var _obj = array_safe_get_fast(cached_object, index, noone); + if(_obj == noone) { _obj = new class(); } else if(!is_instanceof(_obj, class)) { @@ -636,4 +654,8 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr cached_object[index] = _obj; return _obj; } #endregion + + static getPreviewObjects = function() { return [ getPreviewObject(), gizmo ]; } + static getPreviewObjectOutline = function() { return [ getPreviewObject(), gizmo ]; } + } \ No newline at end of file diff --git a/scripts/d3d_gizmo_axis/d3d_gizmo_axis.gml b/scripts/d3d_gizmo_axis/d3d_gizmo_axis.gml new file mode 100644 index 000000000..327da8939 --- /dev/null +++ b/scripts/d3d_gizmo_axis/d3d_gizmo_axis.gml @@ -0,0 +1,18 @@ +function __3dGizmoAxis(_size = .5, color = c_white, alpha = 1) : __3dGizmo() constructor { + vertex = [ + [ + new __vertex( -_size, 0, 0, color, alpha ), + new __vertex( _size, 0, 0, color, alpha ), + ], + [ + new __vertex( 0, -_size, 0, color, alpha ), + new __vertex( 0, _size, 0, color, alpha ), + ], + [ + new __vertex( 0, 0, -_size, color, alpha ), + new __vertex( 0, 0, _size, color, alpha ), + ], + ]; + object_counts = 3; + VB = build(); +} \ No newline at end of file diff --git a/scripts/d3d_gizmo_axis/d3d_gizmo_axis.yy b/scripts/d3d_gizmo_axis/d3d_gizmo_axis.yy new file mode 100644 index 000000000..2e974d658 --- /dev/null +++ b/scripts/d3d_gizmo_axis/d3d_gizmo_axis.yy @@ -0,0 +1,13 @@ +{ + "$GMScript":"", + "%Name":"d3d_gizmo_axis", + "isCompatibility":false, + "isDnD":false, + "name":"d3d_gizmo_axis", + "parent":{ + "name":"gizmo", + "path":"folders/functions/3d/gizmo.yy", + }, + "resourceType":"GMScript", + "resourceVersion":"2.0", +} \ No newline at end of file diff --git a/scripts/d3d_object/d3d_object.gml b/scripts/d3d_object/d3d_object.gml index 299e771a5..1c7a802cb 100644 --- a/scripts/d3d_object/d3d_object.gml +++ b/scripts/d3d_object/d3d_object.gml @@ -121,6 +121,7 @@ function __3dObject() constructor { _s.show_normal = false; submitVertex(_s, sh_d3d_silhouette); } #endregion + static submitShader = function(scene = {}, shader = noone) {} static submitShadow = function(scene = {}, object = noone) {} diff --git a/scripts/panel_preview/panel_preview.gml b/scripts/panel_preview/panel_preview.gml index e13568388..bf24ca666 100644 --- a/scripts/panel_preview/panel_preview.gml +++ b/scripts/panel_preview/panel_preview.gml @@ -1002,10 +1002,10 @@ function Panel_Preview() : PanelContent() constructor { #region draw d3_scene_preview.reset(); - gpu_set_cullmode(cull_counterclockwise); + gpu_set_cullmode(cull_counterclockwise); var _prev_obj = _prev_node.getPreviewObjects(); - + if(d3_scene_preview == d3_scene) { if(d3_scene_light_enabled) { d3_scene_preview.addLightDirectional(d3_scene_light0); @@ -1016,19 +1016,18 @@ function Panel_Preview() : PanelContent() constructor { for( var i = 0, n = array_length(_prev_obj); i < n; i++ ) { var _prev = _prev_obj[i]; if(_prev == noone) continue; - + _prev.submitShader(d3_scene_preview); } d3_scene_preview.apply(d3_deferData); - //print("========= Submit begin ========="); for( var i = 0, n = array_length(_prev_obj); i < n; i++ ) { var _prev = _prev_obj[i]; if(_prev == noone) continue; - _prev.submitUI(d3_scene_preview); //////////////// SUBMIT //////////////// + + _prev.submitUI(d3_scene_preview); } - //print("========= Submit end ========="); gpu_set_cullmode(cull_noculling); surface_reset_target();