Point light, shadow, improved obj import

This commit is contained in:
Tanasart 2023-08-22 11:51:45 +02:00
parent 66351fa767
commit c17a3a306d
100 changed files with 2557 additions and 586 deletions

View file

@ -292,6 +292,7 @@
{"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":4,"path":"scripts/d3d_scene/d3d_scene.yy",},
{"name":"sh_channel_R2A","order":13,"path":"shaders/sh_channel_R2A/sh_channel_R2A.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",},
@ -377,6 +378,7 @@
{"name":"s_node_replace_palette","order":59,"path":"sprites/s_node_replace_palette/s_node_replace_palette.yy",},
{"name":"sh_cell_noise_round","order":4,"path":"shaders/sh_cell_noise_round/sh_cell_noise_round.yy",},
{"name":"s_node_cross_product_2d","order":12,"path":"sprites/s_node_cross_product_2d/s_node_cross_product_2d.yy",},
{"name":"d3d_uvsphere","order":3,"path":"scripts/d3d_uvsphere/d3d_uvsphere.yy",},
{"name":"s_node_path_plot","order":12,"path":"sprites/s_node_path_plot/s_node_path_plot.yy",},
{"name":"__initAddon","order":2,"path":"scripts/__initAddon/__initAddon.yy",},
{"name":"node_pb_draw_trapezoid","order":8,"path":"scripts/node_pb_draw_trapezoid/node_pb_draw_trapezoid.yy",},
@ -589,6 +591,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":"node_3d_mesh_cylinder","order":3,"path":"scripts/node_3d_mesh_cylinder/node_3d_mesh_cylinder.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",},
@ -607,7 +610,6 @@
{"name":"s_node_surface_from_buffer","order":1,"path":"sprites/s_node_surface_from_buffer/s_node_surface_from_buffer.yy",},
{"name":"node_iterator_filter_output","order":2,"path":"scripts/node_iterator_filter_output/node_iterator_filter_output.yy",},
{"name":"color_function","order":9,"path":"scripts/color_function/color_function.yy",},
{"name":"d3d_cube_faces","order":1,"path":"scripts/d3d_cube_faces/d3d_cube_faces.yy",},
{"name":"fd_rectangle_set_pressure_size","order":11,"path":"scripts/fd_rectangle_set_pressure_size/fd_rectangle_set_pressure_size.yy",},
{"name":"node_color_data","order":6,"path":"scripts/node_color_data/node_color_data.yy",},
{"name":"node_array_shift","order":24,"path":"scripts/node_array_shift/node_array_shift.yy",},
@ -666,6 +668,7 @@
{"name":"s_node_text_splice","order":6,"path":"sprites/s_node_text_splice/s_node_text_splice.yy",},
{"name":"__atlas","order":6,"path":"scripts/__atlas/__atlas.yy",},
{"name":"node_3d_transform","order":7,"path":"scripts/node_3d_transform/node_3d_transform.yy",},
{"name":"__d3d_gizmo","order":2,"path":"scripts/__d3d_gizmo/__d3d_gizmo.yy",},
{"name":"sh_draw_single_channel","order":3,"path":"shaders/sh_draw_single_channel/sh_draw_single_channel.yy",},
{"name":"draw_sprite_ext_override","order":9,"path":"scripts/draw_sprite_ext_override/draw_sprite_ext_override.yy",},
{"name":"node_array_add","order":9,"path":"scripts/node_array_add/node_array_add.yy",},
@ -677,6 +680,7 @@
{"name":"s_node_pb_fx_radial","order":4,"path":"sprites/s_node_pb_fx_radial/s_node_pb_fx_radial.yy",},
{"name":"__background_get_internal","order":2,"path":"scripts/__background_get_internal/__background_get_internal.yy",},
{"name":"s_biterator_b_labels","order":9,"path":"sprites/s_biterator_b_labels/s_biterator_b_labels.yy",},
{"name":"d3d_ray","order":9,"path":"scripts/d3d_ray/d3d_ray.yy",},
{"name":"sh_combine_hsv","order":10,"path":"shaders/sh_combine_hsv/sh_combine_hsv.yy",},
{"name":"s_node_array_insert","order":4,"path":"sprites/s_node_array_insert/s_node_array_insert.yy",},
{"name":"addon_lua","order":1,"path":"scripts/addon_lua/addon_lua.yy",},
@ -694,6 +698,7 @@
{"name":"buttonColor","order":3,"path":"scripts/buttonColor/buttonColor.yy",},
{"name":"notification_system","order":7,"path":"scripts/notification_system/notification_system.yy",},
{"name":"buffer_object","order":1,"path":"scripts/buffer_object/buffer_object.yy",},
{"name":"node_3d_mesh_sphere","order":4,"path":"scripts/node_3d_mesh_sphere/node_3d_mesh_sphere.yy",},
{"name":"s_node_audio_trim","order":3,"path":"sprites/s_node_audio_trim/s_node_audio_trim.yy",},
{"name":"s_node_pb_fx_highlight","order":7,"path":"sprites/s_node_pb_fx_highlight/s_node_pb_fx_highlight.yy",},
{"name":"node_color_from_hsv","order":8,"path":"scripts/node_color_from_hsv/node_color_from_hsv.yy",},
@ -887,6 +892,7 @@
{"name":"s_node_draw_stack","order":4,"path":"sprites/s_node_draw_stack/s_node_draw_stack.yy",},
{"name":"sh_d3d_grid_view","order":12,"path":"shaders/sh_d3d_grid_view/sh_d3d_grid_view.yy",},
{"name":"delaunay","order":1,"path":"scripts/delaunay/delaunay.yy",},
{"name":"sh_d3d_shadow_depth","order":19,"path":"shaders/sh_d3d_shadow_depth/sh_d3d_shadow_depth.yy",},
{"name":"s_node_noise_fbm","order":26,"path":"sprites/s_node_noise_fbm/s_node_noise_fbm.yy",},
{"name":"sh_color_select_content","order":1,"path":"shaders/sh_color_select_content/sh_color_select_content.yy",},
{"name":"sh_outline","order":18,"path":"shaders/sh_outline/sh_outline.yy",},
@ -919,6 +925,7 @@
{"name":"safe_operation","order":6,"path":"scripts/safe_operation/safe_operation.yy",},
{"name":"s_node_rigid_override","order":9,"path":"sprites/s_node_rigid_override/s_node_rigid_override.yy",},
{"name":"s_node_array_get","order":3,"path":"sprites/s_node_array_get/s_node_array_get.yy",},
{"name":"d3d_bbox","order":8,"path":"scripts/d3d_bbox/d3d_bbox.yy",},
{"name":"o_dialog_save","order":12,"path":"objects/o_dialog_save/o_dialog_save.yy",},
{"name":"s_node_BW","order":13,"path":"sprites/s_node_BW/s_node_BW.yy",},
{"name":"s_node_strandSim_collide","order":7,"path":"sprites/s_node_strandSim_collide/s_node_strandSim_collide.yy",},
@ -926,6 +933,7 @@
{"name":"sh_fd_turbulence","order":22,"path":"shaders/sh_fd_turbulence/sh_fd_turbulence.yy",},
{"name":"s_node_compare","order":1,"path":"sprites/s_node_compare/s_node_compare.yy",},
{"name":"s_node_fluidSim_domain_queue","order":9,"path":"sprites/s_node_fluidSim_domain_queue/s_node_fluidSim_domain_queue.yy",},
{"name":"sh_d3d_shadow_cube_depth","order":20,"path":"shaders/sh_d3d_shadow_cube_depth/sh_d3d_shadow_cube_depth.yy",},
{"name":"s_node_vfx_spawn","order":2,"path":"sprites/s_node_vfx_spawn/s_node_vfx_spawn.yy",},
{"name":"d3d_vec3","order":4,"path":"scripts/d3d_vec3/d3d_vec3.yy",},
{"name":"texture_set_repeat","order":1,"path":"scripts/texture_set_repeat/texture_set_repeat.yy",},
@ -948,7 +956,9 @@
{"name":"getGradientData","order":1,"path":"scripts/getGradientData/getGradientData.yy",},
{"name":"s_node_pb_box_inset","order":22,"path":"sprites/s_node_pb_box_inset/s_node_pb_box_inset.yy",},
{"name":"node_glow","order":10,"path":"scripts/node_glow/node_glow.yy",},
{"name":"o_dialog_preview_snap","order":4,"path":"objects/o_dialog_preview_snap/o_dialog_preview_snap.yy",},
{"name":"sh_blend_min","order":9,"path":"shaders/sh_blend_min/sh_blend_min.yy",},
{"name":"d3d_gizmo_circle_z","order":4,"path":"scripts/d3d_gizmo_circle_z/d3d_gizmo_circle_z.yy",},
{"name":"sh_pb_shade_half","order":5,"path":"shaders/sh_pb_shade_half/sh_pb_shade_half.yy",},
{"name":"node_polar","order":4,"path":"scripts/node_polar/node_polar.yy",},
{"name":"s_node_twirl","order":41,"path":"sprites/s_node_twirl/s_node_twirl.yy",},
@ -998,6 +1008,7 @@
{"name":"s_node_crop_content","order":13,"path":"sprites/s_node_crop_content/s_node_crop_content.yy",},
{"name":"draw_line_zigzag","order":20,"path":"scripts/draw_line_zigzag/draw_line_zigzag.yy",},
{"name":"sh_alpha_grey","order":1,"path":"shaders/sh_alpha_grey/sh_alpha_grey.yy",},
{"name":"sh_channel_R2B","order":12,"path":"shaders/sh_channel_R2B/sh_channel_R2B.yy",},
{"name":"s_node_rigidSim_activate","order":6,"path":"sprites/s_node_rigidSim_activate/s_node_rigidSim_activate.yy",},
{"name":"s_transparent","order":1,"path":"sprites/s_transparent/s_transparent.yy",},
{"name":"o_dialog_animation","order":1,"path":"objects/o_dialog_animation/o_dialog_animation.yy",},
@ -1036,6 +1047,7 @@
{"name":"node_pb_draw_ellipse","order":2,"path":"scripts/node_pb_draw_ellipse/node_pb_draw_ellipse.yy",},
{"name":"sh_outline_only","order":35,"path":"shaders/sh_outline_only/sh_outline_only.yy",},
{"name":"lcd_function","order":13,"path":"scripts/lcd_function/lcd_function.yy",},
{"name":"d3d_gizmo_line","order":1,"path":"scripts/d3d_gizmo_line/d3d_gizmo_line.yy",},
{"name":"s_node_destray","order":18,"path":"sprites/s_node_destray/s_node_destray.yy",},
{"name":"node_color_sampler","order":3,"path":"scripts/node_color_sampler/node_color_sampler.yy",},
{"name":"node_iterator_sort_output","order":2,"path":"scripts/node_iterator_sort_output/node_iterator_sort_output.yy",},
@ -1117,12 +1129,14 @@
{"name":"node_text_file_read","order":7,"path":"scripts/node_text_file_read/node_text_file_read.yy",},
{"name":"node_pb_box_divide_grid","order":7,"path":"scripts/node_pb_box_divide_grid/node_pb_box_divide_grid.yy",},
{"name":"draw_tooltip","order":13,"path":"scripts/draw_tooltip/draw_tooltip.yy",},
{"name":"d3d_cylinder","order":2,"path":"scripts/d3d_cylinder/d3d_cylinder.yy",},
{"name":"sh_palette_replace","order":45,"path":"shaders/sh_palette_replace/sh_palette_replace.yy",},
{"name":"sh_cell_noise_random","order":3,"path":"shaders/sh_cell_noise_random/sh_cell_noise_random.yy",},
{"name":"node_iterator_input","order":1,"path":"scripts/node_iterator_input/node_iterator_input.yy",},
{"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_cube","order":1,"path":"scripts/d3d_cube/d3d_cube.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",},
@ -1135,6 +1149,7 @@
{"name":"node_array_length","order":11,"path":"scripts/node_array_length/node_array_length.yy",},
{"name":"node_erode","order":9,"path":"scripts/node_erode/node_erode.yy",},
{"name":"sh_colours_replace","order":54,"path":"shaders/sh_colours_replace/sh_colours_replace.yy",},
{"name":"sh_channel_R2G","order":11,"path":"shaders/sh_channel_R2G/sh_channel_R2G.yy",},
{"name":"node_wrap_mesh","order":6,"path":"scripts/node_wrap_mesh/node_wrap_mesh.yy",},
{"name":"sh_alpha_hash","order":2,"path":"shaders/sh_alpha_hash/sh_alpha_hash.yy",},
{"name":"vct_slider","order":1,"path":"scripts/vct_slider/vct_slider.yy",},
@ -1144,6 +1159,7 @@
{"name":"value_snap","order":10,"path":"scripts/value_snap/value_snap.yy",},
{"name":"file_dropper","order":1,"path":"extensions/file_dropper/file_dropper.yy",},
{"name":"s_biterator_b_shape_idle","order":3,"path":"sprites/s_biterator_b_shape_idle/s_biterator_b_shape_idle.yy",},
{"name":"o_dialog_preview_3d_settings","order":3,"path":"objects/o_dialog_preview_3d_settings/o_dialog_preview_3d_settings.yy",},
{"name":"sh_mirror_mask","order":8,"path":"shaders/sh_mirror_mask/sh_mirror_mask.yy",},
{"name":"node_export","order":10,"path":"scripts/node_export/node_export.yy",},
{"name":"controlPointBox","order":21,"path":"scripts/controlPointBox/controlPointBox.yy",},
@ -1220,6 +1236,7 @@
{"name":"node_strand_update","order":3,"path":"scripts/node_strand_update/node_strand_update.yy",},
{"name":"sh_grid_noise","order":2,"path":"shaders/sh_grid_noise/sh_grid_noise.yy",},
{"name":"draw_set_blend_mode","order":1,"path":"scripts/draw_set_blend_mode/draw_set_blend_mode.yy",},
{"name":"d3d_gizmo_line_dashed","order":3,"path":"scripts/d3d_gizmo_line_dashed/d3d_gizmo_line_dashed.yy",},
{"name":"gameframe_macros","order":1,"path":"scripts/gameframe_macros/gameframe_macros.yy",},
{"name":"s_node_trigger_bool","order":4,"path":"sprites/s_node_trigger_bool/s_node_trigger_bool.yy",},
{"name":"panel_color","order":1,"path":"scripts/panel_color/panel_color.yy",},
@ -1252,7 +1269,6 @@
{"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":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",},
@ -1355,6 +1371,7 @@
{"name":"s_node_ase_layer","order":14,"path":"sprites/s_node_ase_layer/s_node_ase_layer.yy",},
{"name":"_f_p1","order":1,"path":"fonts/_f_p1/_f_p1.yy",},
{"name":"tuple_functions","order":5,"path":"scripts/tuple_functions/tuple_functions.yy",},
{"name":"node_3d_mesh_obj","order":2,"path":"scripts/node_3d_mesh_obj/node_3d_mesh_obj.yy",},
{"name":"sh_blur_simple","order":6,"path":"shaders/sh_blur_simple/sh_blur_simple.yy",},
{"name":"sh_blend_difference","order":51,"path":"shaders/sh_blend_difference/sh_blend_difference.yy",},
{"name":"s_node_image_animation","order":2,"path":"sprites/s_node_image_animation/s_node_image_animation.yy",},

View file

@ -276,6 +276,8 @@
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"graphics.json","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"1.png.tmp$$","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"graphics x2.ai","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_3d_preview_settings.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_3d_snap_settings.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_ac_constant.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_ac_function.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_ac_node.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
@ -344,6 +346,7 @@
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_icon_output_visibility.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_icon_play_sound.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_icon_preview_export.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_icon_preview_light.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_icon_reset_16.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_icon_reset_when_preview_strip2.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_icon_revert.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
@ -476,6 +479,7 @@
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_node_bg_name.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/node",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_node_bg_pill.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/node",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_node_bg.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/node",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_node_deprecated_badge.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/node",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_node_draw_area.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/node",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_node_draw_path.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/node",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_node_frame_bg.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/node",},
@ -814,6 +818,7 @@
{"id":{"name":"o_dialog_notifications","path":"objects/o_dialog_notifications/o_dialog_notifications.yy",},},
{"id":{"name":"sh_draw_color","path":"shaders/sh_draw_color/sh_draw_color.yy",},},
{"id":{"name":"d3d_scene","path":"scripts/d3d_scene/d3d_scene.yy",},},
{"id":{"name":"sh_channel_R2A","path":"shaders/sh_channel_R2A/sh_channel_R2A.yy",},},
{"id":{"name":"s_node_array_find","path":"sprites/s_node_array_find/s_node_array_find.yy",},},
{"id":{"name":"fd_rectangle_set_velocity_time_step","path":"scripts/fd_rectangle_set_velocity_time_step/fd_rectangle_set_velocity_time_step.yy",},},
{"id":{"name":"fd_rectangle_set_collision_mask_sprite","path":"scripts/fd_rectangle_set_collision_mask_sprite/fd_rectangle_set_collision_mask_sprite.yy",},},
@ -914,6 +919,7 @@
{"id":{"name":"s_node_replace_palette","path":"sprites/s_node_replace_palette/s_node_replace_palette.yy",},},
{"id":{"name":"sh_cell_noise_round","path":"shaders/sh_cell_noise_round/sh_cell_noise_round.yy",},},
{"id":{"name":"s_node_cross_product_2d","path":"sprites/s_node_cross_product_2d/s_node_cross_product_2d.yy",},},
{"id":{"name":"d3d_uvsphere","path":"scripts/d3d_uvsphere/d3d_uvsphere.yy",},},
{"id":{"name":"s_node_path_plot","path":"sprites/s_node_path_plot/s_node_path_plot.yy",},},
{"id":{"name":"__initAddon","path":"scripts/__initAddon/__initAddon.yy",},},
{"id":{"name":"node_pb_draw_trapezoid","path":"scripts/node_pb_draw_trapezoid/node_pb_draw_trapezoid.yy",},},
@ -1160,6 +1166,7 @@
{"id":{"name":"sh_warp_4points_pers","path":"shaders/sh_warp_4points_pers/sh_warp_4points_pers.yy",},},
{"id":{"name":"node_mirror","path":"scripts/node_mirror/node_mirror.yy",},},
{"id":{"name":"node_corner","path":"scripts/node_corner/node_corner.yy",},},
{"id":{"name":"node_3d_mesh_cylinder","path":"scripts/node_3d_mesh_cylinder/node_3d_mesh_cylinder.yy",},},
{"id":{"name":"__vertex_function","path":"scripts/__vertex_function/__vertex_function.yy",},},
{"id":{"name":"node_path_anchor","path":"scripts/node_path_anchor/node_path_anchor.yy",},},
{"id":{"name":"s_node_path_wave","path":"sprites/s_node_path_wave/s_node_path_wave.yy",},},
@ -1250,6 +1257,7 @@
{"id":{"name":"s_node_text_splice","path":"sprites/s_node_text_splice/s_node_text_splice.yy",},},
{"id":{"name":"__atlas","path":"scripts/__atlas/__atlas.yy",},},
{"id":{"name":"node_3d_transform","path":"scripts/node_3d_transform/node_3d_transform.yy",},},
{"id":{"name":"__d3d_gizmo","path":"scripts/__d3d_gizmo/__d3d_gizmo.yy",},},
{"id":{"name":"sh_draw_single_channel","path":"shaders/sh_draw_single_channel/sh_draw_single_channel.yy",},},
{"id":{"name":"draw_sprite_ext_override","path":"scripts/draw_sprite_ext_override/draw_sprite_ext_override.yy",},},
{"id":{"name":"node_array_add","path":"scripts/node_array_add/node_array_add.yy",},},
@ -1261,6 +1269,7 @@
{"id":{"name":"s_node_pb_fx_radial","path":"sprites/s_node_pb_fx_radial/s_node_pb_fx_radial.yy",},},
{"id":{"name":"__background_get_internal","path":"scripts/__background_get_internal/__background_get_internal.yy",},},
{"id":{"name":"s_biterator_b_labels","path":"sprites/s_biterator_b_labels/s_biterator_b_labels.yy",},},
{"id":{"name":"d3d_ray","path":"scripts/d3d_ray/d3d_ray.yy",},},
{"id":{"name":"sh_combine_hsv","path":"shaders/sh_combine_hsv/sh_combine_hsv.yy",},},
{"id":{"name":"s_node_array_insert","path":"sprites/s_node_array_insert/s_node_array_insert.yy",},},
{"id":{"name":"addon_lua","path":"scripts/addon_lua/addon_lua.yy",},},
@ -1281,6 +1290,7 @@
{"id":{"name":"buttonColor","path":"scripts/buttonColor/buttonColor.yy",},},
{"id":{"name":"notification_system","path":"scripts/notification_system/notification_system.yy",},},
{"id":{"name":"buffer_object","path":"scripts/buffer_object/buffer_object.yy",},},
{"id":{"name":"node_3d_mesh_sphere","path":"scripts/node_3d_mesh_sphere/node_3d_mesh_sphere.yy",},},
{"id":{"name":"s_node_audio_trim","path":"sprites/s_node_audio_trim/s_node_audio_trim.yy",},},
{"id":{"name":"s_node_pb_fx_highlight","path":"sprites/s_node_pb_fx_highlight/s_node_pb_fx_highlight.yy",},},
{"id":{"name":"sh_shadow_cast","path":"shaders/sh_shadow_cast/sh_shadow_cast.yy",},},
@ -1496,6 +1506,7 @@
{"id":{"name":"s_node_draw_stack","path":"sprites/s_node_draw_stack/s_node_draw_stack.yy",},},
{"id":{"name":"sh_d3d_grid_view","path":"shaders/sh_d3d_grid_view/sh_d3d_grid_view.yy",},},
{"id":{"name":"delaunay","path":"scripts/delaunay/delaunay.yy",},},
{"id":{"name":"sh_d3d_shadow_depth","path":"shaders/sh_d3d_shadow_depth/sh_d3d_shadow_depth.yy",},},
{"id":{"name":"s_node_noise_fbm","path":"sprites/s_node_noise_fbm/s_node_noise_fbm.yy",},},
{"id":{"name":"sh_color_select_content","path":"shaders/sh_color_select_content/sh_color_select_content.yy",},},
{"id":{"name":"sh_outline","path":"shaders/sh_outline/sh_outline.yy",},},
@ -1530,6 +1541,7 @@
{"id":{"name":"safe_operation","path":"scripts/safe_operation/safe_operation.yy",},},
{"id":{"name":"s_node_rigid_override","path":"sprites/s_node_rigid_override/s_node_rigid_override.yy",},},
{"id":{"name":"s_node_array_get","path":"sprites/s_node_array_get/s_node_array_get.yy",},},
{"id":{"name":"d3d_bbox","path":"scripts/d3d_bbox/d3d_bbox.yy",},},
{"id":{"name":"o_dialog_save","path":"objects/o_dialog_save/o_dialog_save.yy",},},
{"id":{"name":"s_node_BW","path":"sprites/s_node_BW/s_node_BW.yy",},},
{"id":{"name":"s_node_strandSim_collide","path":"sprites/s_node_strandSim_collide/s_node_strandSim_collide.yy",},},
@ -1537,6 +1549,7 @@
{"id":{"name":"sh_fd_turbulence","path":"shaders/sh_fd_turbulence/sh_fd_turbulence.yy",},},
{"id":{"name":"s_node_compare","path":"sprites/s_node_compare/s_node_compare.yy",},},
{"id":{"name":"s_node_fluidSim_domain_queue","path":"sprites/s_node_fluidSim_domain_queue/s_node_fluidSim_domain_queue.yy",},},
{"id":{"name":"sh_d3d_shadow_cube_depth","path":"shaders/sh_d3d_shadow_cube_depth/sh_d3d_shadow_cube_depth.yy",},},
{"id":{"name":"sh_camera","path":"shaders/sh_camera/sh_camera.yy",},},
{"id":{"name":"s_node_vfx_spawn","path":"sprites/s_node_vfx_spawn/s_node_vfx_spawn.yy",},},
{"id":{"name":"d3d_vec3","path":"scripts/d3d_vec3/d3d_vec3.yy",},},
@ -1564,7 +1577,9 @@
{"id":{"name":"s_node_character","path":"sprites/s_node_character/s_node_character.yy",},},
{"id":{"name":"s_node_pb_box_inset","path":"sprites/s_node_pb_box_inset/s_node_pb_box_inset.yy",},},
{"id":{"name":"node_glow","path":"scripts/node_glow/node_glow.yy",},},
{"id":{"name":"o_dialog_preview_snap","path":"objects/o_dialog_preview_snap/o_dialog_preview_snap.yy",},},
{"id":{"name":"sh_blend_min","path":"shaders/sh_blend_min/sh_blend_min.yy",},},
{"id":{"name":"d3d_gizmo_circle_z","path":"scripts/d3d_gizmo_circle_z/d3d_gizmo_circle_z.yy",},},
{"id":{"name":"sh_pb_shade_half","path":"shaders/sh_pb_shade_half/sh_pb_shade_half.yy",},},
{"id":{"name":"node_polar","path":"scripts/node_polar/node_polar.yy",},},
{"id":{"name":"s_node_twirl","path":"sprites/s_node_twirl/s_node_twirl.yy",},},
@ -1617,6 +1632,7 @@
{"id":{"name":"s_node_crop_content","path":"sprites/s_node_crop_content/s_node_crop_content.yy",},},
{"id":{"name":"draw_line_zigzag","path":"scripts/draw_line_zigzag/draw_line_zigzag.yy",},},
{"id":{"name":"sh_alpha_grey","path":"shaders/sh_alpha_grey/sh_alpha_grey.yy",},},
{"id":{"name":"sh_channel_R2B","path":"shaders/sh_channel_R2B/sh_channel_R2B.yy",},},
{"id":{"name":"s_node_rigidSim_activate","path":"sprites/s_node_rigidSim_activate/s_node_rigidSim_activate.yy",},},
{"id":{"name":"s_transparent","path":"sprites/s_transparent/s_transparent.yy",},},
{"id":{"name":"o_dialog_animation","path":"objects/o_dialog_animation/o_dialog_animation.yy",},},
@ -1660,6 +1676,7 @@
{"id":{"name":"sh_blink_extract","path":"shaders/sh_blink_extract/sh_blink_extract.yy",},},
{"id":{"name":"sh_outline_only","path":"shaders/sh_outline_only/sh_outline_only.yy",},},
{"id":{"name":"lcd_function","path":"scripts/lcd_function/lcd_function.yy",},},
{"id":{"name":"d3d_gizmo_line","path":"scripts/d3d_gizmo_line/d3d_gizmo_line.yy",},},
{"id":{"name":"s_node_destray","path":"sprites/s_node_destray/s_node_destray.yy",},},
{"id":{"name":"node_color_sampler","path":"scripts/node_color_sampler/node_color_sampler.yy",},},
{"id":{"name":"node_iterator_sort_output","path":"scripts/node_iterator_sort_output/node_iterator_sort_output.yy",},},
@ -1751,6 +1768,7 @@
{"id":{"name":"s_menu_transparent","path":"sprites/s_menu_transparent/s_menu_transparent.yy",},},
{"id":{"name":"node_pb_box_divide_grid","path":"scripts/node_pb_box_divide_grid/node_pb_box_divide_grid.yy",},},
{"id":{"name":"draw_tooltip","path":"scripts/draw_tooltip/draw_tooltip.yy",},},
{"id":{"name":"d3d_cylinder","path":"scripts/d3d_cylinder/d3d_cylinder.yy",},},
{"id":{"name":"sh_palette_replace","path":"shaders/sh_palette_replace/sh_palette_replace.yy",},},
{"id":{"name":"buffer_functions","path":"scripts/buffer_functions/buffer_functions.yy",},},
{"id":{"name":"key_press","path":"scripts/key_press/key_press.yy",},},
@ -1775,6 +1793,7 @@
{"id":{"name":"node_array_length","path":"scripts/node_array_length/node_array_length.yy",},},
{"id":{"name":"node_erode","path":"scripts/node_erode/node_erode.yy",},},
{"id":{"name":"sh_colours_replace","path":"shaders/sh_colours_replace/sh_colours_replace.yy",},},
{"id":{"name":"sh_channel_R2G","path":"shaders/sh_channel_R2G/sh_channel_R2G.yy",},},
{"id":{"name":"node_wrap_mesh","path":"scripts/node_wrap_mesh/node_wrap_mesh.yy",},},
{"id":{"name":"node_surface_to_buffer","path":"scripts/node_surface_to_buffer/node_surface_to_buffer.yy",},},
{"id":{"name":"node_curve","path":"scripts/node_curve/node_curve.yy",},},
@ -1792,6 +1811,7 @@
{"id":{"name":"node_pb_draw_rectangle","path":"scripts/node_pb_draw_rectangle/node_pb_draw_rectangle.yy",},},
{"id":{"name":"s_biterator_b_shape_idle","path":"sprites/s_biterator_b_shape_idle/s_biterator_b_shape_idle.yy",},},
{"id":{"name":"compat_path_array","path":"scripts/compat_path_array/compat_path_array.yy",},},
{"id":{"name":"o_dialog_preview_3d_settings","path":"objects/o_dialog_preview_3d_settings/o_dialog_preview_3d_settings.yy",},},
{"id":{"name":"sh_mirror_mask","path":"shaders/sh_mirror_mask/sh_mirror_mask.yy",},},
{"id":{"name":"node_export","path":"scripts/node_export/node_export.yy",},},
{"id":{"name":"controlPointBox","path":"scripts/controlPointBox/controlPointBox.yy",},},
@ -1879,6 +1899,7 @@
{"id":{"name":"node_strand_update","path":"scripts/node_strand_update/node_strand_update.yy",},},
{"id":{"name":"sh_grid_noise","path":"shaders/sh_grid_noise/sh_grid_noise.yy",},},
{"id":{"name":"draw_set_blend_mode","path":"scripts/draw_set_blend_mode/draw_set_blend_mode.yy",},},
{"id":{"name":"d3d_gizmo_line_dashed","path":"scripts/d3d_gizmo_line_dashed/d3d_gizmo_line_dashed.yy",},},
{"id":{"name":"gameframe_macros","path":"scripts/gameframe_macros/gameframe_macros.yy",},},
{"id":{"name":"s_node_trigger_bool","path":"sprites/s_node_trigger_bool/s_node_trigger_bool.yy",},},
{"id":{"name":"panel_color","path":"scripts/panel_color/panel_color.yy",},},
@ -1919,7 +1940,6 @@
{"id":{"name":"sh_sample","path":"shaders/sh_sample/sh_sample.yy",},},
{"id":{"name":"s_node_texture_map","path":"sprites/s_node_texture_map/s_node_texture_map.yy",},},
{"id":{"name":"fd_rectangle_create","path":"scripts/fd_rectangle_create/fd_rectangle_create.yy",},},
{"id":{"name":"d3d_gizmo","path":"scripts/d3d_gizmo/d3d_gizmo.yy",},},
{"id":{"name":"s_node_level_selector","path":"sprites/s_node_level_selector/s_node_level_selector.yy",},},
{"id":{"name":"random_function","path":"scripts/random_function/random_function.yy",},},
{"id":{"name":"s_node_input","path":"sprites/s_node_input/s_node_input.yy",},},
@ -2036,6 +2056,7 @@
{"id":{"name":"_f_p1","path":"fonts/_f_p1/_f_p1.yy",},},
{"id":{"name":"tuple_functions","path":"scripts/tuple_functions/tuple_functions.yy",},},
{"id":{"name":"curve_bezier_function","path":"scripts/curve_bezier_function/curve_bezier_function.yy",},},
{"id":{"name":"node_3d_mesh_obj","path":"scripts/node_3d_mesh_obj/node_3d_mesh_obj.yy",},},
{"id":{"name":"sh_blur_simple","path":"shaders/sh_blur_simple/sh_blur_simple.yy",},},
{"id":{"name":"sh_blend_difference","path":"shaders/sh_blend_difference/sh_blend_difference.yy",},},
{"id":{"name":"s_node_image_animation","path":"sprites/s_node_image_animation/s_node_image_animation.yy",},},

Binary file not shown.

View file

@ -433,6 +433,11 @@ event_inherited();
draw_sprite_ui_uniform(THEME.node_new_badge, 1, _boxx + grid_size - ui(12), yy + ui(6));
}
if(_node.deprecated) {
draw_sprite_ui_uniform(THEME.node_deprecated_badge, 0, _boxx + grid_size - ui(12), yy + ui(6),, COLORS._main_value_negative);
draw_sprite_ui_uniform(THEME.node_deprecated_badge, 1, _boxx + grid_size - ui(12), yy + ui(6));
}
var fav = array_exists(global.FAV_NODES, _node.node);
if(fav)
draw_sprite_ui_uniform(THEME.star, 0, _boxx + grid_size - ui(10), yy + grid_size - ui(10), 0.7, COLORS._main_accent, 1.);
@ -546,6 +551,12 @@ event_inherited();
tx += ui(40);
}
if(_node.deprecated) {
draw_sprite_ui_uniform(THEME.node_deprecated_badge, 0, tx + ui(16), yy + list_height / 2 + ui(1),, COLORS._main_value_negative);
draw_sprite_ui_uniform(THEME.node_deprecated_badge, 1, tx + ui(16), yy + list_height / 2 + ui(1));
tx += ui(40);
}
draw_set_text(f_p2, fa_left, fa_center, COLORS._main_text);
draw_text_add(tx, yy + list_height / 2, _node.getName());
@ -634,6 +645,7 @@ event_inherited();
if(is_string(_node)) continue;
if(ds_map_exists(search_map, _node.node)) continue;
if(_node[$ "deprecated"]) continue;
var match = string_partial_match(string_lower(_node.getName()), search_lower);
var param = "";

