From 388fa8fc6970e7542ea5ef3a268ada267615a1af Mon Sep 17 00:00:00 2001 From: Tanasart Date: Sat, 21 Dec 2024 09:08:14 +0700 Subject: [PATCH] [Preview] Now show default dimension outline when not previewing any nodes. --- PixelComposer.resource_order | 22 +-- PixelComposer.yyp | 2 + scripts/d3d_object/d3d_object.gml | 6 + .../d3d_plane_bend_mesh.gml | 145 ++++++++++++++++++ .../d3d_plane_bend_mesh.yy | 14 ++ scripts/globals/globals.gml | 2 +- .../node_3d_mesh_plane_bend.gml | 44 ++++++ .../node_3d_mesh_plane_bend.yy | 14 ++ scripts/panel_preview/panel_preview.gml | 21 ++- 9 files changed, 251 insertions(+), 19 deletions(-) create mode 100644 scripts/d3d_plane_bend_mesh/d3d_plane_bend_mesh.gml create mode 100644 scripts/d3d_plane_bend_mesh/d3d_plane_bend_mesh.yy create mode 100644 scripts/node_3d_mesh_plane_bend/node_3d_mesh_plane_bend.gml create mode 100644 scripts/node_3d_mesh_plane_bend/node_3d_mesh_plane_bend.yy diff --git a/PixelComposer.resource_order b/PixelComposer.resource_order index 07df11c2b..fe263acf8 100644 --- a/PixelComposer.resource_order +++ b/PixelComposer.resource_order @@ -533,7 +533,7 @@ {"name":"d3d_cone","order":5,"path":"scripts/d3d_cone/d3d_cone.yy",}, {"name":"d3d_cube_faces","order":1,"path":"scripts/d3d_cube_faces/d3d_cube_faces.yy",}, {"name":"d3d_cube","order":2,"path":"scripts/d3d_cube/d3d_cube.yy",}, - {"name":"d3d_cylinder_nocaps","order":10,"path":"scripts/d3d_cylinder_nocaps/d3d_cylinder_nocaps.yy",}, + {"name":"d3d_cylinder_nocaps","order":11,"path":"scripts/d3d_cylinder_nocaps/d3d_cylinder_nocaps.yy",}, {"name":"d3d_cylinder","order":3,"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",}, @@ -548,15 +548,16 @@ {"name":"d3d_material","order":4,"path":"scripts/d3d_material/d3d_material.yy",}, {"name":"d3d_object_instancer","order":5,"path":"scripts/d3d_object_instancer/d3d_object_instancer.yy",}, {"name":"d3d_object","order":1,"path":"scripts/d3d_object/d3d_object.yy",}, - {"name":"d3d_path_extrude","order":11,"path":"scripts/d3d_path_extrude/d3d_path_extrude.yy",}, + {"name":"d3d_path_extrude","order":12,"path":"scripts/d3d_path_extrude/d3d_path_extrude.yy",}, + {"name":"d3d_plane_bend_mesh","order":8,"path":"scripts/d3d_plane_bend_mesh/d3d_plane_bend_mesh.yy",}, {"name":"d3d_plane_mesh","order":7,"path":"scripts/d3d_plane_mesh/d3d_plane_mesh.yy",}, {"name":"d3d_plane","order":2,"path":"scripts/d3d_plane/d3d_plane.yy",}, {"name":"d3d_ray","order":9,"path":"scripts/d3d_ray/d3d_ray.yy",}, {"name":"d3d_rot3","order":3,"path":"scripts/d3d_rot3/d3d_rot3.yy",}, {"name":"d3d_scene","order":2,"path":"scripts/d3d_scene/d3d_scene.yy",}, - {"name":"d3d_surface_extrude","order":8,"path":"scripts/d3d_surface_extrude/d3d_surface_extrude.yy",}, - {"name":"d3d_terrain","order":9,"path":"scripts/d3d_terrain/d3d_terrain.yy",}, - {"name":"d3d_torus","order":12,"path":"scripts/d3d_torus/d3d_torus.yy",}, + {"name":"d3d_surface_extrude","order":9,"path":"scripts/d3d_surface_extrude/d3d_surface_extrude.yy",}, + {"name":"d3d_terrain","order":10,"path":"scripts/d3d_terrain/d3d_terrain.yy",}, + {"name":"d3d_torus","order":13,"path":"scripts/d3d_torus/d3d_torus.yy",}, {"name":"d3d_transformation","order":12,"path":"scripts/d3d_transformation/d3d_transformation.yy",}, {"name":"d3d_uvsphere","order":4,"path":"scripts/d3d_uvsphere/d3d_uvsphere.yy",}, {"name":"d3d_vertex","order":10,"path":"scripts/d3d_vertex/d3d_vertex.yy",}, @@ -677,16 +678,17 @@ {"name":"node_3d_mesh_cube","order":2,"path":"scripts/node_3d_mesh_cube/node_3d_mesh_cube.yy",}, {"name":"node_3d_mesh_cylinder","order":4,"path":"scripts/node_3d_mesh_cylinder/node_3d_mesh_cylinder.yy",}, {"name":"node_3d_mesh_export","order":14,"path":"scripts/node_3d_mesh_export/node_3d_mesh_export.yy",}, - {"name":"node_3d_mesh_extrude","order":9,"path":"scripts/node_3d_mesh_extrude/node_3d_mesh_extrude.yy",}, + {"name":"node_3d_mesh_extrude","order":10,"path":"scripts/node_3d_mesh_extrude/node_3d_mesh_extrude.yy",}, {"name":"node_3d_mesh_obj","order":3,"path":"scripts/node_3d_mesh_obj/node_3d_mesh_obj.yy",}, - {"name":"node_3d_mesh_path_extrude","order":11,"path":"scripts/node_3d_mesh_path_extrude/node_3d_mesh_path_extrude.yy",}, + {"name":"node_3d_mesh_path_extrude","order":12,"path":"scripts/node_3d_mesh_path_extrude/node_3d_mesh_path_extrude.yy",}, + {"name":"node_3d_mesh_plane_bend","order":9,"path":"scripts/node_3d_mesh_plane_bend/node_3d_mesh_plane_bend.yy",}, {"name":"node_3d_mesh_plane","order":8,"path":"scripts/node_3d_mesh_plane/node_3d_mesh_plane.yy",}, {"name":"node_3d_mesh_sphere_ico","order":6,"path":"scripts/node_3d_mesh_sphere_ico/node_3d_mesh_sphere_ico.yy",}, {"name":"node_3d_mesh_sphere_uv","order":5,"path":"scripts/node_3d_mesh_sphere_uv/node_3d_mesh_sphere_uv.yy",}, {"name":"node_3d_mesh_stack_slice","order":7,"path":"scripts/node_3d_mesh_stack_slice/node_3d_mesh_stack_slice.yy",}, - {"name":"node_3d_mesh_terrain","order":10,"path":"scripts/node_3d_mesh_terrain/node_3d_mesh_terrain.yy",}, - {"name":"node_3d_mesh_torus","order":12,"path":"scripts/node_3d_mesh_torus/node_3d_mesh_torus.yy",}, - {"name":"node_3d_mesh_wall_builder","order":13,"path":"scripts/node_3d_mesh_wall_builder/node_3d_mesh_wall_builder.yy",}, + {"name":"node_3d_mesh_terrain","order":11,"path":"scripts/node_3d_mesh_terrain/node_3d_mesh_terrain.yy",}, + {"name":"node_3d_mesh_torus","order":13,"path":"scripts/node_3d_mesh_torus/node_3d_mesh_torus.yy",}, + {"name":"node_3d_mesh_wall_builder","order":14,"path":"scripts/node_3d_mesh_wall_builder/node_3d_mesh_wall_builder.yy",}, {"name":"node_3d_point_affector","order":12,"path":"scripts/node_3d_point_affector/node_3d_point_affector.yy",}, {"name":"node_3d_repeat","order":1,"path":"scripts/node_3d_repeat/node_3d_repeat.yy",}, {"name":"node_3d_round_vertex","order":1,"path":"scripts/node_3d_round_vertex/node_3d_round_vertex.yy",}, diff --git a/PixelComposer.yyp b/PixelComposer.yyp index 4da71f50a..6b632caf8 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -1031,6 +1031,7 @@ {"id":{"name":"d3d_object_instancer","path":"scripts/d3d_object_instancer/d3d_object_instancer.yy",},}, {"id":{"name":"d3d_object","path":"scripts/d3d_object/d3d_object.yy",},}, {"id":{"name":"d3d_path_extrude","path":"scripts/d3d_path_extrude/d3d_path_extrude.yy",},}, + {"id":{"name":"d3d_plane_bend_mesh","path":"scripts/d3d_plane_bend_mesh/d3d_plane_bend_mesh.yy",},}, {"id":{"name":"d3d_plane_mesh","path":"scripts/d3d_plane_mesh/d3d_plane_mesh.yy",},}, {"id":{"name":"d3d_plane","path":"scripts/d3d_plane/d3d_plane.yy",},}, {"id":{"name":"d3d_ray","path":"scripts/d3d_ray/d3d_ray.yy",},}, @@ -1184,6 +1185,7 @@ {"id":{"name":"node_3d_mesh_extrude","path":"scripts/node_3d_mesh_extrude/node_3d_mesh_extrude.yy",},}, {"id":{"name":"node_3d_mesh_obj","path":"scripts/node_3d_mesh_obj/node_3d_mesh_obj.yy",},}, {"id":{"name":"node_3d_mesh_path_extrude","path":"scripts/node_3d_mesh_path_extrude/node_3d_mesh_path_extrude.yy",},}, + {"id":{"name":"node_3d_mesh_plane_bend","path":"scripts/node_3d_mesh_plane_bend/node_3d_mesh_plane_bend.yy",},}, {"id":{"name":"node_3d_mesh_plane","path":"scripts/node_3d_mesh_plane/node_3d_mesh_plane.yy",},}, {"id":{"name":"node_3d_mesh_sphere_ico","path":"scripts/node_3d_mesh_sphere_ico/node_3d_mesh_sphere_ico.yy",},}, {"id":{"name":"node_3d_mesh_sphere_uv","path":"scripts/node_3d_mesh_sphere_uv/node_3d_mesh_sphere_uv.yy",},}, diff --git a/scripts/d3d_object/d3d_object.gml b/scripts/d3d_object/d3d_object.gml index 0df8c697c..5a38e8b01 100644 --- a/scripts/d3d_object/d3d_object.gml +++ b/scripts/d3d_object/d3d_object.gml @@ -16,6 +16,12 @@ vertex_format_add_custom(vertex_type_float3, vertex_usage_texcoord); // x y z // 12 // barycentric global.VF_POS_NORM_TEX_COL = vertex_format_end(); global.VF_POS_NORM_TEX_COL_size = 48; + + #macro vertex_pos3 vertex_position_3d + #macro vertex_norm vertex_normal + #macro vertex_texc vertex_texcoord + #macro vertex_colr vertex_color + #macro vertex_vec3 vertex_float3 #endregion function __3dObject() constructor { diff --git a/scripts/d3d_plane_bend_mesh/d3d_plane_bend_mesh.gml b/scripts/d3d_plane_bend_mesh/d3d_plane_bend_mesh.gml new file mode 100644 index 000000000..80b09ff43 --- /dev/null +++ b/scripts/d3d_plane_bend_mesh/d3d_plane_bend_mesh.gml @@ -0,0 +1,145 @@ +function __3dPlaneBend() : __3dObject() constructor { + VB = [ noone ]; + VF = global.VF_POS_NORM_TEX_COL; + render_type = pr_trianglelist; + smooth = false; + + subdivision = 4; + bendAxis = 0; + bendRadius = 1; + + static initModel = function() { + var _hs = 1 / 2; + var _vt = array_create(3 * 2 * subdivision * subdivision); + var _in = 0; + + var amo_ch = (subdivision + 1) * (subdivision + 1); + var hs = array_length(heights) == amo_ch; + var st = 1 / subdivision; + var st2 = st * 2; + + for( var i = 0; i < subdivision; i++ ) + for( var j = 0; j < subdivision; j++ ) { + var u0 = i * st; + var u1 = u0 + st; + var v0 = j * st; + var v1 = v0 + st; + + var x0 = u0 - 0.5; + var x1 = u1 - 0.5; + var y0 = v0 - 0.5; + var y1 = v1 - 0.5; + + _vt[_in + 0] = new __vertex(x0, y0, 0).setNormal(0., 0., 1.).setUV(u0, v0); + _vt[_in + 1] = new __vertex(x1, y1, 0).setNormal(0., 0., 1.).setUV(u1, v1); + _vt[_in + 2] = new __vertex(x1, y0, 0).setNormal(0., 0., 1.).setUV(u1, v0); + + _vt[_in + 3] = new __vertex(x0, y0, 0).setNormal(0., 0., 1.).setUV(u0, v0); + _vt[_in + 4] = new __vertex(x0, y1, 0).setNormal(0., 0., 1.).setUV(u0, v1); + _vt[_in + 5] = new __vertex(x1, y1, 0).setNormal(0., 0., 1.).setUV(u1, v1); + + _in += 6; + } + + vertex = [ _vt ]; + updateBend(); + } initModel(); + + static updateBend = function() { + var _in = 0; + var _vt = vertex[0]; + var sub = subdivision; + var sub1 = sub + 1; + var st = 1 / subdivision; + var st2 = st * 2; + + if(VB[0]) vertex_delete_buffer(VB[0]); + VB[0] = vertex_create_buffer(); + vertex_begin(VB[0], VF); + + var vb = VB[0]; + var n = 0, i = 0, j = 0; + + repeat( sub * sub ) { + i = floor(n / sub); + j = n % sub; + + var _v0 = _vt[_in + 0]; + var _v1 = _vt[_in + 1]; + var _v2 = _vt[_in + 2]; + var _v3 = _vt[_in + 3]; + var _v4 = _vt[_in + 4]; + var _v5 = _vt[_in + 5]; + + //////////////////////////////////////////////////////////////////////////////// + + var _x0 = i * st - .5; + var _x1 = u0 + st - .5; + var _y0 = j * st - .5; + var _y1 = v0 + st - .5; + + var x0 = _x0; + var y0 = _y0; + var z0 = 0; + + var x1 = _x1; + var y1 = _y1; + var z1 = 0; + + _v0.x = x0; _v0.y = y0; + _v1.x = x1; _v1.y = y1; + _v2.x = x1; _v2.y = y0; + + _v3.x = x0; _v3.y = y0; + _v4.x = x0; _v4.y = y1; + _v5.x = x1; _v5.y = y1; + + //////////////////////////////////////////////////////////////////////////////// + + vertex_pos3(vb, _v0.x, _v0.y, _v0.z); + vertex_norm(vb, _v0.nx, _v0.ny, _v0.nz); + vertex_texc(vb, _v0.u, _v0.v); + vertex_colr(vb, _v0.color, _v0.alpha); + vertex_vec3(vb, 255, 0, 0); + + vertex_pos3(vb, _v1.x, _v1.y, _v1.z); + vertex_norm(vb, _v1.nx, _v1.ny, _v1.nz); + vertex_texc(vb, _v1.u, _v1.v); + vertex_colr(vb, _v1.color, _v1.alpha); + vertex_vec3(vb, 0, 255, 0); + + vertex_pos3(vb, _v2.x, _v2.y, _v2.z); + vertex_norm(vb, _v2.nx, _v2.ny, _v2.nz); + vertex_texc(vb, _v2.u, _v2.v); + vertex_colr(vb, _v2.color, _v2.alpha); + vertex_vec3(vb, 0, 0, 255); + + + vertex_pos3(vb, _v3.x, _v3.y, _v3.z); + vertex_norm(vb, _v3.nx, _v3.ny, _v3.nz); + vertex_texc(vb, _v3.u, _v3.v); + vertex_colr(vb, _v3.color, _v3.alpha); + vertex_vec3(vb, 255, 0, 0); + + vertex_pos3(vb, _v4.x, _v4.y, _v4.z); + vertex_norm(vb, _v4.nx, _v4.ny, _v4.nz); + vertex_texc(vb, _v4.u, _v4.v); + vertex_colr(vb, _v4.color, _v4.alpha); + vertex_vec3(vb, 0, 255, 0); + + vertex_pos3(vb, _v5.x, _v5.y, _v5.z); + vertex_norm(vb, _v5.nx, _v5.ny, _v5.nz); + vertex_texc(vb, _v5.u, _v5.v); + vertex_colr(vb, _v5.color, _v5.alpha); + vertex_vec3(vb, 0, 0, 255); + + _in += 6; + + n++; + } + + vertex_end(VB[0]); + } + + onParameterUpdate = initModel; +} \ No newline at end of file diff --git a/scripts/d3d_plane_bend_mesh/d3d_plane_bend_mesh.yy b/scripts/d3d_plane_bend_mesh/d3d_plane_bend_mesh.yy new file mode 100644 index 000000000..677bf4a32 --- /dev/null +++ b/scripts/d3d_plane_bend_mesh/d3d_plane_bend_mesh.yy @@ -0,0 +1,14 @@ +{ + "$GMScript":"v1", + "%Name":"d3d_plane_bend_mesh", + "isCompatibility":false, + "isDnD":false, + "name":"d3d_plane_bend_mesh", + "parent":{ + "name":"mesh", + "path":"folders/nodes/data/3D/d3d_mesh/mesh.yy", + }, + "resourceType":"GMScript", + "resourceVersion":"2.0", + "tags":[], +} \ No newline at end of file diff --git a/scripts/globals/globals.gml b/scripts/globals/globals.gml index 612563933..073efcb8e 100644 --- a/scripts/globals/globals.gml +++ b/scripts/globals/globals.gml @@ -44,7 +44,7 @@ LATEST_VERSION = 1_18_00_0; VERSION = 1_18_05_1; SAVE_VERSION = 1_18_05_0; - VERSION_STRING = MAC? "1.18.003m" : "1.18.6.008"; + VERSION_STRING = MAC? "1.18.003m" : "1.18.6.009"; BUILD_NUMBER = 1_18_05_6; var _vsp = string_split(VERSION_STRING, "."); diff --git a/scripts/node_3d_mesh_plane_bend/node_3d_mesh_plane_bend.gml b/scripts/node_3d_mesh_plane_bend/node_3d_mesh_plane_bend.gml new file mode 100644 index 000000000..7e29b5c89 --- /dev/null +++ b/scripts/node_3d_mesh_plane_bend/node_3d_mesh_plane_bend.gml @@ -0,0 +1,44 @@ +function Node_3D_Mesh_Plane_Bend(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _group) constructor { + name = "3D Bend Plane"; + + object_class = __3dPlaneBend; + + newInput(in_mesh + 0, nodeValue_D3Material("Material", self, new __d3dMaterial())) + .setVisible(true, true); + + newInput(in_mesh + 1, nodeValue_Enum_Button("Normal", self, 2 , [ "X", "Y", "Z" ])); + + newInput(in_mesh + 2, nodeValue_Bool("Both side", self, false )) + .rejectArray(); + + newInput(in_mesh + 3, nodeValue_D3Material("Back Material", self, new __d3dMaterial())) + + input_display_list = [ + __d3d_input_list_mesh, in_mesh + 1, + __d3d_input_list_transform, + ["Material", false], in_mesh + 2, in_mesh + 0, in_mesh + 3, + ] + + static preGetInputs = function() { + var _both = inputs[in_mesh + 2].getValue(); + + inputs[in_mesh + 3].setVisible(_both, _both); + } + + static processData = function(_output, _data, _output_index, _array_index = 0) { + var _mat = _data[in_mesh + 0]; + var _axs = _data[in_mesh + 1]; + var _both = _data[in_mesh + 2]; + var _bmat = _data[in_mesh + 3]; + + var object = getObject(_array_index); + object.checkParameter({ normal: _axs, two_side: _both }); + object.materials = _both? [ _mat, _bmat ] : [ _mat ]; + + setTransform(object, _data); + + return object; + } + + static getPreviewValues = function() { return getSingleValue(in_mesh + 0); } +} \ No newline at end of file diff --git a/scripts/node_3d_mesh_plane_bend/node_3d_mesh_plane_bend.yy b/scripts/node_3d_mesh_plane_bend/node_3d_mesh_plane_bend.yy new file mode 100644 index 000000000..2555807c4 --- /dev/null +++ b/scripts/node_3d_mesh_plane_bend/node_3d_mesh_plane_bend.yy @@ -0,0 +1,14 @@ +{ + "$GMScript":"v1", + "%Name":"node_3d_mesh_plane_bend", + "isCompatibility":false, + "isDnD":false, + "name":"node_3d_mesh_plane_bend", + "parent":{ + "name":"d3d_mesh", + "path":"folders/nodes/data/3D/d3d_mesh.yy", + }, + "resourceType":"GMScript", + "resourceVersion":"2.0", + "tags":[], +} \ No newline at end of file diff --git a/scripts/panel_preview/panel_preview.gml b/scripts/panel_preview/panel_preview.gml index cf6d3695b..a1df44e26 100644 --- a/scripts/panel_preview/panel_preview.gml +++ b/scripts/panel_preview/panel_preview.gml @@ -539,7 +539,7 @@ function Panel_Preview() : PanelContent() constructor { locked = false; } - function __getNodePreview() { return preview_node[splitView? splitSelection : 0]; } + function __getNodePreview() { return preview_node[splitView? splitSelection : 0]; } function getNodePreview() { var _node = __getNodePreview(); if(_node == noone) return noone; @@ -2310,18 +2310,15 @@ function Panel_Preview() : PanelContent() constructor { d3_active = _prev_node == noone? NODE_3D.none : _prev_node.is_3D; bg_color = lerp_color(bg_color, d3_active? COLORS.panel_3d_bg : COLORS.panel_bg_clear, 0.3); - draw_clear(bg_color); - if(canvas_bg == -1) { - if(canvas_s >= 0.1) draw_sprite_tiled_ext(s_transparent, 0, canvas_x, canvas_y, canvas_s, canvas_s, COLORS.panel_preview_transparent, 1); - } else - draw_clear(canvas_bg); + draw_clear(canvas_bg == -1? bg_color : canvas_bg); + if(canvas_bg == -1 && canvas_s >= 0.1) + draw_sprite_tiled_ext(s_transparent, 0, canvas_x, canvas_y, canvas_s, canvas_s, COLORS.panel_preview_transparent, 1); draw_set_color(COLORS._main_icon_dark); draw_line_width(canvas_x, 0, canvas_x, h, 1); draw_line_width(0, canvas_y, w, canvas_y, 1); title = __txt("Preview"); - getPreviewData(); if(_prev_node) { @@ -2332,7 +2329,15 @@ function Panel_Preview() : PanelContent() constructor { dragCanvas(); drawNodePreview(); } - } else dragCanvas(); + + } else { + dragCanvas(); + + draw_set_color(COLORS.panel_preview_surface_outline); + draw_set_alpha(.75); + draw_rectangle(canvas_x, canvas_y, canvas_x + DEF_SURF_W * canvas_s - 1, canvas_y + DEF_SURF_H * canvas_s - 1, true); + draw_set_alpha(1); + } drawPreviewOverlay();