View file

@ -27,7 +27,7 @@ if(PANEL_GRAPH.project == noone || !PANEL_GRAPH.project.active)
tb_size.register();
draw_set_text(f_p1, fa_left, fa_center, COLORS._main_text);
draw_text(dialog_x + ui(32), yy, __txtx("grid_size", "Grid size"));
tb_size.draw(dialog_x + dialog_w - ui(24), yy, ww, TEXTBOX_HEIGHT, PANEL_GRAPH.project.graphGrid.size, mouse_ui,, fa_right, fa_center);
tb_size.draw(dialog_x + dialog_w - ui(24), yy, ww, TEXTBOX_HEIGHT, PANEL_GRAPH.project.graphGrid.size, mouse_ui, fa_right, fa_center);
yy += ui(40);
sl_opacity.setFocusHover(sFOCUS, sHOVER);

View file

@ -29,8 +29,10 @@ if !ready exit;
draw_text(dialog_x + ui(32), yy, _text);
var params = new widgetParam(dialog_x + dialog_w - ui(16) - ww, yy - wh / 2, ww, wh, _data);
if(is_instanceof(_widg, checkBox))
if(is_instanceof(_widg, checkBox)) {
params.halign = fa_center;
params.valign = fa_center;
}
_widg.drawParam(params);

View file

@ -0,0 +1,41 @@
/// @description init
event_inherited();
#region data
dialog_w = ui(320);
destroy_on_click_out = true;
preview_panel = noone;
#endregion
#region data
properties = [
[
new checkBox(function() { preview_panel.d3_scene_light_enabled = !preview_panel.d3_scene_light_enabled; }),
__txt("Preview Light"),
function() { return preview_panel.d3_scene_light_enabled },
],
[
new buttonColor(function(col) {
preview_panel.d3_scene.lightAmbient = col; }),
__txt("Ambient Color"),
function() { return preview_panel.d3_scene.lightAmbient },
],
[
new slider(0, 1, 0.01, function(val) {
preview_panel.d3_scene_light0.intensity = val;
preview_panel.d3_scene_light1.intensity = val;
}),
__txt("Light Intensity"),
function() { return preview_panel.d3_scene_light0.intensity },
],
[
new checkBox(function() {
preview_panel.d3_scene_light0.shadow_active = !preview_panel.d3_scene_light0.shadow_active; }),
__txt("Shadow"),
function() { return preview_panel.d3_scene_light0.shadow_active },
],
]
dialog_h = ui(60 + 40 * array_length(properties));
#endregion

View file

@ -0,0 +1,41 @@
/// @description init
if !ready exit;
#region base UI
draw_sprite_stretched(THEME.dialog_bg, 0, dialog_x, dialog_y, dialog_w, dialog_h);
if(sFOCUS)
draw_sprite_stretched_ext(THEME.dialog_active, 0, dialog_x, dialog_y, dialog_w, dialog_h, COLORS._main_accent, 1);
draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text);
draw_text(dialog_x + ui(24), dialog_y + ui(16), __txtx("preview_3d_settings", "3D Preview Settings"));
#endregion
#region draw
var yy = dialog_y + ui(64);
var ww = ui(128);
var wh = TEXTBOX_HEIGHT;
for( var i = 0, n = array_length(properties); i < n; i++ ) {
var _prop = properties[i];
var _widg = _prop[0];
var _text = _prop[1];
var _data = _prop[2]();
_widg.setFocusHover(sFOCUS, sHOVER);
_widg.register();
draw_set_text(f_p1, fa_left, fa_center, COLORS._main_text);
draw_text(dialog_x + ui(32), yy, _text);
var params = new widgetParam(dialog_x + dialog_w - ui(16) - ww, yy - wh / 2, ww, wh, _data);
if(is_instanceof(_widg, checkBox)) {
params.halign = fa_center;
params.valign = fa_center;
}
_widg.drawParam(params);
yy += ui(40);
}
#endregion

View file

@ -0,0 +1,37 @@
{
"resourceType": "GMObject",
"resourceVersion": "1.0",
"name": "o_dialog_preview_3d_settings",
"eventList": [
{"resourceType":"GMEvent","resourceVersion":"1.0","name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,},
{"resourceType":"GMEvent","resourceVersion":"1.0","name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,},
],
"managed": true,
"overriddenProperties": [],
"parent": {
"name": "preview",
"path": "folders/dialog/preview.yy",
},
"parentObjectId": {
"name": "_p_dialog",
"path": "objects/_p_dialog/_p_dialog.yy",
},
"persistent": false,
"physicsAngularDamping": 0.1,
"physicsDensity": 0.5,
"physicsFriction": 0.2,
"physicsGroup": 1,
"physicsKinematic": false,
"physicsLinearDamping": 0.1,
"physicsObject": false,
"physicsRestitution": 0.1,
"physicsSensor": false,
"physicsShape": 1,
"physicsShapePoints": [],
"physicsStartAwake": true,
"properties": [],
"solid": false,
"spriteId": null,
"spriteMaskId": null,
"visible": true,
}

View file

@ -0,0 +1,31 @@
/// @description init
event_inherited();
#region data
dialog_w = ui(320);
destroy_on_click_out = true;
preview_panel = noone;
#endregion
#region data
properties = [
[
new checkBox(function() { preview_panel.d3_tool_snap = !preview_panel.d3_tool_snap; }),
__txt("Snap"),
function() { return preview_panel.d3_tool_snap },
],
[
new textBox(TEXTBOX_INPUT.number, function(val) { preview_panel.d3_tool_snap_position = val; }),
__txt("Linear"),
function() { return preview_panel.d3_tool_snap_position },
],
[
new textBox(TEXTBOX_INPUT.number, function(val) { preview_panel.d3_tool_snap_rotation = val; }),
__txt("Rotation"),
function() { return preview_panel.d3_tool_snap_rotation },
],
]
dialog_h = ui(60 + 40 * array_length(properties));
#endregion

View file

@ -0,0 +1,41 @@
/// @description init
if !ready exit;
#region base UI
draw_sprite_stretched(THEME.dialog_bg, 0, dialog_x, dialog_y, dialog_w, dialog_h);
if(sFOCUS)
draw_sprite_stretched_ext(THEME.dialog_active, 0, dialog_x, dialog_y, dialog_w, dialog_h, COLORS._main_accent, 1);
draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text);
draw_text(dialog_x + ui(24), dialog_y + ui(16), __txtx("preview_3d_settings", "3D Preview Settings"));
#endregion
#region draw
var yy = dialog_y + ui(64);
var ww = ui(128);
var wh = TEXTBOX_HEIGHT;
for( var i = 0, n = array_length(properties); i < n; i++ ) {
var _prop = properties[i];
var _widg = _prop[0];
var _text = _prop[1];
var _data = _prop[2]();
_widg.setFocusHover(sFOCUS, sHOVER);
_widg.register();
draw_set_text(f_p1, fa_left, fa_center, COLORS._main_text);
draw_text(dialog_x + ui(32), yy, _text);
var params = new widgetParam(dialog_x + dialog_w - ui(16) - ww, yy - wh / 2, ww, wh, _data);
if(is_instanceof(_widg, checkBox)) {
params.halign = fa_center;
params.valign = fa_center;
}
_widg.drawParam(params);
yy += ui(40);
}
#endregion

View file

@ -0,0 +1,37 @@
{
"resourceType": "GMObject",
"resourceVersion": "1.0",
"name": "o_dialog_preview_snap",
"eventList": [
{"resourceType":"GMEvent","resourceVersion":"1.0","name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,},
{"resourceType":"GMEvent","resourceVersion":"1.0","name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,},
],
"managed": true,
"overriddenProperties": [],
"parent": {
"name": "preview",
"path": "folders/dialog/preview.yy",
},
"parentObjectId": {
"name": "_p_dialog",
"path": "objects/_p_dialog/_p_dialog.yy",
},
"persistent": false,
"physicsAngularDamping": 0.1,
"physicsDensity": 0.5,
"physicsFriction": 0.2,
"physicsGroup": 1,
"physicsKinematic": false,
"physicsLinearDamping": 0.1,
"physicsObject": false,
"physicsRestitution": 0.1,
"physicsSensor": false,
"physicsShape": 1,
"physicsShapePoints": [],
"physicsStartAwake": true,
"properties": [],
"solid": false,
"spriteId": null,
"spriteMaskId": null,
"visible": true,
}

View file

@ -301,6 +301,10 @@
NODE_COLOR_SHOW_PALETTE = false;
#endregion
#region 3D
set3DGlobalPreview();
#endregion
#region debug
//instance_create_depth(0, 0, 0, addon_key_displayer);
#endregion

View file

@ -139,12 +139,3 @@ if(PROJECT.active) {
}
}
#endregion
//print("===== Step end =====");
//if(keyboard_check_pressed(ord("Q"))) {
// if(key_mod_press(CTRL))
// print(panelSerializeArray());
// else
// print(panelSerialize());
//}

View file

@ -156,9 +156,9 @@ function BBMOD_Quaternion(_x=0.0, _y=0.0, _z=0.0, _w=1.0) constructor
gml_pragma("forceinline");
_angle = -_angle;
var _sinHalfAngle = dsin(_angle * 0.5);
X = _axis.X * _sinHalfAngle;
Y = _axis.Y * _sinHalfAngle;
Z = _axis.Z * _sinHalfAngle;
X = is_nan(_axis.X)? 0 : _axis.X * _sinHalfAngle;
Y = is_nan(_axis.Y)? 0 : _axis.Y * _sinHalfAngle;
Z = is_nan(_axis.Z)? 0 : _axis.Z * _sinHalfAngle;
W = dcos(_angle * 0.5);
return self;
};

View file

@ -0,0 +1,12 @@
function __3dGizmo() : __3dObject() constructor {
vertex = [];
VF = global.VF_POS_COL;
render_type = pr_linelist;
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",
"isCompatibility": false,
"isDnD": false,
"parent": {
"name": "gizmo",
"path": "folders/functions/3d/gizmo.yy",
},
}

View file

@ -2,6 +2,12 @@ function Node_3D(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constr
name = "3D";
is_3D = true;
w = 64;
h = 64;
min_h = h;
mesh_prev_surface = surface_create(64, 64);
static drawOverlay3D = function(active, params, _mx, _my, _snx, _sny, _panel) {}
static processData = function(_outSurf, _data, _output_index, _array_index) {}
@ -26,4 +32,46 @@ function Node_3D(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constr
} #endregion
static getPreviewObjectOutline = function() { return getPreviewObject() }
static refreshPreview = function() { #region
var _prev_obj = getPreviewObject();
mesh_prev_surface = surface_verify(mesh_prev_surface, 64, 64);
surface_set_target(mesh_prev_surface);
DRAW_CLEAR
gpu_set_zwriteenable(true);
gpu_set_ztestenable(true);
gpu_set_cullmode(cull_noculling);
D3D_GLOBAL_PREVIEW.applyCamera();
D3D_GLOBAL_PREVIEW.apply();
for( var i = 0, n = array_length(_prev_obj); i < n; i++ ) {
var _prev = _prev_obj[i];
if(_prev == noone) continue;
var _b = _prev.getBBOX();
var _c = _prev.getCenter();
if(_b == noone || _c == noone) continue;
D3D_GLOBAL_PREVIEW.custom_transform.set(_c);
var _sca = 1 / _b.getMaximumScale();
D3D_GLOBAL_PREVIEW.custom_scale.set(_sca);
_prev.submitUI(D3D_GLOBAL_PREVIEW);
}
surface_reset_target();
D3D_GLOBAL_PREVIEW.resetCamera();
} #endregion
static postUpdate = function() { refreshPreview(); }
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover = false, _focus = false) { #region
if(!is_surface(mesh_prev_surface)) return;
var bbox = drawGetBbox(xx, yy, _s);
draw_surface_bbox(mesh_prev_surface, bbox);
} #endregion
}

View file

@ -4,20 +4,22 @@ function Node_3D_Light(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group)
if(!LOADING && !APPENDING)
inputs[| 0].setValue([ 0, 0, 1 ]);
inputs[| in_d3d + 0] = nodeValue("Color", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_white);
inputs[| in_d3d + 0] = nodeValue("Active", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
inputs[| in_d3d + 1] = nodeValue("Intensity", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
inputs[| in_d3d + 1] = nodeValue("Color", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_white);
inputs[| in_d3d + 2] = nodeValue("Intensity", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
.setDisplay(VALUE_DISPLAY.slider, [ 0, 1, 0.01 ]);
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], in_d3d + 0, in_d3d + 1
#macro __d3d_input_list_light ["Light", false], in_d3d + 0, in_d3d + 1, in_d3d + 2
static setLight = function(light, _data) {
var _col = _data[in_d3d + 0];
var _int = _data[in_d3d + 1];
var _col = _data[in_d3d + 1];
var _int = _data[in_d3d + 2];
light.color = _col;
light.intensity = _int;
@ -25,16 +27,14 @@ function Node_3D_Light(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group)
return light;
}
static processData = function(_output, _data, _output_index, _array_index = 0) {
var object = new __3dLight();
setTransform(object, _data);
setLight(object, _data);
return object;
}
static processData = function(_output, _data, _output_index, _array_index = 0) { }
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
var _colr = current_data[in_d3d + 1];
var bbox = drawGetBbox(xx, yy, _s);
draw_set_color(_colr);
draw_circle(bbox.xc, bbox.yc, 8 * _s, false);
draw_circle(bbox.xc, bbox.yc, 12 * _s, true);
}
}

View file

@ -8,8 +8,4 @@ function Node_3D_Mesh(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group) c
#macro __d3d_input_list_mesh ["Mesh", false]
static processData = function(_output, _data, _output_index, _array_index = 0) {}
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
}
}

View file

@ -1,7 +1,7 @@
function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constructor {
name = "3D Object";
h = 64;
min_h = h;
cached_object = [];
object_class = noone;
preview_channel = 0;
@ -24,6 +24,7 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr
drag_delta = 0;
drag_prev = 0;
drag_val = 0;
drag_mx = 0;
drag_my = 0;
drag_px = 0;
@ -124,7 +125,7 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr
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)
continue;
@ -215,11 +216,11 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr
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))
drag_val[i] += prj.getIndex(i) * _dist;
if(inputs[| index].setValue(value_snap(drag_val, _snx)))
UNDO_HOLDING = true;
}
} else {
@ -239,9 +240,9 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr
var _diff = mAdj.subtract(drag_prev);
for( var i = 0; i < 3; i++ )
_pos[i] += _diff.getIndex(i);
if(inputs[| index].setValue(_pos))
drag_val[i] += _diff.getIndex(i);
if(inputs[| index].setValue(value_snap(drag_val, _snx)))
UNDO_HOLDING = true;
}
}
@ -263,7 +264,8 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr
drag_py = _my;
drag_cx = cx;
drag_cy = cy;
drag_val = _pos;
drag_original = new __vec3(_pos);
} #endregion
} #endregion
@ -345,7 +347,7 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr
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);
@ -353,12 +355,19 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr
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();
drag_val = _currR.Mul(drag_val);
var _axs = drag_val.GetAxis();
var _ang = drag_val.GetAngle();
var _ans = value_snap(_ang, _sny);
var _NrotE = new BBMOD_Quaternion().FromAxisAngle(_axs, -_ans);
var _Nrot = _NrotE.ToArray();
if(inputs[| index].setValue(_Nrot))
UNDO_HOLDING = true;
}
}
draw_set_color(COLORS._main_accent);
draw_line_dashed(cx, cy, _mx, _my, 1, 4);
@ -369,6 +378,9 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr
if(_hover != noone && mouse_press(mb_left, active)) { #region
drag_axis = _hover;
drag_prev = undefined;
drag_axs = undefined;
drag_val = _qrot.Clone();
} #endregion
} #endregion
@ -514,9 +526,9 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr
var _dist = _diff.dot(prj);
for( var i = 0; i < 3; i++ )
_sca[i] += prj.getIndex(i) * _dist;
drag_val[i] += prj.getIndex(i) * _dist;
if(inputs[| index].setValue(_sca))
if(inputs[| index].setValue(value_snap(drag_val, _snx)))
UNDO_HOLDING = true;
}
} else {
@ -535,9 +547,9 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr
var _diff = mAdj.subtract(drag_prev);
for( var i = 0; i < 3; i++ )
_sca[i] += _diff.getIndex(i);
drag_val[i] += _diff.getIndex(i);
if(inputs[| index].setValue(_sca))
if(inputs[| index].setValue(value_snap(drag_val, _snx)))
UNDO_HOLDING = true;
}
}
@ -560,6 +572,7 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr
drag_cx = cx;
drag_cy = cy;
drag_val = _sca;
drag_original = new __vec3(_sca);
} #endregion
} #endregion
@ -583,6 +596,7 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr
} #endregion
static setTransform = function(object, _data) { #region
if(object == noone) return;
var _pos = _data[0];
var _rot = _data[1];
var _sca = _data[2];
@ -592,4 +606,19 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr
object.scale.set(_sca[0], _sca[1], _sca[2]);
return object;
} #endregion
static newObject = function() { return object_class == noone? noone : new object_class(); }
static getObject = function(index, class = object_class) { #region
var _obj = array_safe_get(cached_object, index, noone);
if(_obj == noone) {
_obj = newObject();
} else if(!is_instanceof(_obj, class)) {
_obj.destroy();
_obj = newObject();
}
cached_object[index] = _obj;
return _obj;
} #endregion
}

View file

@ -9,18 +9,25 @@ MATRIX_IDENTITY = matrix_build_identity();
global.format_pc = vertex_format_end();
#endregion
function vertex_add_pt(vertex, position, texture) {
vertex_position_3d(vertex, position[0], position[1], position[2]);
vertex_texcoord(vertex, texture[0], texture[1]);
function vertex_add_pt(buffer, position, texture) {
vertex_position_3d(buffer, position[0], position[1], position[2]);
vertex_texcoord(buffer, texture[0], texture[1]);
}
function vertex_add_pnt(vertex, position, normal, texture) {
vertex_position_3d(vertex, position[0], position[1], position[2]);
vertex_normal(vertex, normal[0], normal[1], normal[2]);
vertex_texcoord(vertex, texture[0], texture[1]);
function vertex_add_pnt(buffer, position, normal, texture) {
vertex_position_3d(buffer, position[0], position[1], position[2]);
vertex_normal(buffer, normal[0], normal[1], normal[2]);
vertex_texcoord(buffer, texture[0], texture[1]);
}
function vertex_add_2pc(vertex, _x, _y, color, alpha = 1) {
vertex_position(vertex, _x, _y);
vertex_color(vertex, color, alpha);
function vertex_add_pntc(buffer, position, normal, texture, color = c_white, alpha = 1) {
vertex_position_3d(buffer, position[0], position[1], position[2]);
vertex_normal(buffer, normal[0], normal[1], normal[2]);
vertex_texcoord(buffer, texture[0], texture[1]);
vertex_color(buffer, color, alpha);
}
function vertex_add_2pc(buffer, _x, _y, color, alpha = 1) {
vertex_position(buffer, _x, _y);
vertex_color(buffer, color, alpha);
}

View file

@ -9,7 +9,9 @@ function array_create_from_list(list) {
}
function array_safe_set(arr, index, value, fill = 0) {
if(!is_array(arr)) return arr;
if(!is_array(arr)) return arr;
if(is_array(index)) return arr;
if(index < 0) return arr;
if(index >= array_length(arr)) {
var i = array_length(arr);
@ -42,7 +44,8 @@ enum ARRAY_OVERFLOW {
function array_safe_get(arr, index, def = 0, overflow = ARRAY_OVERFLOW._default) {
gml_pragma("forceinline");
if(!is_array(arr)) return def;
if(!is_array(arr)) return def;
if(is_array(index)) return def;
if(overflow == ARRAY_OVERFLOW.loop) {
var len = array_length(arr);

View file

@ -24,15 +24,21 @@ function checkBox(_onClick) : widget() constructor {
static drawParam = function(params) {
var ss = params.s;
var x0;
var x0, y0;
switch(params.halign) {
case fa_left : x0 = params.x; break;
case fa_center : x0 = params.x + (params.w - ss) / 2; break;
case fa_right : x0 = params.x + params.w - ss; break;
case fa_right : x0 = params.x + params.w - ss; break;
}
return draw(x0, params.y, params.data, params.m, params.s);
switch(params.valign) {
case fa_top : y0 = params.y; break;
case fa_center : y0 = params.y + (params.h - ss) / 2; break;
case fa_bottom : y0 = params.y + params.h - ss; break;
}
return draw(x0, y0, params.data, params.m, params.s);
}
static draw = function(_x, _y, _value, _m, ss = ui(28), halign = fa_left, valign = fa_top) {

View file

@ -8,10 +8,12 @@ function d3_normalize(vec) {
return vec;
}
function d3_cross_product(a, b, result) {
function d3_cross_product(a, b) {
var ax = a[0], ay = a[1], az = a[2],
bx = b[0], by = b[1], bz = b[2];
result[@ 0] = ay * bz - az * by;
result[@ 1] = az * bx - ax * bz;
result[@ 2] = ax * by - ay * bx;
var result = [];
result[0] = ay * bz - az * by;
result[1] = az * bx - ax * bz;
result[2] = ax * by - ay * bx;
return result;
}

View file

@ -0,0 +1,22 @@
function __bbox3D(first, second) constructor {
self.first = first;
self.second = second;
static getScale = function() {
gml_pragma("forceinline");
return sqrt(
sqr(first.x - second.x) +
sqr(first.y - second.y) +
sqr(first.z - second.z)
);
}
static getMaximumScale = function() {
gml_pragma("forceinline");
return max(
abs(first.x - second.x),
abs(first.y - second.y),
abs(first.z - second.z),
);
}
}

View file

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

View file

@ -9,6 +9,8 @@ function __3dCamera() constructor {
focus = new __vec3();
up = new __vec3(0, 0, -1);
raw = camera_create();
useFocus = true;
focus_angle_x = 0;
focus_angle_y = 0;
@ -17,8 +19,8 @@ function __3dCamera() constructor {
projection = CAMERA_PROJECTION.perspective;
fov = 60;
view_near = 1;
view_far = 32000;
view_near = .01;
view_far = 100;
view_w = 1;
view_h = 1;
@ -40,18 +42,26 @@ function __3dCamera() constructor {
return upVector._normalize();
}
static applyCamera = function(cam) {
camera_set_proj_mat(cam, projMat.raw);
camera_set_view_mat(cam, viewMat.raw);
static applyCamera = function() {
camera_set_proj_mat(raw, projMat.raw);
camera_set_view_mat(raw, viewMat.raw);
camera_apply(cam);
camera_apply(raw);
}
static resetCamera = function() {
camera_apply(0);
gpu_set_cullmode(cull_noculling);
}
static setMatrix = function() {
if(projection == CAMERA_PROJECTION.perspective)
projMat.setRaw(matrix_build_projection_perspective_fov(fov, view_aspect, view_near, view_far));
else
else {
projMat.setRaw(matrix_build_projection_ortho(view_w, view_h, view_near, view_far));
//print($"{view_w}, {view_h}, {view_near}, {view_far}")
//print(projMat);
}
if(useFocus)
viewMat.setRaw(matrix_build_lookat(position.x, position.y, position.z, focus.x, focus.y, focus.z, up.x, up.y, up.z));

View file

@ -5,7 +5,7 @@
"isCompatibility": false,
"isDnD": false,
"parent": {
"name": "3d",
"path": "folders/functions/3d.yy",
"name": "mesh",
"path": "folders/functions/3d/mesh.yy",
},
}

View file

@ -0,0 +1,113 @@
function __3dCylinder(radius = 0.5, height = 1, sides = 8, smooth = false) : __3dObject() constructor {
VF = global.VF_POS_NORM_TEX_COL;
render_type = pr_trianglelist;
self.radius = radius;
self.height = height;
self.sides = sides;
self.smooth = smooth;
static initModel = function() {
var v0 = array_create(3 * sides);
var v1 = array_create(3 * sides);
var n0 = array_create(3 * sides);
var n1 = array_create(3 * sides);
var u0 = array_create(3 * sides);
var u1 = array_create(3 * sides);
var _h = height / 2;
for( var i = 0; i < sides; i++ ) {
var a0 = (i + 0) / sides * 360;
var a1 = (i + 1) / sides * 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);
v0[i * 3 + 0] = [ 0, 0, _h];
v0[i * 3 + 1] = [x0, y0, _h];
v0[i * 3 + 2] = [x1, y1, _h];
v1[i * 3 + 0] = [ 0, 0, -_h];
v1[i * 3 + 1] = [x0, y0, -_h];
v1[i * 3 + 2] = [x1, y1, -_h];
n0[i * 3 + 0] = [ 0, 0, 1];
n0[i * 3 + 1] = [ 0, 0, 1];
n0[i * 3 + 2] = [ 0, 0, 1];
n1[i * 3 + 0] = [ 0, 0, -1];
n1[i * 3 + 1] = [ 0, 0, -1];
n1[i * 3 + 2] = [ 0, 0, -1];
var _u0 = 0.5 + lengthdir_x(0.5, a0);
var _v0 = 0.5 + lengthdir_y(0.5, a0);
var _u1 = 0.5 + lengthdir_x(0.5, a1);
var _v1 = 0.5 + lengthdir_y(0.5, a1);
u0[i * 3 + 0] = [ 0.5, 0.5];
u0[i * 3 + 1] = [ _u0, _v0];
u0[i * 3 + 2] = [ _u1, _v1];
u1[i * 3 + 0] = [ 0.5, 0.5];
u1[i * 3 + 1] = [ _u0, _v0];
u1[i * 3 + 2] = [ _u1, _v1];
}
var vs = array_create(3 * sides * 2);
var ns = array_create(3 * sides * 2);
var us = array_create(3 * sides * 2);
for( var i = 0; i < sides; i++ ) {
var a0 = (i + 0) / sides * 360;
var a1 = (i + 1) / sides * 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);
vs[i * 3 * 2 + 0] = [x0, y0, _h];
vs[i * 3 * 2 + 1] = [x1, y1, _h];
vs[i * 3 * 2 + 2] = [x0, y0, -_h];
vs[i * 3 * 2 + 3] = [x0, y0, -_h];
vs[i * 3 * 2 + 4] = [x1, y1, _h];
vs[i * 3 * 2 + 5] = [x1, y1, -_h];
var nx0 = smooth? lengthdir_x(1, a0) : lengthdir_x(1, (a0 + a1) / 2);
var ny0 = smooth? lengthdir_y(1, a0) : lengthdir_y(1, (a0 + a1) / 2);
var nx1 = smooth? lengthdir_x(1, a1) : lengthdir_x(1, (a0 + a1) / 2);
var ny1 = smooth? lengthdir_y(1, a1) : lengthdir_y(1, (a0 + a1) / 2);
ns[i * 3 * 2 + 0] = [nx0, ny0, 0];
ns[i * 3 * 2 + 1] = [nx1, ny1, 0];
ns[i * 3 * 2 + 2] = [nx0, ny0, 0];
ns[i * 3 * 2 + 3] = [nx0, ny0, 0];
ns[i * 3 * 2 + 4] = [nx1, ny1, 0];
ns[i * 3 * 2 + 5] = [nx1, ny1, 0];
var ux0 = (i + 0) / sides;
var ux1 = (i + 1) / sides;
us[i * 3 * 2 + 0] = [ux0, 0];
us[i * 3 * 2 + 1] = [ux1, 0];
us[i * 3 * 2 + 2] = [ux0, 1];
us[i * 3 * 2 + 3] = [ux0, 1];
us[i * 3 * 2 + 4] = [ux1, 0];
us[i * 3 * 2 + 5] = [ux1, 1];
}
vertex = [ v0, v1, vs ];
normals = [ n0, n1, ns ];
uv = [ u0, u1, us ];
VB = build();
} initModel();
static onParameterUpdate = initModel;
}

View file

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

View file

@ -1,3 +0,0 @@
function __3dGizmo() constructor {
}

View file

@ -0,0 +1,18 @@
function __3dGizmoCircleZ(radius = 0.5, color = c_white, alpha = 1) : __3dGizmo() constructor {
vertex = array_create(33 * 2);
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++] = [ x0, y0, 0, color, alpha ];
vertex[_i++] = [ x1, y1, 0, color, alpha ];
}
VB = build();
}

View file

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

View file

@ -0,0 +1,7 @@
function __3dGizmoLine(from, to, color = c_white, alpha = 1) : __3dGizmo() constructor {
vertex = [
[ from.x, from.y, from.z, color, alpha ],
[ to.x, to.y, to.z, color, alpha ],
];
VB = build();
}

View file

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

View file

@ -0,0 +1,14 @@
function __3dGizmoLineDashed(from, to, dash = 0.1, color = c_white, alpha = 1) : __3dGizmo() constructor {
var _dist = from.distance(to);
var _dash = max(2, ceil(_dist / dash));
vertex = array_create(_dash);
for( var i = 0; i < _dash; i++ ) {
var prog = i / (_dash - 1);
vertex[i] = [ lerp(from.x, to.x, prog),
lerp(from.y, to.y, prog),
lerp(from.z, to.z, prog),
color, alpha ]
}
VB = build();
}

View file

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

View file

@ -1,4 +1,4 @@
function __3dGizmoSphere(radius = 0.5, color = c_white, alpha = 1) : __3dObject() constructor {
function __3dGizmoSphere(radius = 0.5, color = c_white, alpha = 1) : __3dGizmo() constructor {
vertex = array_create(33 * 3);
var _i = 0;
@ -17,14 +17,6 @@ function __3dGizmoSphere(radius = 0.5, color = c_white, alpha = 1) : __3dObject(
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();
}
VB = build();
}

View file

@ -1,6 +1,45 @@
function __3dGroup() constructor {
objects = [];
static getCenter = function() {
var _v = new __vec3();
var _i = 0;
for( var i = 0, n = array_length(objects); i < n; i++ ) {
var _c = objects[i].getCenter();
if(_c == noone) continue;
_v._add(objects[i].getCenter());
_i++;
}
return _i == 0? new __vec3() : _v.multiply(1 / _i);
}
static getBBOX = function() {
if(array_empty(objects)) return new __bbox3D(new __vec3(-0.5), new __vec3(0.5));
var _m0 = noone;
var _m1 = noone;
var _cc = getCenter();
for( var i = 0, n = array_length(objects); i < n; i++ ) {
var _c = objects[i].getCenter();
var _b = objects[i].getBBOX();
if(_c == noone || _b == noone) continue;
var _n0 = _b.first.add(_c);
var _n1 = _b.second.add(_c);
_m0 = _m0 == noone? _n0 : _m0.minVal(_n0);
_m1 = _m1 == noone? _n1 : _m1.maxVal(_n1);
}
_m0._subtract(_cc);
_m1._subtract(_cc);
return new __bbox3D(_m0, _m1);
}
static _submit = function(callback, params = {}, shader = noone) {
for( var i = 0, n = array_length(objects); i < n; i++ )
callback(objects[i], params, shader);
@ -8,6 +47,11 @@ function __3dGroup() constructor {
static submitShader = function(params = {}) { _submit(function(_obj, params) { _obj.submitShader(params); }, params); }
static submitSel = function(params = {}) { _submit(function(_obj, params) { _obj.submitSel(params); }, params); }
static submitUI = function(params = {}, shader = noone) { _submit(function(_obj, params, shader) { _obj.submitUI(params, shader); }, params); }
static submit = function(params = {}, shader = noone) { _submit(function(_obj, params, shader) { _obj.submit(params, shader); }, params); }
static submitUI = function(params = {}, shader = noone) { _submit(function(_obj, params, shader) { _obj.submitUI(params, shader); }, params, shader); }
static submit = function(params = {}, shader = noone) { _submit(function(_obj, params, shader) { _obj.submit(params, shader); }, params, shader); }
static map = function(callback, params = {}) {
for( var i = 0, n = array_length(objects); i < n; i++ )
callback(objects[i], params);
}
}

View file

@ -6,5 +6,41 @@ function __3dLight() : __3dObject() constructor {
color = c_white;
intensity = 1;
shadow_mapper = sh_d3d_shadow_depth;
shadow_active = false;
shadow_map = noone;
shadow_map_size = 1024;
shadow_map_scale = 256;
shadow_map_camera = camera_create();
shadow_map_view = array_create(16, 0);
shadow_map_proj = array_create(16, 0);
static getCenter = function() { return noone; }
static getBBOX = function() { return noone; }
static submit = function(params = {}, shader = noone) {}
static setShadow = function(active, shadowMapSize, shadowMapScale = shadow_map_scale) { #region
shadow_active = active;
shadow_map_size = shadowMapSize;
shadow_map_scale = shadowMapScale;
return self;
} #endregion
static shadowProjectBegin = function() {}
static shadowProjectEnd = function() {}
static shadowProjectVertex = function(scene, objects) { #region
if(!shadow_active) return;
shadowProjectBegin();
for( var i = 0, n = array_length(objects); i < n; i++ ) {
var _prev = objects[i];
if(_prev == noone) continue;
_prev.submit(scene, shadow_mapper);
}
shadowProjectEnd();
} #endregion
}

View file

@ -8,15 +8,17 @@ function __3dLightDirectional() : __3dLight() constructor {
intensity = 1;
position.set(4, 0, 0);
static submitSel = function(params = {}) {
shadow_mapper = sh_d3d_shadow_depth;
static submitSel = function(params = {}) { #region
shader_set(sh_d3d_wireframe);
preSubmitVertex(params);
shader_reset();
}
} #endregion
static submitShader = function(params = {}) { params.addLightDirectional(self); }
static preSubmitVertex = function(params = {}) {
static preSubmitVertex = function(params = {}) { #region
var _rot = new __rot3(0, 0, 0).lookAt(position, params.camera.position);
var rot = matrix_build(0, 0, 0,
@ -42,5 +44,28 @@ function __3dLightDirectional() : __3dLight() constructor {
matrix_stack_clear();
matrix_set(matrix_world, matrix_build_identity());
}
} #endregion
static shadowProjectBegin = function() { #region
shadow_map = surface_verify(shadow_map, shadow_map_size, shadow_map_size, surface_r32float);
shadow_map_view = matrix_build_lookat(position.x, position.y, position.z, 0, 0, 0, 0, 0, -1);
shadow_map_proj = matrix_build_projection_ortho(shadow_map_size / shadow_map_scale, shadow_map_size / shadow_map_scale, .01, 100);
surface_set_target(shadow_map);
draw_clear(c_black);
shader_set(shadow_mapper);
gpu_set_ztestenable(true);
camera_set_view_mat(shadow_map_camera, shadow_map_view);
camera_set_proj_mat(shadow_map_camera, shadow_map_proj);
camera_apply(shadow_map_camera);
} #endregion
static shadowProjectEnd = function() { #region
shader_reset();
surface_reset_target();
camera_apply(0);
gpu_set_ztestenable(false);
} #endregion
}

View file

@ -3,6 +3,13 @@ function __3dLightPoint() : __3dLight() constructor {
intensity = 1;
radius = 10;
shadow_mapper = sh_d3d_shadow_depth;
shadow_map_size = 512;
shadow_map_scale = 128;
shadow_map_views = array_create(6);
shadow_maps = array_create(6);
static submitSel = function(params = {}) {
shader_set(sh_d3d_wireframe);
preSubmitVertex(params);
@ -11,7 +18,7 @@ function __3dLightPoint() : __3dLight() constructor {
static submitShader = function(params = {}) { params.addLightPoint(self); }
static preSubmitVertex = function(params = {}) {
static preSubmitVertex = function(params = {}) { #region
var _rot = new __rot3(0, 0, 0).lookAt(position, params.camera.position);
var rot = matrix_build(0, 0, 0,
@ -46,5 +53,75 @@ function __3dLightPoint() : __3dLight() constructor {
matrix_stack_clear();
matrix_set(matrix_world, matrix_build_identity());
}
} #endregion
static shadowProjectBegin = function(index = 0) { #region
//print($"Projecting cube face {index} to {shadow_maps[index]} with view {shadow_map_views[index]}")
surface_set_target(shadow_maps[index]);
draw_clear(c_black);
shader_set(shadow_mapper);
gpu_set_ztestenable(true);
camera_set_view_mat(shadow_map_camera, shadow_map_views[index]);
camera_set_proj_mat(shadow_map_camera, shadow_map_proj);
camera_apply(shadow_map_camera);
} #endregion
static shadowProjectEnd = function() { #region
shader_reset();
surface_reset_target();
camera_apply(0);
gpu_set_ztestenable(false);
} #endregion
static shadowProjectVertex = function(scene, objects) { #region
if(!shadow_active) return;
for( var i = 0; i < 6; i++ )
shadow_maps[i] = surface_verify(shadow_maps[i], shadow_map_size, shadow_map_size, surface_r32float);
shadow_map_views = array_create(6);
shadow_map_views[0] = matrix_build_lookat(position.x, position.y, position.z, position.x + 1, position.y, position.z, 0, 0, -1);
shadow_map_views[1] = matrix_build_lookat(position.x, position.y, position.z, position.x - 1, position.y, position.z, 0, 0, -1);
shadow_map_views[2] = matrix_build_lookat(position.x, position.y, position.z, position.x, position.y + 1, position.z, 0, 0, -1);
shadow_map_views[3] = matrix_build_lookat(position.x, position.y, position.z, position.x, position.y - 1, position.z, 0, 0, -1);
shadow_map_views[4] = matrix_build_lookat(position.x, position.y, position.z, position.x, position.y, position.z + 1, 0, -1, 0);
shadow_map_views[5] = matrix_build_lookat(position.x, position.y, position.z, position.x, position.y, position.z - 1, 0, 1, 0);
shadow_map_view = array_merge( shadow_map_views[0], shadow_map_views[1], shadow_map_views[2], shadow_map_views[3], shadow_map_views[4], shadow_map_views[5] );
shadow_map_proj = matrix_build_projection_perspective_fov(90, 1, .01, radius);
for( var j = 0; j < 6; j++ ) { ///FUCK There's gotta be a better way to do this in GameMaker
shadowProjectBegin(j);
for( var i = 0, n = array_length(objects); i < n; i++ ) {
var _prev = objects[i];
if(_prev == noone) continue;
_prev.submit(scene, shadow_mapper);
}
shadowProjectEnd();
}
shadow_map = surface_verify(shadow_map, shadow_map_size * 2, shadow_map_size, surface_rgba32float);
surface_set_target(shadow_map);
draw_clear(c_black);
gpu_set_blendmode_ext(bm_one, bm_one);
draw_surface(shadow_maps[0], 0, 0);
draw_surface(shadow_maps[3], shadow_map_size, 0);
shader_set(sh_channel_R2G);
draw_surface(shadow_maps[1], 0, 0);
draw_surface(shadow_maps[4], shadow_map_size, 0);
shader_reset();
shader_set(sh_channel_R2B);
draw_surface(shadow_maps[2], 0, 0);
draw_surface(shadow_maps[5], shadow_map_size, 0);
shader_reset();
gpu_set_blendmode(bm_normal);
surface_reset_target();
} #endregion
}

View file

@ -22,13 +22,29 @@ function __3dObject() constructor {
custom_shader = noone;
position = new __vec3(0, 0, 0);
position = new __vec3(0);
rotation = new BBMOD_Quaternion();
scale = new __vec3(1, 1, 1);
scale = new __vec3(1);
size = new __vec3(1);
texture = -1;
static buildVertex = function(_vertex, _normal, _uv) {
static checkParameter = function(params = {}) { #region
var _keys = struct_get_names(params);
var check = false;
for( var i = 0, n = array_length(_keys); i < n; i++ ) {
var key = _keys[i];
if(self[$ key] != params[$ key])
check = true;
self[$ key] = params[$ key];
}
if(check) onParameterUpdate();
} #endregion
static onParameterUpdate = function() {}
static buildVertex = function(_vertex, _normal, _uv) { #region
var _buffer = vertex_create_buffer();
vertex_begin(_buffer, VF);
for( var i = 0, n = array_length(_vertex); i < n; i++ ) {
@ -48,17 +64,14 @@ function __3dObject() constructor {
var cc = array_length(v) > 3? v[3] : c_white;
var aa = array_length(v) > 4? v[4] : 1;
vertex_position_3d(_buffer, v[0], v[1], v[2]);
vertex_normal(_buffer, nor[0], nor[1], nor[2]);
vertex_texcoord(_buffer, uuv[0], uuv[1]);
vertex_color(_buffer, cc, aa);
vertex_add_pntc(_buffer, v, nor, uuv, cc, aa);
break;
}
}
vertex_end(_buffer);
return _buffer;
}
} #endregion
static build = function(_buffer = VB, _vertex = vertex, _normal = normals, _uv = uv) { #region
if(is_array(_buffer)) {
@ -81,6 +94,9 @@ function __3dObject() constructor {
static preSubmitVertex = function(params = {}) {}
static postSubmitVertex = function(params = {}) {}
static getCenter = function() { return new __vec3(position.x, position.y, position.z); }
static getBBOX = function() { return new __bbox3D(size.multiplyVec(scale).multiply(-0.5), size.multiplyVec(scale).multiply(0.5)); }
static submitShader = function(params = {}, shader = noone) {}
static submit = function(params = {}, shader = noone) { submitVertex(params, shader); }
@ -102,19 +118,37 @@ function __3dObject() constructor {
preSubmitVertex(params);
if(VB != noone) {
var pos = matrix_build(position.x, position.y, position.z,
0, 0, 0,
1, 1, 1);
var rot = rotation.ToMatrix();
var sca = matrix_build(0, 0, 0,
0, 0, 0,
scale.x, scale.y, scale.z);
matrix_stack_clear();
matrix_stack_push(pos);
matrix_stack_push(rot);
matrix_stack_push(sca);
matrix_set(matrix_world, matrix_stack_top());
if(params.apply_transform) {
var pos = matrix_build(position.x, position.y, position.z,
0, 0, 0,
1, 1, 1);
var rot = rotation.ToMatrix();
var sca = matrix_build(0, 0, 0,
0, 0, 0,
scale.x, scale.y, scale.z);
matrix_stack_push(pos);
matrix_stack_push(rot);
matrix_stack_push(sca);
matrix_set(matrix_world, matrix_stack_top());
} else {
var pos = matrix_build(position.x - params.custom_transform.x, position.y - params.custom_transform.y, position.z - params.custom_transform.z,
0, 0, 0,
1, 1, 1);
var siz = matrix_build(0, 0, 0,
0, 0, 0,
scale.x, scale.y, scale.z);
var sca = matrix_build(0, 0, 0,
0, 0, 0,
params.custom_scale.x, params.custom_scale.y, params.custom_scale.z);
matrix_stack_push(pos);
matrix_stack_push(siz);
matrix_stack_push(sca);
matrix_set(matrix_world, matrix_stack_top());
}
if(is_array(VB)) {
for( var i = 0, n = array_length(VB); i < n; i++ )
@ -130,4 +164,20 @@ function __3dObject() constructor {
shader_reset();
} #endregion
static clone = function() { #region
var _obj = variable_clone(self);
return _obj;
} #endregion
static destroy = function() { #region
if(is_array(VB)) {
for( var i = 0, n = array_length(VB); i < n; i++ )
vertex_delete_buffer(VB[i]);
} else if(VB != noone)
vertex_delete_buffer(VB);
onDestroy();
} #endregion
static onDestroy = function() { }
}

View file

@ -1,13 +1,3 @@
function __ray(origin, direction) constructor {
self.origin = origin;
self.direction = direction.normalize();
static sampleDistance = function(t) {
gml_pragma("forceinline");
return origin.add(direction.multiply(t));
}
}
function __plane(origin, normal) constructor {
self.origin = origin;
self.normal = normal.normalize();

View file

@ -0,0 +1,9 @@
function __ray(origin, direction) constructor {
self.origin = origin;
self.direction = direction.normalize();
static sampleDistance = function(t) {
gml_pragma("forceinline");
return origin.add(direction.multiply(t));
}
}

View file

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

View file

@ -51,7 +51,8 @@ function __rot3(_x = 0, _y = 0, _z = 0) constructor {
var w0 = new __vec3( -dir.y, dir.x, 0);
var u0 = w0.cross(dir);
var ax = arctan2( w0.dot(up) / w0.length(), u0.dot(up) / u0.length() );
if(is_nan(ax)) ax = 0;
ax = radtodeg(ax);
ay = radtodeg(ay);
az = radtodeg(az);

View file

@ -1,65 +1,161 @@
#region global preview camera
globalvar D3D_GLOBAL_PREVIEW;
function set3DGlobalPreview() {
var d3_view_camera = new __3dCamera();
d3_view_camera.setViewSize(2, 2);
d3_view_camera.setFocusAngle(135, 45, 8);
d3_view_camera.position.set(calculate_3d_position(0, 0, 0, d3_view_camera.focus_angle_x, d3_view_camera.focus_angle_y, d3_view_camera.focus_dist));
d3_view_camera.projection = CAMERA_PROJECTION.orthograph;
d3_view_camera.setMatrix();
D3D_GLOBAL_PREVIEW = new __3dScene(d3_view_camera);
D3D_GLOBAL_PREVIEW.apply_transform = false;
var d3_scene_light0 = new __3dLightDirectional();
d3_scene_light0.position.set(-1, -2, 3);
d3_scene_light0.color = $AAAAAA;
var d3_scene_light1 = new __3dLightDirectional();
d3_scene_light1.position.set(1, 2, 3);
d3_scene_light1.color = $FFFFFF;
D3D_GLOBAL_PREVIEW.lightAmbient = $404040;
D3D_GLOBAL_PREVIEW.addLightDirectional(d3_scene_light0);
D3D_GLOBAL_PREVIEW.addLightDirectional(d3_scene_light1);
}
#endregion
function __3dScene(camera) constructor {
self.camera = camera;
name = "New scene";
lightAmbient = c_black;
lightDir_count = 0;
lightDir_direction = [];
lightDir_color = [];
lightDir_intensity = [];
apply_transform = true;
custom_transform = new __vec3();
custom_scale = new __vec3(1, 1, 1);
lightPnt_count = 0;
lightPnt_position = [];
lightPnt_color = [];
lightPnt_intensity = [];
lightPnt_radius = [];
lightAmbient = c_black;
lightDir_max = 16;
lightDir_shadow_max = 4;
lightPnt_max = 16;
lightPnt_shadow_max = 4;
gammaCorrection = true;
static reset = function() {
lightDir_count = 0;
lightDir_direction = [];
lightDir_color = [];
lightDir_intensity = [];
lightDir_shadow_count = 0;
lightDir_shadow = [];
lightDir_shadowMap = [];
lightDir_viewMat = [];
lightDir_projMat = [];
lightDir_shadowBias = .001;
lightPnt_count = 0;
lightPnt_position = [];
lightPnt_color = [];
lightPnt_intensity = [];
lightPnt_radius = [];
}
lightPnt_shadow_count = 0;
lightPnt_shadow = [];
lightPnt_shadowMap = [];
lightPnt_viewMat = [];
lightPnt_projMat = [];
} reset();
static applyCamera = function() { camera.applyCamera(); }
static resetCamera = function() { camera.resetCamera(); }
static apply = function() {
shader_set(sh_d3d_default);
shader_set_f("light_ambient", colToVec4(lightAmbient));
shader_set_i("light_dir_count", lightDir_count);
shader_set_f("light_dir_direction", lightDir_direction);
shader_set_f("light_dir_color", lightDir_color);
shader_set_f("light_dir_intensity", lightDir_intensity);
if(lightDir_count) {
shader_set_f("light_dir_direction", lightDir_direction);
shader_set_f("light_dir_color", lightDir_color);
shader_set_f("light_dir_intensity", lightDir_intensity);
shader_set_i("light_dir_shadow_active", lightDir_shadow);
for( var i = 0, n = array_length(lightDir_shadowMap); i < n; i++ )
shader_set_surface($"light_dir_shadowmap_{i}", lightDir_shadowMap[i], true);
shader_set_f("light_dir_view", lightDir_viewMat);
shader_set_f("light_dir_proj", lightDir_projMat);
shader_set_f("shadowBias", lightDir_shadowBias);
}
shader_set_i("light_pnt_count", lightPnt_count);
shader_set_f("light_pnt_position", lightPnt_position);
shader_set_f("light_pnt_color", lightPnt_color);
shader_set_f("light_pnt_intensity", lightPnt_intensity);
shader_set_f("light_pnt_radius", lightPnt_radius);
if(lightPnt_count) {
shader_set_f("light_pnt_position", lightPnt_position);
shader_set_f("light_pnt_color", lightPnt_color);
shader_set_f("light_pnt_intensity", lightPnt_intensity);
shader_set_f("light_pnt_radius", lightPnt_radius);
shader_set_i("light_pnt_shadow_active", lightPnt_shadow);
for( var i = 0, n = array_length(lightPnt_shadowMap); i < n; i++ )
shader_set_surface($"light_pnt_shadowmap_{i}", lightPnt_shadowMap[i], true, true);
shader_set_f("light_pnt_view", lightPnt_viewMat);
shader_set_f("light_pnt_proj", lightPnt_projMat);
}
//print($"Scene {name} submit {lightPnt_position} point lights");
shader_set_i("gammaCorrection", gammaCorrection);
shader_reset();
}
static addLightDirectional = function(light) {
if(lightDir_count >= lightDir_max) {
noti_warning("Direction light limit exceeded");
return self;
}
array_append(lightDir_direction, [ light.position.x, light.position.y, light.position.z ]);
array_append(lightDir_color, colToVec4(light.color));
array_append(lightDir_intensity, [ light.intensity ]);
array_push(lightDir_intensity, light.intensity);
array_push(lightDir_shadow, light.shadow_active);
if(light.shadow_active) {
if(lightDir_shadow_count < lightDir_shadow_max) {
array_push(lightDir_shadowMap, light.shadow_map);
lightDir_shadow_count++;
} else
noti_warning("Direction light shadow caster limit exceeded");
}
array_append(lightDir_viewMat, light.shadow_map_view);
array_append(lightDir_projMat, light.shadow_map_proj);
lightDir_count++;
return self;
}
static addLightPoint = function(light) {
if(lightPnt_count >= lightPnt_max) {
noti_warning("Point light limit exceeded");
return self;
}
array_append(lightPnt_position, [ light.position.x, light.position.y, light.position.z ]);
array_append(lightPnt_color, colToVec4(light.color));
array_append(lightPnt_intensity, [ light.intensity ]);
array_append(lightPnt_radius, [ light.radius ]);
array_push(lightPnt_intensity, light.intensity);
array_push(lightPnt_radius, light.radius);
array_push(lightPnt_shadow, light.shadow_active);
if(light.shadow_active) {
if(lightPnt_shadow_count < lightPnt_shadow_max) {
array_push(lightPnt_shadowMap, light.shadow_map);
lightPnt_shadow_count++;
} else
noti_warning("Point light shadow caster limit exceeded");
}
array_append(lightPnt_viewMat, light.shadow_map_view);
array_append(lightPnt_projMat, light.shadow_map_proj);
lightPnt_count++;
return self;

View file

@ -0,0 +1,100 @@
function __3dUVSphere(radius = 0.5, hori = 16, vert = 8, smt = false) : __3dObject() constructor {
VF = global.VF_POS_NORM_TEX_COL;
render_type = pr_trianglelist;
self.radius = radius;
self.hori = hori;
self.vert = vert;
self.smooth = smt;
static initModel = function() { // swap H, V because fuck me
vertex = array_create(vert * hori * 2 * 3);
normals = array_create(vert * hori * 2 * 3);
uv = array_create(vert * hori * 2 * 3);
var amo = 0;
for (var i = 0; i < vert; i++)
for (var j = 0; j < hori; j++) {
var ha0 = (i + 0) / vert * 360;
var ha1 = (i + 1) / vert * 360;
var va0 = 90 - (j + 0) / hori * 180;
var va1 = 90 - (j + 1) / hori * 180;
var h0 = dsin(va0) * 0.5;
var h1 = dsin(va1) * 0.5;
var r0 = dcos(va0) * 0.5;
var r1 = dcos(va1) * 0.5;
var hx0 = dcos(ha0) * r0;
var hy0 = dsin(ha0) * r0;
var hz0 = h0;
var hx1 = dcos(ha1) * r0;
var hy1 = dsin(ha1) * r0;
var hz1 = h0;
var hx2 = dcos(ha0) * r1;
var hy2 = dsin(ha0) * r1;
var hz2 = h1;
var hx3 = dcos(ha1) * r1;
var hy3 = dsin(ha1) * r1;
var hz3 = h1;
var u0 = ha0 / 360;
var v0 = 0.5 - 0.5 * dsin(va0);
var u1 = ha1 / 360;
var v1 = 0.5 - 0.5 * dsin(va0);
var u2 = ha0 / 360;
var v2 = 0.5 - 0.5 * dsin(va1);
var u3 = ha1 / 360;
var v3 = 0.5 - 0.5 * dsin(va1);
var ind = (i * hori + j) * 6;
vertex[ind + 0] = [hx0, hy0, hz0];
vertex[ind + 1] = [hx1, hy1, hz1];
vertex[ind + 2] = [hx2, hy2, hz2];
vertex[ind + 3] = [hx1, hy1, hz1];
vertex[ind + 4] = [hx2, hy2, hz2];
vertex[ind + 5] = [hx3, hy3, hz3];
if(smooth) {
normals[ind + 0] = d3_normalize([hx0, hy0, hz0]);
normals[ind + 1] = d3_normalize([hx1, hy1, hz1]);
normals[ind + 2] = d3_normalize([hx2, hy2, hz2]);
normals[ind + 3] = d3_normalize([hx1, hy1, hz1]);
normals[ind + 4] = d3_normalize([hx2, hy2, hz2]);
normals[ind + 5] = d3_normalize([hx3, hy3, hz3]);
} else {
var nor = d3_cross_product([hx2 - hx0, hy2 - hy0, hz2 - hz0], [hx1 - hx0, hy1 - hy0, hz1 - hz0]);
nor = d3_normalize(nor);
normals[ind + 0] = nor;
normals[ind + 1] = nor;
normals[ind + 2] = nor;
normals[ind + 3] = nor;
normals[ind + 4] = nor;
normals[ind + 5] = nor;
}
uv[ind + 0] = [u0, v0];
uv[ind + 1] = [u1, v1];
uv[ind + 2] = [u2, v2];
uv[ind + 3] = [u1, v1];
uv[ind + 4] = [u2, v2];
uv[ind + 5] = [u3, v3];
}
VB = build();
} initModel();
static onParameterUpdate = initModel;
}

View file

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

View file

@ -2,7 +2,7 @@
#macro __vec3_right new __vec3(0.0, 1.0, 0.0)
#macro __vec3_up new __vec3(0.0, 0.0, 1.0)
function __vec3(_x = 0, _y = 0, _z = 0) constructor {
function __vec3(_x = 0, _y = _x, _z = _x) constructor {
static set = function(_x = 0, _y = _x, _z = _x) {
if(is_struct(_x) && is_instanceof(_x, __vec3)) {
x = _x.x;
@ -70,6 +70,11 @@ function __vec3(_x = 0, _y = 0, _z = 0) constructor {
return new __vec3(x * _scalar, y * _scalar, z * _scalar);
}
static multiplyVec = function(_vec) {
gml_pragma("forceinline");
return new __vec3(x * _vec.x, y * _vec.y, z * _vec.z);
}
static divide = function(_scalar) {
gml_pragma("forceinline");
if (_scalar != 0)
@ -116,6 +121,14 @@ function __vec3(_x = 0, _y = 0, _z = 0) constructor {
return self;
}
static _multiplyVec = function(_vec) {
gml_pragma("forceinline");
x *= _vec.x;
y *= _vec.y;
z *= _vec.z;
return self;
}
static _divide = function(_scalar) {
gml_pragma("forceinline");
if (_scalar != 0) {
@ -174,6 +187,24 @@ function __vec3(_x = 0, _y = 0, _z = 0) constructor {
return x == to.x && y == to.y && z == to.z;
}
static minVal = function(vec) {
gml_pragma("forceinline");
return new __vec3(
min(x, vec.x),
min(y, vec.y),
min(z, vec.z),
);
}
static maxVal = function(vec) {
gml_pragma("forceinline");
return new __vec3(
max(x, vec.x),
max(y, vec.y),
max(z, vec.z),
);
}
static clone = function() {
gml_pragma("forceinline");
return new __vec3(x, y, z);

View file

@ -1,4 +1,4 @@
function __vec4(_x = 0, _y = 0, _z = 0, _w = 0) constructor {
function __vec4(_x = 0, _y = _x, _z = _x, _w = _x) constructor {
static set = function(_x = 0, _y = _x, _z = _x, _w = _x) {
if (is_struct(_x)) {
if(is_instanceof(_x, __vec4)) {
@ -166,6 +166,26 @@ function __vec4(_x = 0, _y = 0, _z = 0, _w = 0) constructor {
return x == to.x && y == to.y && z == to.z && w == to.w;
}
static minVal = function(vec) {
gml_pragma("forceinline");
return new __vec4(
min(x, vec.x),
min(y, vec.y),
min(z, vec.z),
min(w, vec.w),
);
}
static maxVal = function(vec) {
gml_pragma("forceinline");
return new __vec4(
max(x, vec.x),
max(y, vec.y),
max(z, vec.z),
max(w, vec.w),
);
}
static clone = function() {
gml_pragma("forceinline");
return new __vec4(x, y, z, w);

View file

@ -15,7 +15,7 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover = false, _foc
var lb_y = yy + lb_h / 2;
var butx = xx;
if(jun.connect_type == JUNCTION_CONNECT.input && jun.isAnimable() && !jun.expUse) {
if(jun.connect_type == JUNCTION_CONNECT.input && jun.isAnimable() && !jun.expUse) { #region animation
var index = jun.value_from == noone? jun.is_anim : 2;
draw_sprite_ui_uniform(THEME.animate_clock, index, butx, lb_y, 1, index == 2? COLORS._main_accent : c_white, 0.8);
if(_hover && point_in_circle(_m[0], _m[1], butx, lb_y, ui(10))) {
@ -36,13 +36,13 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover = false, _foc
PANEL_ANIMATION.updatePropertyList();
}
}
}
} #endregion
if(anim_hold != noone && mouse_release(mb_left))
anim_hold = noone;
butx += ui(20);
if(!global_var) {
if(!global_var) { #region visibility
index = jun.visible;
draw_sprite_ui_uniform(THEME.junc_visible, index, butx, lb_y, 1,, 0.8);
if(_hover && point_in_circle(_m[0], _m[1], butx, lb_y, ui(10))) {
@ -57,6 +57,7 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover = false, _foc
visi_hold = jun.visible;
}
}
#endregion
} else
draw_sprite_ui_uniform(THEME.node_use_expression, 0, butx, lb_y, 1,, 0.8);
@ -192,7 +193,7 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover = false, _foc
var widH = lineBreak? editBoxH : 0;
var mbRight = true;
if(jun.expUse) {
if(jun.expUse) { #region expression editor
var expValid = jun.expTree != noone && jun.expTree.validate();
jun.express_edit.boxColor = expValid? COLORS._main_value_positive : COLORS._main_value_negative;
jun.express_edit.rx = rx;
@ -203,7 +204,8 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover = false, _foc
var wd_h = jun.express_edit.draw(editBoxX, editBoxY, editBoxW, editBoxH, jun.expression, _m);
widH = wd_h - (TEXTBOX_HEIGHT * !lineBreak);
} else if(jun.editWidget) {
#endregion
} else if(jun.editWidget) { #region edit widget
jun.editWidget.setFocusHover(_focus, _hover);
if(jun.connect_type == JUNCTION_CONNECT.input) {
@ -213,11 +215,6 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover = false, _foc
jun.editWidget.setInteract(false);
}
//if(jun.display_type == VALUE_DISPLAY.area) {
// print("======= Show value widget =====");
// print(jun.animator.values[| 0].value);
// print(jun.showValue());
//}
var param = new widgetParam(editBoxX, editBoxY, editBoxW, editBoxH, jun.showValue(), jun.extra_data, _m, rx, ry);
switch(jun.type) {
@ -241,19 +238,15 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover = false, _foc
var _widH = jun.editWidget.drawParam(param) ?? 0;
widH = _widH - (TEXTBOX_HEIGHT * !lineBreak);
} else if(jun.display_type == VALUE_DISPLAY.label) {
#endregion
} else if(jun.display_type == VALUE_DISPLAY.label) { #region label
draw_set_text(f_p1, fa_left, fa_top, COLORS._main_text_sub);
draw_text_add(xx + ui(16), _hsy, jun.display_data);
widH = string_height(jun.display_data);
#endregion
} else
widH = 0;
//draw_set_color(c_white);
//draw_rectangle(xx, yy, xx + ww, yy + widH, true);
//draw_set_color(c_red);
//draw_line(xx + ww / 2, yy, xx + ww / 2, yy + widH);
return [ widH, mbRight ];
}

View file

@ -3,6 +3,10 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group)
object = new __3dCamera_object();
camera = new __3dCamera();
lookat = new __3dGizmoSphere(0.5, c_ltgray, 1);
lookLine = noone;
lookRad = new __3dGizmoCircleZ(0.5, c_yellow, 0.5);
w = 128;
scene = new __3dScene(camera);
scene.name = "Camera";
@ -10,7 +14,7 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group)
inputs[| in_d3d + 0] = nodeValue("FOV", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 60)
.setDisplay(VALUE_DISPLAY.slider, [ 10, 90, 1 ]);
inputs[| in_d3d + 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, [ 0.01, 100 ])
.setDisplay(VALUE_DISPLAY.vector);
inputs[| in_d3d + 2] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF )
@ -171,6 +175,7 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group)
camera.rotation = new BBMOD_Quaternion().FromLookRotation(_for, camera.up).Mul(_qi1).Mul(_qi2);
lookat.position.set(_look);
lookLine = new __3dGizmoLineDashed(camera.position, camera.focus, 0.25, c_gray, 1);
break;
case 2 :
camera.useFocus = true;
@ -184,11 +189,18 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group)
camera.rotation = new BBMOD_Quaternion().FromLookRotation(_for, camera.up).Mul(_qi1).Mul(_qi3);
lookat.position.set(_look);
lookLine = new __3dGizmoLineDashed(camera.position, camera.focus, 0.25, c_gray, 1);
var _camRad = camera.position.subtract(camera.focus);
var _rad = point_distance(0, 0, _camRad.x, _camRad.y) * 2;
lookRad.scale.set(_rad, _rad, 1);
lookRad.position.set(new __vec3(camera.focus.x, camera.focus.y, camera.position.z));
break;
}
object.position.set(camera.position);
object.rotation = camera.rotation.Clone();
object.scale.set(1, _dim[0] / _dim[1], 1);
if(_scne == noone) return;
@ -211,17 +223,17 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group)
gpu_set_ztestenable(true);
gpu_set_cullmode(_back);
var cam = camera_get_active();
camera.applyCamera(cam);
camera.applyCamera();
scene.reset();
_scne.submitShader(scene);
scene.apply();
_scne.submit(scene); //////////////// SUBMIT ////////////////
surface_reset_target();
gpu_set_cullmode(cull_noculling);
scene.resetCamera();
return _output;
} #endregion
@ -239,8 +251,8 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group)
switch(_posm) {
case 0 : return [ object, _scene ];
case 1 : return [ object, lookat, _scene ];
case 2 : return [ object, lookat, _scene ];
case 1 : return [ object, lookat, lookLine, _scene ];
case 2 : return [ object, lookat, lookLine, lookRad, _scene ];
}
return [ object, _scene ];

View file

@ -1,16 +1,37 @@
function Node_3D_Light_Directional(_x, _y, _group = noone) : Node_3D_Light(_x, _y, _group) constructor {
name = "Directional Light";
name = "Directional Light";
object_class = __3dLightDirectional;
inputs[| in_light + 0] = nodeValue("Cast Shadow", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
inputs[| in_light + 1] = nodeValue("Shadow Map Size", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1024);
inputs[| in_light + 2] = nodeValue("Shadow Map Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 256);
input_display_list = [
["Transform", false], 0,
__d3d_input_list_light,
["Shadow", false], in_light + 0, in_light + 1, in_light + 2,
]
tools = [ tool_pos ];
tool_settings = [];
tool_attribute.context = 1;
static processData = function(_output, _data, _output_index, _array_index = 0) {
var object = new __3dLightDirectional();
var _active = _data[in_d3d + 0];
if(!_active) return noone;
var _shadow_active = _data[in_light + 0];
var _shadow_map_size = _data[in_light + 1];
var _shadow_map_scal = _data[in_light + 2];
var object = getObject(_array_index);
setTransform(object, _data);
setLight(object, _data);
object.setShadow(_shadow_active, _shadow_map_size, _shadow_map_scal);
var _rot = new __rot3().lookAt(object.position, new __vec3());
object.rotation.FromEuler(_rot.x, _rot.y, _rot.z);

View file

@ -1,21 +1,38 @@
function Node_3D_Light_Point(_x, _y, _group = noone) : Node_3D_Light(_x, _y, _group) constructor {
name = "Point Light";
object_class = __3dLightPoint;
inputs[| in_light + 0] = nodeValue("Radius", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 4)
inputs[| in_light + 1] = nodeValue("Cast Shadow", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
inputs[| in_light + 2] = nodeValue("Shadow Map Size", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1024);
input_display_list = [
["Transform", false], 0,
__d3d_input_list_light, in_light,
["Shadow", false], in_light + 1, in_light + 2, in_light + 3,
]
tools = [ tool_pos ];
tool_settings = [];
tool_attribute.context = 1;
static processData = function(_output, _data, _output_index, _array_index = 0) {
var object = new __3dLightPoint();
var _active = _data[in_d3d + 0];
if(!_active) return noone;
var _radius = _data[in_light + 0];
var _shadow_active = _data[in_light + 1];
var _shadow_map_size = _data[in_light + 2];
var object = getObject(_array_index);
setTransform(object, _data);
setLight(object, _data);
var _rad = inputs[| in_light + 0].getValue();
object.radius = _rad;
object.setShadow(_shadow_active, _shadow_map_size);
object.radius = _radius;
return object;
}

View file

@ -1,19 +1,21 @@
function Node_3D_Mesh_Cube(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _group) constructor {
name = "3D Cube";
object_class = noone;
inputs[| in_mesh + 0] = nodeValue("Texture per side", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false );
inputs[| in_mesh + 1] = nodeValue("Texture", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone );
inputs[| in_mesh + 2] = nodeValue("Texture 2", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone );
inputs[| in_mesh + 2] = nodeValue("Texture Bottom", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone );
inputs[| in_mesh + 3] = nodeValue("Texture 3", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone );
inputs[| in_mesh + 3] = nodeValue("Texture Left", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone );
inputs[| in_mesh + 4] = nodeValue("Texture 4", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone );
inputs[| in_mesh + 4] = nodeValue("Texture Right", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone );
inputs[| in_mesh + 5] = nodeValue("Texture 5", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone );
inputs[| in_mesh + 5] = nodeValue("Texture Back", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone );
inputs[| in_mesh + 6] = nodeValue("Texture 6", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone );
inputs[| in_mesh + 6] = nodeValue("Texture Front", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone );
input_display_list = [
__d3d_input_list_mesh,
@ -22,10 +24,15 @@ function Node_3D_Mesh_Cube(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _group
in_mesh + 4, in_mesh + 5, in_mesh + 6,
]
static newObject = function(_side) {
if(_side) return new __3dCubeFaces();
return new __3dCube();
}
static step = function() { #region
var _tex_side = inputs[| in_mesh + 0].getValue();
inputs[| in_mesh + 1].name = _tex_side? "Texture 1" : "Texture";
inputs[| in_mesh + 1].name = _tex_side? "Texture Top" : "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);
@ -45,12 +52,12 @@ function Node_3D_Mesh_Cube(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _group
var object;
if(_tex_side) {
object = new __3dCubeFaces();
object = getObject(_array_index, __3dCubeFaces);
object.texture = [ surface_texture(_tex_1), surface_texture(_tex_2),
surface_texture(_tex_3), surface_texture(_tex_4),
surface_texture(_tex_5), surface_texture(_tex_6) ];
} else {
object = new __3dCube();
object = getObject(_array_index, __3dCube);
object.texture = surface_texture(_tex_1);
}

View file

@ -0,0 +1,39 @@
function Node_3D_Mesh_Cylinder(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _group) constructor {
name = "3D Cylinder";
object_class = __3dCylinder;
inputs[| in_mesh + 0] = nodeValue("Side", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 8 );
inputs[| in_mesh + 1] = nodeValue("Texture Top", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone );
inputs[| in_mesh + 2] = nodeValue("Texture Bottom", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone );
inputs[| in_mesh + 3] = nodeValue("Texture Side", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone );
inputs[| in_mesh + 4] = nodeValue("Smooth Side", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false );
input_display_list = [
__d3d_input_list_mesh, in_mesh + 0, in_mesh + 4,
__d3d_input_list_transform,
["Texture", false], in_mesh + 1, in_mesh + 2, in_mesh + 3,
]
static processData = function(_output, _data, _output_index, _array_index = 0) { #region
var _side = _data[in_mesh + 0];
var _tex_top = _data[in_mesh + 1];
var _tex_bot = _data[in_mesh + 2];
var _tex_sid = _data[in_mesh + 3];
var _smt = _data[in_mesh + 4];
var object = getObject(_array_index);
object.checkParameter({sides: _side, smooth: _smt});
object.texture = [ surface_texture(_tex_top), surface_texture(_tex_bot), surface_texture(_tex_sid) ];
setTransform(object, _data);
return object;
} #endregion
static getPreviewValues = function() { return array_safe_get(all_inputs, in_mesh + 1, noone); }
}

View file

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

View file

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

View file

@ -0,0 +1,154 @@
function Node_create_3D_Obj(_x, _y, _group = noone) {
var path = "";
if(!LOADING && !APPENDING && !CLONING) {
path = get_open_filename(".obj", "");
key_release();
if(path == "") return noone;
}
var node = new Node_3D_Mesh_Obj(_x, _y, _group);
node.setPath(path);
return node;
}
function Node_create_3D_Obj_path(_x, _y, path) {
if(!file_exists(path)) return noone;
var node = new Node_3D_Mesh_Obj(_x, _y, PANEL_GRAPH.getCurrentContext());
node.setPath(path);
return node;
}
function Node_3D_Mesh_Obj(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _group) constructor {
name = "3D Obj";
object = noone;
object_class = __3dObject;
inputs[| in_mesh + 0] = nodeValue("File Path", self, JUNCTION_CONNECT.input, VALUE_TYPE.path, "" )
.setDisplay(VALUE_DISPLAY.path_load, [ "*.obj", "" ])
.rejectArray();
inputs[| in_mesh + 1] = nodeValue("Flip UV", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true, "Flip UV axis, can be use to fix some texture mapping error.")
.rejectArray();
input_display_list = [
__d3d_input_list_mesh,
__d3d_input_list_transform,
["Object", false], in_mesh + 0,
["Texture", false], in_mesh + 1,
]
input_fix_len = ds_list_size(inputs);
input_display_len = array_length(input_display_list);
current_path = "";
materials = [];
materialNames = [];
materialIndex = [];
use_normal = false;
function setPath(path) {
inputs[| in_mesh + 0].setValue(path);
updateObj(path);
}
static createMaterial = function(m_index) { #region
var index = ds_list_size(inputs);
inputs[| index] = nodeValue(materialNames[m_index] + " Texture", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone)
.setVisible(true, true);
input_display_list[input_display_len + m_index] = index;
if(m_index >= array_length(materials)) return;
var matY = y - (array_length(materials) - 1) / 2 * (128 + 32);
var mat = materials[m_index];
if(file_exists(mat.diff_path)) {
var sol = Node_create_Image_path(x - (w + 128), matY + m_index * (128 + 32), mat.diff_path);
sol.name = mat.name + " texture";
inputs[| index].setFrom(sol.outputs[| 0]);
} else {
var sol = nodeBuild("Node_Solid", x - (w + 128), matY + m_index * (128 + 32));
sol.name = mat.name + " texture";
sol.inputs[| 1].setValue(mat.diff);
inputs[| index].setFrom(sol.outputs[| 0]);
}
} #endregion
static updateObj = function(_path) { #region
if(!file_exists(_path)) return;
current_path = _path;
var _flip = inputs[| in_mesh + 1].getValue();
var _dir = filename_dir(_path);
var _pathMtl = string_copy(_path, 1, string_length(_path) - 4) + ".mtl";
var _v = readObj(_path, _flip);
if(_v == noone) return;
if(object != noone) object.destroy();
object = new __3dObject();
object.VB = _v.vertex_groups;
object.vertex = _v.vertex_positions;
object.normals = _v.vertex_normals;
object.uv = _v.vertex_textures;
object.size = _v.model_size;
materialNames = _v.materials;
materialIndex = _v.material_index;
use_normal = _v.use_normal;
if(_v.mtl_path != "")
_pathMtl = _dir + "/" + _v.mtl_path;
if(array_length(materialNames))
materials = readMtl(_pathMtl);
else {
materialNames = ["Material"];
materialIndex = [0];
materials = [ new MTLmaterial("Material") ];
}
array_resize(input_display_list, input_display_len);
while(ds_list_size(inputs) > input_fix_len)
ds_list_delete(inputs, input_fix_len);
for(var i = 0; i < array_length(materialNames); i++)
createMaterial(i);
triggerRender();
} #endregion
static step = function() { #region
} #endregion
static processData = function(_output, _data, _output_index, _array_index = 0) { #region
var _path = _data[in_mesh + 0];
if(_path != current_path)
updateObj(_path);
var textures = [];
for( var i = input_fix_len, n = array_length(_data); i < n; i++ )
textures[i - input_fix_len] = surface_texture(_data[i]);
var _object = getObject(_array_index);
if(object == noone)
return _object;
_object.VF = global.VF_POS_NORM_TEX_COL;
_object.VB = object.VB;
_object.vertex = object.vertex;
_object.normals = object.normals;
_object.uv = object.uv;
_object.texture = textures;
setTransform(_object, _data);
return _object;
} #endregion
//static getPreviewValues = function() { return array_safe_get(all_inputs, in_mesh + 1, noone); }
}

View file

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

View file

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

View file

@ -0,0 +1,36 @@
function Node_3D_Mesh_Sphere(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _group) constructor {
name = "3D Sphere";
object_class = __3dUVSphere;
inputs[| in_mesh + 0] = nodeValue("Horizontal Slices", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 16 );
inputs[| in_mesh + 1] = nodeValue("Vertical Slices", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 8 );
inputs[| in_mesh + 2] = nodeValue("Texture", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone );
inputs[| in_mesh + 3] = nodeValue("Smooth Normal", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false );
input_display_list = [
__d3d_input_list_mesh, in_mesh + 0, in_mesh + 1, in_mesh + 3,
__d3d_input_list_transform,
["Texture", false], in_mesh + 2,
]
static processData = function(_output, _data, _output_index, _array_index = 0) { #region
var _sideH = _data[in_mesh + 0];
var _sideV = _data[in_mesh + 1];
var _tex = _data[in_mesh + 2];
var _smt = _data[in_mesh + 3];
var object = getObject(_array_index);
object.checkParameter({hori: _sideH, vert: _sideV, smooth: _smt});
object.texture = surface_texture(_tex);
setTransform(object, _data);
return object;
} #endregion
static getPreviewValues = function() { return array_safe_get(all_inputs, in_mesh + 1, noone); }
}

View file

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

View file

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

View file

@ -1,24 +1,3 @@
function Node_create_3D_Obj(_x, _y, _group = noone) {
var path = "";
if(!LOADING && !APPENDING && !CLONING) {
path = get_open_filename(".obj", "");
key_release();
if(path == "") return noone;
}
var node = new Node_3D_Obj(_x, _y, _group);
node.setPath(path);
return node;
}
function Node_create_3D_Obj_path(_x, _y, path) {
if(!file_exists(path)) return noone;
var node = new Node_3D_Obj(_x, _y, PANEL_GRAPH.getCurrentContext());
node.setPath(path);
return node;
}
function Node_3D_Obj(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "3D Object";
@ -94,7 +73,7 @@ function Node_3D_Obj(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
["Textures", true], 12,
];
input_length = ds_list_size(inputs);
input_display_len = array_length(input_display_list);
input_display_len = array_length(input_display_list);
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
@ -110,6 +89,10 @@ function Node_3D_Obj(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
tex_surface = surface_create(1, 1);
materialNames = [];
materialIndex = [];
materials = [];
function reset_tex() {
tex_surface = surface_verify(tex_surface, 1, 1);
surface_set_target(tex_surface);
@ -153,10 +136,6 @@ function Node_3D_Obj(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
}
}
materialNames = [];
materialIndex = [];
materials = [];
static updateObj = function(updateMat = true) {
var _path = inputs[| 0].getValue();
if(!file_exists(_path)) return;

View file

@ -51,6 +51,4 @@ function Node_3D_Scene(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constru
return _scene;
}
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {}
}

View file

@ -137,17 +137,6 @@ function Node_Array(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
input_display_list = [ 0, array_adjust_tool, 1 ];
//var _typ = getType();
//for( var i = input_fix_len; i < ds_list_size(inputs); i++ ) {
// if(_typ != VALUE_TYPE.any)
// inputs[| i].type = _typ;
// inputs[| i].resetDisplay();
// if(_typ && inputs[| i].value_from && (value_bit(inputs[| i].value_from.type) & value_bit(_typ) == 0))
// inputs[| i].removeFrom();
//}
refreshDynamicInput();
}

View file

@ -614,12 +614,15 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
static drawGetBbox = function(xx, yy, _s) { #region
var pad_label = draw_name && display_parameter.avoid_label;
var _w = w - draw_padding * 2;
var _h = h - draw_padding * 2 - 20 * pad_label;
var _w = w;
var _h = h;
_w *= display_parameter.preview_scale / 100 * _s;
_h *= display_parameter.preview_scale / 100 * _s;
_w -= draw_padding * 2;
_h -= draw_padding * 2 + 20 * pad_label;
var _xc = xx + w * _s / 2;
var _yc = yy + (h * _s + 20 * pad_label) / 2;
@ -1024,6 +1027,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
outputs[| i].destroy();
onDestroy();
UPDATE |= RENDER_TYPE.full;
} #endregion
static restore = function() { #region

View file

@ -202,11 +202,6 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor {
var fTime = from.time;
var tTime = to.time;
//if(from > PROJECT.animator.frames_total) {
// fTime = fTime % PROJECT.animator.frames_total;
// tTime = tTime - PROJECT.animator.frames_total;
//}
var prog = PROJECT.animator.frames_total - fTime + _time;
var totl = PROJECT.animator.frames_total - fTime + tTime;

View file

@ -11,6 +11,7 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct
attributes.array_process = ARRAY_PROCESS.loop;
current_data = [];
inputs_data = [];
inputs_is_array = [];
all_inputs = [];
process_amount = 0;
@ -29,7 +30,7 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct
static processData = function(_outSurf, _data, _output_index, _array_index = 0) { return _outSurf; }
static getSingleValue = function(_index, _arr = 0, output = false) {
static getSingleValue = function(_index, _arr = 0, output = false) { #region
var _l = output? outputs : inputs;
var _n = _l[| _index];
var _in = _n.getValue();
@ -44,9 +45,9 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct
}
return array_safe_get(_in, _index);
}
} #endregion
static getDimension = function(arr = 0) {
static getDimension = function(arr = 0) { #region
if(dimension_index == -1) return [1, 1];
var _in = getSingleValue(dimension_index, arr);
@ -61,9 +62,9 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct
return _in;
return [1, 1];
}
} #endregion
static preProcess = function(outIndex) {
static preProcess = function(outIndex) { #region
var _out = outputs[| outIndex].getValue();
all_inputs = array_create(ds_list_size(inputs));
@ -128,15 +129,18 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct
for(var i = 0; i < ds_list_size(inputs); i++) { #region input preparation
var _in = inputs_data[i];
if(!inputs[| i].isArray(_in)) {
_data[i] = inputs_data[i];
if(!inputs_is_array[i]) {
_data[i] = _in;
all_inputs[i][l] = _data[i];
continue;
}
if(array_length(_in) == 0) {
_data[i] = 0;
all_inputs[i][l] = _data[i];
continue;
}
var _index = 0;
switch(attributes.array_process) {
case ARRAY_PROCESS.loop : _index = safe_mod(l, array_length(_in)); break;
@ -145,7 +149,7 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct
case ARRAY_PROCESS.expand_inv : _index = floor(l / process_length[ds_list_size(inputs) - 1 - i][1]) % process_length[i][0]; break;
}
_data[i] = _in[_index];
_data[i] = inputs[| i].arrayBalance(_in[_index]);
all_inputs[i][l] = _data[i];
} #endregion
@ -180,18 +184,20 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct
}
return _out;
}
} #endregion
static update = function(frame = PROJECT.animator.current_frame) { #region
process_amount = 0;
inputs_data = array_create(ds_list_size(inputs));
inputs_is_array = array_create(ds_list_size(inputs));
process_length = array_create(ds_list_size(inputs));
for(var i = 0; i < ds_list_size(inputs); i++) { //pre-collect current input data
var val = inputs[| i].getValue();
var amo = inputs[| i].arrayLength(val);
inputs_data[i] = val;
inputs_data[i] = val;
inputs_is_array[i] = inputs[| i].isArray(val);
switch(attributes.array_process) {
case ARRAY_PROCESS.loop :
@ -224,8 +230,12 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct
val = processData(noone, noone, i);
outputs[| i].setValue(val);
}
postUpdate();
} #endregion
static postUpdate = function() {}
static processSerialize = function(_map) { #region
_map.array_process = attributes.array_process;
} #endregion

View file

@ -5,7 +5,8 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor {
createNode = _create;
self.tags = tags;
tooltip = "";
tooltip = "";
deprecated = false;
var pth = DIRECTORY + "Nodes/tooltip/" + node + ".png";
if(file_exists(pth))
@ -26,6 +27,11 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor {
return self;
}
static isDeprecated = function() {
deprecated = true;
return self;
}
static getName = function() { return name; /*__txt_node_name(node, name); */ }
static getTooltip = function() { return tooltip; /*__txt_node_tooltip(node, tooltip); */ }
@ -354,27 +360,30 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor {
addNodeObject(threeD, "3D Camera", s_node_3d_cube, "Node_3D_Camera", [1, Node_3D_Camera]);
ds_list_add(threeD, "Mesh");
addNodeObject(threeD, "3D Cube", s_node_3d_cube, "Node_3D_Mesh_Cube", [1, Node_3D_Mesh_Cube]);
addNodeObject(threeD, "3D Object", s_node_3d_obj, "Node_3D_Mesh_Obj", [0, Node_create_3D_Obj],, "Load .obj file from your computer as a 3D object.");
addNodeObject(threeD, "3D Cube", s_node_3d_cube, "Node_3D_Mesh_Cube", [1, Node_3D_Mesh_Cube]);
addNodeObject(threeD, "3D Cylinder", s_node_3d_cylinder, "Node_3D_Mesh_Cylinder", [1, Node_3D_Mesh_Cylinder]);
addNodeObject(threeD, "3D Sphere", s_node_3d_sphere, "Node_3D_Mesh_Sphere", [1, Node_3D_Mesh_Sphere]);
ds_list_add(threeD, "Light");
addNodeObject(threeD, "Directional Light", s_node_3d_cube, "Node_3D_Light_Directional", [1, Node_3D_Light_Directional]);
addNodeObject(threeD, "Point Light", s_node_3d_cube, "Node_3D_Light_Point", [1, Node_3D_Light_Point]);
ds_list_add(threeD, "Legacy");
addNodeObject(threeD, "3D Object", s_node_3d_obj, "Node_3D_Obj", [0, Node_create_3D_Obj],, "Load .obj file from your computer as a 3D object.");
addNodeObject(threeD, "3D Plane", s_node_3d_plane, "Node_3D_Plane", [1, Node_3D_Plane],, "Put 2D image on a plane in 3D space.");
addNodeObject(threeD, "3D Cube", s_node_3d_cube, "Node_3D_Cube", [1, Node_3D_Cube]);
addNodeObject(threeD, "3D Cylinder", s_node_3d_cylinder, "Node_3D_Cylinder", [1, Node_3D_Cylinder]);
addNodeObject(threeD, "3D Sphere", s_node_3d_sphere, "Node_3D_Sphere", [1, Node_3D_Sphere]).setVersion(1090);
addNodeObject(threeD, "3D Cone", s_node_3d_cone, "Node_3D_Cone", [1, Node_3D_Cone]).setVersion(1090);
addNodeObject(threeD, "3D Extrude", s_node_3d_extrude, "Node_3D_Extrude", [1, Node_3D_Extrude],, "Extrude 2D image into 3D object.");
addNodeObject(threeD, "3D Object", s_node_3d_obj, "Node_3D_Obj", [1, Node_3D_Obj],, "Load .obj file from your computer as a 3D object.").isDeprecated();
addNodeObject(threeD, "3D Plane", s_node_3d_plane, "Node_3D_Plane", [1, Node_3D_Plane],, "Put 2D image on a plane in 3D space.").isDeprecated();
addNodeObject(threeD, "3D Cube", s_node_3d_cube, "Node_3D_Cube", [1, Node_3D_Cube]).isDeprecated();
addNodeObject(threeD, "3D Cylinder", s_node_3d_cylinder, "Node_3D_Cylinder", [1, Node_3D_Cylinder]).isDeprecated();
addNodeObject(threeD, "3D Sphere", s_node_3d_sphere, "Node_3D_Sphere", [1, Node_3D_Sphere]).setVersion(1090).isDeprecated();
addNodeObject(threeD, "3D Cone", s_node_3d_cone, "Node_3D_Cone", [1, Node_3D_Cone]).setVersion(1090).isDeprecated();
addNodeObject(threeD, "3D Extrude", s_node_3d_extrude, "Node_3D_Extrude", [1, Node_3D_Extrude],, "Extrude 2D image into 3D object.").isDeprecated();
addNodeObject(threeD, "3D Transform", s_node_3d_transform, "Node_3D_Transform", [1, Node_3D_Transform]).setVersion(1080);
addNodeObject(threeD, "3D Combine", s_node_3d_obj_combine, "Node_3D_Combine", [1, Node_3D_Combine],, "Combine multiple 3D object to a single scene,").setVersion(1080);
addNodeObject(threeD, "3D Repeat", s_node_3d_array, "Node_3D_Repeat", [1, Node_3D_Repeat], ["3d array"], "Repeat 3D object multiple times.").setVersion(1080);
addNodeObject(threeD, "3D Displace", s_node_3d_displace, "Node_3D_Displace", [1, Node_3D_Displace]).setVersion(1143);
addNodeObject(threeD, "3D Transform", s_node_3d_transform, "Node_3D_Transform", [1, Node_3D_Transform]).setVersion(1080).isDeprecated();
addNodeObject(threeD, "3D Combine", s_node_3d_obj_combine, "Node_3D_Combine", [1, Node_3D_Combine],, "Combine multiple 3D object to a single scene,").setVersion(1080).isDeprecated();
addNodeObject(threeD, "3D Repeat", s_node_3d_array, "Node_3D_Repeat", [1, Node_3D_Repeat], ["3d array"], "Repeat 3D object multiple times.").setVersion(1080).isDeprecated();
addNodeObject(threeD, "3D Displace", s_node_3d_displace, "Node_3D_Displace", [1, Node_3D_Displace]).setVersion(1143).isDeprecated();
addNodeObject(threeD, "3D Export", s_node_3d_export, "Node_3D_Export", [1, Node_3D_Export]).setVersion(1143);
addNodeObject(threeD, "3D Export", s_node_3d_export, "Node_3D_Export", [1, Node_3D_Export]).setVersion(1143).isDeprecated();
var generator = ds_list_create();
addNodeCatagory("Generate", generator);

View file

@ -71,6 +71,8 @@ function Node_Struct(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
if(frm != noone && frm.type == VALUE_TYPE.surface)
str[$ key] = new Surface(val);
else if(frm != noone && frm.type == VALUE_TYPE.buffer)
str[$ key] = new Buffer(val);
else
str[$ key] = val;
}

View file

@ -32,10 +32,10 @@ function Node_Struct_Get(_x, _y, _group = noone) : Node(_x, _y, _group) construc
var val = variable_struct_get(_str, k);
if(j == array_length(keys) - 1) {
if(is_struct(val)) {
if(instanceof(val) == "Surface") {
if(is_instanceof(val, Surface)) {
out.type = VALUE_TYPE.surface;
val = val.get();
} else if(instanceof(val) == "Buffer") {
} else if(is_instanceof(val, Buffer)) {
out.type = VALUE_TYPE.buffer;
val = val.buffer;
} else

View file

@ -438,6 +438,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
#region ---- value ----
def_val = _value;
def_length = is_array(def_val)? array_length(def_val) : 0;
unit = new nodeValueUnit(self);
extra_data = {};
dyna_depo = ds_list_create();
@ -1171,6 +1172,23 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
return animator.getValue(_time);
} #endregion
static arrayBalance = function(val) { #region //Balance array (generate uniform array from single values)
if(!is_array(def_val))
return val;
if(typeArrayDynamic(display_type))
return val;
if(!is_array(val))
val = array_create(def_length, val);
else if(array_length(val) < def_length) {
for( var i = array_length(val); i < def_length; i++ )
val[i] = 0;
} else if(array_length(val) > def_length)
array_resize(val, def_length);
return val;
} #endregion
static _getValue = function(_time = PROJECT.animator.current_frame, applyUnit = true, arrIndex = 0) { #region
var _val = getValueRecursive(_time);
var val = _val[0];
@ -1178,6 +1196,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
var typ = nod.type;
var dis = nod.display_type;
if(connect_type == JUNCTION_CONNECT.output)
return val;
if(typ == VALUE_TYPE.surface && (type == VALUE_TYPE.integer || type == VALUE_TYPE.float) && accept_array) { //Dimension conversion
if(is_array(val)) {
var eqSize = true;
@ -1203,15 +1224,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
return [1, 1];
}
if(is_array(def_val) && !typeArrayDynamic(display_type)) { //Balance array (generate uniform array from single values)
if(!is_array(val)) {
val = array_create(array_length(def_val), val);
return valueProcess(val, nod, applyUnit, arrIndex);
} else if(array_length(val) < array_length(def_val)) {
for( var i = array_length(val); i < array_length(def_val); i++ )
val[i] = 0;
}
}
val = arrayBalance(val);
if(isArray(val) && array_length(val) < 128) { //Process data
for( var i = 0, n = array_length(val); i < n; i++ )
@ -1266,6 +1279,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
} #endregion
static setAnim = function(anim) { #region
if(anim && !is_anim && ds_list_size(animator.values) == 1)
animator.values[| 0].time = PROJECT.animator.current_frame;
is_anim = anim;
PANEL_ANIMATION.updatePropertyList();
} #endregion

View file

@ -6,57 +6,56 @@ function readObj(path, flipUV = false) {
var _VBN = [];
var mats = [];
var matIndex = [];
var tris = [];
var mtlPath = "";
var use_normal = true;
var v = [];
var vt = [];
var vn = [];
var f = [];
var ft = [];
var fn = [];
var face = 0;
var v = ds_list_create();
var vt = ds_list_create();
var vn = ds_list_create();
var f = ds_list_create();
var ft = ds_list_create();
var fn = ds_list_create();
var tri = 0;
var file = file_text_open_read(path);
while(!file_text_eof(file)) {
var l = file_text_readln(file);
l = string_replace_all(l, "\n", "");
l = string_trim(l);
var sep = string_splice(l, " ");
if(array_length(sep) == 0 || sep[0] == "") continue;
var sep = string_split(l, " ");
if(array_length(sep) == 0) continue;
switch(sep[0]) {
case "v" :
array_push(v, [ toNumber(sep[1]), toNumber(sep[2]), toNumber(sep[3]) ]);
ds_list_add(v, [ toNumber(sep[1]), toNumber(sep[2]), toNumber(sep[3]) ]);
break;
case "vt" :
if(flipUV)
array_push(vt, [ toNumber(sep[1]), 1 - toNumber(sep[2]) ]);
else
array_push(vt, [ toNumber(sep[1]), toNumber(sep[2]) ]);
ds_list_add(vt, [ toNumber(sep[1]), flipUV + toNumber(sep[2]) * (1 - flipUV * 2) ]); // flipUV? 1 - sep[2] : sep[2]
break;
case "vn" :
array_push(vn, [ toNumber(sep[1]), toNumber(sep[2]), toNumber(sep[3]) ]);
ds_list_add(vn, [ toNumber(sep[1]), toNumber(sep[2]), toNumber(sep[3]) ]);
break;
case "f" :
var _f = [];
var _ft = [];
var _fn = [];
var _len = array_length(sep);
var _f = array_create(_len - 1);
var _ft = array_create(_len - 1);
var _fn = array_create(_len - 1);
for( var i = 1; i < array_length(sep); i++ ) {
var _sp = string_splice(sep[i], "/");
for( var i = 1; i < _len; i++ ) {
var _sp = string_split(sep[i], "/");
if(array_length(_sp) < 2) continue;
_f[i - 1] = toNumber(array_safe_get(_sp, 0));
_ft[i - 1] = toNumber(array_safe_get(_sp, 1));
_fn[i - 1] = toNumber(array_safe_get(_sp, 2));
_f[i - 1] = toNumber(array_safe_get(_sp, 0, 1));
_ft[i - 1] = toNumber(array_safe_get(_sp, 1, 1));
_fn[i - 1] = toNumber(array_safe_get(_sp, 2, 1));
if(array_length(_sp) < 3) use_normal = false;
}
face++;
array_push(f, _f ); //get position
array_push(ft, _ft); //get texture map
array_push(fn, _fn); //get normal
tri += _len - 2;
ds_list_add(f, _f ); //get position
ds_list_add(ft, _ft); //get texture map
ds_list_add(fn, _fn); //get normal
break;
case "usemtl" :
var mname = "";
@ -67,14 +66,17 @@ function readObj(path, flipUV = false) {
array_push_unique(mats, mname);
array_push(matIndex, array_find(mats, mname));
if(array_length(f)) {
if(!ds_list_empty(f)) {
array_push(_VB, f);
array_push(_VBT, ft);
array_push(_VBN, fn);
f = [];
ft = [];
fn = [];
array_push(tris, tri);
f = ds_list_create();
ft = ds_list_create();
fn = ds_list_create();
}
tri = 0;
break;
case "mtllib" :
mtlPath = "";
@ -87,93 +89,162 @@ function readObj(path, flipUV = false) {
break;
}
}
if(array_length(f)) {
if(!ds_list_empty(f)) {
array_push(_VB, f);
array_push(_VBT, ft);
array_push(_VBN, fn);
array_push(tris, tri);
}
file_text_close(file);
//var txt = "OBJ summary";
//txt += "\n\tVerticies : " + string(array_length(v));
//txt += "\n\tTexture Verticies : " + string(array_length(vt));
//txt += "\n\tNormal Verticies : " + string(array_length(vn));
//txt += "\n\tFaces : " + string(face);
//txt += "\n\tVertex groups : " + string(array_length(_VB));
//print(txt);
if(use_normal) vn[| 0] = [ 0, 0, 0 ];
var txt = "OBJ summary";
txt += $"\n\tVerticies : {ds_list_size(v)}";
txt += $"\n\tTexture Verticies : {ds_list_size(vt)}";
txt += $"\n\tNormal Verticies : {ds_list_size(vn)}";
txt += $"\n\tVertex groups : {array_length(_VB)}";
txt += $"\n\tTriangles : {tris}";
print(txt);
#region centralize vertex
var _bmin = v[| 0];
var _bmax = v[| 0];
var cv = [0, 0, 0];
var vertex = array_length(v);
var vertex = ds_list_size(v);
for( var i = 0; i < vertex; i++ ) {
var _v = v[i];
var _v = v[| i];
cv[0] += _v[0];
cv[1] += _v[1];
cv[2] += _v[2];
_bmin = [
min(_bmin[0], _v[0]),
min(_bmin[1], _v[1]),
min(_bmin[2], _v[2]),
];
_bmax = [
max(_bmax[0], _v[0]),
max(_bmax[1], _v[1]),
max(_bmax[2], _v[2]),
];
}
cv[0] /= vertex;
cv[1] /= vertex;
cv[2] /= vertex;
for( var i = 0, n = array_length(v); i < n; i++ ) {
v[i][0] -= cv[0];
v[i][1] -= cv[1];
v[i][2] -= cv[2];
for( var i = 0, n = ds_list_size(v); i < n; i++ ) {
v[| i][0] -= cv[0];
v[| i][1] -= cv[1];
v[| i][2] -= cv[2];
}
var _size = new __vec3(
_bmax[0] - _bmin[0],
_bmax[1] - _bmin[1],
_bmax[2] - _bmin[2],
);
#endregion
#region vertex buffer creation
var _vblen = array_length(_VB);
var VBS = array_create(_vblen);
var Vpos = array_create(_vblen);
var Vnor = array_create(_vblen);
var Vtex = array_create(_vblen);
for(var i = 0; i < _vblen; i++) {
var VB = vertex_create_buffer();
vertex_begin(VB, global.VF_POS_NORM_TEX_COL);
var face = _VB[i];
var facet = _VBT[i];
var facen = _VBN[i];
var tri = tris[i];
var _flen = ds_list_size(face);
var _vpos = array_create(tri * 3);
var _vnor = array_create(tri * 3);
var _vtex = array_create(tri * 3);
var _vind = 0;
for(var j = 0; j < _flen; j++) {
var _f = face[| j];
var _ft = facet[| j];
var _fn = facen[| j];
var _vlen = array_length(_f);
var _pf = array_create(_vlen);
var _pft = array_create(_vlen);
var _pfn = array_create(_vlen);
for( var k = 0; k < _vlen; k++ ) {
var _vPindex = _f[k] - 1;
_pf[k] = v[| _vPindex];
var _vNindex = _fn[k] - 1;
_pfn[k] = vn[| _vNindex];
var _vTindex = _ft[k] - 1;
_pft[k] = vt[| _vTindex];
//print($"vPos {k}[{_vPindex}] = {_pf[k]}");
//print($"vNor {k}[{_vNindex}] = {_pfn[k]}");
//print($"vTex {k}[{_vTindex}] = {_pft[k]}");
}
if(_vlen >= 3) {
vertex_add_pntc(VB, _pf[0], _pfn[0], _pft[0]);
vertex_add_pntc(VB, _pf[1], _pfn[1], _pft[1]);
vertex_add_pntc(VB, _pf[2], _pfn[2], _pft[2]);
_vpos[_vind] = _pf[0]; _vnor[_vind] = _pfn[0]; _vtex[_vind] = _pft[0]; _vind++;
_vpos[_vind] = _pf[1]; _vnor[_vind] = _pfn[1]; _vtex[_vind] = _pft[1]; _vind++;
_vpos[_vind] = _pf[2]; _vnor[_vind] = _pfn[2]; _vtex[_vind] = _pft[2]; _vind++;
}
if(_vlen >= 4) {
vertex_add_pntc(VB, _pf[0], _pfn[0], _pft[0]);
vertex_add_pntc(VB, _pf[2], _pfn[2], _pft[2]);
vertex_add_pntc(VB, _pf[3], _pfn[3], _pft[3]);
_vpos[_vind] = _pf[0]; _vnor[_vind] = _pfn[0]; _vtex[_vind] = _pft[0]; _vind++;
_vpos[_vind] = _pf[2]; _vnor[_vind] = _pfn[2]; _vtex[_vind] = _pft[2]; _vind++;
_vpos[_vind] = _pf[3]; _vnor[_vind] = _pfn[3]; _vtex[_vind] = _pft[3]; _vind++;
}
}
vertex_end(VB);
vertex_freeze(VB);
VBS[i] = VB;
Vpos[i] = _vpos;
Vnor[i] = _vnor;
Vtex[i] = _vtex;
}
#endregion
var VBS = [];
for(var i = 0; i < array_length(_VB); i++) {
var VB = vertex_create_buffer();
vertex_begin(VB, FORMAT_PNT);
var face = _VB[i];
var facet = _VBT[i];
var facen = _VBN[i];
#region clean
array_foreach(_VB, function(val, ind) { ds_list_destroy(val); });
array_foreach(_VBT, function(val, ind) { ds_list_destroy(val); });
array_foreach(_VBN, function(val, ind) { ds_list_destroy(val); });
for(var j = 0; j < array_length(face); j++) {
var _f = face[j];
var _ft = facet[j];
var _fn = facen[j];
var _pf = [];
var _pft = [];
var _pfn = [];
for( var k = 0; k < array_length(_f); k++ ) {
var _f1 = v[_f[k] - 1];
var _ft1 = vt[_ft[k] - 1];
var _fn1 = _fn[k]? vn[_fn[k] - 1] : [0, 0, 0];
array_push( _pf, _f1);
array_push(_pft, _ft1);
array_push(_pfn, _fn1);
}
if(array_length(_f) >= 3) {
vertex_add_pnt(VB, _pf[0], _pfn[0], _pft[0]);
vertex_add_pnt(VB, _pf[1], _pfn[1], _pft[1]);
vertex_add_pnt(VB, _pf[2], _pfn[2], _pft[2]);
}
if(array_length(_f) >= 4) {
vertex_add_pnt(VB, _pf[0], _pfn[0], _pft[0]);
vertex_add_pnt(VB, _pf[2], _pfn[2], _pft[2]);
vertex_add_pnt(VB, _pf[3], _pfn[3], _pft[3]);
}
}
vertex_end(VB);
vertex_freeze(VB);
array_push(VBS, VB);
}
ds_list_destroy(v);
ds_list_destroy(vn);
ds_list_destroy(vt);
#endregion
return {
vertex_groups: VBS,
vertex_groups: VBS,
vertex_positions: Vpos,
vertex_normals: Vnor,
vertex_textures: Vtex,
materials: mats,
material_index: matIndex,
use_normal: use_normal,
mtl_path: mtlPath,
model_size: _size,
};
}

View file

@ -4,112 +4,122 @@ function Inspector_Custom_Renderer(drawFn) : widget() constructor {
}
function Panel_Inspector() : PanelContent() constructor {
title = __txt("Inspector");
context_str = "Inspector";
icon = THEME.panel_inspector;
#region ---- main ----
title = __txt("Inspector");
context_str = "Inspector";
icon = THEME.panel_inspector;
w = ui(400);
h = ui(640);
w = ui(400);
h = ui(640);
min_w = ui(160);
locked = false;
inspecting = noone;
top_bar_h = ui(100);
locked = false;
inspecting = noone;
top_bar_h = ui(100);
static initSize = function() {
content_w = w - ui(32);
content_h = h - top_bar_h - ui(12);
}
initSize();
#endregion
prop_hover = noone;
prop_selecting = noone;
#region ---- properties ----
prop_hover = noone;
prop_selecting = noone;
prop_dragging = noone;
prop_sel_drag_x = 0;
prop_sel_drag_y = 0;
prop_dragging = noone;
prop_sel_drag_x = 0;
prop_sel_drag_y = 0;
color_picking = false;
static initSize = function() {
content_w = w - ui(32);
content_h = h - top_bar_h - ui(12);
}
initSize();
keyframe_dragging = noone;
keyframe_drag_st = 0;
color_picking = false;
picker_index = 0;
picker_change = false;
#endregion
globalvar_viewer_init();
drawWidgetInit();
min_w = ui(160);
#region ---- header labels ----
tb_node_name = new textBox(TEXTBOX_INPUT.text, function(txt) {
if(inspecting) inspecting.setDisplayName(txt);
})
tb_node_name = new textBox(TEXTBOX_INPUT.text, function(txt) {
if(inspecting) inspecting.setDisplayName(txt);
})
tb_prop_filter = new textBox(TEXTBOX_INPUT.text, function(txt) { filter_text = txt; })
tb_prop_filter.no_empty = false;
tb_prop_filter.auto_update = true;
tb_prop_filter.font = f_p0;
tb_prop_filter.color = COLORS._main_text_sub;
tb_prop_filter.align = fa_center;
tb_prop_filter.hide = true;
filter_text = "";
tb_prop_filter = new textBox(TEXTBOX_INPUT.text, function(txt) { filter_text = txt; })
tb_prop_filter.no_empty = false;
tb_prop_filter.auto_update = true;
tb_prop_filter.font = f_p0;
tb_prop_filter.color = COLORS._main_text_sub;
tb_prop_filter.align = fa_center;
tb_prop_filter.hide = true;
filter_text = "";
prop_page_button = new buttonGroup([ "Properties", "Settings" ], function(val) { prop_page = val; });
prop_page_button.buttonSpr = [ THEME.button_hide_left, THEME.button_hide_middle, THEME.button_hide_right ];
prop_page_button.font = f_p1;
prop_page_button.fColor = COLORS._main_text_sub;
prop_page = 0;
#endregion
prop_page_button = new buttonGroup([ "Properties", "Settings" ], function(val) { prop_page = val; });
prop_page_button.buttonSpr = [ THEME.button_hide_left, THEME.button_hide_middle, THEME.button_hide_right ];
prop_page_button.font = f_p1;
prop_page_button.fColor = COLORS._main_text_sub;
prop_page = 0;
#region ---- metadata ----
current_meta = -1;
meta_tb[0] = new textArea(TEXTBOX_INPUT.text, function(str) { current_meta.description = str; });
meta_tb[1] = new textArea(TEXTBOX_INPUT.text, function(str) { current_meta.author = str; });
meta_tb[2] = new textArea(TEXTBOX_INPUT.text, function(str) { current_meta.contact = str; });
meta_tb[3] = new textArea(TEXTBOX_INPUT.text, function(str) { current_meta.alias = str; });
meta_tb[4] = new textArrayBox(noone, META_TAGS);
for( var i = 0, n = array_length(meta_tb); i < n; i++ )
meta_tb[i].hide = true;
picker_index = 0;
picker_change = false;
meta_display = [
[ __txt("Project Settings"), false ],
[ __txt("Metadata"), true ],
[ __txtx("panel_globalvar", "Global variables"), true, button(function() { panelAdd("Panel_Globalvar", true); }, THEME.node_goto).setIcon(THEME.node_goto, 0, COLORS._main_icon) ]
];
#endregion
current_meta = -1;
meta_tb[0] = new textArea(TEXTBOX_INPUT.text, function(str) { current_meta.description = str; });
meta_tb[1] = new textArea(TEXTBOX_INPUT.text, function(str) { current_meta.author = str; });
meta_tb[2] = new textArea(TEXTBOX_INPUT.text, function(str) { current_meta.contact = str; });
meta_tb[3] = new textArea(TEXTBOX_INPUT.text, function(str) { current_meta.alias = str; });
meta_tb[4] = new textArrayBox(noone, META_TAGS);
for( var i = 0, n = array_length(meta_tb); i < n; i++ )
meta_tb[i].hide = true;
#region ---- workshop ----
workshop_uploading = false;
#endregion
meta_display = [
[ __txt("Project Settings"), false ],
[ __txt("Metadata"), true ],
[ __txtx("panel_globalvar", "Global variables"), true, button(function() { panelAdd("Panel_Globalvar", true); }, THEME.node_goto).setIcon(THEME.node_goto, 0, COLORS._main_icon) ]
];
#region ++++ hotkeys ++++
addHotkey("Inspector", "Copy property", "C", MOD_KEY.ctrl, function() { PANEL_INSPECTOR.propSelectCopy(); });
addHotkey("Inspector", "Paste property", "V", MOD_KEY.ctrl, function() { PANEL_INSPECTOR.propSelectPaste(); });
addHotkey("Inspector", "Toggle animation", "I", MOD_KEY.none, function() { PANEL_INSPECTOR.anim_toggling = true; });
workshop_uploading = false;
addHotkey("", "Color picker", "", MOD_KEY.alt, function() {
if(!PREF_MAP[? "alt_picker"]) return;
PANEL_INSPECTOR.color_picking = true;
});
#endregion
addHotkey("Inspector", "Copy property", "C", MOD_KEY.ctrl, function() { PANEL_INSPECTOR.propSelectCopy(); });
addHotkey("Inspector", "Paste property", "V", MOD_KEY.ctrl, function() { PANEL_INSPECTOR.propSelectPaste(); });
addHotkey("Inspector", "Toggle animation", "I", MOD_KEY.none, function() { PANEL_INSPECTOR.anim_toggling = true; });
addHotkey("", "Color picker", "", MOD_KEY.alt, function() {
if(!PREF_MAP[? "alt_picker"]) return;
PANEL_INSPECTOR.color_picking = true;
});
group_menu = [
menuItem(__txt("Expand all"), function() {
if(inspecting == noone) return;
if(inspecting.input_display_list == -1) return;
#region ++++ menus ++++
group_menu = [
menuItem(__txt("Expand all"), function() {
if(inspecting == noone) return;
if(inspecting.input_display_list == -1) return;
var dlist = inspecting.input_display_list;
for( var i = 0, n = array_length(dlist); i < n; i++ ) {
if(!is_array(dlist[i])) continue;
dlist[i][@ 1] = false;
}
}),
menuItem(__txt("Collapse all"), function() {
if(inspecting == noone) return;
if(inspecting.input_display_list == -1) return;
var dlist = inspecting.input_display_list;
for( var i = 0, n = array_length(dlist); i < n; i++ ) {
if(!is_array(dlist[i])) continue;
dlist[i][@ 1] = false;
}
}),
menuItem(__txt("Collapse all"), function() {
if(inspecting == noone) return;
if(inspecting.input_display_list == -1) return;
var dlist = inspecting.input_display_list;
for( var i = 0, n = array_length(dlist); i < n; i++ ) {
if(!is_array(dlist[i])) continue;
dlist[i][@ 1] = true;
}
}),
]
var dlist = inspecting.input_display_list;
for( var i = 0, n = array_length(dlist); i < n; i++ ) {
if(!is_array(dlist[i])) continue;
dlist[i][@ 1] = true;
}
}),
]
#endregion
function setInspecting(inspecting) {
function setInspecting(inspecting) { #region
if(locked) return;
self.inspecting = inspecting;
@ -120,16 +130,16 @@ function Panel_Inspector() : PanelContent() constructor {
contentPane.scroll_y_to = 0;
picker_index = 0;
}
} #endregion
function onFocusBegin() { PANEL_INSPECTOR = self; }
function onResize() {
function onResize() { #region
initSize();
contentPane.resize(content_w, content_h);
}
} #endregion
static drawMeta = function(_y, _m) {
static drawMeta = function(_y, _m) { #region
var con_w = contentPane.surface_w - ui(4);
var _hover = pHOVER && contentPane.hover;
@ -310,9 +320,9 @@ function Panel_Inspector() : PanelContent() constructor {
}
return hh;
}
} #endregion
contentPane = new scrollPane(content_w, content_h, function(_y, _m) {
contentPane = new scrollPane(content_w, content_h, function(_y, _m) { #region
var con_w = contentPane.surface_w - ui(4);
var _hover = pHOVER && contentPane.hover;
@ -342,7 +352,7 @@ function Panel_Inspector() : PanelContent() constructor {
var xc = con_w / 2;
if(prop_page == 1) {
if(prop_page == 1) { #region attribute/settings editor
hh += ui(8);
var hg = ui(32);
var yy = hh;
@ -391,7 +401,7 @@ function Panel_Inspector() : PanelContent() constructor {
hh += hg + ui(8);
}
return hh;
}
} #endregion
var color_picker_selecting = noone;
var color_picker_index = 0;
@ -400,7 +410,7 @@ function Panel_Inspector() : PanelContent() constructor {
for(var i = 0; i < amo; i++) {
var yy = hh + _y;
if(i < amoIn) {
if(i < amoIn) { #region inputs
if(inspecting.input_display_list == -1) {
jun = inspecting.inputs[| i];
} else {
@ -453,17 +463,20 @@ function Panel_Inspector() : PanelContent() constructor {
}
jun = inspecting.inputs[| inspecting.input_display_list[i]];
}
} else if(i == amoIn) {
#endregion
} else if(i == amoIn) { #region output label
hh += ui(8 + 32 + 8);
draw_sprite_stretched_ext(THEME.group_label, 0, 0, yy + ui(8), con_w, ui(32), COLORS.panel_inspector_output_label, 0.85);
draw_set_text(f_p0b, fa_center, fa_center, COLORS._main_text_sub);
draw_text_add(xc, yy + ui(8 + 16), __txt("Outputs"));
continue;
} else {
#endregion
} else { #region outputs
var outInd = i - amoIn - 1;
jun = inspecting.outputs[| outInd];
}
#endregion
}
if(!is_struct(jun)) continue;
if(instanceof(jun) != "NodeValue") continue;
@ -474,34 +487,36 @@ function Panel_Inspector() : PanelContent() constructor {
if(pos == 0) continue;
}
var lb_h = line_get_height(f_p0) + ui(8);
var lb_w = line_get_width(jun.name, f_p0) + ui(16);
var padd = ui(8);
#region ++++ draw widget
var lb_h = line_get_height(f_p0) + ui(8);
var lb_w = line_get_width(jun.name, f_p0) + ui(16);
var padd = ui(8);
var _selY = yy - ui(0);
var lbHov = point_in_rectangle(_m[0], _m[1], ui(48), _selY, ui(48) + lb_w, _selY + lb_h);
if(lbHov)
draw_sprite_stretched_ext(THEME.group_label, 0, ui(48), _selY + ui(2), lb_w, lb_h - ui(4), COLORS._main_icon_dark, 0.85);
var _selY = yy - ui(0);
var lbHov = point_in_rectangle(_m[0], _m[1], ui(48), _selY, ui(48) + lb_w, _selY + lb_h);
if(lbHov)
draw_sprite_stretched_ext(THEME.group_label, 0, ui(48), _selY + ui(2), lb_w, lb_h - ui(4), COLORS._main_icon_dark, 0.85);
var widg = drawWidget(ui(16), yy, contentPane.surface_w - ui(24), _m, jun, false, pHOVER && contentPane.hover, pFOCUS, contentPane, ui(16) + x, top_bar_h + y);
var widH = widg[0];
var mbRight = widg[1];
var widg = drawWidget(ui(16), yy, contentPane.surface_w - ui(24), _m, jun, false, pHOVER && contentPane.hover, pFOCUS, contentPane, ui(16) + x, top_bar_h + y);
var widH = widg[0];
var mbRight = widg[1];
hh += lb_h + widH + padd;
hh += lb_h + widH + padd;
var _selY1 = yy + lb_h + widH + ui(2);
var _selH = _selY1 - _selY;
var _selY1 = yy + lb_h + widH + ui(2);
var _selH = _selY1 - _selY;
if(_hover && lbHov) {
if(prop_dragging == noone && mouse_press(mb_left, pFOCUS)) {
prop_dragging = jun;
if(_hover && lbHov) {
if(prop_dragging == noone && mouse_press(mb_left, pFOCUS)) {
prop_dragging = jun;
prop_sel_drag_x = mouse_mx;
prop_sel_drag_y = mouse_my;
prop_sel_drag_x = mouse_mx;
prop_sel_drag_y = mouse_my;
}
}
}
#endregion
if(jun.connect_type == JUNCTION_CONNECT.input && jun.type == VALUE_TYPE.color && jun.display_type == VALUE_DISPLAY._default) {
if(jun.connect_type == JUNCTION_CONNECT.input && jun.type == VALUE_TYPE.color && jun.display_type == VALUE_DISPLAY._default) { #region color picker
pickers[color_picker_index] = jun;
if(color_picker_index == picker_index) {
if(color_picking && WIDGET_CURRENT == noone && !instance_exists(_p_dialog))
@ -510,9 +525,9 @@ function Panel_Inspector() : PanelContent() constructor {
}
color_picker_index++;
}
} #endregion
if(_hover && point_in_rectangle(_m[0], _m[1], ui(4), _selY, contentPane.surface_w - ui(4), _selY + _selH)) {
if(_hover && point_in_rectangle(_m[0], _m[1], ui(4), _selY, contentPane.surface_w - ui(4), _selY + _selH)) { #region mouse in widget
_HOVERING_ELEMENT = jun;
if(NODE_DROPPER_TARGET != noone && NODE_DROPPER_TARGET != jun) {
@ -535,7 +550,7 @@ function Panel_Inspector() : PanelContent() constructor {
if(mouse_press(mb_left, pFOCUS))
prop_selecting = jun;
if(mouse_press(mb_right, pFOCUS && mbRight)) {
if(mouse_press(mb_right, pFOCUS && mbRight)) { #region right click menu
var _menuItem = [];
if(i < amoIn) {
@ -595,8 +610,8 @@ function Panel_Inspector() : PanelContent() constructor {
var dia = menuCall("inspector_value_menu",,, _menuItem,, jun);
__dialog_junction = jun;
}
}
} #endregion
} #endregion
}
if(color_picker_selecting == noone)
@ -627,18 +642,19 @@ function Panel_Inspector() : PanelContent() constructor {
color_picking = false;
return hh;
});
}); #endregion
function propSelectCopy() {
function propSelectCopy() { #region
if(!prop_selecting) return;
clipboard_set_text(prop_selecting.getShowString());
}
function propSelectPaste() {
} #endregion
function propSelectPaste() { #region
if(!prop_selecting) return;
prop_selecting.setString(clipboard_get_text());
}
} #endregion
function drawInspectingNode() {
function drawInspectingNode() { #region
tb_node_name.font = f_h5;
tb_node_name.hide = true;
tb_node_name.setFocusHover(pFOCUS, pHOVER);
@ -684,9 +700,9 @@ function Panel_Inspector() : PanelContent() constructor {
if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(32), [mx, my], pFOCUS, pHOVER, inspecting.insp2UpdateTooltip, icon[0], icon[1], icon[2]) = 2)
inspecting.inspector2Update();
}
}
} #endregion
function drawContent(panel) {
function drawContent(panel) { #region >>>>>>>>>>>>>>>>>>>> MAIN DRAW <<<<<<<<<<<<<<<<<<<<
draw_clear_alpha(COLORS.panel_bg_clear, 0);
lineBreak = w < PREF_MAP[? "inspector_line_break_width"];
@ -761,5 +777,5 @@ function Panel_Inspector() : PanelContent() constructor {
if(!locked && PANEL_GRAPH.node_focus && inspecting != PANEL_GRAPH.node_focus)
setInspecting(PANEL_GRAPH.node_focus);
}
} #endregion
}

View file

@ -89,37 +89,56 @@ function Panel_Preview() : PanelContent() constructor {
d3_surface = noone;
d3_outline_surface = noone;
d3_view_camera = new __3dCamera();
d3_camW = 1;
d3_camH = 1;
#region camera
d3_view_camera = new __3dCamera();
d3_camW = 1;
d3_camH = 1;
d3_view_camera.setFocusAngle(135, 45, 16);
d3_camLerp = false;
d3_view_camera.setFocusAngle(135, 45, 16);
d3_camLerp = false;
d3_camTarget = new __vec3();
d3_camTarget = new __vec3();
d3_camPanning = false;
d3_camPan_mx = 0;
d3_camPan_my = 0;
d3_camPanning = false;
d3_camPan_mx = 0;
d3_camPan_my = 0;
d3_zoom_speed = 0.2;
d3_pan_speed = 2;
d3_zoom_speed = 0.2;
d3_pan_speed = 2;
#endregion
d3_scene = new __3dScene(d3_view_camera);
d3_scene.lightAmbient = $404040;
#region scene
d3_scene = new __3dScene(d3_view_camera);
d3_scene.lightAmbient = $404040;
d3_scene_light0 = new __3dLightDirectional();
d3_scene_light0.position.set(-1, -2, 3);
d3_scene_light0.color = $AAAAAA;
d3_scene_light_enabled = true;
d3_scene_light0 = new __3dLightDirectional();
d3_scene_light0.position.set(-1, -2, 3);
d3_scene_light0.color = $FFFFFF;
d3_scene_light0.shadow_active = false;
d3_scene_light0.shadow_map_scale = 128;
d3_scene_light1 = new __3dLightDirectional();
d3_scene_light1.position.set(1, 2, -3);
d3_scene_light1.color = $505050;
#endregion
d3_scene_light1 = new __3dLightDirectional();
d3_scene_light1.position.set(1, 2, 3);
d3_scene_light1.color = $FFFFFF;
#region tool
d3_tool_snap = false;
d3_tool_snap_position = 1;
d3_tool_snap_rotation = 15;
#endregion
#region shadow map
#endregion
#endregion
tb_framerate = new textBox(TEXTBOX_INPUT.number, function(val) { preview_rate = real(val); });
#region ++++ toolbars & actions ++++
topbar_height = ui(32);
toolbar_height = ui(40);
toolbars = [
[
@ -183,6 +202,29 @@ function Panel_Preview() : PanelContent() constructor {
],
];
toolbars_3d = [
[
THEME.d3d_preview_settings,
function() { return 0; },
function() { return __txt("3D Preview Settings") },
function(param) {
var gs = dialogCall(o_dialog_preview_3d_settings, param.x, param.y);
gs.anchor = ANCHOR.bottom | ANCHOR.left;
gs.preview_panel = self;
}
],
[
THEME.d3d_snap_settings,
function() { return 0; },
function() { return __txt("3D Snap Settings") },
function(param) {
var gs = dialogCall(o_dialog_preview_snap, param.x, param.y);
gs.anchor = ANCHOR.bottom | ANCHOR.left;
gs.preview_panel = self;
}
],
];
actions = [
[
THEME.icon_preview_export,
@ -699,7 +741,6 @@ function Panel_Preview() : PanelContent() constructor {
_prev_node.previewing = 1;
#region view
var cam = camera_get_active();
var _pos, targ, _blend = 1;
targ = d3_camTarget;
@ -737,14 +778,34 @@ function Panel_Preview() : PanelContent() constructor {
d3_view_camera.setMatrix();
#endregion
#region draw
#region shadow
if(_prev_node.is_3D) {
var _prev_obj = _prev_node.getPreviewObject();
d3_scene_light0.shadowProjectVertex(d3_scene, _prev_obj);
for( var i = 0, n = array_length(_prev_obj); i < n; i++ ) {
var _prev = _prev_obj[i];
if(_prev == noone)
continue;
if(!is_instanceof(_prev, __3dGroup))
continue;
_prev.map(function(object, params) {
if(!is_instanceof(object, __3dLight)) return;
object.shadowProjectVertex(params.scene, params.objs);
}, { scene: d3_scene, objs:_prev_obj });
}
}
#endregion
#region grid
d3_surface = surface_verify(d3_surface, w, h);
d3_outline_surface = surface_verify(d3_outline_surface, w, h);
surface_set_target(d3_surface);
draw_clear(bg_color);
d3_view_camera.applyCamera(cam);
d3_view_camera.applyCamera();
gpu_set_ztestenable(true);
gpu_set_zwriteenable(false);
@ -764,12 +825,17 @@ function Panel_Preview() : PanelContent() constructor {
gpu_set_zwriteenable(true);
d3_scene.reset();
#endregion
#region draw
if(_prev_node.is_3D) {
var _prev_obj = _prev_node.getPreviewObject();
d3_scene.addLightDirectional(d3_scene_light0);
d3_scene.addLightDirectional(d3_scene_light1);
if(d3_scene_light_enabled) {
d3_scene.addLightDirectional(d3_scene_light0);
d3_scene.addLightDirectional(d3_scene_light1);
}
for( var i = 0, n = array_length(_prev_obj); i < n; i++ ) {
var _prev = _prev_obj[i];
if(_prev == noone) continue;
@ -788,6 +854,7 @@ function Panel_Preview() : PanelContent() constructor {
surface_reset_target();
draw_surface_safe(d3_surface);
//draw_surface_stretched(d3_scene_light0.shadow_map, 64, 64, 96, 96);
#endregion
#region outline
@ -799,7 +866,7 @@ function Panel_Preview() : PanelContent() constructor {
surface_set_target(d3_outline_surface);
draw_clear(c_black);
d3_view_camera.applyCamera(cam);
d3_view_camera.applyCamera();
gpu_set_ztestenable(false);
for( var i = 0, n = array_length(_inspect_obj); i < n; i++ ) {
@ -815,6 +882,8 @@ function Panel_Preview() : PanelContent() constructor {
shader_reset();
}
#endregion
d3_scene.resetCamera();
} #endregion
function drawPreviewOverlay() { #region
@ -960,21 +1029,29 @@ function Panel_Preview() : PanelContent() constructor {
mouse_on_preview = false;
}
if(key_mod_press(CTRL)) {
_snx = PROJECT.previewGrid.show? PROJECT.previewGrid.width : 1;
_sny = PROJECT.previewGrid.show? PROJECT.previewGrid.height : 1;
} else if(PROJECT.previewGrid.snap) {
_snx = PROJECT.previewGrid.width;
_sny = PROJECT.previewGrid.height;
}
var overlayHover = tool_hovering == noone;
overlayHover &= active && isHover;
overlayHover &= point_in_rectangle(mx, my, 0, toolbar_height, w, h - toolbar_height);
overlayHover &= !key_mod_press(CTRL);
if(_node.is_3D) _node.drawOverlay3D(overlayHover, d3_scene, _mx, _my, _snx, _sny, { w, h });
else _node.drawOverlay(overlayHover, cx, cy, canvas_s, _mx, _my, _snx, _sny, { w, h });
if(_node.is_3D) {
if(key_mod_press(CTRL) || d3_tool_snap) {
_snx = d3_tool_snap_position;
_sny = d3_tool_snap_rotation;
}
_node.drawOverlay3D(overlayHover, d3_scene, _mx, _my, _snx, _sny, { w, h });
} else {
if(key_mod_press(CTRL)) {
_snx = PROJECT.previewGrid.show? PROJECT.previewGrid.width : 1;
_sny = PROJECT.previewGrid.show? PROJECT.previewGrid.height : 1;
} else if(PROJECT.previewGrid.snap) {
_snx = PROJECT.previewGrid.width;
_sny = PROJECT.previewGrid.height;
}
_node.drawOverlay(overlayHover, cx, cy, canvas_s, _mx, _my, _snx, _sny, { w, h });
}
var _tool = tool_hovering;
tool_hovering = noone;
@ -984,7 +1061,7 @@ function Panel_Preview() : PanelContent() constructor {
return;
}
var aa = d3_active? 0.5 : 1;
var aa = d3_active? 0.8 : 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;
@ -1068,10 +1145,8 @@ function Panel_Preview() : PanelContent() constructor {
var ty = h - toolbar_height;
//draw_sprite_stretched_ext(THEME.toolbar_shadow, 0, 0, ty - 12 + 4, w, 12, c_white, 0.5);
var scHeight = ui(32);
var aa = d3_active? 0.5 : 1;
draw_sprite_stretched_ext(THEME.toolbar, 1, 0, 0, w, scHeight, c_white, aa);
var aa = d3_active? 0.8 : 1;
draw_sprite_stretched_ext(THEME.toolbar, 1, 0, 0, w, topbar_height, c_white, aa);
draw_sprite_stretched_ext(THEME.toolbar, 0, 0, ty, w, toolbar_height, c_white, aa);
if(!_node) return;
@ -1126,7 +1201,7 @@ function Panel_Preview() : PanelContent() constructor {
var cx = ui(10);
var cy = ui(10);
var cw = ui(32);
var ch = scHeight - ui(16);
var ch = topbar_height - ui(16);
if(sample_color != noone) {
draw_set_color(sample_color);
@ -1152,14 +1227,17 @@ function Panel_Preview() : PanelContent() constructor {
var tbx = toolbar_height / 2;
var tby = ty + toolbar_height / 2;
for( var i = 0, n = array_length(toolbars); i < n; i++ ) {
var tb = toolbars[i];
var tbSpr = tb[0];
var tbInd = tb[1]();
var _toolbars = d3_active? toolbars_3d : toolbars;
for( var i = 0, n = array_length(_toolbars); i < n; i++ ) {
var tb = _toolbars[i];
var tbSpr = tb[0];
var tbInd = tb[1]();
var tbTooltip = tb[2]();
var tbActive = tb[3];
var b = buttonInstant(THEME.button_hide, tbx - ui(14), tby - ui(14), ui(28), ui(28), [mx, my], pFOCUS, pHOVER, tbTooltip, tbSpr, tbInd);
if(b == 2) tb[3]( { x: x + tbx - ui(14), y: y + tby - ui(14) } );
if(b == 2) tbActive( { x: x + tbx - ui(14), y: y + tby - ui(14) } );
tbx += ui(32);
}

View file

@ -51,12 +51,14 @@ function shader_set_uniform_f_array_safe(uniform, array, max_length = 128) {
shader_set_uniform_f_array(uniform, array);
}
function shader_set_surface(sampler, surface) {
function shader_set_surface(sampler, surface, linear = false, _repeat = false) {
var shader = shader_current();
if(!is_surface(surface)) return;
var t = shader_get_sampler_index(shader, sampler);
texture_set_stage(t, surface_get_texture(surface));
gpu_set_tex_filter_ext(t, linear);
gpu_set_tex_repeat_ext(t, _repeat);
}
function shader_set_surface_dimension(uniform, surface) {

View file

@ -129,10 +129,10 @@ function surface_verify(surf, w, h, format = surface_rgba8unorm) {
gml_pragma("forceinline");
w = round(w);
h = round(h);
var s = is_surface(surf);
if(!is_surface(surf))
return surface_create_valid(w, h, format);
return surface_size_to(surf, w, h, format);
if(!s) return surface_create_valid(w, h, format);
return surface_size_to(surf, w, h, format, true);
}
//get
@ -251,22 +251,23 @@ function surface_size_lim(surface, width, height) {
return s;
}
function surface_size_to(surface, width, height, format = noone) {
if(!is_surface(surface)) return surface;
function surface_size_to(surface, width, height, format = noone, skipCheck = false) {
if(!skipCheck && !is_surface(surface)) return surface;
if(width < 1 && height < 1) return surface;
if(format != noone && format != surface_get_format(surface)) {
surface_free(surface);
return surface_create_valid(width, height, format);
return surface_create(width, height, format);
}
width = surface_valid_size(width);
height = surface_valid_size(height);
var ww = surface_get_width(surface);
var hh = surface_get_height(surface);
var ww = surface_get_width(surface);
var hh = surface_get_height(surface);
if(ww == width && hh == height) return surface;
//print($"Reset surface {ww}, {width} | {hh}, {height}");
surface_resize(surface, width, height);
surface_clear(surface);

View file

@ -1,4 +1,14 @@
function value_snap(val, snap = 1) {
if(snap == 0) return val;
return round(val / snap) * snap;
gml_pragma("forceinline")
if(!is_array(val)) {
if(snap == 0)
return val;
return round(val / snap) * snap;
}
var _val = [];
for( var i = 0, n = array_length(val); i < n; i++ )
_val[i] = snap == 0? val[i] : round(val[i] / snap) * snap;
return _val;
}

View file

@ -0,0 +1,10 @@
//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main() {
vec4 col = texture2D( gm_BaseTexture, v_vTexcoord );
gl_FragColor = vec4(0., 0., 0., col.r);
}

View file

@ -0,0 +1,19 @@
//
// Simple passthrough vertex shader
//
attribute vec3 in_Position; // (x,y,z)
//attribute vec3 in_Normal; // (x,y,z) unused in this shader.
attribute vec4 in_Colour; // (r,g,b,a)
attribute vec2 in_TextureCoord; // (u,v)
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main()
{
vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0);
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos;
v_vColour = in_Colour;
v_vTexcoord = in_TextureCoord;
}

View file

@ -0,0 +1,10 @@
{
"resourceType": "GMShader",
"resourceVersion": "1.0",
"name": "sh_channel_R2A",
"parent": {
"name": "channels",
"path": "folders/shader/channels.yy",
},
"type": 1,
}

View file

@ -0,0 +1,10 @@
//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main() {
vec4 col = texture2D( gm_BaseTexture, v_vTexcoord );
gl_FragColor = vec4(0., 0., col.r, 0.);
}

View file

@ -0,0 +1,19 @@
//
// Simple passthrough vertex shader
//
attribute vec3 in_Position; // (x,y,z)
//attribute vec3 in_Normal; // (x,y,z) unused in this shader.
attribute vec4 in_Colour; // (r,g,b,a)
attribute vec2 in_TextureCoord; // (u,v)
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main()
{
vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0);
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos;
v_vColour = in_Colour;
v_vTexcoord = in_TextureCoord;
}

View file

@ -0,0 +1,10 @@
{
"resourceType": "GMShader",
"resourceVersion": "1.0",
"name": "sh_channel_R2B",
"parent": {
"name": "channels",
"path": "folders/shader/channels.yy",
},
"type": 1,
}

View file

@ -0,0 +1,10 @@
//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main() {
vec4 col = texture2D( gm_BaseTexture, v_vTexcoord );
gl_FragColor = vec4(0., col.r, 0., 0.);
}

View file

@ -0,0 +1,19 @@
//
// Simple passthrough vertex shader
//
attribute vec3 in_Position; // (x,y,z)
//attribute vec3 in_Normal; // (x,y,z) unused in this shader.
attribute vec4 in_Colour; // (r,g,b,a)
attribute vec2 in_TextureCoord; // (u,v)
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main()
{
vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0);
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos;
v_vColour = in_Colour;
v_vTexcoord = in_TextureCoord;
}

View file

@ -0,0 +1,10 @@
{
"resourceType": "GMShader",
"resourceVersion": "1.0",
"name": "sh_channel_R2G",
"parent": {
"name": "channels",
"path": "folders/shader/channels.yy",
},
"type": 1,
}

View file

@ -5,59 +5,186 @@ varying vec2 v_vTexcoord;
varying vec4 v_vColour;
varying vec3 v_vNormal;
varying vec3 v_worldPosition;
varying vec4 v_worldPosition;
#region ---- light ----
uniform vec4 light_ambient;
uniform float shadowBias;
#define LIGHT_DIR_LIMIT 16
uniform int light_dir_count;
uniform vec3 light_dir_direction[LIGHT_DIR_LIMIT];
uniform vec4 light_dir_color[LIGHT_DIR_LIMIT];
uniform float light_dir_intensity[LIGHT_DIR_LIMIT];
uniform mat4 light_dir_view[LIGHT_DIR_LIMIT];
uniform mat4 light_dir_proj[LIGHT_DIR_LIMIT];
uniform int light_dir_shadow_active[LIGHT_DIR_LIMIT];
uniform sampler2D light_dir_shadowmap_0;
uniform sampler2D light_dir_shadowmap_1;
uniform sampler2D light_dir_shadowmap_2;
uniform sampler2D light_dir_shadowmap_3;
#define LIGHT_PNT_LIMIT 16
uniform int light_pnt_count;
uniform vec3 light_pnt_position[LIGHT_PNT_LIMIT];
uniform vec4 light_pnt_color[LIGHT_PNT_LIMIT];
uniform float light_pnt_intensity[LIGHT_PNT_LIMIT];
uniform float light_pnt_radius[LIGHT_PNT_LIMIT];
uniform mat4 light_pnt_view[96];
uniform mat4 light_pnt_proj[LIGHT_PNT_LIMIT];
uniform int light_pnt_shadow_active[LIGHT_PNT_LIMIT];
uniform sampler2D light_pnt_shadowmap_0;
uniform sampler2D light_pnt_shadowmap_1;
uniform sampler2D light_pnt_shadowmap_2;
uniform sampler2D light_pnt_shadowmap_3;
uniform sampler2D light_pnt_shadowmap_4;
uniform sampler2D light_pnt_shadowmap_5;
uniform sampler2D light_pnt_shadowmap_6;
uniform sampler2D light_pnt_shadowmap_7;
#endregion
#region ---- rendering ----
uniform int gammaCorrection;
#endregion
#region ---- matrix ----
float matrixGet(mat4 matrix, int index) {
if(index < 0 || index > 15) return 0.;
int _x = int(floor(float(index) / 4.));
int _y = int(mod(float(index), 4.));
return matrix[_x][_y];
}
mat4 matrixSet(mat4 matrix, int index, float value) {
if(index < 0 || index > 15) return matrix;
int _x = int(floor(float(index) / 4.));
int _y = int(mod(float(index), 4.));
matrix[_x][_y] = value;
return matrix;
}
#endregion
float sampleDirShadowMap(int index, vec2 position) {
if(index == 0) return texture2D(light_dir_shadowmap_0, position).r;
if(index == 1) return texture2D(light_dir_shadowmap_1, position).r;
if(index == 2) return texture2D(light_dir_shadowmap_2, position).r;
if(index == 3) return texture2D(light_dir_shadowmap_3, position).r;
return 0.;
}
float samplePntShadowMap(int index, vec2 position, int side) {
position.x /= 2.;
if(side >= 3) {
position.x += 0.5;
side -= 3;
}
if(index == 0) return texture2D(light_pnt_shadowmap_0, position)[side];
if(index == 1) return texture2D(light_pnt_shadowmap_1, position)[side];
if(index == 2) return texture2D(light_pnt_shadowmap_2, position)[side];
if(index == 3) return texture2D(light_pnt_shadowmap_3, position)[side];
return 0.;
}
void main() {
vec4 final_color = texture2D( gm_BaseTexture, v_vTexcoord );
final_color *= v_vColour;
gl_FragColor = vec4(0.);
#region ++++ light ++++
int shadow_map_index = 0;
vec3 light_effect = light_ambient.rgb;
float val = 0.;
for(int i = 0; i < light_dir_count; i++) {
float light_dir_strength = dot(normalize(v_vNormal), normalize(light_dir_direction[i]));
if(light_dir_strength < 0.)
continue;
#region ---- directional ----
float light_dir_strength;
float light_map_depth;
float lightDistance;
float shadow_culled;
shadow_map_index = 0;
for(int i = 0; i < light_dir_count; i++) {
light_dir_strength = dot(normalize(v_vNormal), normalize(light_dir_direction[i]));
if(light_dir_strength < 0.)
continue;
if(light_dir_shadow_active[i] == 1) {
vec4 cameraSpace = light_dir_view[i] * v_worldPosition;
vec4 screenSpace = light_dir_proj[i] * cameraSpace;
float v_lightDistance = screenSpace.z / screenSpace.w;
vec2 lightMapPosition = (screenSpace.xy / screenSpace.w * 0.5) + 0.5;
light_dir_strength = max(light_dir_strength * light_dir_intensity[i], 0.);
light_effect += light_dir_color[i].rgb * light_dir_strength;
}
light_map_depth = sampleDirShadowMap(shadow_map_index, lightMapPosition);
shadow_map_index++;
lightDistance = v_lightDistance;
if(lightDistance > light_map_depth + shadowBias)
continue;
}
light_dir_strength = max(light_dir_strength * light_dir_intensity[i], 0.);
light_effect += light_dir_color[i].rgb * light_dir_strength;
}
#endregion
#region ---- point ----
float light_pnt_strength;
float light_distance;
float light_attenuation;
for(int i = 0; i < light_pnt_count; i++) {
float light_pnt_strength = dot(normalize(v_vNormal), normalize(light_pnt_position[i] - v_worldPosition));
if(light_pnt_strength < 0.)
continue;
shadow_map_index = 0;
for(int i = 0; i < light_pnt_count; i++) {
light_pnt_strength = dot(normalize(v_vNormal), normalize(light_pnt_position[i] - v_worldPosition.xyz));
if(light_pnt_strength < 0.)
continue;
float light_distance = distance(light_pnt_position[i], v_worldPosition);
if(light_distance > light_pnt_radius[i])
continue;
light_distance = distance(light_pnt_position[i], v_worldPosition.xyz);
if(light_distance > light_pnt_radius[i])
continue;
float light_attenuation = 1. - pow(light_distance / light_pnt_radius[i], 2.);
if(light_pnt_shadow_active[i] == 1) {
vec3 dir = v_worldPosition.xyz - light_pnt_position[i];
vec3 dirAbs = abs(dir);
int side = dirAbs.x > dirAbs.y ?
(dirAbs.x > dirAbs.z ? 0 : 2) :
(dirAbs.y > dirAbs.z ? 1 : 2);
side *= 2;
if(side == 0 && dir.x < 0.) side += 1;
else if(side == 2 && dir.y < 0.) side += 1;
else if(side == 4 && dir.z < 0.) side += 1;
vec4 cameraSpace = light_pnt_view[i * 6 + side] * v_worldPosition;
vec4 screenSpace = light_pnt_proj[i] * cameraSpace;
float v_lightDistance = screenSpace.z / screenSpace.w;
vec2 lightMapPosition = (screenSpace.xy / screenSpace.w * 0.5) + 0.5;
light_map_depth = samplePntShadowMap(shadow_map_index, lightMapPosition, side);
shadow_map_index++;
if(v_lightDistance > light_map_depth + shadowBias)
continue;
}
light_pnt_strength = max(light_pnt_strength * light_pnt_intensity[i] * light_attenuation, 0.);
light_effect += light_pnt_color[i].rgb * light_pnt_strength;
}
light_attenuation = 1. - pow(light_distance / light_pnt_radius[i], 2.);
light_pnt_strength = max(light_pnt_strength * light_pnt_intensity[i] * light_attenuation, 0.);
light_effect += light_pnt_color[i].rgb * light_pnt_strength;
}
#endregion
light_effect = max(light_effect, 0.);
final_color.rgb *= light_effect;
#endregion
gl_FragColor = final_color;
if(gammaCorrection == 1) {
final_color.r = pow(final_color.r, 1. / 2.2);
final_color.g = pow(final_color.g, 1. / 2.2);
final_color.b = pow(final_color.b, 1. / 2.2);
}
gl_FragColor = final_color;
}

View file

@ -10,14 +10,13 @@ varying vec2 v_vTexcoord;
varying vec4 v_vColour;
varying vec3 v_vNormal;
varying vec3 v_worldPosition;
varying vec4 v_worldPosition;
void main()
{
void main() {
vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0);
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos;
v_worldPosition = (gm_Matrices[MATRIX_WORLD] * object_space_pos).xyz;
v_worldPosition = (gm_Matrices[MATRIX_WORLD] * object_space_pos);
v_vColour = in_Colour;
v_vTexcoord = in_TextureCoord;

View file

@ -0,0 +1,13 @@
varying vec2 v_vTexcoord;
varying float v_LightDepth_0;
varying float v_LightDepth_1;
varying float v_LightDepth_2;
varying float v_LightDepth_3;
varying float v_LightDepth_4;
varying float v_LightDepth_5;
void main() {
gl_FragData[0] = vec4(v_LightDepth_0, v_LightDepth_1, v_LightDepth_2, 1.);
gl_FragData[1] = vec4(v_LightDepth_3, v_LightDepth_4, v_LightDepth_5, 1.);
}

View file

@ -0,0 +1,42 @@
attribute vec3 in_Position;
attribute vec3 in_Normal;
attribute vec4 in_Colour;
attribute vec2 in_TextureCoord;
varying vec2 v_vTexcoord;
varying float v_LightDepth_0;
varying float v_LightDepth_1;
varying float v_LightDepth_2;
varying float v_LightDepth_3;
varying float v_LightDepth_4;
varying float v_LightDepth_5;
uniform mat4 viewMat[6];
uniform mat4 projMat;
void main() {
v_vTexcoord = in_TextureCoord;
vec4 object_space_pos = vec4( in_Position, 1.0);
gl_Position = vec4(0., 0., 1., 1.);
vec4 worldPos = gm_Matrices[MATRIX_WORLD] * object_space_pos;
vec4 proj0 = projMat * (viewMat[0] * object_space_pos);
v_LightDepth_0 = proj0.z / proj0.w;
vec4 proj1 = projMat * (viewMat[1] * object_space_pos);
v_LightDepth_1 = proj1.z / proj1.w;
vec4 proj2 = projMat * (viewMat[2] * object_space_pos);
v_LightDepth_2 = proj2.z / proj2.w;
vec4 proj3 = projMat * (viewMat[3] * object_space_pos);
v_LightDepth_3 = proj3.z / proj3.w;
vec4 proj4 = projMat * (viewMat[4] * object_space_pos);
v_LightDepth_4 = proj4.z / proj4.w;
vec4 proj5 = projMat * (viewMat[5] * object_space_pos);
v_LightDepth_5 = proj5.z / proj5.w;
}

View file

@ -0,0 +1,10 @@
{
"resourceType": "GMShader",
"resourceVersion": "1.0",
"name": "sh_d3d_shadow_cube_depth",
"parent": {
"name": "3d",
"path": "folders/shader/3d.yy",
},
"type": 1,
}

View file

@ -0,0 +1,5 @@
varying float v_LightDepth;
void main() {
gl_FragColor = vec4(v_LightDepth, v_LightDepth, v_LightDepth, 1.);
}

View file

@ -0,0 +1,13 @@
attribute vec3 in_Position;
attribute vec3 in_Normal;
attribute vec4 in_Colour;
attribute vec2 in_TextureCoord;
varying float v_LightDepth;
void main() {
vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0);
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos;
v_LightDepth = gl_Position.z / gl_Position.w;
}

View file

@ -0,0 +1,10 @@
{
"resourceType": "GMShader",
"resourceVersion": "1.0",
"name": "sh_d3d_shadow_depth",
"parent": {
"name": "3d",
"path": "folders/shader/3d.yy",
},
"type": 1,
}