diff --git a/Assets/Textures/black.svg b/Assets/Textures/black.svg new file mode 100644 index 0000000..234b731 --- /dev/null +++ b/Assets/Textures/black.svg @@ -0,0 +1,55 @@ + + + + diff --git a/Assets/Textures/black.svg.import b/Assets/Textures/black.svg.import new file mode 100644 index 0000000..3170822 --- /dev/null +++ b/Assets/Textures/black.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://kv20kvoxm0nm" +path="res://.godot/imported/black.svg-e64c1ca690c6ed521c021a0c289dbfcc.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Assets/Textures/black.svg" +dest_files=["res://.godot/imported/black.svg-e64c1ca690c6ed521c021a0c289dbfcc.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Assets/Textures/white.svg b/Assets/Textures/white.svg new file mode 100644 index 0000000..a26f024 --- /dev/null +++ b/Assets/Textures/white.svg @@ -0,0 +1,55 @@ + + + + diff --git a/Assets/Textures/white.svg.import b/Assets/Textures/white.svg.import new file mode 100644 index 0000000..b5844f5 --- /dev/null +++ b/Assets/Textures/white.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://coc7upm22lwcw" +path="res://.godot/imported/white.svg-6515ccdbdfcea435b23d45ef68955f3e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Assets/Textures/white.svg" +dest_files=["res://.godot/imported/white.svg-6515ccdbdfcea435b23d45ef68955f3e.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Icons/1stPersonCamera.svg b/Icons/1stPersonCamera.svg new file mode 100644 index 0000000..a2c858d --- /dev/null +++ b/Icons/1stPersonCamera.svg @@ -0,0 +1,272 @@ + + diff --git a/Icons/1stPersonCamera.svg.import b/Icons/1stPersonCamera.svg.import new file mode 100644 index 0000000..ea85676 --- /dev/null +++ b/Icons/1stPersonCamera.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bybc633uoyc63" +path="res://.godot/imported/1stPersonCamera.svg-5780039fa0f577bdcb3cebdee20c47ca.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Icons/1stPersonCamera.svg" +dest_files=["res://.godot/imported/1stPersonCamera.svg-5780039fa0f577bdcb3cebdee20c47ca.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Icons/3rdPersonCamera.svg b/Icons/3rdPersonCamera.svg new file mode 100644 index 0000000..5bb7a85 --- /dev/null +++ b/Icons/3rdPersonCamera.svg @@ -0,0 +1,344 @@ + + diff --git a/Icons/3rdPersonCamera.svg.import b/Icons/3rdPersonCamera.svg.import new file mode 100644 index 0000000..5cc61a8 --- /dev/null +++ b/Icons/3rdPersonCamera.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bysvvauiou31r" +path="res://.godot/imported/3rdPersonCamera.svg-b43310ef7b96c4b20d3a94a7a829a27a.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Icons/3rdPersonCamera.svg" +dest_files=["res://.godot/imported/3rdPersonCamera.svg-b43310ef7b96c4b20d3a94a7a829a27a.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Icons/App.svg b/Icons/App.svg new file mode 100644 index 0000000..d3fc1bd --- /dev/null +++ b/Icons/App.svg @@ -0,0 +1,214 @@ + + diff --git a/Icons/App.svg.import b/Icons/App.svg.import new file mode 100644 index 0000000..663491c --- /dev/null +++ b/Icons/App.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dws653np5py2n" +path="res://.godot/imported/App.svg-f7901091f65f647809fad5646e1473c9.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Icons/App.svg" +dest_files=["res://.godot/imported/App.svg-f7901091f65f647809fad5646e1473c9.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Icons/AudioManager.svg b/Icons/AudioManager.svg new file mode 100644 index 0000000..dca31d2 --- /dev/null +++ b/Icons/AudioManager.svg @@ -0,0 +1,251 @@ + + diff --git a/Icons/AudioManager.svg.import b/Icons/AudioManager.svg.import new file mode 100644 index 0000000..7dfb601 --- /dev/null +++ b/Icons/AudioManager.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bbg0o3nwhk8id" +path="res://.godot/imported/AudioManager.svg-f71d6864097b95764d9bb5386b195758.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Icons/AudioManager.svg" +dest_files=["res://.godot/imported/AudioManager.svg-f71d6864097b95764d9bb5386b195758.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Icons/EditorCamera.svg b/Icons/EditorCamera.svg new file mode 100644 index 0000000..925ed66 --- /dev/null +++ b/Icons/EditorCamera.svg @@ -0,0 +1,368 @@ + + diff --git a/Icons/EditorCamera.svg.import b/Icons/EditorCamera.svg.import new file mode 100644 index 0000000..41838b8 --- /dev/null +++ b/Icons/EditorCamera.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://q5o327w2m523" +path="res://.godot/imported/EditorCamera.svg-43cdf6f8dc7b68d182e82963eaf7dd9b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Icons/EditorCamera.svg" +dest_files=["res://.godot/imported/EditorCamera.svg-43cdf6f8dc7b68d182e82963eaf7dd9b.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Icons/FollowCamera.svg b/Icons/FollowCamera.svg new file mode 100644 index 0000000..b9ee3fc --- /dev/null +++ b/Icons/FollowCamera.svg @@ -0,0 +1,384 @@ + + diff --git a/Icons/FollowCamera.svg.import b/Icons/FollowCamera.svg.import new file mode 100644 index 0000000..5de38c2 --- /dev/null +++ b/Icons/FollowCamera.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bnwjpf3k16lpc" +path="res://.godot/imported/FollowCamera.svg-2d02c63e5396da01c254b582b773e3c3.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Icons/FollowCamera.svg" +dest_files=["res://.godot/imported/FollowCamera.svg-2d02c63e5396da01c254b582b773e3c3.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Icons/LocaleManager.svg b/Icons/LocaleManager.svg index 20e085b..57860f3 100644 --- a/Icons/LocaleManager.svg +++ b/Icons/LocaleManager.svg @@ -15,6 +15,17 @@ xmlns:svg="http://www.w3.org/2000/svg"> + ry="3.1061034" /> diff --git a/Icons/LookAtCamera.svg b/Icons/LookAtCamera.svg new file mode 100644 index 0000000..9e1c63d --- /dev/null +++ b/Icons/LookAtCamera.svg @@ -0,0 +1,368 @@ + + diff --git a/Icons/LookAtCamera.svg.import b/Icons/LookAtCamera.svg.import new file mode 100644 index 0000000..0ed5c34 --- /dev/null +++ b/Icons/LookAtCamera.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cbln0ypjm4ii4" +path="res://.godot/imported/LookAtCamera.svg-e132258383111453e13a4bf0c03eb9ac.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Icons/LookAtCamera.svg" +dest_files=["res://.godot/imported/LookAtCamera.svg-e132258383111453e13a4bf0c03eb9ac.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Icons/NetworkManager.svg b/Icons/NetworkManager.svg index 2cefb36..88d0059 100644 --- a/Icons/NetworkManager.svg +++ b/Icons/NetworkManager.svg @@ -14,6 +14,78 @@ xmlns:svg="http://www.w3.org/2000/svg"> + + + + + + + + + + + + + + + + + + + + + + @@ -182,6 +254,49 @@ r="3.5763378" gradientUnits="userSpaceOnUse" gradientTransform="matrix(2.5133018,1.6535943,-2.2403611,2.1022182,-15.418199,-9.6704081)" /> + + + + + @@ -263,6 +384,20 @@ d="m 11.163139,13.737204 c -0.144258,0.180322 -2.74089,1.009801 -2.74089,1.009801 L 6.1862598,14.422427 5.3207156,13.845397 H 6.835418 c 0,0 1.8392813,0.180321 2.019603,0.180321 0.1803217,0 2.308118,-0.288514 2.308118,-0.288514 z" id="path62527" /> + + diff --git a/Icons/OnEvent.svg b/Icons/OnEvent.svg index 2ede91c..d2153a4 100644 --- a/Icons/OnEvent.svg +++ b/Icons/OnEvent.svg @@ -9,14 +9,39 @@ inkscape:version="1.2.2 (732a01da63, 2022-12-09)" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"> + id="defs8"> + + + + + + + id="path2265" + style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:14.6322;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers" + d="m 565.05414,249.80434 c -10.13061,17.02752 -19.39646,35.46483 -27.46539,53.49172 -9.56873,-1.59929 -19.1799,-2.19189 -28.80426,-2.30675 v -0.0147 c -0.0658,0 -0.13096,0.0147 -0.18729,0.0147 -0.0586,0 -0.12438,-0.0147 -0.18436,-0.0147 v 0.0147 c -9.64337,0.1141 -19.2487,0.70746 -28.81887,2.30675 -8.06381,-18.02469 -17.32236,-36.46347 -27.4676,-53.49099 -25.36275,5.63854 -50.45115,13.48579 -73.97316,25.32545 0.53773,20.77042 1.8795,40.67243 4.60183,60.88757 -9.1349,5.85215 -18.7351,10.87539 -27.2686,17.72619 -8.66886,6.66937 -17.52501,13.05193 -25.37446,20.85237 -15.68207,-10.37277 -32.27866,-20.12077 -49.37786,-28.7267 -18.43074,19.8369 -35.6675,41.24822 -49.74588,65.20555 10.59226,17.13505 21.65056,33.19537 33.59044,48.43629 h 0.33216 v 147.04109 c 0.26849,0 0.53992,0.0147 0.80696,0.0366 l 90.14396,8.68934 c 4.72254,0.45578 8.4223,4.25796 8.75079,8.99002 l 2.78012,39.79159 78.63353,5.61291 5.41537,-36.72833 c 0.70235,-4.76205 4.7884,-8.28842 9.60459,-8.28842 h 95.10575 c 4.81472,0 8.89931,3.52637 9.60238,8.28842 l 5.41538,36.72833 78.63572,-5.61291 2.77721,-39.79159 c 0.3314,-4.73206 4.02823,-8.53204 8.7508,-8.99002 l 90.10811,-8.68934 c 0.26627,-0.022 0.53476,-0.0366 0.80325,-0.0366 v -11.7343 l 0.0362,-0.0146 v -135.2944 h 0.33216 c 11.94135,-15.24092 22.99308,-31.30196 33.59042,-48.43629 -14.07396,-23.95804 -31.31731,-45.37011 -49.74879,-65.20554 -17.09478,8.60449 -33.70015,18.35248 -49.38224,28.72669 -7.84725,-7.79968 -16.68585,-14.18227 -25.36787,-20.85163 -8.52911,-6.85153 -18.1432,-11.87476 -27.26127,-17.72692 2.715,-20.21514 4.05898,-40.11642 4.5989,-60.88611 -23.52422,-11.8404 -48.61188,-19.68985 -73.98781,-25.32764 z M 380.80602,464.90595 c 30.00482,0 54.32503,24.30265 54.32503,54.29795 0,30.01434 -24.32021,54.32774 -54.32503,54.32774 -29.99091,0 -54.3177,-24.3134 -54.3177,-54.32774 0,-29.9953 24.32825,-54.29795 54.3177,-54.29795 z m 255.57506,0 c 29.98799,0 54.31038,24.30265 54.31038,54.29795 0,30.01434 -24.32239,54.32774 -54.31038,54.32774 -30.00923,0 -54.32797,-24.3134 -54.32797,-54.32774 0,-29.9953 24.31874,-54.29795 54.32797,-54.29795 z m -127.79924,31.77313 c 9.65874,0 17.50526,7.12588 17.50526,15.89277 v 50.00977 c 0,8.77347 -7.84727,15.89131 -17.50526,15.89131 -9.65873,0 -17.4855,-7.11784 -17.4855,-15.89131 v -50.00977 c 0,-8.76689 7.82677,-15.89277 17.4855,-15.89277 z m 102.03409,192.12369 c -19.91077,0 -36.04133,16.15176 -36.04133,36.06035 0,19.9086 16.13201,36.04427 36.04133,36.04427 19.92908,0 36.05743,-16.13567 36.05743,-36.04427 0,-19.90859 -16.12907,-36.06035 -36.05743,-36.06035 z m -205.9572,5.68021 c -19.91371,0 -36.0567,16.15179 -36.0567,36.06038 0,19.90933 16.14299,36.04352 36.0567,36.04352 19.92469,0 36.06037,-16.13419 36.06037,-36.04352 0,-19.90787 -16.13641,-36.06038 -36.06037,-36.06038 z" /> diff --git a/Icons/SensorManager.svg b/Icons/SensorManager.svg index 5079165..567ef6f 100644 --- a/Icons/SensorManager.svg +++ b/Icons/SensorManager.svg @@ -14,6 +14,22 @@ xmlns:svg="http://www.w3.org/2000/svg"> + + + + + @@ -182,6 +198,17 @@ r="3.5763378" gradientUnits="userSpaceOnUse" gradientTransform="matrix(2.5133018,1.6535943,-2.2403611,2.1022182,-15.418199,-9.6704081)" /> + + inkscape:current-layer="g10886" /> @@ -212,7 +239,7 @@ id="g10886" transform="matrix(0.94595208,0,0,0.94595208,0.43331955,0.43182955)"> + diff --git a/Icons/StrategyTopDownCamera.svg.import b/Icons/StrategyTopDownCamera.svg.import new file mode 100644 index 0000000..abc387f --- /dev/null +++ b/Icons/StrategyTopDownCamera.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ck4vu18arqsrj" +path="res://.godot/imported/StrategyTopDownCamera.svg-9941bec42760ab8979ae0c4c20d1ed91.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Icons/StrategyTopDownCamera.svg" +dest_files=["res://.godot/imported/StrategyTopDownCamera.svg-9941bec42760ab8979ae0c4c20d1ed91.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Icons/TimeLineManager.svg b/Icons/TimeLineManager.svg index 354dd7c..359f433 100644 --- a/Icons/TimeLineManager.svg +++ b/Icons/TimeLineManager.svg @@ -16,10 +16,16 @@ id="defs8"> + inkscape:transform-center-x="-1.6869533" /> diff --git a/Icons/UI.svg b/Icons/UI.svg index bbda55d..462bd02 100644 --- a/Icons/UI.svg +++ b/Icons/UI.svg @@ -15,6 +15,39 @@ xmlns:svg="http://www.w3.org/2000/svg"> + style="font-weight:bold;font-size:20.5236px;line-height:1;font-family:Jost;-inkscape-font-specification:'Jost Bold';stroke-width:1.42896;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:0.391011;paint-order:stroke fill markers;fill-opacity:1;fill:url(#linearGradient52839)" + d="M 23.119092 28.045115 L 23.119092 37.690573 C 23.119092 38.593611 23.263165 39.382069 23.550495 40.052506 C 23.837825 40.70926 24.238494 41.261889 24.758424 41.713408 C 25.292038 42.151245 25.908467 42.475235 26.606268 42.680471 C 27.30407 42.899388 28.064572 43.007618 28.885515 43.007618 C 29.679094 43.007618 30.423821 42.899388 31.121622 42.680471 C 31.833106 42.475235 32.449536 42.151245 32.969466 41.713408 C 33.50308 41.261889 33.911636 40.70926 34.198966 40.052506 C 34.499978 39.382069 34.651939 38.593611 34.651939 37.690573 L 34.651939 28.045115 L 31.182738 28.045115 L 31.182738 37.446111 C 31.182738 37.938677 31.094577 38.367301 30.916706 38.736726 C 30.752517 39.092467 30.500215 39.376321 30.158155 39.581557 C 29.829778 39.786793 29.413334 39.887134 28.907086 39.887134 C 28.373473 39.887134 27.933365 39.786793 27.591306 39.581557 C 27.262929 39.376321 27.010626 39.092467 26.832755 38.736726 C 26.654884 38.367301 26.566723 37.938677 26.566723 37.446111 L 26.566723 28.045115 L 23.119092 28.045115 z M 37.607052 28.045115 L 37.607052 42.410844 L 41.115798 42.410844 L 41.115798 28.045115 L 37.607052 28.045115 z " /> diff --git a/Icons/UIBorderImage.svg b/Icons/UIBorderImage.svg index d62706c..ba5b293 100644 --- a/Icons/UIBorderImage.svg +++ b/Icons/UIBorderImage.svg @@ -15,6 +15,22 @@ xmlns:svg="http://www.w3.org/2000/svg"> diff --git a/Icons/UIBreak.svg b/Icons/UIBreak.svg new file mode 100644 index 0000000..a4ff410 --- /dev/null +++ b/Icons/UIBreak.svg @@ -0,0 +1,119 @@ + + diff --git a/Icons/UIBreak.svg.import b/Icons/UIBreak.svg.import new file mode 100644 index 0000000..33fc65d --- /dev/null +++ b/Icons/UIBreak.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cevqikjws5bwf" +path="res://.godot/imported/UIBreak.svg-0f0f122342064fcefe62ba29fed1cd20.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Icons/UIBreak.svg" +dest_files=["res://.godot/imported/UIBreak.svg-0f0f122342064fcefe62ba29fed1cd20.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Icons/UIImage.svg b/Icons/UIImage.svg index 00e32cb..a371622 100644 --- a/Icons/UIImage.svg +++ b/Icons/UIImage.svg @@ -16,10 +16,10 @@ id="defs8"> + + + + + + + + @@ -200,6 +224,28 @@ x2="-5.8460503" y2="26.179316" gradientUnits="userSpaceOnUse" /> + + + inkscape:current-layer="g32301" /> @@ -236,12 +282,12 @@ id="g32301" transform="matrix(1.1197583,0,0,1.1197583,3.8403849,-0.76965192)"> diff --git a/Icons/UISpace.svg b/Icons/UISpace.svg new file mode 100644 index 0000000..0dbc343 --- /dev/null +++ b/Icons/UISpace.svg @@ -0,0 +1,135 @@ + + diff --git a/Icons/UISpace.svg.import b/Icons/UISpace.svg.import new file mode 100644 index 0000000..548b99c --- /dev/null +++ b/Icons/UISpace.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://7fsyqv1158ka" +path="res://.godot/imported/UISpace.svg-1c2449c73a72290a0d81eb9ad67033f8.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Icons/UISpace.svg" +dest_files=["res://.godot/imported/UISpace.svg-1c2449c73a72290a0d81eb9ad67033f8.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Icons/UIText.svg b/Icons/UIText.svg index 67b4d7c..5f5d84d 100644 --- a/Icons/UIText.svg +++ b/Icons/UIText.svg @@ -15,6 +15,14 @@ xmlns:svg="http://www.w3.org/2000/svg"> + id="path53229" + style="fill:url(#radialGradient62177);fill-opacity:1" /> diff --git a/Icons/VirtualCamera3D.svg b/Icons/VirtualCamera3D.svg index d9e08cb..0aa5088 100644 --- a/Icons/VirtualCamera3D.svg +++ b/Icons/VirtualCamera3D.svg @@ -15,6 +15,14 @@ xmlns:svg="http://www.w3.org/2000/svg"> + style="fill:url(#radialGradient1015);fill-opacity:1;stroke:none;stroke-width:1.72262;stroke-opacity:1" /> diff --git a/Icons/VirtualCamera3DSlot.svg b/Icons/VirtualCamera3DSlot.svg index 4ea6451..e84c3e7 100644 --- a/Icons/VirtualCamera3DSlot.svg +++ b/Icons/VirtualCamera3DSlot.svg @@ -15,6 +15,14 @@ xmlns:svg="http://www.w3.org/2000/svg"> + style="fill:url(#radialGradient2582);fill-opacity:1;stroke:none;stroke-width:1.42356;stroke-opacity:1" + d="M 38.807791 25.690372 A 4.270706 4.270706 0 0 0 34.536898 29.644902 A 4.270706 4.270706 0 1 0 30.266006 36.831361 L 30.266006 39.92668 A 1.4235688 1.4235688 0 0 0 31.689637 41.350311 L 40.231421 41.350311 A 1.4235688 1.4235688 0 0 0 41.655052 39.92668 L 41.655052 38.503049 L 45.925945 41.350311 L 45.925945 32.808526 L 41.655052 35.655787 L 41.655052 33.135673 A 4.270706 4.270706 0 0 0 38.807791 25.690372 z M 17.791261 30.669485 L 17.791261 39.980605 L 25.854907 35.325045 L 17.791261 30.669485 z " /> diff --git a/Icons/VirtualCameraManager.svg b/Icons/VirtualCameraManager.svg index 96c71c6..ce37737 100644 --- a/Icons/VirtualCameraManager.svg +++ b/Icons/VirtualCameraManager.svg @@ -15,6 +15,22 @@ xmlns:svg="http://www.w3.org/2000/svg"> + style="fill:url(#radialGradient60172);fill-opacity:1;stroke:none;stroke-width:1.70175;stroke-linecap:round;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1;paint-order:markers stroke fill" /> diff --git a/Icons/WorldMap.svg b/Icons/WorldMap.svg new file mode 100644 index 0000000..341d892 --- /dev/null +++ b/Icons/WorldMap.svg @@ -0,0 +1,514 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Icons/WorldMap.svg.import b/Icons/WorldMap.svg.import new file mode 100644 index 0000000..dcdfcfe --- /dev/null +++ b/Icons/WorldMap.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dlj6allpr756i" +path="res://.godot/imported/WorldMap.svg-f53933db960d94846c09fcda614ad68d.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Icons/WorldMap.svg" +dest_files=["res://.godot/imported/WorldMap.svg-f53933db960d94846c09fcda614ad68d.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Icons/WorldMapLayer.svg b/Icons/WorldMapLayer.svg new file mode 100644 index 0000000..a612d7f --- /dev/null +++ b/Icons/WorldMapLayer.svg @@ -0,0 +1,771 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Icons/WorldMapLayer.svg.import b/Icons/WorldMapLayer.svg.import new file mode 100644 index 0000000..694057f --- /dev/null +++ b/Icons/WorldMapLayer.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://g6uo0nag2t8q" +path="res://.godot/imported/WorldMapLayer.svg-f9e4a287695d4348ffbd491fa4cebc34.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/rokojori_action_library/Icons/WorldMapLayer.svg" +dest_files=["res://.godot/imported/WorldMapLayer.svg-f9e4a287695d4348ffbd491fa4cebc34.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/RokojoriPlugin.cs b/RokojoriPlugin.cs index 1dafab6..3d62400 100644 --- a/RokojoriPlugin.cs +++ b/RokojoriPlugin.cs @@ -225,7 +225,7 @@ namespace Rokojori { if ( editingSceneUI != null ) { - editingSceneUI.RemoveSelf(); + editingSceneUI.DeleteSelf(); editingSceneUI = null; } diff --git a/Runtime/Actions/Node3D/PlaySound.cs b/Runtime/Actions/Node3D/PlaySound.cs index 4e225a5..4a7d883 100644 --- a/Runtime/Actions/Node3D/PlaySound.cs +++ b/Runtime/Actions/Node3D/PlaySound.cs @@ -116,7 +116,7 @@ namespace Rokojori var start = tl.position; - var stopDuration = ( durationPerSound.GetDurationInSeconds() - audioManager.bufferCutLength * cutBufferLengths ) / player.PitchScale; + var stopDuration = ( durationPerSound.GetDurationInSeconds() - audioManager.data.bufferCutDuration * cutBufferLengths ) / player.PitchScale; TimeLineManager.ScheduleSpanIn( durationPerSound.timeLine, 0, stopDuration, ( span, type )=> { diff --git a/Runtime/Animation/MoveLoop.cs b/Runtime/Animation/MoveLoop.cs new file mode 100644 index 0000000..649d4a7 --- /dev/null +++ b/Runtime/Animation/MoveLoop.cs @@ -0,0 +1,65 @@ +using System.Collections; +using System.Collections.Generic; +using System.Text.RegularExpressions; +using System.Text; +using Godot; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class MoveLoop:Node3D + { + [Export] + public Curve x; + + [Export] + public Curve y; + + [Export] + public Curve z; + + [Export] + public Node3D target; + + [Export] + public Duration duration; + + [Export] + public bool global = false; + + public override void _Process( double delta ) + { + if ( target == null || duration == null ) + { + return; + } + + var phase = duration.GetLoopPhase(); + + var position = target.GetLocalOrGlobalPosition( global ); + + if ( x != null ) + { + position.X = x.Sample( phase ); + } + + if ( y != null ) + { + position.Y = y.Sample( phase ); + } + + if ( z != null ) + { + position.Z = z.Sample( phase ); + } + + target.SetLocalOrGlobalPosition( position, global ); + + + + + } + } + +} \ No newline at end of file diff --git a/Runtime/Animation/MoveLoop.cs.uid b/Runtime/Animation/MoveLoop.cs.uid new file mode 100644 index 0000000..ce38a0f --- /dev/null +++ b/Runtime/Animation/MoveLoop.cs.uid @@ -0,0 +1 @@ +uid://dxk3tw332wbds diff --git a/Runtime/App/App.cs b/Runtime/App/App.cs index 3351b1c..5816c31 100644 --- a/Runtime/App/App.cs +++ b/Runtime/App/App.cs @@ -28,7 +28,7 @@ namespace Rokojori } [Tool] - [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/SensorManager.svg")] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/App.svg")] public partial class App: Node { [Export] @@ -48,55 +48,7 @@ namespace Rokojori set { _fps = value; Engine.MaxFps = _fps; } } - - - [ExportToolButton( "Initialize")] - public Callable InitializeButton => Callable.From( Initialize ); - - public override void _Process( double delta ) - { - Engine.MaxFps = _fps; - } - - public void Initialize() - { - var types = new List{ - typeof ( TimeLineManager ), - typeof ( SensorManager ), - typeof ( NetworkManager ), - typeof ( LocaleManager ), - typeof ( VirtualCamera3DManager ), - typeof ( MouseEditorCamera ), - typeof ( Camera3D ), - typeof ( UI ) - - }; - - types.ForEach( - ( t )=> - { - this.LogInfo( "Creating:", t.Name ); - this.CreateChildWithType( t, t.Name ); - } - ); - - - - - } - - void InitializeCamera() - { - var cameraManager = this.Get(); - var camera = this.Get(); - - cameraManager.camera = camera; - var slot = cameraManager.CreateChild(); - slot.camera = this.Get(); - - } - - + } } \ No newline at end of file diff --git a/Runtime/App/Settings/AppSetting.cs b/Runtime/App/Settings/AppSetting.cs new file mode 100644 index 0000000..f550dec --- /dev/null +++ b/Runtime/App/Settings/AppSetting.cs @@ -0,0 +1,17 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class AppSetting:Resource + { + public LocaleText GetName(){ return null; } + public LocaleText GetInfo(){ return null; } + + public string Serialize(){ return null; } + public void SetFromSerialized( string serializedValue ){} + } +} \ No newline at end of file diff --git a/Runtime/App/Settings/AppSetting.cs.uid b/Runtime/App/Settings/AppSetting.cs.uid new file mode 100644 index 0000000..feaa994 --- /dev/null +++ b/Runtime/App/Settings/AppSetting.cs.uid @@ -0,0 +1 @@ +uid://cjl1jm2vsnfqp diff --git a/Runtime/Audio/AudioManager/AudioManager.cs b/Runtime/Audio/AudioManager/AudioManager.cs index a204582..9088ced 100644 --- a/Runtime/Audio/AudioManager/AudioManager.cs +++ b/Runtime/Audio/AudioManager/AudioManager.cs @@ -4,12 +4,12 @@ using System.Text; namespace Rokojori { - [GlobalClass,Tool] + [GlobalClass,Tool, Icon("res://addons/rokojori_action_library/Icons/AudioManager.svg") ] public partial class AudioManager:Node { [Export] - public float bufferCutLength = 0.021f; - + public AudioManagerData data; + Dictionary _lastPlayTime = new Dictionary(); public float GetLastPlayed( SelectorFlag selectorFlag ) diff --git a/Runtime/Audio/AudioManager/AudioManagerData.cs b/Runtime/Audio/AudioManager/AudioManagerData.cs new file mode 100644 index 0000000..d92f34f --- /dev/null +++ b/Runtime/Audio/AudioManager/AudioManagerData.cs @@ -0,0 +1,13 @@ +using Godot; +using System.Collections.Generic; +using System.Text; + +namespace Rokojori +{ + [GlobalClass,Tool, Icon("res://addons/rokojori_action_library/Icons/AudioManager.svg") ] + public partial class AudioManagerData:Resource + { + [Export] + public float bufferCutDuration = 0.021f; + } +} \ No newline at end of file diff --git a/Runtime/Audio/AudioManager/AudioManagerData.cs.uid b/Runtime/Audio/AudioManager/AudioManagerData.cs.uid new file mode 100644 index 0000000..ed15310 --- /dev/null +++ b/Runtime/Audio/AudioManager/AudioManagerData.cs.uid @@ -0,0 +1 @@ +uid://cylo4w2wfqxd1 diff --git a/Runtime/VirtualCameras/VirtualCamera3DManager.cs b/Runtime/Cameras/CameraManager.cs similarity index 80% rename from Runtime/VirtualCameras/VirtualCamera3DManager.cs rename to Runtime/Cameras/CameraManager.cs index 37f338a..4353928 100644 --- a/Runtime/VirtualCameras/VirtualCamera3DManager.cs +++ b/Runtime/Cameras/CameraManager.cs @@ -11,7 +11,7 @@ namespace Rokojori { [Tool] [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/VirtualCameraManager.svg") ] - public partial class VirtualCamera3DManager:NetworkNode + public partial class CameraManager:NetworkNode { [Export] public Camera3D camera; @@ -19,24 +19,33 @@ namespace Rokojori [Export] public WorldEnvironment worldEnvironment; + [Export] + public VirtualCamera debugCamera; + + [Export] + public Sensor debugCameraToggle; + + [Export] + public bool debugCameraActive = false; + [Export] public bool refreshSlots = false; [Export] - public bool active = false; + public bool active = true; [Export] - public bool postProcess = false; + public bool postProcess = true; [Export] public PostProcessVolume[] postProcessVolumes = []; - public static VirtualCamera3DManager Get() + public static CameraManager Get() { - return Unique.Get(); + return Unique.Get(); } - public VirtualCamera3DSlot activeSlot + public CameraSlot activeSlot { get { @@ -69,6 +78,7 @@ namespace Rokojori } List prios = new List(); + public override void _Process( double delta ) { if ( ! active ) @@ -78,11 +88,31 @@ namespace Rokojori ProcessCameras( delta ); + + ProcessDebugCamera(); + + ProcessPostProcess( delta ); } + void ProcessDebugCamera() + { + if ( Sensors.IsDown( debugCameraToggle ) ) + { + debugCameraActive = ! debugCameraActive; + this.LogInfo( debugCameraActive ); + } + + if ( debugCameraActive && debugCamera != null ) + { + SetDebugCamera( debugCamera ); + return; + } + + } + PostProcessEffectProcessor glowEffectProcessor = new PostProcessEffectProcessor(); PostProcessEffectProcessor fogEffectProcessor = new PostProcessEffectProcessor(); @@ -174,6 +204,8 @@ namespace Rokojori void ProcessCameras( double delta ) { + + if ( ! _lerpingCameras ) { RefreshSlots(); @@ -194,7 +226,46 @@ namespace Rokojori } } - void SetSingleCamera( VirtualCamera3DSlot c, double delta ) + void SetDebugCamera( VirtualCamera c ) + { + var rotation = c.GetCameraRotation(); + + var vUp = rotation * Vector3.Up; + var vForward = rotation * Vector3.Forward; + + var position = c.GetCameraPosition(); + var up = vUp; + var forward = vForward; + var fov = c.GetCameraFOV(); + + if ( forward.LengthSquared() == 0 ) + { + forward = camera.Basis.Z; + } + else + { + forward = forward.Normalized(); + } + + if ( up.LengthSquared() == 0 ) + { + up = camera.Basis.Y; + } + else + { + up = up.Normalized(); + } + + // RJLog.Log( "Set Cam", position ); + + + + camera.GlobalPosition = position; + camera.LookAt( position - forward, up ); + camera.Fov = fov; + } + + void SetSingleCamera( CameraSlot c, double delta ) { c.Update( delta, this ); @@ -256,24 +327,24 @@ namespace Rokojori public float smoothStepDelta => 1f / CameraPrioritySmoothingStepFPS; public float safeSmoothing => Mathf.Max( 0, CameraPrioritySmoothingCoefficient ); - List _cameraSlots = new List(); + List _cameraSlots = new List(); - public VirtualCamera3DSlot GetSlot( int index ) + public CameraSlot GetSlot( int index ) { return _cameraSlots[ index ]; } - public VirtualCamera3DSlot GetSlot( VirtualCamera3D virtualCamera3D ) + public CameraSlot GetSlot( VirtualCamera virtualCamera3D ) { return _cameraSlots.Find( s => s.camera == virtualCamera3D ); } - public VirtualCamera3DSlot GetSlot( SelectorFlag[] flags ) + public CameraSlot GetSlot( SelectorFlag[] flags ) { return _cameraSlots.Find( s => Arrays.ContainsAll( s.flags, flags ) ); } - public void SetActiveSlot( VirtualCamera3DSlot slot ) + public void SetActiveSlot( CameraSlot slot ) { _cameraSlots.ForEach( c => c.priority = ( c == slot ? 1 : 0 ) ); StartLerping(); @@ -290,13 +361,13 @@ namespace Rokojori } refreshSlots = false; - _cameraSlots = Nodes.GetDirectChildren( this ); + _cameraSlots = Nodes.GetDirectChildren( this ); StartLerping(); } - public void RemoveSlot( VirtualCamera3DSlot slot ) + public void RemoveSlot( CameraSlot slot ) { if ( slot == null || slot.GetParent() != this ) { @@ -419,12 +490,12 @@ namespace Rokojori } - public VirtualCamera3D GetCamera( int index ) + public VirtualCamera GetCamera( int index ) { return _cameraSlots[ index ].camera; } - public int GetCameraIndex( VirtualCamera3D camera3D ) + public int GetCameraIndex( VirtualCamera camera3D ) { return _cameraSlots.FindIndex( c => c.camera == camera3D ); } diff --git a/Runtime/Cameras/CameraManager.cs.uid b/Runtime/Cameras/CameraManager.cs.uid new file mode 100644 index 0000000..34d52f0 --- /dev/null +++ b/Runtime/Cameras/CameraManager.cs.uid @@ -0,0 +1 @@ +uid://b64ylf5cx2514 diff --git a/Runtime/VirtualCameras/VirtualCamera3DManager.cs.uid b/Runtime/Cameras/CameraManager.uid similarity index 100% rename from Runtime/VirtualCameras/VirtualCamera3DManager.cs.uid rename to Runtime/Cameras/CameraManager.uid diff --git a/Runtime/Cameras/CameraSetupIcon.cs b/Runtime/Cameras/CameraSetupIcon.cs new file mode 100644 index 0000000..97b7581 --- /dev/null +++ b/Runtime/Cameras/CameraSetupIcon.cs @@ -0,0 +1,17 @@ + +using System.Diagnostics; +using System.Collections; +using System.Collections.Generic; +using System; +using Godot; + + +namespace Rokojori +{ + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/VirtualCameraManager.svg") ] + public partial class CameraSetupIcon:Node + { + + } +} \ No newline at end of file diff --git a/Runtime/Cameras/CameraSetupIcon.cs.uid b/Runtime/Cameras/CameraSetupIcon.cs.uid new file mode 100644 index 0000000..66ac514 --- /dev/null +++ b/Runtime/Cameras/CameraSetupIcon.cs.uid @@ -0,0 +1 @@ +uid://bubc2xm3er1rw diff --git a/Runtime/VirtualCameras/VirtualCamera3DSlot.cs b/Runtime/Cameras/CameraSlot.cs similarity index 92% rename from Runtime/VirtualCameras/VirtualCamera3DSlot.cs rename to Runtime/Cameras/CameraSlot.cs index 746b3cb..505cce3 100644 --- a/Runtime/VirtualCameras/VirtualCamera3DSlot.cs +++ b/Runtime/Cameras/CameraSlot.cs @@ -11,10 +11,10 @@ namespace Rokojori [Tool] [Icon("res://addons/rokojori_action_library/Icons/VirtualCamera3DSlot.svg") ] [GlobalClass] - public partial class VirtualCamera3DSlot:Action + public partial class CameraSlot:Action { [Export] - public VirtualCamera3D camera; + public VirtualCamera camera; [Export] public float priority; @@ -30,7 +30,7 @@ namespace Rokojori Smoother smoother = new Smoother(); - public void Update( double delta, VirtualCamera3DManager manager ) + public void Update( double delta, CameraManager manager ) { if ( cameraEffectRunner != null ) { @@ -110,7 +110,7 @@ namespace Rokojori protected override void _OnTrigger() { - var vm = GetParent(); + var vm = GetParent(); if ( vm == null ) { diff --git a/Runtime/Cameras/CameraSlot.cs.uid b/Runtime/Cameras/CameraSlot.cs.uid new file mode 100644 index 0000000..06d5f50 --- /dev/null +++ b/Runtime/Cameras/CameraSlot.cs.uid @@ -0,0 +1 @@ +uid://dna13qop6b0na diff --git a/Runtime/VirtualCameras/VirtualCamera3DSlot.cs.uid b/Runtime/Cameras/CameraSlot.uid similarity index 100% rename from Runtime/VirtualCameras/VirtualCamera3DSlot.cs.uid rename to Runtime/Cameras/CameraSlot.uid diff --git a/Runtime/VirtualCameras/CameraSlotSelectors/CameraSlotSelector.cs b/Runtime/Cameras/CameraSlotSelectors/CameraSlotSelector.cs similarity index 67% rename from Runtime/VirtualCameras/CameraSlotSelectors/CameraSlotSelector.cs rename to Runtime/Cameras/CameraSlotSelectors/CameraSlotSelector.cs index df8cd40..39d0784 100644 --- a/Runtime/VirtualCameras/CameraSlotSelectors/CameraSlotSelector.cs +++ b/Runtime/Cameras/CameraSlotSelectors/CameraSlotSelector.cs @@ -12,14 +12,14 @@ namespace Rokojori [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/SetActiveVirtualCamera3D.svg") ] public partial class CameraSlotSelector:Action { - public virtual VirtualCamera3DSlot GetCameraSlot() + public virtual CameraSlot GetCameraSlot() { - return VirtualCamera3DManager.Get().activeSlot; + return CameraManager.Get().activeSlot; } protected override void _OnTrigger() { - VirtualCamera3DManager.Get().SetActiveSlot( GetCameraSlot() ); + CameraManager.Get().SetActiveSlot( GetCameraSlot() ); } } } \ No newline at end of file diff --git a/Runtime/VirtualCameras/CameraSlotSelectors/CameraSlotSelector.cs.uid b/Runtime/Cameras/CameraSlotSelectors/CameraSlotSelector.cs.uid similarity index 100% rename from Runtime/VirtualCameras/CameraSlotSelectors/CameraSlotSelector.cs.uid rename to Runtime/Cameras/CameraSlotSelectors/CameraSlotSelector.cs.uid diff --git a/Runtime/VirtualCameras/CameraSlotSelectors/SetActiveCamera.cs b/Runtime/Cameras/CameraSlotSelectors/SetActiveCamera.cs similarity index 75% rename from Runtime/VirtualCameras/CameraSlotSelectors/SetActiveCamera.cs rename to Runtime/Cameras/CameraSlotSelectors/SetActiveCamera.cs index d38d748..698b28c 100644 --- a/Runtime/VirtualCameras/CameraSlotSelectors/SetActiveCamera.cs +++ b/Runtime/Cameras/CameraSlotSelectors/SetActiveCamera.cs @@ -13,7 +13,7 @@ namespace Rokojori public partial class SetActiveCamera:CameraSlotSelector { [Export] - public VirtualCamera3D virtualCamera; + public VirtualCamera virtualCamera; [ExportGroup( "Create Slot")] [Export] @@ -22,14 +22,14 @@ namespace Rokojori [Export] public SelectorFlag[] slotFlags; - public override VirtualCamera3DSlot GetCameraSlot() + public override CameraSlot GetCameraSlot() { - var vm = VirtualCamera3DManager.Get(); + var vm = CameraManager.Get(); var slot = vm.GetSlot( virtualCamera ); if ( slot == null ) { - slot = vm.CreateChild(); + slot = vm.CreateChild(); slot.camera = virtualCamera; slot.flags = slotFlags; diff --git a/Runtime/VirtualCameras/CameraSlotSelectors/SetActiveCamera.cs.uid b/Runtime/Cameras/CameraSlotSelectors/SetActiveCamera.cs.uid similarity index 100% rename from Runtime/VirtualCameras/CameraSlotSelectors/SetActiveCamera.cs.uid rename to Runtime/Cameras/CameraSlotSelectors/SetActiveCamera.cs.uid diff --git a/Runtime/VirtualCameras/CameraSlotSelectors/SetActiveCameraSlot.cs b/Runtime/Cameras/CameraSlotSelectors/SetActiveCameraSlot.cs similarity index 74% rename from Runtime/VirtualCameras/CameraSlotSelectors/SetActiveCameraSlot.cs rename to Runtime/Cameras/CameraSlotSelectors/SetActiveCameraSlot.cs index aaaa45c..dfcad86 100644 --- a/Runtime/VirtualCameras/CameraSlotSelectors/SetActiveCameraSlot.cs +++ b/Runtime/Cameras/CameraSlotSelectors/SetActiveCameraSlot.cs @@ -13,9 +13,9 @@ namespace Rokojori public partial class SetActiveCameraSlot:CameraSlotSelector { [Export] - public VirtualCamera3DSlot slot; + public CameraSlot slot; - public override VirtualCamera3DSlot GetCameraSlot() + public override CameraSlot GetCameraSlot() { return slot; } diff --git a/Runtime/VirtualCameras/CameraSlotSelectors/SetActiveCameraSlot.cs.uid b/Runtime/Cameras/CameraSlotSelectors/SetActiveCameraSlot.cs.uid similarity index 100% rename from Runtime/VirtualCameras/CameraSlotSelectors/SetActiveCameraSlot.cs.uid rename to Runtime/Cameras/CameraSlotSelectors/SetActiveCameraSlot.cs.uid diff --git a/Runtime/VirtualCameras/CameraSlotSelectors/SetActiveCameraSlotByFlags.cs b/Runtime/Cameras/CameraSlotSelectors/SetActiveCameraSlotByFlags.cs similarity index 72% rename from Runtime/VirtualCameras/CameraSlotSelectors/SetActiveCameraSlotByFlags.cs rename to Runtime/Cameras/CameraSlotSelectors/SetActiveCameraSlotByFlags.cs index 7f1d1c3..c0ed6ef 100644 --- a/Runtime/VirtualCameras/CameraSlotSelectors/SetActiveCameraSlotByFlags.cs +++ b/Runtime/Cameras/CameraSlotSelectors/SetActiveCameraSlotByFlags.cs @@ -15,9 +15,9 @@ namespace Rokojori [Export] public SelectorFlag[] flags; - public override VirtualCamera3DSlot GetCameraSlot() + public override CameraSlot GetCameraSlot() { - var slot = VirtualCamera3DManager.Get().GetSlot( flags ); + var slot = CameraManager.Get().GetSlot( flags ); return slot; } diff --git a/Runtime/VirtualCameras/CameraSlotSelectors/SetActiveCameraSlotByFlags.cs.uid b/Runtime/Cameras/CameraSlotSelectors/SetActiveCameraSlotByFlags.cs.uid similarity index 100% rename from Runtime/VirtualCameras/CameraSlotSelectors/SetActiveCameraSlotByFlags.cs.uid rename to Runtime/Cameras/CameraSlotSelectors/SetActiveCameraSlotByFlags.cs.uid diff --git a/Runtime/VirtualCameras/CameraSlotSelectors/SetActiveCameraSlotIndex.cs b/Runtime/Cameras/CameraSlotSelectors/SetActiveCameraSlotIndex.cs similarity index 70% rename from Runtime/VirtualCameras/CameraSlotSelectors/SetActiveCameraSlotIndex.cs rename to Runtime/Cameras/CameraSlotSelectors/SetActiveCameraSlotIndex.cs index c43e0c7..0490458 100644 --- a/Runtime/VirtualCameras/CameraSlotSelectors/SetActiveCameraSlotIndex.cs +++ b/Runtime/Cameras/CameraSlotSelectors/SetActiveCameraSlotIndex.cs @@ -15,9 +15,9 @@ namespace Rokojori [Export] public int cameraSlotIndex; - public override VirtualCamera3DSlot GetCameraSlot() + public override CameraSlot GetCameraSlot() { - var slot = VirtualCamera3DManager.Get().GetSlot( cameraSlotIndex ); + var slot = CameraManager.Get().GetSlot( cameraSlotIndex ); return slot; } diff --git a/Runtime/VirtualCameras/CameraSlotSelectors/SetActiveCameraSlotIndex.cs.uid b/Runtime/Cameras/CameraSlotSelectors/SetActiveCameraSlotIndex.cs.uid similarity index 100% rename from Runtime/VirtualCameras/CameraSlotSelectors/SetActiveCameraSlotIndex.cs.uid rename to Runtime/Cameras/CameraSlotSelectors/SetActiveCameraSlotIndex.cs.uid diff --git a/Runtime/VirtualCameras/CameraTargetOffset.cs b/Runtime/Cameras/CameraTargetOffset.cs similarity index 100% rename from Runtime/VirtualCameras/CameraTargetOffset.cs rename to Runtime/Cameras/CameraTargetOffset.cs diff --git a/Runtime/VirtualCameras/CameraTargetOffset.cs.uid b/Runtime/Cameras/CameraTargetOffset.cs.uid similarity index 100% rename from Runtime/VirtualCameras/CameraTargetOffset.cs.uid rename to Runtime/Cameras/CameraTargetOffset.cs.uid diff --git a/Runtime/Cameras/CameraTypes/FirstPersonCamera/FirstPersonCamera.cs b/Runtime/Cameras/CameraTypes/FirstPersonCamera/FirstPersonCamera.cs new file mode 100644 index 0000000..6208a76 --- /dev/null +++ b/Runtime/Cameras/CameraTypes/FirstPersonCamera/FirstPersonCamera.cs @@ -0,0 +1,17 @@ + +using System.Diagnostics; +using System.Collections; +using System.Collections.Generic; +using System; +using Godot; + + +namespace Rokojori +{ + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/1stPersonCamera.svg") ] + public partial class FirstPersonCamera:VirtualCamera + { + + } +} \ No newline at end of file diff --git a/Runtime/Cameras/CameraTypes/FirstPersonCamera/FirstPersonCamera.cs.uid b/Runtime/Cameras/CameraTypes/FirstPersonCamera/FirstPersonCamera.cs.uid new file mode 100644 index 0000000..4a6dc2b --- /dev/null +++ b/Runtime/Cameras/CameraTypes/FirstPersonCamera/FirstPersonCamera.cs.uid @@ -0,0 +1 @@ +uid://cxue7ikbpt1ig diff --git a/Runtime/VirtualCameras/FollowCamera3D.cs b/Runtime/Cameras/CameraTypes/FollowCamera/FollowCamera3D.cs similarity index 90% rename from Runtime/VirtualCameras/FollowCamera3D.cs rename to Runtime/Cameras/CameraTypes/FollowCamera/FollowCamera3D.cs index b289012..10defbf 100644 --- a/Runtime/VirtualCameras/FollowCamera3D.cs +++ b/Runtime/Cameras/CameraTypes/FollowCamera/FollowCamera3D.cs @@ -9,8 +9,8 @@ using Godot; namespace Rokojori { [Tool] - [GlobalClass] - public partial class FollowCamera3D:VirtualCamera3D + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/FollowCamera.svg") ] + public partial class FollowCamera3D:VirtualCamera { [Export] public Node3D target; diff --git a/Runtime/VirtualCameras/FollowCamera3D.cs.uid b/Runtime/Cameras/CameraTypes/FollowCamera/FollowCamera3D.cs.uid similarity index 100% rename from Runtime/VirtualCameras/FollowCamera3D.cs.uid rename to Runtime/Cameras/CameraTypes/FollowCamera/FollowCamera3D.cs.uid diff --git a/Runtime/VirtualCameras/LookAtCamera.cs b/Runtime/Cameras/CameraTypes/LookAtCamera/LookAtCamera.cs similarity index 91% rename from Runtime/VirtualCameras/LookAtCamera.cs rename to Runtime/Cameras/CameraTypes/LookAtCamera/LookAtCamera.cs index 5ede411..ff6bc9e 100644 --- a/Runtime/VirtualCameras/LookAtCamera.cs +++ b/Runtime/Cameras/CameraTypes/LookAtCamera/LookAtCamera.cs @@ -9,8 +9,8 @@ using Godot; namespace Rokojori { [Tool] - [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/VirtualCamera3D.svg") ] - public partial class LookAtCamera:VirtualCamera3D + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/LookAtCamera.svg") ] + public partial class LookAtCamera:VirtualCamera { [Export] public Node3D target; diff --git a/Runtime/VirtualCameras/LookAtCamera.cs.uid b/Runtime/Cameras/CameraTypes/LookAtCamera/LookAtCamera.cs.uid similarity index 100% rename from Runtime/VirtualCameras/LookAtCamera.cs.uid rename to Runtime/Cameras/CameraTypes/LookAtCamera/LookAtCamera.cs.uid diff --git a/Runtime/VirtualCameras/StrategyTopDownCamera.cs b/Runtime/Cameras/CameraTypes/StrategyTopDownCamera/StrategyTopDownCamera.cs similarity index 97% rename from Runtime/VirtualCameras/StrategyTopDownCamera.cs rename to Runtime/Cameras/CameraTypes/StrategyTopDownCamera/StrategyTopDownCamera.cs index 21474a7..9ba9dc0 100644 --- a/Runtime/VirtualCameras/StrategyTopDownCamera.cs +++ b/Runtime/Cameras/CameraTypes/StrategyTopDownCamera/StrategyTopDownCamera.cs @@ -9,8 +9,8 @@ using Godot; namespace Rokojori { [Tool] - [GlobalClass] - public partial class StrategyTopDownCamera:VirtualCamera3D + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/StrategyTopDownCamera.svg") ] + public partial class StrategyTopDownCamera:VirtualCamera { public enum ConstrainMode { diff --git a/Runtime/VirtualCameras/StrategyTopDownCamera.cs.uid b/Runtime/Cameras/CameraTypes/StrategyTopDownCamera/StrategyTopDownCamera.cs.uid similarity index 100% rename from Runtime/VirtualCameras/StrategyTopDownCamera.cs.uid rename to Runtime/Cameras/CameraTypes/StrategyTopDownCamera/StrategyTopDownCamera.cs.uid diff --git a/Runtime/VirtualCameras/ThirdPersonCamera.cs b/Runtime/Cameras/CameraTypes/ThirdPersonCamera/ThirdPersonCamera.cs similarity index 96% rename from Runtime/VirtualCameras/ThirdPersonCamera.cs rename to Runtime/Cameras/CameraTypes/ThirdPersonCamera/ThirdPersonCamera.cs index 03a76db..c68a19d 100644 --- a/Runtime/VirtualCameras/ThirdPersonCamera.cs +++ b/Runtime/Cameras/CameraTypes/ThirdPersonCamera/ThirdPersonCamera.cs @@ -9,8 +9,8 @@ using Godot; namespace Rokojori { [Tool] - [GlobalClass] - public partial class ThirdPersonCamera:VirtualCamera3D + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/3rdPersonCamera.svg") ] + public partial class ThirdPersonCamera:VirtualCamera { [Export] public Node3D target; @@ -42,7 +42,7 @@ namespace Rokojori public Smoothing yawSmoothing = new FrameSmoothing(); [Export] - public bool yawGoesBehindPlayer = true; + public bool yawGoesBehindPlayer = false; [Export] public Smoothing yawToBehingSmoothing = new FrameSmoothing(); diff --git a/Runtime/VirtualCameras/ThirdPersonCamera.cs.uid b/Runtime/Cameras/CameraTypes/ThirdPersonCamera/ThirdPersonCamera.cs.uid similarity index 100% rename from Runtime/VirtualCameras/ThirdPersonCamera.cs.uid rename to Runtime/Cameras/CameraTypes/ThirdPersonCamera/ThirdPersonCamera.cs.uid diff --git a/Runtime/VirtualCameras/ThirdPersonCameraTargetOffset.cs b/Runtime/Cameras/CameraTypes/ThirdPersonCamera/ThirdPersonCameraTargetOffset.cs similarity index 100% rename from Runtime/VirtualCameras/ThirdPersonCameraTargetOffset.cs rename to Runtime/Cameras/CameraTypes/ThirdPersonCamera/ThirdPersonCameraTargetOffset.cs diff --git a/Runtime/VirtualCameras/ThirdPersonCameraTargetOffset.cs.uid b/Runtime/Cameras/CameraTypes/ThirdPersonCamera/ThirdPersonCameraTargetOffset.cs.uid similarity index 100% rename from Runtime/VirtualCameras/ThirdPersonCameraTargetOffset.cs.uid rename to Runtime/Cameras/CameraTypes/ThirdPersonCamera/ThirdPersonCameraTargetOffset.cs.uid diff --git a/Runtime/VirtualCameras/MouseEditorCamera/MouseEditorCamera.cs b/Runtime/Cameras/EditorCamera/EditorCamera.cs similarity index 91% rename from Runtime/VirtualCameras/MouseEditorCamera/MouseEditorCamera.cs rename to Runtime/Cameras/EditorCamera/EditorCamera.cs index b3f3e13..082f589 100644 --- a/Runtime/VirtualCameras/MouseEditorCamera/MouseEditorCamera.cs +++ b/Runtime/Cameras/EditorCamera/EditorCamera.cs @@ -9,8 +9,8 @@ using Godot; namespace Rokojori { [Tool] - [GlobalClass] - public partial class MouseEditorCamera:VirtualCamera3D + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/EditorCamera.svg") ] + public partial class EditorCamera:VirtualCamera { [Export] public Vector3 target; @@ -45,10 +45,10 @@ namespace Rokojori public Vector3 moveDirection = Vector3.Zero; [Export] - public MouseEditorCameraInputSettings keyboardMouseInputs; + public EditorCameraInputSettings keyboardMouseInputs; [Export] - public MouseEditorCameraInputSettings controllerInputs; + public EditorCameraInputSettings controllerInputs; float _cachedDistance = -1; diff --git a/Runtime/VirtualCameras/MouseEditorCamera/MouseEditorCamera.cs.uid b/Runtime/Cameras/EditorCamera/EditorCamera.cs.uid similarity index 100% rename from Runtime/VirtualCameras/MouseEditorCamera/MouseEditorCamera.cs.uid rename to Runtime/Cameras/EditorCamera/EditorCamera.cs.uid diff --git a/Runtime/VirtualCameras/MouseEditorCamera/MouseEditorCameraInputSettings.cs b/Runtime/Cameras/EditorCamera/EditorCameraInputSettings.cs similarity index 93% rename from Runtime/VirtualCameras/MouseEditorCamera/MouseEditorCameraInputSettings.cs rename to Runtime/Cameras/EditorCamera/EditorCameraInputSettings.cs index 54d08f7..c3fb791 100644 --- a/Runtime/VirtualCameras/MouseEditorCamera/MouseEditorCameraInputSettings.cs +++ b/Runtime/Cameras/EditorCamera/EditorCameraInputSettings.cs @@ -10,7 +10,7 @@ namespace Rokojori { [Tool] [GlobalClass] - public partial class MouseEditorCameraInputSettings:Resource + public partial class EditorCameraInputSettings:Resource { [ExportGroup( "Orbit")] @@ -119,7 +119,7 @@ namespace Rokojori public Sensor[] mouseMovementPanModifierButtons = []; - public void Zoom( MouseEditorCamera mouseEditorCamera ) + public void Zoom( EditorCamera mouseEditorCamera ) { if ( minimizeDistanceOnMovement ) { @@ -150,7 +150,7 @@ namespace Rokojori } - public void Move( MouseEditorCamera mouseEditorCamera ) + public void Move( EditorCamera mouseEditorCamera ) { Vector3 moveDirection = Vector3.Zero; @@ -187,7 +187,7 @@ namespace Rokojori mouseEditorCamera.moveDirection += moveDirection.Normalized() * moveSpeed; } - void OrbitByMouse( MouseEditorCamera mouseEditorCamera ) + void OrbitByMouse( EditorCamera mouseEditorCamera ) { if ( ! mouseMovementEnabled ) { @@ -212,7 +212,7 @@ namespace Rokojori } - public void Orbit( MouseEditorCamera mouseEditorCamera ) + public void Orbit( EditorCamera mouseEditorCamera ) { OrbitByMouse( mouseEditorCamera ); @@ -220,7 +220,7 @@ namespace Rokojori mouseEditorCamera.pitch += Sensors.PolarAxis( pitchDecreaseButton, pitchIncreaseButton ) * pitchButtonsSpeed; } - public void Pan( MouseEditorCamera mouseEditorCamera ) + public void Pan( EditorCamera mouseEditorCamera ) { if ( ! mouseMovementEnabled ) { diff --git a/Runtime/VirtualCameras/MouseEditorCamera/MouseEditorCameraInputSettings.cs.uid b/Runtime/Cameras/EditorCamera/EditorCameraInputSettings.cs.uid similarity index 100% rename from Runtime/VirtualCameras/MouseEditorCamera/MouseEditorCameraInputSettings.cs.uid rename to Runtime/Cameras/EditorCamera/EditorCameraInputSettings.cs.uid diff --git a/Runtime/VirtualCameras/MouseEditorCamera/Inputs/MouseEditorCamera Default Inputs.tres b/Runtime/Cameras/EditorCamera/Inputs/MouseEditorCamera Default Inputs.tres similarity index 100% rename from Runtime/VirtualCameras/MouseEditorCamera/Inputs/MouseEditorCamera Default Inputs.tres rename to Runtime/Cameras/EditorCamera/Inputs/MouseEditorCamera Default Inputs.tres diff --git a/Runtime/VirtualCameras/MouseEditorCamera/Inputs/Sensors/Mouse Orbit Button.tres b/Runtime/Cameras/EditorCamera/Inputs/Sensors/Mouse Orbit Button.tres similarity index 100% rename from Runtime/VirtualCameras/MouseEditorCamera/Inputs/Sensors/Mouse Orbit Button.tres rename to Runtime/Cameras/EditorCamera/Inputs/Sensors/Mouse Orbit Button.tres diff --git a/Runtime/VirtualCameras/MouseEditorCamera/Inputs/Sensors/Mouse Pan Button.tres b/Runtime/Cameras/EditorCamera/Inputs/Sensors/Mouse Pan Button.tres similarity index 100% rename from Runtime/VirtualCameras/MouseEditorCamera/Inputs/Sensors/Mouse Pan Button.tres rename to Runtime/Cameras/EditorCamera/Inputs/Sensors/Mouse Pan Button.tres diff --git a/Runtime/VirtualCameras/MouseEditorCamera/Inputs/Sensors/Move Back.tres b/Runtime/Cameras/EditorCamera/Inputs/Sensors/Move Back.tres similarity index 100% rename from Runtime/VirtualCameras/MouseEditorCamera/Inputs/Sensors/Move Back.tres rename to Runtime/Cameras/EditorCamera/Inputs/Sensors/Move Back.tres diff --git a/Runtime/VirtualCameras/MouseEditorCamera/Inputs/Sensors/Move Down.tres b/Runtime/Cameras/EditorCamera/Inputs/Sensors/Move Down.tres similarity index 100% rename from Runtime/VirtualCameras/MouseEditorCamera/Inputs/Sensors/Move Down.tres rename to Runtime/Cameras/EditorCamera/Inputs/Sensors/Move Down.tres diff --git a/Runtime/VirtualCameras/MouseEditorCamera/Inputs/Sensors/Move Forward.tres b/Runtime/Cameras/EditorCamera/Inputs/Sensors/Move Forward.tres similarity index 100% rename from Runtime/VirtualCameras/MouseEditorCamera/Inputs/Sensors/Move Forward.tres rename to Runtime/Cameras/EditorCamera/Inputs/Sensors/Move Forward.tres diff --git a/Runtime/VirtualCameras/MouseEditorCamera/Inputs/Sensors/Move Left.tres b/Runtime/Cameras/EditorCamera/Inputs/Sensors/Move Left.tres similarity index 100% rename from Runtime/VirtualCameras/MouseEditorCamera/Inputs/Sensors/Move Left.tres rename to Runtime/Cameras/EditorCamera/Inputs/Sensors/Move Left.tres diff --git a/Runtime/VirtualCameras/MouseEditorCamera/Inputs/Sensors/Move Right.tres b/Runtime/Cameras/EditorCamera/Inputs/Sensors/Move Right.tres similarity index 100% rename from Runtime/VirtualCameras/MouseEditorCamera/Inputs/Sensors/Move Right.tres rename to Runtime/Cameras/EditorCamera/Inputs/Sensors/Move Right.tres diff --git a/Runtime/VirtualCameras/MouseEditorCamera/Inputs/Sensors/Move Upward.tres b/Runtime/Cameras/EditorCamera/Inputs/Sensors/Move Upward.tres similarity index 100% rename from Runtime/VirtualCameras/MouseEditorCamera/Inputs/Sensors/Move Upward.tres rename to Runtime/Cameras/EditorCamera/Inputs/Sensors/Move Upward.tres diff --git a/Runtime/VirtualCameras/MouseEditorCamera/Inputs/Sensors/Zoom In.tres b/Runtime/Cameras/EditorCamera/Inputs/Sensors/Zoom In.tres similarity index 100% rename from Runtime/VirtualCameras/MouseEditorCamera/Inputs/Sensors/Zoom In.tres rename to Runtime/Cameras/EditorCamera/Inputs/Sensors/Zoom In.tres diff --git a/Runtime/VirtualCameras/MouseEditorCamera/Inputs/Sensors/Zoom Out.tres b/Runtime/Cameras/EditorCamera/Inputs/Sensors/Zoom Out.tres similarity index 100% rename from Runtime/VirtualCameras/MouseEditorCamera/Inputs/Sensors/Zoom Out.tres rename to Runtime/Cameras/EditorCamera/Inputs/Sensors/Zoom Out.tres diff --git a/Runtime/VirtualCameras/Effects/CameraEffect.cs b/Runtime/Cameras/Effects/CameraEffect.cs similarity index 100% rename from Runtime/VirtualCameras/Effects/CameraEffect.cs rename to Runtime/Cameras/Effects/CameraEffect.cs diff --git a/Runtime/VirtualCameras/Effects/CameraEffect.cs.uid b/Runtime/Cameras/Effects/CameraEffect.cs.uid similarity index 100% rename from Runtime/VirtualCameras/Effects/CameraEffect.cs.uid rename to Runtime/Cameras/Effects/CameraEffect.cs.uid diff --git a/Runtime/VirtualCameras/Effects/CameraEffectTargetAnimationCurve.cs b/Runtime/Cameras/Effects/CameraEffectTargetAnimationCurve.cs similarity index 100% rename from Runtime/VirtualCameras/Effects/CameraEffectTargetAnimationCurve.cs rename to Runtime/Cameras/Effects/CameraEffectTargetAnimationCurve.cs diff --git a/Runtime/VirtualCameras/Effects/CameraEffectTargetAnimationCurve.cs.uid b/Runtime/Cameras/Effects/CameraEffectTargetAnimationCurve.cs.uid similarity index 100% rename from Runtime/VirtualCameras/Effects/CameraEffectTargetAnimationCurve.cs.uid rename to Runtime/Cameras/Effects/CameraEffectTargetAnimationCurve.cs.uid diff --git a/Runtime/VirtualCameras/Effects/CameraEffectTargetType.cs b/Runtime/Cameras/Effects/CameraEffectTargetType.cs similarity index 100% rename from Runtime/VirtualCameras/Effects/CameraEffectTargetType.cs rename to Runtime/Cameras/Effects/CameraEffectTargetType.cs diff --git a/Runtime/VirtualCameras/Effects/CameraEffectTargetType.cs.uid b/Runtime/Cameras/Effects/CameraEffectTargetType.cs.uid similarity index 100% rename from Runtime/VirtualCameras/Effects/CameraEffectTargetType.cs.uid rename to Runtime/Cameras/Effects/CameraEffectTargetType.cs.uid diff --git a/Runtime/VirtualCameras/Effects/PlayCameraEffect.cs b/Runtime/Cameras/Effects/PlayCameraEffect.cs similarity index 83% rename from Runtime/VirtualCameras/Effects/PlayCameraEffect.cs rename to Runtime/Cameras/Effects/PlayCameraEffect.cs index 03c09ca..f03c846 100644 --- a/Runtime/VirtualCameras/Effects/PlayCameraEffect.cs +++ b/Runtime/Cameras/Effects/PlayCameraEffect.cs @@ -20,10 +20,10 @@ namespace Rokojori [ExportGroup("Other Camera Slot")] [Export] - public VirtualCamera3DSlot cameraSlot; + public CameraSlot cameraSlot; [Export] - public VirtualCamera3D camera; + public VirtualCamera camera; [Export] public int cameraSlotIndex = -1; @@ -34,7 +34,7 @@ namespace Rokojori protected override void _OnTrigger() { - var manager = VirtualCamera3DManager.Get(); + var manager = CameraManager.Get(); var resolvedSlot = useActiveCameraSlot ? manager.activeSlot : cameraSlot; if ( resolvedSlot == null && camera != null ) @@ -50,7 +50,7 @@ namespace Rokojori } else if ( cameraSlotSelector != null ) { - resolvedSlot = Selectors.GetFromDirectChildren( manager, cameraSlotSelector ); + resolvedSlot = Selectors.GetFromDirectChildren( manager, cameraSlotSelector ); } } diff --git a/Runtime/VirtualCameras/Effects/PlayCameraEffect.cs.uid b/Runtime/Cameras/Effects/PlayCameraEffect.cs.uid similarity index 100% rename from Runtime/VirtualCameras/Effects/PlayCameraEffect.cs.uid rename to Runtime/Cameras/Effects/PlayCameraEffect.cs.uid diff --git a/Runtime/VirtualCameras/Effects/Presets/Earth Quake.tres b/Runtime/Cameras/Effects/Presets/Earth Quake.tres similarity index 100% rename from Runtime/VirtualCameras/Effects/Presets/Earth Quake.tres rename to Runtime/Cameras/Effects/Presets/Earth Quake.tres diff --git a/Runtime/VirtualCameras/Effects/Presets/ScreenShake.tres b/Runtime/Cameras/Effects/Presets/ScreenShake.tres similarity index 100% rename from Runtime/VirtualCameras/Effects/Presets/ScreenShake.tres rename to Runtime/Cameras/Effects/Presets/ScreenShake.tres diff --git a/Runtime/VirtualCameras/PostProcess/AdjustmentsEffect.cs b/Runtime/Cameras/PostProcess/AdjustmentsEffect.cs similarity index 100% rename from Runtime/VirtualCameras/PostProcess/AdjustmentsEffect.cs rename to Runtime/Cameras/PostProcess/AdjustmentsEffect.cs diff --git a/Runtime/VirtualCameras/PostProcess/AdjustmentsEffect.cs.uid b/Runtime/Cameras/PostProcess/AdjustmentsEffect.cs.uid similarity index 100% rename from Runtime/VirtualCameras/PostProcess/AdjustmentsEffect.cs.uid rename to Runtime/Cameras/PostProcess/AdjustmentsEffect.cs.uid diff --git a/Runtime/VirtualCameras/PostProcess/CenterAndRangeDepthOfFieldEffect.cs b/Runtime/Cameras/PostProcess/CenterAndRangeDepthOfFieldEffect.cs similarity index 100% rename from Runtime/VirtualCameras/PostProcess/CenterAndRangeDepthOfFieldEffect.cs rename to Runtime/Cameras/PostProcess/CenterAndRangeDepthOfFieldEffect.cs diff --git a/Runtime/VirtualCameras/PostProcess/CenterAndRangeDepthOfFieldEffect.cs.uid b/Runtime/Cameras/PostProcess/CenterAndRangeDepthOfFieldEffect.cs.uid similarity index 100% rename from Runtime/VirtualCameras/PostProcess/CenterAndRangeDepthOfFieldEffect.cs.uid rename to Runtime/Cameras/PostProcess/CenterAndRangeDepthOfFieldEffect.cs.uid diff --git a/Runtime/VirtualCameras/PostProcess/FixedDepthOfFieldEffect.cs b/Runtime/Cameras/PostProcess/FixedDepthOfFieldEffect.cs similarity index 100% rename from Runtime/VirtualCameras/PostProcess/FixedDepthOfFieldEffect.cs rename to Runtime/Cameras/PostProcess/FixedDepthOfFieldEffect.cs diff --git a/Runtime/VirtualCameras/PostProcess/FixedDepthOfFieldEffect.cs.uid b/Runtime/Cameras/PostProcess/FixedDepthOfFieldEffect.cs.uid similarity index 100% rename from Runtime/VirtualCameras/PostProcess/FixedDepthOfFieldEffect.cs.uid rename to Runtime/Cameras/PostProcess/FixedDepthOfFieldEffect.cs.uid diff --git a/Runtime/VirtualCameras/PostProcess/FogEffect.cs b/Runtime/Cameras/PostProcess/FogEffect.cs similarity index 100% rename from Runtime/VirtualCameras/PostProcess/FogEffect.cs rename to Runtime/Cameras/PostProcess/FogEffect.cs diff --git a/Runtime/VirtualCameras/PostProcess/FogEffect.cs.uid b/Runtime/Cameras/PostProcess/FogEffect.cs.uid similarity index 100% rename from Runtime/VirtualCameras/PostProcess/FogEffect.cs.uid rename to Runtime/Cameras/PostProcess/FogEffect.cs.uid diff --git a/Runtime/VirtualCameras/PostProcess/FollowDepthOfFieldEffect.cs b/Runtime/Cameras/PostProcess/FollowDepthOfFieldEffect.cs similarity index 100% rename from Runtime/VirtualCameras/PostProcess/FollowDepthOfFieldEffect.cs rename to Runtime/Cameras/PostProcess/FollowDepthOfFieldEffect.cs diff --git a/Runtime/VirtualCameras/PostProcess/FollowDepthOfFieldEffect.cs.uid b/Runtime/Cameras/PostProcess/FollowDepthOfFieldEffect.cs.uid similarity index 100% rename from Runtime/VirtualCameras/PostProcess/FollowDepthOfFieldEffect.cs.uid rename to Runtime/Cameras/PostProcess/FollowDepthOfFieldEffect.cs.uid diff --git a/Runtime/VirtualCameras/PostProcess/GlowEffect.cs b/Runtime/Cameras/PostProcess/GlowEffect.cs similarity index 100% rename from Runtime/VirtualCameras/PostProcess/GlowEffect.cs rename to Runtime/Cameras/PostProcess/GlowEffect.cs diff --git a/Runtime/VirtualCameras/PostProcess/GlowEffect.cs.uid b/Runtime/Cameras/PostProcess/GlowEffect.cs.uid similarity index 100% rename from Runtime/VirtualCameras/PostProcess/GlowEffect.cs.uid rename to Runtime/Cameras/PostProcess/GlowEffect.cs.uid diff --git a/Runtime/VirtualCameras/PostProcess/GlowEffectLevels.cs b/Runtime/Cameras/PostProcess/GlowEffectLevels.cs similarity index 100% rename from Runtime/VirtualCameras/PostProcess/GlowEffectLevels.cs rename to Runtime/Cameras/PostProcess/GlowEffectLevels.cs diff --git a/Runtime/VirtualCameras/PostProcess/GlowEffectLevels.cs.uid b/Runtime/Cameras/PostProcess/GlowEffectLevels.cs.uid similarity index 100% rename from Runtime/VirtualCameras/PostProcess/GlowEffectLevels.cs.uid rename to Runtime/Cameras/PostProcess/GlowEffectLevels.cs.uid diff --git a/Runtime/VirtualCameras/PostProcess/PostProcessEffectProcessor.cs b/Runtime/Cameras/PostProcess/PostProcessEffectProcessor.cs similarity index 100% rename from Runtime/VirtualCameras/PostProcess/PostProcessEffectProcessor.cs rename to Runtime/Cameras/PostProcess/PostProcessEffectProcessor.cs diff --git a/Runtime/VirtualCameras/PostProcess/PostProcessEffectProcessor.cs.uid b/Runtime/Cameras/PostProcess/PostProcessEffectProcessor.cs.uid similarity index 100% rename from Runtime/VirtualCameras/PostProcess/PostProcessEffectProcessor.cs.uid rename to Runtime/Cameras/PostProcess/PostProcessEffectProcessor.cs.uid diff --git a/Runtime/VirtualCameras/PostProcess/PostProcessVolume.cs b/Runtime/Cameras/PostProcess/PostProcessVolume.cs similarity index 86% rename from Runtime/VirtualCameras/PostProcess/PostProcessVolume.cs rename to Runtime/Cameras/PostProcess/PostProcessVolume.cs index 8cbef15..03c1b11 100644 --- a/Runtime/VirtualCameras/PostProcess/PostProcessVolume.cs +++ b/Runtime/Cameras/PostProcess/PostProcessVolume.cs @@ -27,18 +27,18 @@ namespace Rokojori public Callable AddButton => Callable.From( ( ) => { - var volumes = VirtualCamera3DManager.Get().postProcessVolumes; + var volumes = CameraManager.Get().postProcessVolumes; if ( volumes.Contains( this ) ) { return; } - VirtualCamera3DManager.Get().postProcessVolumes = Arrays.Add( volumes, this ); + CameraManager.Get().postProcessVolumes = Arrays.Add( volumes, this ); } ); - public void UpdateEffects( VirtualCamera3DManager manager ) + public void UpdateEffects( CameraManager manager ) { effects.ForEach( ( e )=> diff --git a/Runtime/VirtualCameras/PostProcess/PostProcessVolume.cs.uid b/Runtime/Cameras/PostProcess/PostProcessVolume.cs.uid similarity index 100% rename from Runtime/VirtualCameras/PostProcess/PostProcessVolume.cs.uid rename to Runtime/Cameras/PostProcess/PostProcessVolume.cs.uid diff --git a/Runtime/VirtualCameras/PostProcess/PostProcessVolumeEffect.cs b/Runtime/Cameras/PostProcess/PostProcessVolumeEffect.cs similarity index 100% rename from Runtime/VirtualCameras/PostProcess/PostProcessVolumeEffect.cs rename to Runtime/Cameras/PostProcess/PostProcessVolumeEffect.cs diff --git a/Runtime/VirtualCameras/PostProcess/PostProcessVolumeEffect.cs.uid b/Runtime/Cameras/PostProcess/PostProcessVolumeEffect.cs.uid similarity index 100% rename from Runtime/VirtualCameras/PostProcess/PostProcessVolumeEffect.cs.uid rename to Runtime/Cameras/PostProcess/PostProcessVolumeEffect.cs.uid diff --git a/Runtime/VirtualCameras/PostProcess/_XX_DepthOfFieldEffect.cs b/Runtime/Cameras/PostProcess/_XX_DepthOfFieldEffect.cs similarity index 100% rename from Runtime/VirtualCameras/PostProcess/_XX_DepthOfFieldEffect.cs rename to Runtime/Cameras/PostProcess/_XX_DepthOfFieldEffect.cs diff --git a/Runtime/VirtualCameras/PostProcess/_XX_DepthOfFieldEffect.cs.uid b/Runtime/Cameras/PostProcess/_XX_DepthOfFieldEffect.cs.uid similarity index 100% rename from Runtime/VirtualCameras/PostProcess/_XX_DepthOfFieldEffect.cs.uid rename to Runtime/Cameras/PostProcess/_XX_DepthOfFieldEffect.cs.uid diff --git a/Runtime/VirtualCameras/PostProcess/environment_adjustments_3d_lut_template.webp b/Runtime/Cameras/PostProcess/environment_adjustments_3d_lut_template.webp similarity index 100% rename from Runtime/VirtualCameras/PostProcess/environment_adjustments_3d_lut_template.webp rename to Runtime/Cameras/PostProcess/environment_adjustments_3d_lut_template.webp diff --git a/Runtime/VirtualCameras/PostProcess/environment_adjustments_3d_lut_template.webp.import b/Runtime/Cameras/PostProcess/environment_adjustments_3d_lut_template.webp.import similarity index 66% rename from Runtime/VirtualCameras/PostProcess/environment_adjustments_3d_lut_template.webp.import rename to Runtime/Cameras/PostProcess/environment_adjustments_3d_lut_template.webp.import index dc9ccb3..c19ba34 100644 --- a/Runtime/VirtualCameras/PostProcess/environment_adjustments_3d_lut_template.webp.import +++ b/Runtime/Cameras/PostProcess/environment_adjustments_3d_lut_template.webp.import @@ -3,15 +3,15 @@ importer="3d_texture" type="CompressedTexture3D" uid="uid://dlr7kk6et1g3v" -path="res://.godot/imported/environment_adjustments_3d_lut_template.webp-6d0d1fb6bd1425e1eff35b812ef39d39.ctex3d" +path="res://.godot/imported/environment_adjustments_3d_lut_template.webp-dd5fdb95cbb9f8021a100603ed15b371.ctex3d" metadata={ "vram_texture": false } [deps] -source_file="res://addons/rokojori_action_library/Runtime/VirtualCameras/PostProcess/environment_adjustments_3d_lut_template.webp" -dest_files=["res://.godot/imported/environment_adjustments_3d_lut_template.webp-6d0d1fb6bd1425e1eff35b812ef39d39.ctex3d"] +source_file="res://addons/rokojori_action_library/Runtime/Cameras/PostProcess/environment_adjustments_3d_lut_template.webp" +dest_files=["res://.godot/imported/environment_adjustments_3d_lut_template.webp-dd5fdb95cbb9f8021a100603ed15b371.ctex3d"] [params] diff --git a/Runtime/VirtualCameras/RemoveCameraSlot.cs b/Runtime/Cameras/RemoveCameraSlot.cs similarity index 81% rename from Runtime/VirtualCameras/RemoveCameraSlot.cs rename to Runtime/Cameras/RemoveCameraSlot.cs index 07a2efa..ed4113b 100644 --- a/Runtime/VirtualCameras/RemoveCameraSlot.cs +++ b/Runtime/Cameras/RemoveCameraSlot.cs @@ -13,11 +13,11 @@ namespace Rokojori public partial class RemoveCameraSlot:Action { [Export] - public VirtualCamera3D virtualCamera3D; + public VirtualCamera virtualCamera3D; protected override void _OnTrigger() { - var vm = VirtualCamera3DManager.Get(); + var vm = CameraManager.Get(); vm.RemoveSlot( vm.GetSlot( virtualCamera3D ) ); } diff --git a/Runtime/VirtualCameras/RemoveCameraSlot.cs.uid b/Runtime/Cameras/RemoveCameraSlot.cs.uid similarity index 100% rename from Runtime/VirtualCameras/RemoveCameraSlot.cs.uid rename to Runtime/Cameras/RemoveCameraSlot.cs.uid diff --git a/Runtime/VirtualCameras/VirtualCamera3D.cs b/Runtime/Cameras/VirtualCamera.cs similarity index 91% rename from Runtime/VirtualCameras/VirtualCamera3D.cs rename to Runtime/Cameras/VirtualCamera.cs index c6fefc6..2131ba2 100644 --- a/Runtime/VirtualCameras/VirtualCamera3D.cs +++ b/Runtime/Cameras/VirtualCamera.cs @@ -10,7 +10,7 @@ namespace Rokojori { [Tool] [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/VirtualCamera3D.svg") ] - public partial class VirtualCamera3D:Node3D + public partial class VirtualCamera:Node3D { [Export] public float fov = 60; diff --git a/Runtime/VirtualCameras/VirtualCamera3D.cs.uid b/Runtime/Cameras/VirtualCamera.cs.uid similarity index 100% rename from Runtime/VirtualCameras/VirtualCamera3D.cs.uid rename to Runtime/Cameras/VirtualCamera.cs.uid diff --git a/Runtime/Events/Signals.cs b/Runtime/Events/Signals.cs index f62849d..00a079e 100644 --- a/Runtime/Events/Signals.cs +++ b/Runtime/Events/Signals.cs @@ -24,12 +24,18 @@ namespace Rokojori OnFinished( particles3D, action, true ); } - public static void _OnSignal( Node node, string name, System.Action action ) + public static void _OnSignal( this Node node, string name, System.Action action ) { node.Connect( name, Callable.From( action ) ); } - public static void _OnSignalOnce( Node node, string name, System.Action action ) + public static void _OnSignal( this Node node, string name, Callable callable ) + { + node.Connect( name, callable ); + } + + + public static void _OnSignalOnce( this Node node, string name, System.Action action ) { Callable? onceAction = null; @@ -41,7 +47,7 @@ namespace Rokojori } ); - node.Connect( name, (Callable)onceAction ); + node.Connect( name, (Callable) onceAction ); } } } \ No newline at end of file diff --git a/Runtime/Godot/Nodes.cs b/Runtime/Godot/Nodes.cs index 480a887..c392f3d 100644 --- a/Runtime/Godot/Nodes.cs +++ b/Runtime/Godot/Nodes.cs @@ -155,7 +155,7 @@ namespace Rokojori public static void ForEachInScene( Action callback ) where T:class { var root = Root.Window(); - RJLog.Log( "Iterating:", root ); + // RJLog.Log( "Iterating:", root ); ForEach( root, callback ); } @@ -278,8 +278,8 @@ namespace Rokojori { var t = new T(); parent.AddChild( t ); - - t.Owner = parent.Owner; + + t.Owner = parent.Owner == null ? parent : parent.Owner; if ( name == null ) { @@ -473,12 +473,44 @@ namespace Rokojori node.QueueFree(); } + public static void GetOwnershipOfChildren( this Node node ) + { + node.ForEach( + ( child )=> + { + if ( node == child ) + { + return; + } + + child.Owner = node; + } + ); + } + + public static Error SaveAs( this Node node, string path, bool forceUpdate = false, ResourceSaver.SaverFlags saverFlags = ResourceSaver.SaverFlags.None ) + { + var duplicatedNode = node.Duplicate(); + duplicatedNode.GetOwnershipOfChildren(); + + var packedScene = new PackedScene(); + packedScene.Pack( duplicatedNode ); + var error = ResourceSaver.Save( packedScene, path, saverFlags ); + + if ( forceUpdate ) + { + EditorInterface.Singleton.GetResourceFilesystem().Scan(); + } + + return error; + } + public static void RemoveAndDeleteAll( List nodes ) where N:Node { nodes.ForEach( n => RemoveAndDelete( n ) ); } - public static void RemoveSelf( this Node node ) + public static void RemoveFromParent( this Node node ) { var parent = node.GetParent(); @@ -486,10 +518,24 @@ namespace Rokojori { parent.RemoveChild( node ); } + } + public static void SetParent( this Node node, Node parent ) + { + node.RemoveFromParent(); + + parent.AddChild( node ); + node.Owner = parent.Owner; + } + + public static void DeleteSelf( this Node node ) + { + node.RemoveFromParent(); node.QueueFree(); } + + public static void RemoveAndDeleteChildrenOfType( Node parent, bool includeInternal = false ) where T:Node { if ( parent == null ) @@ -593,6 +639,24 @@ namespace Rokojori return null; } + public static T FindDirectChild( this Node parent, Predicate evaluator ) where T:Node + { + var numChildren = parent.GetChildCount(); + + for ( int i = 0; i < numChildren; i++ ) + { + var node = parent.GetChild( i ); + + if ( node is T t && evaluator( t ) ) + { + return t; + } + + } + + return null; + } + public static List GetDirectChildren( this Node parent ) where T:Node { if ( parent == null ) @@ -607,7 +671,7 @@ namespace Rokojori for ( int i = 0; i < numChildren; i++ ) { var node = parent.GetChild( i ); - var script = node.GetScript(); + // var script = node.GetScript(); // RJLog.Log( "Node is", typeof(T), node.Name, node.GetType(), script.GetType(), ">>", ( node is T ) ); diff --git a/Runtime/Godot/ResourceExtensions.cs b/Runtime/Godot/ResourceExtensions.cs new file mode 100644 index 0000000..c9b0aed --- /dev/null +++ b/Runtime/Godot/ResourceExtensions.cs @@ -0,0 +1,25 @@ +using Godot; + +using System.Collections.Generic; +using System; +using System.Threading.Tasks; +using System.Reflection; +using Microsoft.VisualBasic; + +namespace Rokojori +{ + public static class ResourceExtensions + { + public static Error SaveAs( this Resource resource, string savePath, bool forceUpdate = false, ResourceSaver.SaverFlags saverFlags = ResourceSaver.SaverFlags.None ) + { + var error = ResourceSaver.Save( resource, savePath, saverFlags ); + + if ( forceUpdate ) + { + EditorInterface.Singleton.GetResourceFilesystem().Scan(); + } + + return error; + } + } +} diff --git a/Runtime/Godot/ResourceExtensions.cs.uid b/Runtime/Godot/ResourceExtensions.cs.uid new file mode 100644 index 0000000..60064a6 --- /dev/null +++ b/Runtime/Godot/ResourceExtensions.cs.uid @@ -0,0 +1 @@ +uid://cyricmobj2qhi diff --git a/Runtime/Localization/LocalizedString.cs b/Runtime/Localization/LocalizedString.cs index fd6f08e..9f2ef41 100644 --- a/Runtime/Localization/LocalizedString.cs +++ b/Runtime/Localization/LocalizedString.cs @@ -7,7 +7,7 @@ namespace Rokojori { [Tool] [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/LocalizedString.svg")] - public partial class LocalizedString:Resource + public abstract partial class LocalizedString:Resource { public virtual string GetLocalizedString( LocaleCode localeCode ) { diff --git a/Runtime/Math/Geometry/Box3.cs b/Runtime/Math/Geometry/Box3.cs index a7806e5..795379b 100644 --- a/Runtime/Math/Geometry/Box3.cs +++ b/Runtime/Math/Geometry/Box3.cs @@ -11,6 +11,10 @@ namespace Rokojori public Vector3 center => ( max + min ) / 2f; + public float width => max.X - min.X; + public float height => max.Y - min.Y; + public float depth => max.Z - min.Z; + public static implicit operator Box3( Aabb aabb ) { return Box3.Create( aabb.Position, aabb.End ); diff --git a/Runtime/Math/Math3D.cs b/Runtime/Math/Math3D.cs index 9e0a36b..a48d6bc 100644 --- a/Runtime/Math/Math3D.cs +++ b/Runtime/Math/Math3D.cs @@ -691,6 +691,23 @@ namespace Rokojori return a.GlobalDistanceTo( other ) <= distance; } + public static Vector3 GetLocalOrGlobalPosition( this Node3D node, bool global ) + { + return global ? node.GlobalPosition : node.Position; + } + + public static void SetLocalOrGlobalPosition( this Node3D node, Vector3 position, bool global ) + { + if ( global ) + { + node.GlobalPosition = position; + } + else + { + node.Position = position; + } + } + public static void SetGlobalQuaternion( this Node3D node, Quaternion quaternion ) { var localScale = node.Scale; diff --git a/Runtime/Presets/App/AppPreset.cs b/Runtime/Presets/App/AppPreset.cs new file mode 100644 index 0000000..d4ff844 --- /dev/null +++ b/Runtime/Presets/App/AppPreset.cs @@ -0,0 +1,124 @@ + +using Godot; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Rokojori +{ + + [Tool] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/App.svg")] + public partial class AppPreset: Node + { + [Export] + public MainModule mainModule; + + [Export] + public FeatureModule[] features = []; + + + public enum RenderQualitySettingsMode + { + Keep, + High, + Low + } + + [Export] + public RenderQualitySettingsMode renderQualitySettings = RenderQualitySettingsMode.High; + + public enum RootMode + { + Create_Root, + Use_Existing_Root + } + + [ExportToolButton( "Create" )] + public Callable createButton => Callable.From( + ()=> + { + Create(); + } + ); + + [ExportGroup("Options")] + + [Export] + public RootMode rootMode; + [Export] + public App existingRoot; + + [Export] + public bool removeSelf = false; + + public enum PresetErrorHandlingMode + { + Automatic_Fix, + Ignore + } + + [Export] + public PresetErrorHandlingMode errorHandling; + + + + async Task Create() + { + var root = existingRoot; + + if ( RootMode.Create_Root == rootMode ) + { + var parent = GetParent(); + root = parent.CreateChild( "App" ); + } + + var context = new PresetContext(); + context.root = root; + context.appPreset = this; + + var passes = new List{ + PresetPass.Prefly, + PresetPass.Prepare, + PresetPass.Process, + PresetPass.Post + }; + + foreach ( var p in passes ) + { + context.pass = p; + + if ( mainModule != null ) + { + await mainModule.ProcessPass( context ); + } + + if ( features == null ) + { + continue; + } + + foreach ( var f in features ) + { + if ( f != null ) + { + await f.ProcessPass( context ); + } + } + } + + if ( RenderQualitySettingsMode.Keep != renderQualitySettings ) + { + RenderQualitySettings.SetQuick( RenderQualitySettingsMode.High == renderQualitySettings ); + } + + if ( removeSelf ) + { + this.SelfDestroy(); + } + + return; + + } + + } +} \ No newline at end of file diff --git a/Runtime/Presets/App/AppPreset.cs.uid b/Runtime/Presets/App/AppPreset.cs.uid new file mode 100644 index 0000000..16c42a5 --- /dev/null +++ b/Runtime/Presets/App/AppPreset.cs.uid @@ -0,0 +1 @@ +uid://cptomlybltsi8 diff --git a/Runtime/Presets/App/MainModule.cs b/Runtime/Presets/App/MainModule.cs new file mode 100644 index 0000000..1b28c7d --- /dev/null +++ b/Runtime/Presets/App/MainModule.cs @@ -0,0 +1,164 @@ + +using Godot; +using System.Threading.Tasks; + + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class MainModule: PresetModule + { + [ExportGroup("Basic")] + [Export] + public bool localeManager = true; + + [Export] + public bool sensorManager = true; + + [Export] + public bool timeLineManager = true; + + [Export] + public bool audioManager = true; + + + [ExportGroup("Camera")] + [Export] + public bool cameraManager = true; + + [Export] + public bool mainCamera = true; + + [Export] + public bool debugEditorCamera = true; + + [Export] + public bool worldEnvironment = true; + + + + public async Task ProcessPass( PresetContext context ) + { + if ( PresetPass.Process != context.pass ) + { + return; + } + + CreateBasic( context ); + + CreateCamera( context ); + + return; + } + + void CreateBasic( PresetContext context ) + { + var root = context.root; + + if ( localeManager ) + { + root.CreateChild( "Locale Manager" ); + } + + if ( sensorManager ) + { + root.CreateChild( "Sensor Manager Setup" ); + } + + if ( timeLineManager ) + { + var tm = root.CreateChild( "Timeline Manager" ); + + var timelinePath = "res://addons/rokojori_action_library/Runtime/Time/TimeLines/"; + var gameTime = ResourceLoader.Load( timelinePath + "GameTime.tres" ); + var realTime = ResourceLoader.Load( timelinePath + "RealTime.tres" ); + + tm.gametimeTimeline = gameTime; + tm.realtimeTimeline = realTime; + + tm.timeLines = [ gameTime, realTime ]; + + } + + if ( audioManager ) + { + root.CreateChild( "Audio Manager" ); + } + } + + void CreateCamera( PresetContext context ) + { + var hasCameraSetup = cameraManager || worldEnvironment || mainCamera || debugEditorCamera; + + if ( ! hasCameraSetup ) + { + return; + } + + var root = context.root; + + var cameraSetup = root.CreateChild( "Camera Setup" ); + + + CameraManager camManager = null; + + if ( cameraManager ) + { + camManager = cameraSetup.CreateChild( "Camera Manager" ); + } + + if ( worldEnvironment ) + { + var env = cameraSetup.CreateChild(); + + env.Environment = new Environment(); + env.Environment.BackgroundMode = Environment.BGMode.Sky; + env.Environment.Sky = new Sky(); + env.Environment.Sky.SkyMaterial = new ProceduralSkyMaterial(); + + if ( camManager != null ) + { + camManager.worldEnvironment = env; + } + + var camAtts = new CameraAttributesPractical(); + env.CameraAttributes = camAtts; + camAtts.DofBlurNearEnabled = true; + camAtts.DofBlurNearDistance = 0.2f; + camAtts.DofBlurNearTransition = 0.1f; + camAtts.DofBlurAmount = 0.25f; + + } + + if ( mainCamera ) + { + var mainCam = cameraSetup.CreateChild( "Main Camera" ); + + if ( camManager != null ) + { + camManager.camera = mainCam; + } + } + + if ( debugEditorCamera ) + { + var editorCamera = cameraSetup.CreateChild( "Debug Editor Camera" ); + + if ( camManager != null ) + { + camManager.debugCamera = editorCamera; + var toggleSensor = new KeySensor(); + toggleSensor.key = Key.F5; + camManager.debugCameraToggle = toggleSensor; + } + } + + + + + } + + + } +} \ No newline at end of file diff --git a/Runtime/Presets/App/MainModule.cs.uid b/Runtime/Presets/App/MainModule.cs.uid new file mode 100644 index 0000000..7731b4c --- /dev/null +++ b/Runtime/Presets/App/MainModule.cs.uid @@ -0,0 +1 @@ +uid://b1vlfr8sl1057 diff --git a/Runtime/Presets/App/MainModule.uid b/Runtime/Presets/App/MainModule.uid new file mode 100644 index 0000000..30bc769 --- /dev/null +++ b/Runtime/Presets/App/MainModule.uid @@ -0,0 +1 @@ +uid://b535o02x5yqop diff --git a/Runtime/Presets/Features/DefaultPostProcessing/DefaultPostProcessingModule.cs b/Runtime/Presets/Features/DefaultPostProcessing/DefaultPostProcessingModule.cs new file mode 100644 index 0000000..7ef947c --- /dev/null +++ b/Runtime/Presets/Features/DefaultPostProcessing/DefaultPostProcessingModule.cs @@ -0,0 +1,134 @@ + +using Godot; +using Godot.Collections; +using System.Threading.Tasks; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class DefaultPostProcessingModule: FeatureModule + { + [Export] + public bool ao = true; + + [Export] + public bool ssil = true; + + [Export] + public bool glow = true; + + [Export] + public bool fog = true; + + [Export] + public bool adjustments = true; + + [Export] + public Environment.ToneMapper toneMapping = Environment.ToneMapper.Filmic; + + [Export] + public bool postFX = true; + + public override async Task ProcessPass( PresetContext presetContext ) + { + if ( PresetPass.Prefly == presetContext.pass ) + { + if ( AppPreset.PresetErrorHandlingMode.Automatic_Fix == presetContext.appPreset.errorHandling ) + { + presetContext.appPreset.mainModule.worldEnvironment = true; + } + } + else if ( PresetPass.Process == presetContext.pass ) + { + var environment = presetContext.root.Get(); + SetupPostProcessing( environment ); + } + + return; + } + + void SetupPostProcessing( WorldEnvironment worldEnvironment ) + { + var env = worldEnvironment.Environment; + + if ( ao ) + { + env.SsaoEnabled = true; + env.SsaoAOChannelAffect = 1; + env.SsaoLightAffect = 1; + env.SsaoIntensity = 2.5f; + } + + if ( ssil ) + { + env.SsilEnabled = true; + env.SsilRadius = 2.5f; + env.SsilIntensity = 2; + env.SsilNormalRejection = 0.5f; + } + + if ( glow ) + { + env.GlowEnabled = true; + + for ( int i = 0; i < 7 ; i++ ) + { + var value = i == 0 ? 4 : i == 1 ? 8 : Mathf.Pow( 2, 6 - i ); + env.SetGlowLevel( i, value ); + } + env.GlowNormalized = true; + env.GlowIntensity = 1f; + env.GlowBlendMode = Environment.GlowBlendModeEnum.Screen; + } + + if ( fog ) + { + env.FogEnabled = true; + env.FogLightColor = new Color( 160f/255f, 169f/255f, 174f/255f ); + env.FogSunScatter = 0.5f; + env.FogAerialPerspective = 0.5f; + env.FogSkyAffect = 0f; + env.FogDensity = 0.005f; + } + + if ( adjustments ) + { + env.AdjustmentEnabled = true; + env.AdjustmentContrast = 0.9f; + env.AdjustmentSaturation = 1.1f; + } + + env.TonemapMode = toneMapping; + + if ( Environment.ToneMapper.Filmic == env.TonemapMode ) + { + env.TonemapExposure = 1.5f; + env.TonemapWhite = 1.5f; + } + + if ( postFX ) + { + if ( worldEnvironment.Compositor == null ) + { + worldEnvironment.Compositor =new Compositor(); + } + + var compositor = worldEnvironment.Compositor; + + var vignette = new VignetteEffect(); + vignette.amount = 0.5f; + + var chromaticAberation = new ChromaticAberation(); + + var temporalSmear = new TemporalSmearEffect(); + temporalSmear.amount = 0.1f; + temporalSmear.smearingFrames = 6; + + var array = new Godot.Collections.Array(); + array.AddRange( [vignette, chromaticAberation, temporalSmear ]); + compositor.CompositorEffects = array; + } + } + } +} \ No newline at end of file diff --git a/Runtime/Presets/Features/DefaultPostProcessing/DefaultPostProcessingModule.cs.uid b/Runtime/Presets/Features/DefaultPostProcessing/DefaultPostProcessingModule.cs.uid new file mode 100644 index 0000000..101fb31 --- /dev/null +++ b/Runtime/Presets/Features/DefaultPostProcessing/DefaultPostProcessingModule.cs.uid @@ -0,0 +1 @@ +uid://b62jx5e2cdo0t diff --git a/Runtime/Presets/Features/FeatureModule.cs b/Runtime/Presets/Features/FeatureModule.cs new file mode 100644 index 0000000..7e76e5c --- /dev/null +++ b/Runtime/Presets/Features/FeatureModule.cs @@ -0,0 +1,13 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public abstract partial class FeatureModule: PresetModule + { + + } +} \ No newline at end of file diff --git a/Runtime/Presets/Features/FeatureModule.cs.uid b/Runtime/Presets/Features/FeatureModule.cs.uid new file mode 100644 index 0000000..90bf79b --- /dev/null +++ b/Runtime/Presets/Features/FeatureModule.cs.uid @@ -0,0 +1 @@ +uid://yevtp72wghev diff --git a/Runtime/Presets/Features/ThirdPersonCamera/ThirdPersonCameraModule.cs b/Runtime/Presets/Features/ThirdPersonCamera/ThirdPersonCameraModule.cs new file mode 100644 index 0000000..efd3794 --- /dev/null +++ b/Runtime/Presets/Features/ThirdPersonCamera/ThirdPersonCameraModule.cs @@ -0,0 +1,43 @@ + +using Godot; +using System.Threading.Tasks; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class ThirdPersonCameraModule: FeatureModule + { + + public override async Task ProcessPass( PresetContext presetContext ) + { + if ( PresetPass.Prefly == presetContext.pass ) + { + if ( AppPreset.PresetErrorHandlingMode.Automatic_Fix == presetContext.appPreset.errorHandling ) + { + presetContext.appPreset.mainModule.cameraManager = true; + } + } + else if ( PresetPass.Process == presetContext.pass ) + { + SetupThirdPersonCamera( presetContext ); + } + + return; + } + + void SetupThirdPersonCamera( PresetContext presetContext ) + { + var cameraManager = Unique.Get(); + var slot = cameraManager.CreateChild( "Third Person Camera Slot" ); + + var vCam = presetContext.root.CreateChild( "Third Person Camera" ); + + slot.camera = vCam; + slot.priority = 1; + + cameraManager.active = true; + cameraManager.refreshSlots = true; + } + } +} \ No newline at end of file diff --git a/Runtime/Presets/Features/ThirdPersonCamera/ThirdPersonCameraModule.cs.uid b/Runtime/Presets/Features/ThirdPersonCamera/ThirdPersonCameraModule.cs.uid new file mode 100644 index 0000000..d04866f --- /dev/null +++ b/Runtime/Presets/Features/ThirdPersonCamera/ThirdPersonCameraModule.cs.uid @@ -0,0 +1 @@ +uid://cbuwr3lddt0mu diff --git a/Runtime/Presets/PresetContext.cs b/Runtime/Presets/PresetContext.cs new file mode 100644 index 0000000..6f33b28 --- /dev/null +++ b/Runtime/Presets/PresetContext.cs @@ -0,0 +1,21 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + public enum PresetPass + { + Prefly, + Prepare, + Process, + Post + } + + public class PresetContext + { + public Node root; + public AppPreset appPreset; + public PresetPass pass; + } +} \ No newline at end of file diff --git a/Runtime/Presets/PresetContext.cs.uid b/Runtime/Presets/PresetContext.cs.uid new file mode 100644 index 0000000..7436052 --- /dev/null +++ b/Runtime/Presets/PresetContext.cs.uid @@ -0,0 +1 @@ +uid://dnqi5gt3t0jwj diff --git a/Runtime/Presets/PresetModule.cs b/Runtime/Presets/PresetModule.cs new file mode 100644 index 0000000..63cf199 --- /dev/null +++ b/Runtime/Presets/PresetModule.cs @@ -0,0 +1,16 @@ + +using Godot; +using System.Threading.Tasks; + +namespace Rokojori +{ + [Tool] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/SensorManager.svg")] + public partial class PresetModule: Resource + { + public virtual async Task ProcessPass( PresetContext context ) + { + return; + } + } +} \ No newline at end of file diff --git a/Runtime/Presets/PresetModule.cs.uid b/Runtime/Presets/PresetModule.cs.uid new file mode 100644 index 0000000..b13689f --- /dev/null +++ b/Runtime/Presets/PresetModule.cs.uid @@ -0,0 +1 @@ +uid://dmv8s2uxnw34v diff --git a/Runtime/Presets/RenderQualitySettings.cs b/Runtime/Presets/RenderQualitySettings.cs new file mode 100644 index 0000000..d5dd077 --- /dev/null +++ b/Runtime/Presets/RenderQualitySettings.cs @@ -0,0 +1,41 @@ + +using Godot; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class RenderQualitySettings:Node + { + [ExportToolButton( "Set High")] + public Callable setHighButton => Callable.From( ()=> { SetQuick( true ); }); + + [ExportToolButton( "Set Low")] + public Callable setLowButton => Callable.From( ()=> { SetQuick( false ); }); + + public static void SetQuick( bool high ) + { + ProjectSettings.SetSetting( "rendering/anti_aliasing/quality/msaa_3d", high ? 3 : 0 ); + ProjectSettings.SetSetting( "rendering/anti_aliasing/quality/use_debanding", high ); + + ProjectSettings.SetSetting( "rendering/lights_and_shadows/positional_shadow/soft_shadow_filter_quality", high ? 5 : 0 ); + ProjectSettings.SetSetting( "rendering/lights_and_shadows/directional_shadow/soft_shadow_filter_quality", high ? 5 : 0 ); + + ProjectSettings.SetSetting( "rendering/textures/default_filters/anisotropic_filtering_level", high ? 4 : 0 ); + ProjectSettings.SetSetting( "rendering/textures/decals/filter", high ? 5 : 3 ); + ProjectSettings.SetSetting( "rendering/textures/light_projectors/filter", high ? 5 : 3 ); + + ProjectSettings.SetSetting( "rendering/camera/depth_of_field/depth_of_field_bokeh_quality", high ? 3 : 0 ); + ProjectSettings.SetSetting( "rendering/camera/depth_of_field/depth_of_field_bokeh_shape", high ? 2 : 0 ); + + ProjectSettings.SetSetting( "rendering/environment/ssao/quality", high ? 4 : 0 ); + ProjectSettings.SetSetting( "rendering/environment/glow/upscale_mode", high ? 1 : 0 ); + ProjectSettings.SetSetting( "rendering/environment/subsurface_scattering/subsurface_scattering_quality", high ? 3 : 0 ); + ProjectSettings.SetSetting( "rendering/environment/ssil/quality", high ? 4 : 0 ); + + + + ProjectSettings.Save(); + } + } +} \ No newline at end of file diff --git a/Runtime/Presets/RenderQualitySettings.cs.uid b/Runtime/Presets/RenderQualitySettings.cs.uid new file mode 100644 index 0000000..8d1108f --- /dev/null +++ b/Runtime/Presets/RenderQualitySettings.cs.uid @@ -0,0 +1 @@ +uid://d054ma7xwplq8 diff --git a/Runtime/Procedural/Parametric/Plane/ClipMapPlaneMeshType.cs b/Runtime/Procedural/Parametric/Plane/ClipMapPlaneMeshType.cs index 3b7ab62..a1d7500 100644 --- a/Runtime/Procedural/Parametric/Plane/ClipMapPlaneMeshType.cs +++ b/Runtime/Procedural/Parametric/Plane/ClipMapPlaneMeshType.cs @@ -115,8 +115,9 @@ namespace Rokojori float CellSize( int x, int z ) { - var c = CellOffset( x, z ); - var cL = c + new Vector2( 1, 1 ) * maxCellSize / 2; + var mOffset = 0; + var c = CellOffset( x + mOffset, z + mOffset); + var cL = c; // + new Vector2( 1, 1 ) * maxCellSize / 2; var s = cL.Length() / maxDistance; @@ -133,7 +134,10 @@ namespace Rokojori int CellDivisions( int x, int z ) { var cellSize = CellSize( x, z ); - var divisions = Mathf.CeilToInt( maxCellSize / cellSize ); + var numDivisions = maxCellSize / cellSize; + var divisions = Mathf.CeilToInt( numDivisions ); + + // this.LogInfo( "Computed divisions xz:", x, z, " >> ", numDivisions._FFF(), ">", divisions ); if ( ClipMapCellConstraints.Rounded_Integer_Divisions == cellConstrains ) { @@ -257,6 +261,8 @@ namespace Rokojori numDivisions, numDivisions ); + + sectionMG.ApplyTranslation( new Vector3( -maxCellSize/2, 0, -maxCellSize/2 )); mg.Add( sectionMG ); } } diff --git a/Runtime/Procedural/Parametric/Plane/Plane.cs b/Runtime/Procedural/Parametric/Plane/Plane.cs index 372a7f6..111d673 100644 --- a/Runtime/Procedural/Parametric/Plane/Plane.cs +++ b/Runtime/Procedural/Parametric/Plane/Plane.cs @@ -88,6 +88,7 @@ namespace Rokojori var outputMesh = this.CreateChild( mg.name ); outputMesh.Mesh = mg.GenerateMesh(); + if ( extendBoundingBox ) { diff --git a/Runtime/Rendering/Assets/Foliage/FoliageData.cs b/Runtime/Rendering/Assets/Foliage/FoliageData.cs index 6392c71..033479b 100644 --- a/Runtime/Rendering/Assets/Foliage/FoliageData.cs +++ b/Runtime/Rendering/Assets/Foliage/FoliageData.cs @@ -26,42 +26,191 @@ namespace Rokojori public partial class FoliageData:Resource { + [Export] + public string layerName; + + [Export] public bool enabled = true; - + + [Export] + public bool updateSettings = true; + + [Export] + public FoliageQualitySettings[] qualitySettings; + + + [ExportGroup("Visibility")] + [Export] public float cellSize = 1.0f; + public float GetCellSize( int subLayerIndex = -1 ) + { + if ( subLayerIndex < 0 ) + { + return cellSize; + } + + var subLayer = subLayers[ subLayerIndex ]; + + return subLayer.cellSizeOffset + subLayer.relativeCellSize * cellSize; + } + [Export] public float visibilityRange = 50f; + public float GetVisibilityRange( int subLayerIndex = -1 ) + { + if ( subLayerIndex < 0 ) + { + return visibilityRange; + } + + var subLayer = subLayers[ subLayerIndex ]; + + return subLayer.additionalVisibilityRange + subLayer.relativeVisibilityRange * visibilityRange; + } + [Export] - public float visibilityFadeRelative = 0.2f; + public float visibilityFadeRelative = 0.5f; + + public float GetVisibilityFadeRelative( int subLayerIndex = -1 ) + { + if ( subLayerIndex < 0 ) + { + return visibilityFadeRelative; + } + + var subLayer = subLayers[ subLayerIndex ]; + + return subLayer.visibilityFadeRelative; + } [Export] public float visibilityFadeAbsolute = 0f; + public float GetVisibilityFadeAbsolute( int subLayerIndex = -1 ) + { + if ( subLayerIndex < 0 ) + { + return visibilityFadeAbsolute; + } + + var subLayer = subLayers[ subLayerIndex ]; + + return subLayer.visibilityFadeAbsolute; + } + [Export] public float visibilityFadeHidingOffset = -0.7f; + public float GetVisibilityFadeHidingOffset( int subLayerIndex = -1 ) + { + if ( subLayerIndex < 0 ) + { + return visibilityFadeHidingOffset; + } + + var subLayer = subLayers[ subLayerIndex ]; + + return visibilityFadeHidingOffset + subLayer.additionalVisibilityFadeHidingOffset; + } + + [ExportGroup("Model")] + [Export] + public FoliageSource source; + + [ExportGroup("Renderer")] + + [Export] + public FoliageMaterialOverride materialOverride; + /** Render priority, only for transparent objects*/ [Export] - public int renderPriority; + public FoliagePriority renderPriority; [Export] - public FoliageQualitySettings[] qualitySettings; + public bool shadows = true; + + public bool GetShadows( int subLayerIndex ) + { + if ( subLayerIndex < 0 ) + { + return shadows; + } + + var subLayer = subLayers[ subLayerIndex ]; + + return subLayer.shadows; + } + + [Export] + public bool sort = false; + + public bool GetSort( int subLayerIndex ) + { + if ( subLayerIndex < 0 ) + { + return sort; + } + + var subLayer = subLayers[ subLayerIndex ]; + + return subLayer.sort; + } + [ExportGroup("Sub Layers")] + [Export] + public SubFoliageData[] subLayers = []; + + public int numLayers + { + get + { + var num = 1; + for ( int i = 0; subLayers != null && i < subLayers.Length; i++ ) + { + if ( subLayers[ i ] == null ) + { + continue; + } + num++; + } + + return num; + } + } + + [ExportGroup("Position")] + [Export] + public Vector3 positionVarianceAbsoluteOffset = Vector3.Zero; [Export] - public string layerName; + public Vector3 positionVarianceCellSizeRelativeOffset = Vector3.Zero; [Export] - public Vector3 positionVarianceMaxOffset = Vector3.Zero; + public Vector3 positionOffset = Vector3.Zero; + + public Vector3 GetPositionOffset( int subLayerIndex ) + { + if ( subLayerIndex < 0 ) + { + return positionOffset; + } + + var subLayer = subLayers[ subLayerIndex ]; + + return positionOffset + subLayer.subPositionOffset; + } + [Export] public float positionVarianceScale = 1f; [Export] public Vector2 positionVarianceOffset = Vector2.Zero; + [ExportGroup("Rotation")] + [Export] public Vector3 rotationMin = Vector3.Zero; [Export] @@ -73,6 +222,7 @@ namespace Rokojori public Vector2 rotationVarianceOffset = Vector2.Zero; + [ExportGroup("Scale")] [Export] public Vector3 scaleVarianceMinScale = Vector3.One; [Export] @@ -82,7 +232,7 @@ namespace Rokojori [Export] public Vector2 scaleVarianceOffset = Vector2.Zero; - + [ExportGroup("Occupancy")] [Export(PropertyHint.Range,"0,1")] public float occupancyVarianceAmount = 0f; [Export(PropertyHint.Range,"0,50")] @@ -103,7 +253,33 @@ namespace Rokojori public virtual void Initialize( FoliageRenderLayer renderLayer ) { + var particles = renderLayer.renderer.CreateChild( renderLayer.data.layerName ); + renderLayer.gpuParticles3D = particles; + + var processMaterial = new GPUFoliageShaderMaterial(); + particles.ProcessMaterial = processMaterial; + particles.Lifetime = 0.01f; + particles.Explosiveness = 1f; + particles.FixedFps = 0; + particles.Interpolate = false; + particles.FractDelta = false; + + particles.CustomAabb = Box3.WithSize( 10000 ); + particles.CastShadow = renderLayer.data.GetShadows( renderLayer.subLayerIndex ) ? GeometryInstance3D.ShadowCastingSetting.On : GeometryInstance3D.ShadowCastingSetting.Off; + + + processMaterial.positionVariance.Set( renderLayer.renderer.noise ); + processMaterial.rotationVariance.Set( renderLayer.renderer.noise ); + processMaterial.scaleVariance.Set( renderLayer.renderer.noise ); + processMaterial.occupancyVariance.Set( renderLayer.renderer.noise ); + + renderLayer.gpuFoliageShaderMaterial = processMaterial; + + + source?.SetupFoliageDrawPass( renderLayer ); + materialOverride?.CreateFoliageOverideMaterial( renderLayer ); + } } diff --git a/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/FoliageMaterialOverride.cs b/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/FoliageMaterialOverride.cs new file mode 100644 index 0000000..1db98b2 --- /dev/null +++ b/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/FoliageMaterialOverride.cs @@ -0,0 +1,35 @@ +using System.Collections; +using System.Collections.Generic; +using Godot; +using System; +using System.Threading.Tasks; + + + +namespace Rokojori +{ + /** + + + Abstract archetype resource to create foliage material overrides + + + + + + + + */ + + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Scatterer.svg") ] + public abstract partial class FoliageMaterialOverride:Resource + { + [Export] + public FoliageTranslucencySettings translucencySettings; + + public abstract void CreateFoliageOverideMaterial( FoliageRenderLayer foliageRenderLayer ); + public abstract void UpdateFoliageOverideMaterial( FoliageRenderLayer foliageRenderLayer ); + public abstract Material GetOverrideMaterial( FoliageRenderLayer foliageRenderLayer ); + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/FoliageMaterialOverride.cs.uid b/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/FoliageMaterialOverride.cs.uid new file mode 100644 index 0000000..a927b8b --- /dev/null +++ b/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/FoliageMaterialOverride.cs.uid @@ -0,0 +1 @@ +uid://8dbuxww0lojk diff --git a/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/StandardMaterialOverride.cs b/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/StandardMaterialOverride.cs new file mode 100644 index 0000000..a845f9b --- /dev/null +++ b/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/StandardMaterialOverride.cs @@ -0,0 +1,74 @@ +using System.Collections; +using System.Collections.Generic; +using Godot; +using System; +using System.Threading.Tasks; + + + +namespace Rokojori +{ + /** + + + Abstract archetype resource to create foliage material overrides + + + + + + + + */ + + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Scatterer.svg") ] + public partial class StandardMaterialOverride:FoliageMaterialOverride + { + + [Export] + public FoliageTransparencyRenderMode transparencyRenderMode; + + public override void CreateFoliageOverideMaterial( FoliageRenderLayer foliageRenderLayer ) + { + var gpuParticles3D = foliageRenderLayer.gpuParticles3D; + + if ( gpuParticles3D.DrawPass1 == null ) + { + return; + } + + var originalMaterial = gpuParticles3D.DrawPass1.SurfaceGetMaterial( 0 ); + + if ( ! ( originalMaterial is StandardMaterial3D || originalMaterial is OrmMaterial3D ) ) + { + return; + } + + var overrideMaterial = (StandardMaterial3D)originalMaterial.Duplicate(); + gpuParticles3D.MaterialOverride = overrideMaterial; + + UpdateFoliageOverideMaterial( foliageRenderLayer ); + } + + public override void UpdateFoliageOverideMaterial( FoliageRenderLayer foliageRenderLayer ) + { + var material = foliageRenderLayer.gpuParticles3D.MaterialOverride; + + if ( material == null || ! ( material is StandardMaterial3D ) ) + { + return; + } + + var standardMaterial = (StandardMaterial3D) material; + + transparencyRenderMode?.ApplyTransparencyMode( standardMaterial, foliageRenderLayer ); + } + + public override Material GetOverrideMaterial(FoliageRenderLayer foliageRenderLayer) + { + var material = foliageRenderLayer.gpuParticles3D.MaterialOverride; + return material; + } + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/StandardMaterialOverride.cs.uid b/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/StandardMaterialOverride.cs.uid new file mode 100644 index 0000000..8702c68 --- /dev/null +++ b/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/StandardMaterialOverride.cs.uid @@ -0,0 +1 @@ +uid://bpgeyespylb1l diff --git a/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/TranslucencySettings/BasicFoliageTranslucencySettings.cs b/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/TranslucencySettings/BasicFoliageTranslucencySettings.cs new file mode 100644 index 0000000..96b0b85 --- /dev/null +++ b/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/TranslucencySettings/BasicFoliageTranslucencySettings.cs @@ -0,0 +1,53 @@ +using System.Collections; +using System.Collections.Generic; +using Godot; +using System; +using System.Threading.Tasks; + + + +namespace Rokojori +{ + /** + + + FoliageTranslucencySettings to setup the foliage translucency + + + + + + + + */ + + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Scatterer.svg") ] + public partial class BasicFoliageTranslucencySettings:FoliageTranslucencySettings + { + [Export(PropertyHint.Range,"0,1")] + public float translucency = 0.5f; + + public override void ApplyTranslucency( Material material, FoliageRenderLayer layer ) + { + if ( material is StandardMaterial3D sm ) + { + sm.SubsurfScatterEnabled = translucency > 0; + sm.SubsurfScatterTransmittanceEnabled = translucency > 0; + sm.BacklightEnabled = translucency > 0; + + if ( translucency > 0 ) + { + sm.SubsurfScatterStrength = Mathf.Pow( translucency, 0.6f ); + sm.SubsurfScatterTransmittanceDepth = Mathf.Pow( translucency, 0.6f ) * 8f; + sm.SubsurfScatterSkinMode = true; + sm.SubsurfScatterTransmittanceBoost = 1.0f; + + var bl = Mathf.Pow( translucency, 2f ); + + sm.Backlight = new Color( bl, bl, bl ); + } + } + } + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/TranslucencySettings/BasicFoliageTranslucencySettings.cs.uid b/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/TranslucencySettings/BasicFoliageTranslucencySettings.cs.uid new file mode 100644 index 0000000..51eef6d --- /dev/null +++ b/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/TranslucencySettings/BasicFoliageTranslucencySettings.cs.uid @@ -0,0 +1 @@ +uid://wd7mwlmcw4fy diff --git a/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/TranslucencySettings/FoliageTranslucencySettings.cs b/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/TranslucencySettings/FoliageTranslucencySettings.cs new file mode 100644 index 0000000..80b3369 --- /dev/null +++ b/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/TranslucencySettings/FoliageTranslucencySettings.cs @@ -0,0 +1,31 @@ +using System.Collections; +using System.Collections.Generic; +using Godot; +using System; +using System.Threading.Tasks; + + + +namespace Rokojori +{ + /** + + + Abstract archetype resource to setup the translucency of a material + + + + + + + + */ + + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Scatterer.svg") ] + public abstract partial class FoliageTranslucencySettings:Resource + { + public abstract void ApplyTranslucency( Material material, FoliageRenderLayer layer ); + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/TranslucencySettings/FoliageTranslucencySettings.cs.uid b/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/TranslucencySettings/FoliageTranslucencySettings.cs.uid new file mode 100644 index 0000000..a37b0da --- /dev/null +++ b/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/TranslucencySettings/FoliageTranslucencySettings.cs.uid @@ -0,0 +1 @@ +uid://bdgvso6qi837d diff --git a/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/TransparencyRenderModes/AlphaScissorFoliage.cs b/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/TransparencyRenderModes/AlphaScissorFoliage.cs new file mode 100644 index 0000000..c0aa276 --- /dev/null +++ b/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/TransparencyRenderModes/AlphaScissorFoliage.cs @@ -0,0 +1,33 @@ +using System.Collections; +using System.Collections.Generic; +using Godot; +using System; +using System.Threading.Tasks; + + + +namespace Rokojori +{ + /** + + + Abstract archetype resource to create foliage material overrides + + + + + + + + */ + + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Scatterer.svg") ] + public partial class AlphaScissorFoliage:FoliageTransparencyRenderMode + { + public override void ApplyTransparencyMode( Material material, FoliageRenderLayer layer) + { + + } + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/TransparencyRenderModes/AlphaScissorFoliage.cs.uid b/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/TransparencyRenderModes/AlphaScissorFoliage.cs.uid new file mode 100644 index 0000000..34fd642 --- /dev/null +++ b/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/TransparencyRenderModes/AlphaScissorFoliage.cs.uid @@ -0,0 +1 @@ +uid://b603fevr0ach diff --git a/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/TransparencyRenderModes/BasicFoliageTransparencyRenderMode.cs b/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/TransparencyRenderModes/BasicFoliageTransparencyRenderMode.cs new file mode 100644 index 0000000..90a7bc4 --- /dev/null +++ b/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/TransparencyRenderModes/BasicFoliageTransparencyRenderMode.cs @@ -0,0 +1,107 @@ +using System.Collections; +using System.Collections.Generic; +using Godot; +using System; +using System.Threading.Tasks; + + + +namespace Rokojori +{ + /** + + + FoliageTransparencyRenderMode to setup transparency quickly + + + + + + + + */ + + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Scatterer.svg") ] + public partial class BasicFoliageTransparencyRenderMode:FoliageTransparencyRenderMode + { + public enum BasicFoliageTransparencyRenderModeType + { + OpaqueQueue_Scissor_Soft, + OpaqueQueue_Scissor_Middle, + OpaqueQueue_Scissor_Sharp, + TransparentQueue_Scissor_Soft, + TransparentQueue_Scissor_Middle, + TransparentQueue_Scissor_Sharp, + TransparentQueue_Alpha_Prepass, + TransparentQueue_Alpha_Only + } + + [Export] + public BasicFoliageTransparencyRenderModeType type; + + [Export] + public BaseMaterial3D.TextureFilterEnum textureFilter = BaseMaterial3D.TextureFilterEnum.LinearWithMipmaps; + + + + public override void ApplyTransparencyMode( Material material, FoliageRenderLayer layer) + { + if ( material is StandardMaterial3D sm ) + { + if ( sm.Transparency == BaseMaterial3D.TransparencyEnum.Disabled ) + { + return; + } + + sm.TextureFilter = textureFilter; + + if ( BasicFoliageTransparencyRenderModeType.TransparentQueue_Alpha_Prepass == type ) + { + sm.Transparency = BaseMaterial3D.TransparencyEnum.AlphaDepthPrePass; + } + else if ( BasicFoliageTransparencyRenderModeType.TransparentQueue_Alpha_Only == type ) + { + sm.Transparency = BaseMaterial3D.TransparencyEnum.Alpha; + } + else + { + sm.Transparency = BaseMaterial3D.TransparencyEnum.AlphaScissor; + + if ( + BasicFoliageTransparencyRenderModeType.OpaqueQueue_Scissor_Soft == type || + BasicFoliageTransparencyRenderModeType.TransparentQueue_Scissor_Soft == type + ) + { + var isOpaque = BasicFoliageTransparencyRenderModeType.OpaqueQueue_Scissor_Soft == type; + sm.AlphaScissorThreshold = isOpaque ? 0.02f : 0.0f; + sm.AlphaAntialiasingMode = isOpaque ? BaseMaterial3D.AlphaAntiAliasing.Off : BaseMaterial3D.AlphaAntiAliasing.AlphaToCoverageAndToOne; + sm.AlphaAntialiasingEdge = 0.1f; + } + else if ( + BasicFoliageTransparencyRenderModeType.OpaqueQueue_Scissor_Middle == type || + BasicFoliageTransparencyRenderModeType.TransparentQueue_Scissor_Middle == type + ) + { + var isOpaque = BasicFoliageTransparencyRenderModeType.OpaqueQueue_Scissor_Middle == type; + sm.AlphaScissorThreshold = isOpaque ? 0.1f : 0.02f; + sm.AlphaAntialiasingMode = isOpaque ? BaseMaterial3D.AlphaAntiAliasing.Off : BaseMaterial3D.AlphaAntiAliasing.AlphaToCoverageAndToOne; + sm.AlphaAntialiasingEdge = 0.2f; + } + else if ( + BasicFoliageTransparencyRenderModeType.OpaqueQueue_Scissor_Sharp == type || + BasicFoliageTransparencyRenderModeType.TransparentQueue_Scissor_Sharp == type + ) + { + var isOpaque = BasicFoliageTransparencyRenderModeType.OpaqueQueue_Scissor_Sharp == type; + sm.AlphaScissorThreshold = isOpaque ? 0.2f : 0.1f; + sm.AlphaAntialiasingMode = isOpaque ? BaseMaterial3D.AlphaAntiAliasing.Off : BaseMaterial3D.AlphaAntiAliasing.AlphaToCoverageAndToOne; + sm.AlphaAntialiasingEdge = 0.3f; + } + } + } + } + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/TransparencyRenderModes/BasicFoliageTransparencyRenderMode.cs.uid b/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/TransparencyRenderModes/BasicFoliageTransparencyRenderMode.cs.uid new file mode 100644 index 0000000..f93afd0 --- /dev/null +++ b/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/TransparencyRenderModes/BasicFoliageTransparencyRenderMode.cs.uid @@ -0,0 +1 @@ +uid://bv4cgmogonyq8 diff --git a/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/TransparencyRenderModes/FoliageTransparencyRenderMode.cs b/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/TransparencyRenderModes/FoliageTransparencyRenderMode.cs new file mode 100644 index 0000000..b30d907 --- /dev/null +++ b/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/TransparencyRenderModes/FoliageTransparencyRenderMode.cs @@ -0,0 +1,30 @@ +using System.Collections; +using System.Collections.Generic; +using Godot; +using System; +using System.Threading.Tasks; + + + +namespace Rokojori +{ + /** + + + Abstract archetype resource to create foliage material overrides + + + + + + + + */ + + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Scatterer.svg") ] + public abstract partial class FoliageTransparencyRenderMode:Resource + { + public abstract void ApplyTransparencyMode( Material material, FoliageRenderLayer layer ); + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/TransparencyRenderModes/FoliageTransparencyRenderMode.cs.uid b/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/TransparencyRenderModes/FoliageTransparencyRenderMode.cs.uid new file mode 100644 index 0000000..660e46c --- /dev/null +++ b/Runtime/Rendering/Assets/Foliage/FoliageMaterialOverrides/TransparencyRenderModes/FoliageTransparencyRenderMode.cs.uid @@ -0,0 +1 @@ +uid://ri57abt0v7pn diff --git a/Runtime/Rendering/Assets/Foliage/FoliagePriority/AbsoluteFoliagePriority.cs b/Runtime/Rendering/Assets/Foliage/FoliagePriority/AbsoluteFoliagePriority.cs new file mode 100644 index 0000000..d499dfd --- /dev/null +++ b/Runtime/Rendering/Assets/Foliage/FoliagePriority/AbsoluteFoliagePriority.cs @@ -0,0 +1,31 @@ +using System.Collections; +using System.Collections.Generic; +using Godot; +using System; +using System.Threading.Tasks; + + + +namespace Rokojori +{ + /** + + + FoliagePriority to define the render priority directly + + + + + + + + */ + + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Scatterer.svg") ] + public abstract partial class AbsoluteFoliagePriority:FoliagePriority + { + [Export] + public int renderPriority; + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Assets/Foliage/FoliagePriority/AbsoluteFoliagePriority.cs.uid b/Runtime/Rendering/Assets/Foliage/FoliagePriority/AbsoluteFoliagePriority.cs.uid new file mode 100644 index 0000000..e709229 --- /dev/null +++ b/Runtime/Rendering/Assets/Foliage/FoliagePriority/AbsoluteFoliagePriority.cs.uid @@ -0,0 +1 @@ +uid://bq6gaoet2a3w8 diff --git a/Runtime/Rendering/Assets/Foliage/FoliagePriority/FoliagePriority.cs b/Runtime/Rendering/Assets/Foliage/FoliagePriority/FoliagePriority.cs new file mode 100644 index 0000000..f4d0017 --- /dev/null +++ b/Runtime/Rendering/Assets/Foliage/FoliagePriority/FoliagePriority.cs @@ -0,0 +1,30 @@ +using System.Collections; +using System.Collections.Generic; +using Godot; +using System; +using System.Threading.Tasks; + + + +namespace Rokojori +{ + /** + + + Abstract archetype Resource to define the render priority of a foliage layer + + + + + + + + */ + + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Scatterer.svg") ] + public abstract partial class FoliagePriority:Resource + { + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Assets/Foliage/FoliagePriority/FoliagePriority.cs.uid b/Runtime/Rendering/Assets/Foliage/FoliagePriority/FoliagePriority.cs.uid new file mode 100644 index 0000000..1a83156 --- /dev/null +++ b/Runtime/Rendering/Assets/Foliage/FoliagePriority/FoliagePriority.cs.uid @@ -0,0 +1 @@ +uid://u251rovr2ukq diff --git a/Runtime/Rendering/Assets/Foliage/FoliagePriority/OrderFoliagePriority.cs b/Runtime/Rendering/Assets/Foliage/FoliagePriority/OrderFoliagePriority.cs new file mode 100644 index 0000000..9ecd3d5 --- /dev/null +++ b/Runtime/Rendering/Assets/Foliage/FoliagePriority/OrderFoliagePriority.cs @@ -0,0 +1,30 @@ +using System.Collections; +using System.Collections.Generic; +using Godot; +using System; +using System.Threading.Tasks; + + + +namespace Rokojori +{ + /** + + + FoliagePriority to define the render priority relative to the FoliageRenderer based on the + index it has in the array (inside the layers that also use OrderFoliagePriority) + + + + + + + + */ + + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Scatterer.svg") ] + public abstract partial class OrderFoliagePriority:FoliagePriority + { + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Assets/Foliage/FoliagePriority/OrderFoliagePriority.cs.uid b/Runtime/Rendering/Assets/Foliage/FoliagePriority/OrderFoliagePriority.cs.uid new file mode 100644 index 0000000..22af905 --- /dev/null +++ b/Runtime/Rendering/Assets/Foliage/FoliagePriority/OrderFoliagePriority.cs.uid @@ -0,0 +1 @@ +uid://8okesmfohrsr diff --git a/Runtime/Rendering/Assets/Foliage/FoliagePriority/RelativeFoliagePriority.cs b/Runtime/Rendering/Assets/Foliage/FoliagePriority/RelativeFoliagePriority.cs new file mode 100644 index 0000000..28b598b --- /dev/null +++ b/Runtime/Rendering/Assets/Foliage/FoliagePriority/RelativeFoliagePriority.cs @@ -0,0 +1,31 @@ +using System.Collections; +using System.Collections.Generic; +using Godot; +using System; +using System.Threading.Tasks; + + + +namespace Rokojori +{ + /** + + + FoliagePriority to define the render priority relative to the FoliageRenderer + + + + + + + + */ + + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Scatterer.svg") ] + public abstract partial class RelativeFoliagePriority:FoliagePriority + { + [Export] + public int offset; + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Assets/Foliage/FoliagePriority/RelativeFoliagePriority.cs.uid b/Runtime/Rendering/Assets/Foliage/FoliagePriority/RelativeFoliagePriority.cs.uid new file mode 100644 index 0000000..b7673c6 --- /dev/null +++ b/Runtime/Rendering/Assets/Foliage/FoliagePriority/RelativeFoliagePriority.cs.uid @@ -0,0 +1 @@ +uid://dm5wnrga0hi34 diff --git a/Runtime/Rendering/Assets/Foliage/FoliageRenderLayer.cs b/Runtime/Rendering/Assets/Foliage/FoliageRenderLayer.cs index 8a677da..9f91173 100644 --- a/Runtime/Rendering/Assets/Foliage/FoliageRenderLayer.cs +++ b/Runtime/Rendering/Assets/Foliage/FoliageRenderLayer.cs @@ -27,17 +27,19 @@ namespace Rokojori { public FoliageRenderer renderer; public FoliageData data; + public int subLayerIndex = -1; public GpuParticles3D gpuParticles3D; public GPUFoliageShaderMaterial gpuFoliageShaderMaterial; float _lastCellSize = -1; float _lastMaxVisibility = -1; - public static FoliageRenderLayer Create( FoliageRenderer renderer, FoliageData data ) + public static FoliageRenderLayer Create( FoliageRenderer renderer, FoliageData data, int subIndex = -1 ) { var rl = new FoliageRenderLayer(); rl.renderer = renderer; rl.data = data; - + rl.subLayerIndex = subIndex; + return rl; } @@ -46,89 +48,129 @@ namespace Rokojori public void Update( double delta ) { - if ( gpuFoliageShaderMaterial != null ) + if ( gpuFoliageShaderMaterial == null ) { - if ( data.enabled != _isEnabled) - { - _isEnabled = data.enabled; - gpuParticles3D.SetEnabledState( _isEnabled ); - return; - } + return; + } - if ( ! _isEnabled ) - { - return; - } - gpuFoliageShaderMaterial.cameraPosition.Set( renderer.GetAssignedCamera().GlobalPosition ); + if ( data.enabled != _isEnabled) + { + _isEnabled = data.enabled; + gpuParticles3D.SetEnabledState( _isEnabled ); + return; + } - + if ( ! _isEnabled ) + { + return; + } - var cellSize = FoliageQualitySettings.GetCellSize( renderer.quality, renderer.qualitySettingsAll, data.qualitySettings, data.cellSize ); - var visibilityRange = FoliageQualitySettings.GetVisibilityRange( renderer.quality, renderer.qualitySettingsAll, data.qualitySettings, data.visibilityRange ); - - var sizeInt = Mathf.CeilToInt( visibilityRange / cellSize ) * 2; + gpuFoliageShaderMaterial.cameraPosition.Set( renderer.GetAssignedCamera().GlobalPosition ); - if ( _lastCellSize != cellSize || _lastMaxVisibility != visibilityRange ) - { - _lastCellSize = cellSize; - _lastMaxVisibility = visibilityRange; + if ( ! data.updateSettings ) + { + return; + } - gpuFoliageShaderMaterial.cellSize.Set( cellSize ); - + UpdateProcessMaterial(); - + - gpuParticles3D.Amount = sizeInt * sizeInt; - gpuFoliageShaderMaterial.width.Set( sizeInt ); - gpuFoliageShaderMaterial.height.Set( sizeInt ); + data.materialOverride?.UpdateFoliageOverideMaterial( this ); - } + var material = data.materialOverride != null ? + data.materialOverride.GetOverrideMaterial( this ) : + gpuParticles3D.DrawPass1.SurfaceGetMaterial( 0 ); - var hideStart = visibilityRange - ( visibilityRange * data.visibilityFadeRelative + data.visibilityFadeAbsolute ); - gpuFoliageShaderMaterial.hideMax.Set( visibilityRange ); - gpuFoliageShaderMaterial.hideStart.Set( hideStart ); - gpuFoliageShaderMaterial.hideOffset.Set( data.visibilityFadeHidingOffset ); + data.materialOverride?.translucencySettings?.ApplyTranslucency( material, this ); - gpuFoliageShaderMaterial.positionVariance.Set( renderer.noise ); - gpuFoliageShaderMaterial.rotationVariance.Set( renderer.noise ); - gpuFoliageShaderMaterial.scaleVariance.Set( renderer.noise ); - gpuFoliageShaderMaterial.occupancyVariance.Set( renderer.noise ); - gpuFoliageShaderMaterial.maxPositionOffset.Set( data.positionVarianceMaxOffset ); - gpuFoliageShaderMaterial.positionUvScale.Set( Vector2.One * data.positionVarianceScale ); - gpuFoliageShaderMaterial.positionUvOffset.Set( Vector2.One * data.positionVarianceOffset ); + // if ( data.overwriteAlphaScissorToDepthPrepass && gpuParticles3D.DrawPass1.SurfaceGetMaterial( 0 ) is StandardMaterial3D standardDrawMaterial ) + // { + // if ( BaseMaterial3D.TransparencyEnum.AlphaScissor == standardDrawMaterial.Transparency ) + // { + // var overrideMaterial = (StandardMaterial3D) standardDrawMaterial.Duplicate(); + // overrideMaterial.Transparency = BaseMaterial3D.TransparencyEnum.AlphaDepthPrePass; + // gpuParticles3D.MaterialOverride = overrideMaterial; + // overrideMaterial.RenderPriority = data.renderPriority; + // } - gpuFoliageShaderMaterial.minRotation.Set( data.rotationMin ); - gpuFoliageShaderMaterial.maxRotation.Set( data.rotationMax ); - gpuFoliageShaderMaterial.rotationUvScale.Set( Vector2.One * data.rotationVarianceScale ); - gpuFoliageShaderMaterial.rotationUvOffset.Set( Vector2.One * data.rotationVarianceOffset ); + // } - gpuFoliageShaderMaterial.minScale.Set( data.scaleVarianceMinScale ); - gpuFoliageShaderMaterial.maxScale.Set( data.scaleVarianceMaxScale ); - gpuFoliageShaderMaterial.scaleUvScale.Set( Vector2.One * data.scaleVarianceScale ); - gpuFoliageShaderMaterial.scaleUvOffset.Set( Vector2.One * data.scaleVarianceOffset ); + // if ( gpuParticles3D.DrawPass1.SurfaceGetMaterial( 0 ) is ShaderMaterial drawMaterial ) + // { + // drawMaterial.RenderPriority = data.renderPriority; - gpuFoliageShaderMaterial.occupancyAmount.Set( data.occupancyVarianceAmount ); - gpuFoliageShaderMaterial.occupancyPower.Set( data.occupancyVariancePower ); - gpuFoliageShaderMaterial.occupancyTreshold.Set( data.occupancyTreshold ); + // drawMaterial.SetShaderParameter( "obstacle1", renderer.GetObstacleData( 0 ) ); + // drawMaterial.SetShaderParameter( "obstacle2", renderer.GetObstacleData( 1 ) ); + // drawMaterial.SetShaderParameter( "obstacle3", renderer.GetObstacleData( 2 ) ); + // drawMaterial.SetShaderParameter( "obstacle4", renderer.GetObstacleData( 3 ) ); - gpuFoliageShaderMaterial.occupancyHideOffset.Set( data.occupancyHideOffset ); - gpuFoliageShaderMaterial.occupancyHideScale.Set( data.occupancyHideScale ); + // // RJLog.Log( drawMaterial, renderer.GetObstacleData( 0 ) ); + // } - gpuFoliageShaderMaterial.occupancyUvScale.Set( Vector2.One * data.occupancyVarianceScale ); - gpuFoliageShaderMaterial.occupancyUvOffset.Set( Vector2.One * data.occupancyVarianceOffset ); + + } - if ( gpuParticles3D.DrawPass1.SurfaceGetMaterial( 0 ) is ShaderMaterial drawMaterial ) - { - drawMaterial.SetShaderParameter( "obstacle1", renderer.GetObstacleData( 0 ) ); - drawMaterial.SetShaderParameter( "obstacle2", renderer.GetObstacleData( 1 ) ); - drawMaterial.SetShaderParameter( "obstacle3", renderer.GetObstacleData( 2 ) ); - drawMaterial.SetShaderParameter( "obstacle4", renderer.GetObstacleData( 3 ) ); + void UpdateProcessMaterial() + { + var cellSize = FoliageQualitySettings.GetCellSize( renderer.quality, renderer.qualitySettingsAll, data.qualitySettings, data.GetCellSize( subLayerIndex ) ); + var visibilityRange = FoliageQualitySettings.GetVisibilityRange( renderer.quality, renderer.qualitySettingsAll, data.qualitySettings, data.GetVisibilityRange( subLayerIndex ) ); + + var sizeInt = Mathf.CeilToInt( visibilityRange / cellSize ) * 2; - // RJLog.Log( drawMaterial, renderer.GetObstacleData( 0 ) ); - } + if ( _lastCellSize != cellSize || _lastMaxVisibility != visibilityRange ) + { + _lastCellSize = cellSize; + _lastMaxVisibility = visibilityRange; + + gpuFoliageShaderMaterial.cellSize.Set( cellSize ); + + gpuParticles3D.Amount = sizeInt * sizeInt; + gpuFoliageShaderMaterial.width.Set( sizeInt ); + gpuFoliageShaderMaterial.height.Set( sizeInt ); } - } + + var hideStart = visibilityRange - ( visibilityRange * data.GetVisibilityFadeRelative( subLayerIndex ) + data.GetVisibilityFadeAbsolute( subLayerIndex ) ); + gpuFoliageShaderMaterial.hideMax.Set( visibilityRange ); + gpuFoliageShaderMaterial.hideStart.Set( hideStart ); + gpuFoliageShaderMaterial.hideOffset.Set( data.GetVisibilityFadeHidingOffset( subLayerIndex ) ); + + gpuFoliageShaderMaterial.positionVariance.Set( renderer.noise ); + gpuFoliageShaderMaterial.rotationVariance.Set( renderer.noise ); + gpuFoliageShaderMaterial.scaleVariance.Set( renderer.noise ); + gpuFoliageShaderMaterial.occupancyVariance.Set( renderer.noise ); + + gpuFoliageShaderMaterial.maxPositionOffset.Set( data.positionVarianceAbsoluteOffset + data.positionVarianceCellSizeRelativeOffset * cellSize ); + gpuFoliageShaderMaterial.positionOffset.Set( data.GetPositionOffset( subLayerIndex ) ); + gpuFoliageShaderMaterial.positionUvScale.Set( Vector2.One * data.positionVarianceScale ); + gpuFoliageShaderMaterial.positionUvOffset.Set( Vector2.One * data.positionVarianceOffset ); + + gpuFoliageShaderMaterial.minRotation.Set( data.rotationMin ); + gpuFoliageShaderMaterial.maxRotation.Set( data.rotationMax ); + gpuFoliageShaderMaterial.rotationUvScale.Set( Vector2.One * data.rotationVarianceScale ); + gpuFoliageShaderMaterial.rotationUvOffset.Set( Vector2.One * data.rotationVarianceOffset ); + + gpuFoliageShaderMaterial.minScale.Set( data.scaleVarianceMinScale ); + gpuFoliageShaderMaterial.maxScale.Set( data.scaleVarianceMaxScale ); + gpuFoliageShaderMaterial.scaleUvScale.Set( Vector2.One * data.scaleVarianceScale ); + gpuFoliageShaderMaterial.scaleUvOffset.Set( Vector2.One * data.scaleVarianceOffset ); + + gpuFoliageShaderMaterial.occupancyAmount.Set( data.occupancyVarianceAmount ); + gpuFoliageShaderMaterial.occupancyPower.Set( data.occupancyVariancePower ); + gpuFoliageShaderMaterial.occupancyTreshold.Set( data.occupancyTreshold ); + + gpuFoliageShaderMaterial.occupancyHideOffset.Set( data.occupancyHideOffset ); + gpuFoliageShaderMaterial.occupancyHideScale.Set( data.occupancyHideScale ); + + gpuFoliageShaderMaterial.occupancyUvScale.Set( Vector2.One * data.occupancyVarianceScale ); + gpuFoliageShaderMaterial.occupancyUvOffset.Set( Vector2.One * data.occupancyVarianceOffset ); + + if ( data.GetSort( subLayerIndex ) ) + { + gpuParticles3D.DrawOrder = GpuParticles3D.DrawOrderEnum.ViewDepth; + } + } } } \ No newline at end of file diff --git a/Runtime/Rendering/Assets/Foliage/FoliageRenderer.cs b/Runtime/Rendering/Assets/Foliage/FoliageRenderer.cs index b0c07cf..3e0d47c 100644 --- a/Runtime/Rendering/Assets/Foliage/FoliageRenderer.cs +++ b/Runtime/Rendering/Assets/Foliage/FoliageRenderer.cs @@ -30,16 +30,33 @@ namespace Rokojori [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Scatterer.svg") ] public partial class FoliageRenderer:Node3D { + [ExportToolButton( "Update Layers" )] + public Callable updateLayersButton => Callable.From( ()=> updateLayers = true ) ; + [Export] public FoliageData[] foliage = []; + [ExportGroup("Quality")] [Export( PropertyHint.Range, "0, 200" )] public float quality = 100; [Export] public FoliageQualitySettings[] qualitySettingsAll; + [ExportGroup("Shared")] + + [Export] + public Camera3D camera; + + [Export] + public Texture2D noise; + + [Export] + public int renderPriorityOffset = 0; + + + [ExportGroup("Obstacles")] [Export] public Node3D[] obstacles = []; @@ -58,23 +75,33 @@ namespace Rokojori [Export] public bool processLayers = true; - [Export] public bool updateLayers = true; - [Export] - public Camera3D camera; + Camera3D _assignedCamera; - [Export] - public Texture2D noise; + public Camera3D GetAssignedCamera() { return _assignedCamera; } + public int numFoliageLayers + { + get + { + var numLayers = 0; + + foliage.ForEach( fd => numLayers += fd.numLayers ); + + return numLayers; + } + + } + public override void _Process( double delta ) { _assignedCamera = null; @@ -86,12 +113,32 @@ namespace Rokojori - if ( updateLayers || foliage.Length != renderLayers.Count ) + if ( updateLayers || numFoliageLayers != renderLayers.Count ) { updateLayers = false; this.DestroyChildren(); - renderLayers = foliage.Map( f => FoliageRenderLayer.Create( this, f ) ).ToList(); + + renderLayers = new List(); + foliage.ForEach( + ( fd )=> + { + renderLayers.Add( FoliageRenderLayer.Create( this, fd ) ); + + for ( int i = 0; fd.subLayers != null && i < fd.subLayers.Length; i++ ) + { + if ( fd.subLayers[ i ] == null ) + { + continue; + } + + renderLayers.Add( FoliageRenderLayer.Create( this, fd, i ) ); + } + } + ); + + this.LogInfo( "Initialize:", renderLayers.Count ); renderLayers.ForEach( r => r.data.Initialize( r ) ); + } if ( obstaclesData.Length != 4 ) diff --git a/Runtime/Rendering/Assets/Foliage/FoliageSources/FoliageSource.cs b/Runtime/Rendering/Assets/Foliage/FoliageSources/FoliageSource.cs new file mode 100644 index 0000000..34bbcec --- /dev/null +++ b/Runtime/Rendering/Assets/Foliage/FoliageSources/FoliageSource.cs @@ -0,0 +1,33 @@ +using System.Collections; +using System.Collections.Generic; +using Godot; +using System; +using System.Threading.Tasks; + + + +namespace Rokojori +{ + /** + + + Abstract archetype resource to define from which source the foliage model is loaded + + + + + + + + */ + + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Scatterer.svg") ] + public abstract partial class FoliageSource:Resource + { + public virtual void SetupFoliageDrawPass( FoliageRenderLayer foliageRenderLayer ) + { + + } + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Assets/Foliage/FoliageSources/FoliageSource.cs.uid b/Runtime/Rendering/Assets/Foliage/FoliageSources/FoliageSource.cs.uid new file mode 100644 index 0000000..7f42548 --- /dev/null +++ b/Runtime/Rendering/Assets/Foliage/FoliageSources/FoliageSource.cs.uid @@ -0,0 +1 @@ +uid://6t6w1lp6nyai diff --git a/Runtime/Rendering/Assets/Foliage/FoliageSources/MeshInstanceFoliageSource.cs b/Runtime/Rendering/Assets/Foliage/FoliageSources/MeshInstanceFoliageSource.cs new file mode 100644 index 0000000..50afcb0 --- /dev/null +++ b/Runtime/Rendering/Assets/Foliage/FoliageSources/MeshInstanceFoliageSource.cs @@ -0,0 +1,65 @@ +using System.Collections; +using System.Collections.Generic; +using Godot; +using System; +using System.Threading.Tasks; + + + +namespace Rokojori +{ + /** + + + A FoliageSource that loads the foliage from a MeshInstance reference in the scene. + + + + + + + + */ + + [Tool] + [GlobalClass] + public partial class MeshInstanceFoliageSource:FoliageSource + { + [Export] + public NodePath meshInstanceReference; + + public override void SetupFoliageDrawPass( FoliageRenderLayer renderLayer ) + { + // var particles = renderLayer.renderer.CreateChild(); + + // renderLayer.gpuParticles3D = particles; + + // var processMaterial = new GPUFoliageShaderMaterial(); + // particles.ProcessMaterial = processMaterial; + // particles.Lifetime = 0.01f; + // particles.Explosiveness = 1f; + // particles.FixedFps = 0; + // particles.Interpolate = false; + // particles.FractDelta = false; + + // particles.CustomAabb = Box3.WithSize( 10000 ); + + + // processMaterial.positionVariance.Set( renderLayer.renderer.noise ); + // processMaterial.rotationVariance.Set( renderLayer.renderer.noise ); + // processMaterial.scaleVariance.Set( renderLayer.renderer.noise ); + // processMaterial.occupancyVariance.Set( renderLayer.renderer.noise ); + + // renderLayer.gpuFoliageShaderMaterial = processMaterial; + + var particles = renderLayer.gpuParticles3D; + var meshInstance = renderLayer.renderer.GetNode( meshInstanceReference ) as MeshInstance3D; + + particles.DrawPasses = 1; + particles.DrawPass1 = meshInstance.Mesh; + + // particles.CastShadow = renderLayer.data.shadows ? GeometryInstance3D.ShadowCastingSetting.On : GeometryInstance3D.ShadowCastingSetting.Off; + + } + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Assets/Foliage/MeshInstanceFoliageData.cs.uid b/Runtime/Rendering/Assets/Foliage/FoliageSources/MeshInstanceFoliageSource.cs.uid similarity index 100% rename from Runtime/Rendering/Assets/Foliage/MeshInstanceFoliageData.cs.uid rename to Runtime/Rendering/Assets/Foliage/FoliageSources/MeshInstanceFoliageSource.cs.uid diff --git a/Runtime/Rendering/Assets/Foliage/FoliageSources/SceneFoliageSource.cs b/Runtime/Rendering/Assets/Foliage/FoliageSources/SceneFoliageSource.cs new file mode 100644 index 0000000..36099b8 --- /dev/null +++ b/Runtime/Rendering/Assets/Foliage/FoliageSources/SceneFoliageSource.cs @@ -0,0 +1,69 @@ +using System.Collections; +using System.Collections.Generic; +using Godot; +using System; +using System.Threading.Tasks; + + + +namespace Rokojori +{ + /** + + + A FoliageSource that loads the foliage from the first MeshInstance of a loaded SceneReference. + + + + + + + + */ + + [Tool] + [GlobalClass] + public partial class SceneFoliageSource:FoliageSource + { + [Export] + public SceneReference sceneReference; + + public override void SetupFoliageDrawPass( FoliageRenderLayer renderLayer ) + { + var particles = renderLayer.gpuParticles3D; + + // renderLayer.gpuParticles3D = particles; + + // var processMaterial = new GPUFoliageShaderMaterial(); + // particles.ProcessMaterial = processMaterial; + // particles.Lifetime = 0.01f; + // particles.Explosiveness = 1f; + // particles.FixedFps = 0; + // particles.Interpolate = false; + // particles.FractDelta = false; + + // particles.CustomAabb = Box3.WithSize( 10000 ); + + // processMaterial.positionVariance.Set( renderLayer.renderer.noise ); + // processMaterial.rotationVariance.Set( renderLayer.renderer.noise ); + // processMaterial.scaleVariance.Set( renderLayer.renderer.noise ); + // processMaterial.occupancyVariance.Set( renderLayer.renderer.noise ); + + // renderLayer.gpuFoliageShaderMaterial = processMaterial; + + var packedScene = sceneReference.LoadScene(); + var sceneRoot = packedScene.Instantiate(); + + + + var meshInstance = sceneRoot.GetSelfOrChildOf(); + + this.LogInfo( packedScene, sceneRoot, meshInstance ); + particles.DrawPasses = 1; + particles.DrawPass1 = meshInstance.Mesh; + + // particles.CastShadow = renderLayer.data.shadows ? GeometryInstance3D.ShadowCastingSetting.On : GeometryInstance3D.ShadowCastingSetting.Off; + + } + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Assets/Foliage/SceneFoliageData.cs.uid b/Runtime/Rendering/Assets/Foliage/FoliageSources/SceneFoliageSource.cs.uid similarity index 100% rename from Runtime/Rendering/Assets/Foliage/SceneFoliageData.cs.uid rename to Runtime/Rendering/Assets/Foliage/FoliageSources/SceneFoliageSource.cs.uid diff --git a/Runtime/Rendering/Assets/Foliage/GPUFoliageShader.gdshader b/Runtime/Rendering/Assets/Foliage/GPUFoliageShader.gdshader index 711434e..73d183f 100644 --- a/Runtime/Rendering/Assets/Foliage/GPUFoliageShader.gdshader +++ b/Runtime/Rendering/Assets/Foliage/GPUFoliageShader.gdshader @@ -11,6 +11,7 @@ uniform int height = 10; uniform sampler2D positionVariance; uniform vec3 maxPositionOffset = vec3(0,0,0); +uniform vec3 positionOffset = vec3(0,0,0); uniform vec2 positionUVScale = vec2( 1.0, 1.0 ); uniform vec2 positionUVOffset = vec2( 1.0, 1.0 ); uniform float heightOffset = 0; @@ -80,7 +81,7 @@ void process() vec2 uv = ( vec2( position3D.x, position3D.z ) - mapOffset ) / mapSize; vec3 offset = (textureLod( positionVariance, tilingOffset( uv, positionUVScale, positionUVOffset ), 0 ).rgb - vec3(0.5,0.5,0.5) ) * maxPositionOffset; - position3D += offset; + position3D += offset + positionOffset; vec3 rotSampled = textureLod( rotationVariance, tilingOffset( uv, rotationUVScale, rotationUVOffset ), 0 ).rgb; vec3 rot = ( rotSampled * ( maxRotation - minRotation ) + minRotation ) * PI * 2.0; // rot.y = round( 4.0 * rot.y / PI * 2.0 ) / 4.0 * PI * 2.0; diff --git a/Runtime/Rendering/Assets/Foliage/GPUFoliageShaderMaterial.cs b/Runtime/Rendering/Assets/Foliage/GPUFoliageShaderMaterial.cs index f6d3df8..7296b6f 100644 --- a/Runtime/Rendering/Assets/Foliage/GPUFoliageShaderMaterial.cs +++ b/Runtime/Rendering/Assets/Foliage/GPUFoliageShaderMaterial.cs @@ -17,6 +17,7 @@ namespace Rokojori public static readonly IntPropertyName height = IntPropertyName.Create( "height" ); public static readonly Texture2DPropertyName positionVariance = Texture2DPropertyName.Create( "positionVariance" ); public static readonly Vector3PropertyName maxPositionOffset = Vector3PropertyName.Create( "maxPositionOffset" ); + public static readonly Vector3PropertyName positionOffset = Vector3PropertyName.Create( "positionOffset" ); public static readonly Vector2PropertyName positionUvScale = Vector2PropertyName.Create( "positionUVScale" ); public static readonly Vector2PropertyName positionUvOffset = Vector2PropertyName.Create( "positionUVOffset" ); public static readonly FloatPropertyName heightOffset = FloatPropertyName.Create( "heightOffset" ); @@ -58,6 +59,7 @@ namespace Rokojori public readonly CustomMaterialProperty height; public readonly CustomMaterialProperty positionVariance; public readonly CustomMaterialProperty maxPositionOffset; + public readonly CustomMaterialProperty positionOffset; public readonly CustomMaterialProperty positionUvScale; public readonly CustomMaterialProperty positionUvOffset; public readonly CustomMaterialProperty heightOffset; @@ -96,6 +98,7 @@ namespace Rokojori height = new CustomMaterialProperty( this, GPUFoliageShaderShader.height ); positionVariance = new CustomMaterialProperty( this, GPUFoliageShaderShader.positionVariance ); maxPositionOffset = new CustomMaterialProperty( this, GPUFoliageShaderShader.maxPositionOffset ); + positionOffset = new CustomMaterialProperty( this, GPUFoliageShaderShader.positionOffset ); positionUvScale = new CustomMaterialProperty( this, GPUFoliageShaderShader.positionUvScale ); positionUvOffset = new CustomMaterialProperty( this, GPUFoliageShaderShader.positionUvOffset ); heightOffset = new CustomMaterialProperty( this, GPUFoliageShaderShader.heightOffset ); diff --git a/Runtime/Rendering/Assets/Foliage/MeshInstanceFoliageData.cs b/Runtime/Rendering/Assets/Foliage/MeshInstanceFoliageData.cs deleted file mode 100644 index fc118be..0000000 --- a/Runtime/Rendering/Assets/Foliage/MeshInstanceFoliageData.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using Godot; -using System; -using System.Threading.Tasks; - - - -namespace Rokojori -{ - /** - - - A node to render foliage. - - - - The GrassPatch has various settings to create a different styles of grass. - It allows to change the shapes of the blades, their number and distribution, their triangle count, - rotation and scale, LOD levels and much more. - - - - - - */ - - [Tool] - [GlobalClass] - public partial class MeshInstanceFoliageData:FoliageData - { - [Export] - public NodePath meshInstanceReference; - - public override void Initialize( FoliageRenderLayer renderLayer ) - { - var particles = renderLayer.renderer.CreateChild(); - - renderLayer.gpuParticles3D = particles; - - var processMaterial = new GPUFoliageShaderMaterial(); - particles.ProcessMaterial = processMaterial; - particles.Lifetime = 0.01f; - particles.Explosiveness = 1f; - particles.FixedFps = 0; - particles.Interpolate = false; - particles.FractDelta = false; - - particles.CustomAabb = Box3.WithSize( 10000 ); - - - processMaterial.positionVariance.Set( renderLayer.renderer.noise ); - processMaterial.rotationVariance.Set( renderLayer.renderer.noise ); - processMaterial.scaleVariance.Set( renderLayer.renderer.noise ); - processMaterial.occupancyVariance.Set( renderLayer.renderer.noise ); - - renderLayer.gpuFoliageShaderMaterial = processMaterial; - - var meshInstance = renderLayer.renderer.GetNode( meshInstanceReference ) as MeshInstance3D; - - particles.DrawPasses = 1; - particles.DrawPass1 = meshInstance.Mesh; - - particles.CastShadow = GeometryInstance3D.ShadowCastingSetting.Off; - - } - } -} \ No newline at end of file diff --git a/Runtime/Rendering/Assets/Foliage/SceneFoliageData.cs b/Runtime/Rendering/Assets/Foliage/SceneFoliageData.cs deleted file mode 100644 index 4ceb0f6..0000000 --- a/Runtime/Rendering/Assets/Foliage/SceneFoliageData.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using Godot; -using System; -using System.Threading.Tasks; - - - -namespace Rokojori -{ - /** - - - A node to render foliage. - - - - The GrassPatch has various settings to create a different styles of grass. - It allows to change the shapes of the blades, their number and distribution, their triangle count, - rotation and scale, LOD levels and much more. - - - - - - */ - - [Tool] - [GlobalClass] - public partial class SceneFoliageData:FoliageData - { - [Export] - public SceneReference sceneReference; - - public override void Initialize( FoliageRenderLayer renderLayer ) - { - var particles = renderLayer.renderer.CreateChild(); - - renderLayer.gpuParticles3D = particles; - - var processMaterial = new GPUFoliageShaderMaterial(); - particles.ProcessMaterial = processMaterial; - particles.Lifetime = 0.01f; - particles.Explosiveness = 1f; - particles.FixedFps = 0; - particles.Interpolate = false; - particles.FractDelta = false; - - particles.CustomAabb = Box3.WithSize( 10000 ); - - processMaterial.positionVariance.Set( renderLayer.renderer.noise ); - processMaterial.rotationVariance.Set( renderLayer.renderer.noise ); - processMaterial.scaleVariance.Set( renderLayer.renderer.noise ); - processMaterial.occupancyVariance.Set( renderLayer.renderer.noise ); - - renderLayer.gpuFoliageShaderMaterial = processMaterial; - - var packedScene = sceneReference.LoadScene(); - var sceneRoot = packedScene.Instantiate(); - - this.LogInfo( packedScene, sceneRoot ); - - var meshInstance = sceneRoot.GetSelfOrChildOf(); - particles.DrawPasses = 1; - particles.DrawPass1 = meshInstance.Mesh; - - } - } -} \ No newline at end of file diff --git a/Runtime/Rendering/Assets/Foliage/SubFoliageData.cs b/Runtime/Rendering/Assets/Foliage/SubFoliageData.cs new file mode 100644 index 0000000..2a7d8c6 --- /dev/null +++ b/Runtime/Rendering/Assets/Foliage/SubFoliageData.cs @@ -0,0 +1,62 @@ +using System.Collections; +using System.Collections.Generic; +using Godot; +using System; +using System.Threading.Tasks; + + + +namespace Rokojori +{ + /** + + + Resource to define foliage additional layers + + + + + + + + */ + + [Tool] + [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Scatterer.svg") ] + public partial class SubFoliageData:Resource + { + [ExportGroup( "Visibility")] + [Export] + public float relativeCellSize = 2.0f; + + [Export] + public float cellSizeOffset = 0f; + + [Export] + public float relativeVisibilityRange = 2.0f; + + [Export] + public float additionalVisibilityRange = 0.0f; + + [Export] + public float visibilityFadeRelative = 0.5f; + + [Export] + public float visibilityFadeAbsolute = 0f; + + [Export] + public float additionalVisibilityFadeHidingOffset = 0.0f; + + [ExportGroup( "Renderer")] + [Export] + public bool shadows = true; + + [Export] + public bool sort = false; + + [ExportGroup( "Position")] + [Export] + public Vector3 subPositionOffset = Vector3.Zero; + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Assets/Foliage/SubFoliageData.cs.uid b/Runtime/Rendering/Assets/Foliage/SubFoliageData.cs.uid new file mode 100644 index 0000000..6f17f9f --- /dev/null +++ b/Runtime/Rendering/Assets/Foliage/SubFoliageData.cs.uid @@ -0,0 +1 @@ +uid://d2spx6ewtwc64 diff --git a/Runtime/Rendering/Compositor/CompositorEffects/ChromaticAberation/ChromaticAberation.cs b/Runtime/Rendering/Compositor/CompositorEffects/ChromaticAberation/ChromaticAberation.cs index b4b6e48..ccfb47e 100644 --- a/Runtime/Rendering/Compositor/CompositorEffects/ChromaticAberation/ChromaticAberation.cs +++ b/Runtime/Rendering/Compositor/CompositorEffects/ChromaticAberation/ChromaticAberation.cs @@ -33,6 +33,8 @@ namespace Rokojori [Export] public float unshiftCenter = 16f; + [Export] + public int constantsInternalSize; CEG_ScreenColorTexure screenColorTexture; @@ -57,14 +59,17 @@ namespace Rokojori graph.SetProcessOrder( - screenColorTexture, bufferTexture, - copy, chromaticAberation + screenColorTexture, + bufferTexture, + copy, + chromaticAberation ); } protected override void ForAllViews() { + chromaticAberation.constants.Set( rShift, @@ -74,6 +79,8 @@ namespace Rokojori shiftAll, unshiftCenter ); + + constantsInternalSize = chromaticAberation.constants.internalSize; } diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Sharpen/SharpenEffect.cs b/Runtime/Rendering/Compositor/CompositorEffects/Sharpen/SharpenEffect.cs new file mode 100644 index 0000000..28dc960 --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Sharpen/SharpenEffect.cs @@ -0,0 +1,64 @@ + +using Godot; +using Godot.Collections; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class SharpenEffect:RDGraphCompositorEffect + { + public SharpenEffect():base() + { + Initialize(); + } + + [Export( PropertyHint.Range, "0,1")] + public float amount = 1f; + + [Export( PropertyHint.Range, "0,1")] + public float maxDifference = 0.5f; + + CEG_ScreenColorTexure screenColorTexture; + CEG_BufferTexture bufferTexture; + + CEG_Copy copy; + RD_Sharpen sharpen; + + void Initialize() + { + screenColorTexture = new CEG_ScreenColorTexure( graph ); + bufferTexture = CEG_BufferTexture.ScreenSize( graph ); + + copy = new CEG_Copy( graph ); + sharpen = new RD_Sharpen( graph ); + graph.InitializeNodes(); + + copy.SetTextureSlotInputs( screenColorTexture, bufferTexture ); + sharpen.SetTextureSlotInputs( copy.output, copy.input ); + + + graph.SetProcessOrder( + screenColorTexture, + bufferTexture, + copy, + sharpen + ); + + } + + protected override void ForAllViews() + { + sharpen.constants.Set( + [ + amount, + maxDifference + ] + ); + + } + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/Compositor/CompositorEffects/Sharpen/SharpenEffect.cs.uid b/Runtime/Rendering/Compositor/CompositorEffects/Sharpen/SharpenEffect.cs.uid new file mode 100644 index 0000000..907dc85 --- /dev/null +++ b/Runtime/Rendering/Compositor/CompositorEffects/Sharpen/SharpenEffect.cs.uid @@ -0,0 +1 @@ +uid://cl6wesum33vsv diff --git a/Runtime/Rendering/Compositor/RDGraphCompositorEffect.cs b/Runtime/Rendering/Compositor/RDGraphCompositorEffect.cs index a788944..234345a 100644 --- a/Runtime/Rendering/Compositor/RDGraphCompositorEffect.cs +++ b/Runtime/Rendering/Compositor/RDGraphCompositorEffect.cs @@ -6,7 +6,7 @@ namespace Rokojori { [Tool] [GlobalClass] - public partial class RDGraphCompositorEffect:RokojoriCompositorEffect + public abstract partial class RDGraphCompositorEffect:RokojoriCompositorEffect { protected RDGraph _graph; public RDGraph graph => _graph; diff --git a/Runtime/Rendering/Compositor/RokojoriCompositorEffect.cs b/Runtime/Rendering/Compositor/RokojoriCompositorEffect.cs index 0305845..c31407e 100644 --- a/Runtime/Rendering/Compositor/RokojoriCompositorEffect.cs +++ b/Runtime/Rendering/Compositor/RokojoriCompositorEffect.cs @@ -6,7 +6,7 @@ namespace Rokojori { [Tool] [GlobalClass] - public partial class RokojoriCompositorEffect:CompositorEffect + public abstract partial class RokojoriCompositorEffect:CompositorEffect { public static readonly string effectsPath = "res://addons/rokojori_action_library/Runtime/Rendering/Compositor/CompositorEffects"; public static string Path( string path ) diff --git a/Runtime/Rendering/Compositor/SingleShaderCompositorEffect.cs b/Runtime/Rendering/Compositor/SingleShaderCompositorEffect.cs index 7b6de31..29fe5da 100644 --- a/Runtime/Rendering/Compositor/SingleShaderCompositorEffect.cs +++ b/Runtime/Rendering/Compositor/SingleShaderCompositorEffect.cs @@ -6,7 +6,7 @@ namespace Rokojori { [Tool] [GlobalClass] - public partial class SingleShaderCompositorEffect:RokojoriCompositorEffect + public abstract partial class SingleShaderCompositorEffect:RokojoriCompositorEffect { protected string _shaderPath; diff --git a/Runtime/Rendering/FontFX/FontCreator.cs b/Runtime/Rendering/FontFX/FontCreator.cs new file mode 100644 index 0000000..54a9e08 --- /dev/null +++ b/Runtime/Rendering/FontFX/FontCreator.cs @@ -0,0 +1,136 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class FontCreator:Node3D + { + [Export] + public Font font; + + [Export] + public string characterSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcedfghijklmnopqrstuvwxyz0123456789!?.-#+[]:,;_/"; + + [Export(PropertyHint.Dir)] + public string exportPath; + + [Export] + public FontDefinition fontDefinition; + + [Export] + public Label3D label3D; + + [Export] + public int elements = 3; + + [Export] + public float offset = 0.1f; + + [Export] + public Gradient fillGradient; + + [Export] + public Gradient strokeGradient; + + [Export] + public float height; + + [ExportToolButton( "Create Glyphs" )] + public Callable createButton => Callable.From( ()=> CreateGlyphs() ) ; + + + [Export] + public Node3D[] glyphs; + + + void CreateGlyphs() + { + this.DestroyChildren(); + glyphs = []; + + var gList = new List(); + + for ( int i = 0; i < characterSet.Length; i++ ) + { + var g = CreateGlyph( characterSet[ i ] + "" ); + gList.Add( g ); + } + + glyphs = gList.ToArray(); + + ComputeWidths(); + } + + async void ComputeWidths() + { + await this.RequestNextFrame(); + await this.RequestNextFrame(); + + var glyphList = new List(); + + for ( int i = 0; i < glyphs.Length; i++ ) + { + var label = glyphs[ i ].Get(); + + var bounds = (label.GetAabb()); + + var scenePath = exportPath + "/scene " + glyphs[ i ].Name + ".tscn"; + glyphs[ i ].SaveAs( scenePath, false ); + + var glyph = new FontGlyph(); + glyph.glyphMesh = new SceneReference(); + glyph.glyphMesh.scenePath = scenePath; + glyph.width = bounds.Size.X; + glyph.kerningGroup = 0; + glyph.characters = characterSet[ i ] + ""; + + var glyphPath = exportPath + "/glyph " + glyphs[ i ].Name + ".tres"; + glyph.SaveAs( glyphPath, false ); + + glyphList.Add( glyph ); + + } + + fontDefinition.glyphs = glyphList.ToArray(); + + await this.RequestNextFrame(); + await this.RequestNextFrame(); + + EditorInterface.Singleton.GetResourceFilesystem().ScanSources(); + } + + Node3D CreateGlyph( string character ) + { + + + var characterLabel = ""; + + for ( int i = 0; i < character.Length; i++ ) + { + if ( i != 0 ){ characterLabel += " "; } + characterLabel += character[ i ].MapCharacterToName(); + } + + var container = this.CreateChild( characterLabel ); + + for ( int i = 0; i < elements; i++ ) + { + var label = (Label3D)label3D.Duplicate(); + + label.Text = character; + + label.SetParent( container ); + label.Name = characterLabel; + label.SetLocalZ( i * offset ); + + label.Modulate = fillGradient.Sample( i / ( elements - 1f ) ); + label.OutlineModulate = strokeGradient.Sample( i / ( elements - 1f ) ); + } + + return container; + } + } +} \ No newline at end of file diff --git a/Runtime/Rendering/FontFX/FontCreator.cs.uid b/Runtime/Rendering/FontFX/FontCreator.cs.uid new file mode 100644 index 0000000..f9e7d3d --- /dev/null +++ b/Runtime/Rendering/FontFX/FontCreator.cs.uid @@ -0,0 +1 @@ +uid://g42ibych1di1 diff --git a/Runtime/Rendering/FontFX/FontDefinition.cs b/Runtime/Rendering/FontFX/FontDefinition.cs new file mode 100644 index 0000000..2c68efd --- /dev/null +++ b/Runtime/Rendering/FontFX/FontDefinition.cs @@ -0,0 +1,149 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class FontDefinition: Resource + { + [ExportToolButton( "Clear Cache" )] + public Callable refreshButton => Callable.From( + ()=> + { + ClearCache(); + } + ); + + [Export] + public FontGlyph[] glyphs; + + [Export] + public float defaultWidth = 0.1f; + + [ExportGroup("Height")] + [Export] + public float baseToTop; + + [Export] + public float baseToBottom; + + [ExportGroup("Kerning")] + [Export] + public float defaultKerning; + + [Export] + public FontKerningPair[] kerningPairs; + + HashSet _emptyGlyphs = new HashSet(); + Dictionary _glyphMap = new Dictionary(); + Dictionary _kerning = new Dictionary(); + + void ClearCache() + { + _emptyGlyphs = new HashSet(); + _glyphMap = new Dictionary(); + _kerning = new Dictionary(); + } + + + + public float GetWidth( string characters ) + { + var width = 0f; + + for ( int i = 0; i < characters.Length; i++ ) + { + + width += GetCharacterWidth( characters[ i ] + "" ); + + if ( i == 0 ) + { + continue; + } + + var kerning = GetKerning( characters[ i - 1 ], characters[ i ] ); + + width += kerning; + } + + return width; + } + + public List GetOffsets( string characters ) + { + var positions = new List(); + var position = 0f; + + for ( int i = 0; i < characters.Length; i++ ) + { + if ( i != 0 ) + { + position += GetKerning( characters[ i - 1 ], characters[ i ] ); + } + + positions.Add( position ); + + position += GetCharacterWidth( characters[ i ] + "" ); + } + + return positions; + } + + public float GetKerning( string characterBefore, string characterAfter ) + { + var gBefore = GetFontGlyph( characterBefore ); + var gAfter = GetFontGlyph( characterAfter ); + + return GetKerning( gBefore == null ? -1 : gBefore.kerningGroup, gAfter == null ? -1 : gAfter.kerningGroup ); + } + + public float GetKerning( int before, int after ) + { + var kernID = before + "|" + after; + + if ( _kerning.ContainsKey( kernID ) ) + { + return _kerning[ kernID ]; + } + + var kp = kerningPairs.Find( kp => kp.kerningGroupBefore == before && kp.kerningGroupAfter == after ); + _kerning[ kernID ] = kp == null ? defaultKerning : kp.kerningWidth; + + return _kerning[ kernID ]; + } + + public FontGlyph GetFontGlyph( string character ) + { + if ( _glyphMap.ContainsKey( character ) ) + { + return _glyphMap[ character ]; + } + + if ( _emptyGlyphs.Contains( character ) ) + { + return null; + } + + var glyph = glyphs.Find( g => g.characters == character ); + + if ( glyph == null ) + { + _emptyGlyphs.Add( character ); + return null; + } + + _glyphMap[ character ] = glyph; + + return glyph; + } + + public float GetCharacterWidth( string character ) + { + var g = GetFontGlyph( character ); + + return g == null ? defaultWidth : g.width; + } + } +} \ No newline at end of file diff --git a/Runtime/Rendering/FontFX/FontDefinition.cs.uid b/Runtime/Rendering/FontFX/FontDefinition.cs.uid new file mode 100644 index 0000000..124f67f --- /dev/null +++ b/Runtime/Rendering/FontFX/FontDefinition.cs.uid @@ -0,0 +1 @@ +uid://8morqyt305dd diff --git a/Runtime/Rendering/FontFX/FontFX.cs b/Runtime/Rendering/FontFX/FontFX.cs new file mode 100644 index 0000000..3e79246 --- /dev/null +++ b/Runtime/Rendering/FontFX/FontFX.cs @@ -0,0 +1,116 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class FontFX:Node3D + { + [ExportToolButton( "Update")] + public Callable updateButton => Callable.From( ()=>{ _Update(); } ); + + [ExportToolButton( "Clear Cache")] + public Callable clearCacheButton => Callable.From( ()=>{ ClearCache(); } ); + + [Export] + public FontDefinition font + { + get => _font; + set + { + _font = value; + _Update(); + } + } + + FontDefinition _font; + + [Export] + public LocaleText text{ get => _text; set{ _text = value; _Update(); } } + LocaleText _text; + + FontFXLayouter _layouter = new FontFXLayouter(); + + Transformable _layout; + + Dictionary _glyphMap = new Dictionary(); + + void ClearCache() + { + _glyphMap = new Dictionary(); + } + + + PackedScene GetGlyph( string character ) + { + if ( _glyphMap.ContainsKey( character ) ) + { + return _glyphMap[ character ]; + } + + var g = font.GetFontGlyph( character ); + + _glyphMap[ character ] = g == null ? null : g.glyphMesh.LoadScene(); + + return _glyphMap[ character ]; + } + + void _Update() + { + if ( _font == null || _text == null ) + { + return; + } + + this.DestroyChildren(); + + var realText = _text.currentValue; + + var lines = _layouter.Layout( realText, _font ); + + var offset = 0f; + + lines.ForEach( + ( line )=> + { + offset = CreateLine( line, offset ); + } + ); + } + + float CreateLine( FontFXLine line, float offset ) + { + line.ComptuteOffsets(); + + line.groups.ForEach( + ( g )=> + { + CreateGroup( g, offset ); + } + ); + + return offset + font.baseToBottom + font.baseToTop; + } + + void CreateGroup( FontFXGroup group, float offset ) + { + for ( int i = 0; i < group.characters.Length; i++ ) + { + var sc = GetGlyph( group.characters[ i ] + "" ); + + if ( sc == null ) + { + continue; + } + + var n = sc.Instantiate(); + n.Name = this.GetChildCount() + "-" + group.characters[ i ].MapCharacterToName(); + n.SetParent( this ); + n.SetLocalX( group.absoluteOffsets[ i ] ); + n.SetLocalY( -offset ); + } + } + } +} \ No newline at end of file diff --git a/Runtime/Rendering/FontFX/FontFX.cs.uid b/Runtime/Rendering/FontFX/FontFX.cs.uid new file mode 100644 index 0000000..b45937a --- /dev/null +++ b/Runtime/Rendering/FontFX/FontFX.cs.uid @@ -0,0 +1 @@ +uid://dq7soaa4joud3 diff --git a/Runtime/Rendering/FontFX/FontFXLayouter.cs b/Runtime/Rendering/FontFX/FontFXLayouter.cs new file mode 100644 index 0000000..4078d56 --- /dev/null +++ b/Runtime/Rendering/FontFX/FontFXLayouter.cs @@ -0,0 +1,132 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + public class FontFXGroup + { + public FontDefinition fontDefinition; + public float scale = 1; + public string characters; + + float _width = 0; + public float width + { + get + { + + if ( _width == 0 ) + { + _width = fontDefinition.GetWidth( characters ) * scale; + } + + return _width; + } + } + + public List relativeOffsets => fontDefinition.GetOffsets( characters ).Map( o => o * scale ); + + public List absoluteOffsets; + + + } + + public class FontFXLine + { + public List groups = new List(); + + public void ComptuteOffsets() + { + var offset = 0f; + + for ( int i = 0; i < groups.Count; i++ ) + { + var width = groups[ i ].width; + groups[ i ].absoluteOffsets = groups[ i ].relativeOffsets.Map( o => o + offset ); + offset += width; + } + } + + public List LayoutLineWrapped( float width ) + { + var lines = new List(); + var line = new FontFXLine(); + + var lineWidth = 0f; + + groups.ForEach( + ( g )=> + { + var groupWidth = g.width; + var nextEnd = lineWidth + groupWidth; + + if ( nextEnd > width ) + { + lines.Add( line ); + line = new FontFXLine(); + lineWidth = 0; + } + + line.groups.Add( g ); + lineWidth += groupWidth; + } + ); + + lines.Add( line ); + + return lines; + } + + } + + public class FontFXLayouter + { + + public List Layout( string text, FontDefinition font, float maxWidth = 10000000 ) + { + var lines = new List(); + + var lexed = WordLexer.Lex( text ); + + if ( lexed == null ) + { + return null; + } + + var line = new FontFXLine(); + + lexed.ForEach( + ( l )=> + { + if ( l.isDone ) + { + return; + } + + if ( l.Is( WordLexer.LineBreak ) ) + { + lines.Add( line ); + + line = new FontFXLine(); + return; + } + + var group = new FontFXGroup(); + group.fontDefinition = font; + group.characters = l.match; + + line.groups.Add( group ); + } + ); + + lines.Add( line ); + + + lines = lines.MultiMap( ( line, index ) => line.LayoutLineWrapped( maxWidth ) ); + + + return lines; + } + } +} \ No newline at end of file diff --git a/Runtime/Rendering/FontFX/FontFXLayouter.cs.uid b/Runtime/Rendering/FontFX/FontFXLayouter.cs.uid new file mode 100644 index 0000000..3ce3a3b --- /dev/null +++ b/Runtime/Rendering/FontFX/FontFXLayouter.cs.uid @@ -0,0 +1 @@ +uid://1twv2j76yfb diff --git a/Runtime/Rendering/FontFX/FontGlyph.cs b/Runtime/Rendering/FontFX/FontGlyph.cs new file mode 100644 index 0000000..e47577f --- /dev/null +++ b/Runtime/Rendering/FontFX/FontGlyph.cs @@ -0,0 +1,24 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class FontGlyph: Resource + { + [Export] + public string characters = ""; + + [Export] + public SceneReference glyphMesh; + + [Export] + public float width; + + [Export] + public int kerningGroup; + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/FontFX/FontGlyph.cs.uid b/Runtime/Rendering/FontFX/FontGlyph.cs.uid new file mode 100644 index 0000000..2ad5f8d --- /dev/null +++ b/Runtime/Rendering/FontFX/FontGlyph.cs.uid @@ -0,0 +1 @@ +uid://wuslvbp8v1r0 diff --git a/Runtime/Rendering/FontFX/FontKerningPair.cs b/Runtime/Rendering/FontFX/FontKerningPair.cs new file mode 100644 index 0000000..f216b1e --- /dev/null +++ b/Runtime/Rendering/FontFX/FontKerningPair.cs @@ -0,0 +1,20 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class FontKerningPair: Resource + { + [Export] + public int kerningGroupBefore; + + [Export] + public int kerningGroupAfter; + + [Export] + public float kerningWidth; + } +} \ No newline at end of file diff --git a/Runtime/Rendering/FontFX/FontKerningPair.cs.uid b/Runtime/Rendering/FontFX/FontKerningPair.cs.uid new file mode 100644 index 0000000..91deb87 --- /dev/null +++ b/Runtime/Rendering/FontFX/FontKerningPair.cs.uid @@ -0,0 +1 @@ +uid://boy62txt2ged6 diff --git a/Runtime/Rendering/Objects/RDPushConstants.cs b/Runtime/Rendering/Objects/RDPushConstants.cs index 342ce8c..83b5e1f 100644 --- a/Runtime/Rendering/Objects/RDPushConstants.cs +++ b/Runtime/Rendering/Objects/RDPushConstants.cs @@ -23,6 +23,8 @@ namespace Rokojori public int size => _floatIndex + _intIndex; + public int internalSize => _floats.Count + _ints.Count; + public void Set( params object[] objects ) { diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Sharpeners/Sharpen/RG_Sharpen.cs b/Runtime/Rendering/RenderGraph/Nodes/Processors/Sharpeners/Sharpen/RG_Sharpen.cs new file mode 100644 index 0000000..a19a91b --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Sharpeners/Sharpen/RG_Sharpen.cs @@ -0,0 +1,17 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + public class RD_Sharpen:CEG_ImageProcessor + { + public static readonly string shaderPath = + RDGraph.Path( "Nodes/Processors/Sharpeners/Sharpen/Sharpen.glsl" ); + + public RD_Sharpen( RDGraph graph ):base( graph, shaderPath ) + {} + + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Sharpeners/Sharpen/RG_Sharpen.cs.uid b/Runtime/Rendering/RenderGraph/Nodes/Processors/Sharpeners/Sharpen/RG_Sharpen.cs.uid new file mode 100644 index 0000000..79af2b0 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Sharpeners/Sharpen/RG_Sharpen.cs.uid @@ -0,0 +1 @@ +uid://dpyt671lyienl diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Sharpeners/Sharpen/Sharpen.glsl b/Runtime/Rendering/RenderGraph/Nodes/Processors/Sharpeners/Sharpen/Sharpen.glsl new file mode 100644 index 0000000..4ebc5ea --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Sharpeners/Sharpen/Sharpen.glsl @@ -0,0 +1,58 @@ +#[compute] +#version 450 + +layout( local_size_x = 8, local_size_y = 8, local_size_z = 1 ) in; + +layout( rgba16f, set = 0, binding = 0 ) +uniform image2D inputImage; + +layout( rgba16f, set = 1, binding = 0 ) +uniform image2D outputImage; + + +layout( push_constant, std430 ) +uniform Parameters +{ + float amount; + float maxDifference; + +} parameters; + + +void main( ) +{ + ivec2 size = imageSize( inputImage ); + ivec2 pixelUV = ivec2( gl_GlobalInvocationID.xy ); + + if ( any( greaterThanEqual( pixelUV, size ) ) ) + { + return; + } + + vec4 color = imageLoad( inputImage, pixelUV + ivec2( -1, 0 ) ) + + imageLoad( inputImage, pixelUV + ivec2( 0, -1 ) ) + + imageLoad( inputImage, pixelUV + ivec2( 1, 0 ) ) + + imageLoad( inputImage, pixelUV + ivec2( 0, 1 ) ) + + imageLoad( inputImage, pixelUV + ivec2( -1, -1 ) ) + + imageLoad( inputImage, pixelUV + ivec2( 1, 1 ) ) + + imageLoad( inputImage, pixelUV + ivec2( -1, 1 ) ) + + imageLoad( inputImage, pixelUV + ivec2( 1, -1 ) ) + ; + + + vec4 originalColor = imageLoad( inputImage, pixelUV ); + color.a = originalColor.a; + + color = clamp( originalColor * 9.0 - color, 0.0, 1.0 ); + + vec3 difference = ( originalColor.rgb - color.rgb ); + + if ( length( difference ) > parameters.maxDifference ) + { + color = originalColor - vec4( normalize( difference ) * parameters.maxDifference, color.a ) ; + } + + vec4 mixedColor = mix( originalColor, color, parameters.amount ); + + imageStore( outputImage, pixelUV, mixedColor ); +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderGraph/Nodes/Processors/Sharpeners/Sharpen/Sharpen.glsl.import b/Runtime/Rendering/RenderGraph/Nodes/Processors/Sharpeners/Sharpen/Sharpen.glsl.import new file mode 100644 index 0000000..8680f59 --- /dev/null +++ b/Runtime/Rendering/RenderGraph/Nodes/Processors/Sharpeners/Sharpen/Sharpen.glsl.import @@ -0,0 +1,14 @@ +[remap] + +importer="glsl" +type="RDShaderFile" +uid="uid://tv7pfvjko4qf" +path="res://.godot/imported/Sharpen.glsl-b46162a64710a5b8af940ce9c6966537.res" + +[deps] + +source_file="res://addons/rokojori_action_library/Runtime/Rendering/RenderGraph/Nodes/Processors/Sharpeners/Sharpen/Sharpen.glsl" +dest_files=["res://.godot/imported/Sharpen.glsl-b46162a64710a5b8af940ce9c6966537.res"] + +[params] + diff --git a/Runtime/WorldMap/WorldMapLayerDefinition.cs b/Runtime/Rendering/RenderingManager.cs similarity index 51% rename from Runtime/WorldMap/WorldMapLayerDefinition.cs rename to Runtime/Rendering/RenderingManager.cs index 7bdf020..6bb4e38 100644 --- a/Runtime/WorldMap/WorldMapLayerDefinition.cs +++ b/Runtime/Rendering/RenderingManager.cs @@ -1,16 +1,18 @@ -using Godot; + +using System.Diagnostics; using System.Collections; using System.Collections.Generic; -using System.Text.RegularExpressions; +using System; +using Godot; + namespace Rokojori { [Tool] [GlobalClass] - public partial class WorldMapLayerDefinition:Resource - { + public partial class RenderingManager:Node + { [Export] - public string layerName; - + public RenderingManagerData data; } } \ No newline at end of file diff --git a/Runtime/Rendering/RenderingManager.cs.uid b/Runtime/Rendering/RenderingManager.cs.uid new file mode 100644 index 0000000..4fe3a6a --- /dev/null +++ b/Runtime/Rendering/RenderingManager.cs.uid @@ -0,0 +1 @@ +uid://cvmdx3bhq0i81 diff --git a/Runtime/Rendering/RenderingManagerData.cs b/Runtime/Rendering/RenderingManagerData.cs new file mode 100644 index 0000000..42d42a0 --- /dev/null +++ b/Runtime/Rendering/RenderingManagerData.cs @@ -0,0 +1,18 @@ + +using System.Diagnostics; +using System.Collections; +using System.Collections.Generic; +using System; +using Godot; + + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class RenderingManagerData:Resource + { + [Export] + public RenderingPriority[] renderingPriorities; + } +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderingManagerData.cs.uid b/Runtime/Rendering/RenderingManagerData.cs.uid new file mode 100644 index 0000000..bdae73e --- /dev/null +++ b/Runtime/Rendering/RenderingManagerData.cs.uid @@ -0,0 +1 @@ +uid://db21mjsel81fj diff --git a/Runtime/Rendering/RenderingPriority.cs b/Runtime/Rendering/RenderingPriority.cs new file mode 100644 index 0000000..dd006ad --- /dev/null +++ b/Runtime/Rendering/RenderingPriority.cs @@ -0,0 +1,17 @@ + +using System.Diagnostics; +using System.Collections; +using System.Collections.Generic; +using System; +using Godot; + + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class RenderingPriority:Resource + { + + } +} \ No newline at end of file diff --git a/Runtime/Rendering/RenderingPriority.cs.uid b/Runtime/Rendering/RenderingPriority.cs.uid new file mode 100644 index 0000000..ad343c1 --- /dev/null +++ b/Runtime/Rendering/RenderingPriority.cs.uid @@ -0,0 +1 @@ +uid://drflrd0to2k40 diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Background.svg.import b/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Background.svg.import index 907be92..d9689ae 100644 --- a/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Background.svg.import +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Background.svg.import @@ -21,9 +21,9 @@ compress/lossy_quality=0.7 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 -roughness/mode=0 +roughness/mode=1 roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Left + Right.svg.import b/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Left + Right.svg.import index ac58c76..eb12d63 100644 --- a/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Left + Right.svg.import +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Left + Right.svg.import @@ -21,9 +21,9 @@ compress/lossy_quality=0.7 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 -roughness/mode=0 +roughness/mode=1 roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Pressed.svg.import b/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Pressed.svg.import index ac85d0e..30999f5 100644 --- a/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Pressed.svg.import +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Pressed.svg.import @@ -21,9 +21,9 @@ compress/lossy_quality=0.7 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 -roughness/mode=0 +roughness/mode=1 roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Up + Down.svg.import b/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Up + Down.svg.import index 24dc373..c0087b7 100644 --- a/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Up + Down.svg.import +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Up + Down.svg.import @@ -21,9 +21,9 @@ compress/lossy_quality=0.7 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 -roughness/mode=0 +roughness/mode=1 roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Up.svg.import b/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Up.svg.import index 8edae74..5121236 100644 --- a/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Up.svg.import +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-Axis-Up.svg.import @@ -21,9 +21,9 @@ compress/lossy_quality=0.7 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 -roughness/mode=0 +roughness/mode=1 roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Background.svg.import b/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Background.svg.import index 68f77b2..7e0c92c 100644 --- a/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Background.svg.import +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Background.svg.import @@ -21,9 +21,9 @@ compress/lossy_quality=0.7 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 -roughness/mode=0 +roughness/mode=1 roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Left + Right.svg.import b/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Left + Right.svg.import index 23d470c..356ec3f 100644 --- a/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Left + Right.svg.import +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Left + Right.svg.import @@ -21,9 +21,9 @@ compress/lossy_quality=0.7 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 -roughness/mode=0 +roughness/mode=1 roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Up + Down.svg.import b/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Up + Down.svg.import index 451410f..9a16333 100644 --- a/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Up + Down.svg.import +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Up + Down.svg.import @@ -21,9 +21,9 @@ compress/lossy_quality=0.7 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 -roughness/mode=0 +roughness/mode=1 roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Up.svg.import b/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Up.svg.import index e1d9d10..db19b1d 100644 --- a/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Up.svg.import +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-DPad-Up.svg.import @@ -21,9 +21,9 @@ compress/lossy_quality=0.7 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 -roughness/mode=0 +roughness/mode=1 roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-Left-Shoulder-Button.svg.import b/Runtime/Sensors/InputIcons/Graphics/GamePad-Left-Shoulder-Button.svg.import index 8d69195..eb4d220 100644 --- a/Runtime/Sensors/InputIcons/Graphics/GamePad-Left-Shoulder-Button.svg.import +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-Left-Shoulder-Button.svg.import @@ -21,9 +21,9 @@ compress/lossy_quality=0.7 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 -roughness/mode=0 +roughness/mode=1 roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-MainButton.svg.import b/Runtime/Sensors/InputIcons/Graphics/GamePad-MainButton.svg.import index 0d2ea84..aa62a64 100644 --- a/Runtime/Sensors/InputIcons/Graphics/GamePad-MainButton.svg.import +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-MainButton.svg.import @@ -21,9 +21,9 @@ compress/lossy_quality=0.7 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 -roughness/mode=0 +roughness/mode=1 roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false diff --git a/Runtime/Sensors/InputIcons/Graphics/GamePad-Right-Shoulder-Button.svg.import b/Runtime/Sensors/InputIcons/Graphics/GamePad-Right-Shoulder-Button.svg.import index 1a4b46b..f8bae7e 100644 --- a/Runtime/Sensors/InputIcons/Graphics/GamePad-Right-Shoulder-Button.svg.import +++ b/Runtime/Sensors/InputIcons/Graphics/GamePad-Right-Shoulder-Button.svg.import @@ -21,9 +21,9 @@ compress/lossy_quality=0.7 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 -roughness/mode=0 +roughness/mode=1 roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false diff --git a/Runtime/Sensors/InputIcons/Graphics/Keyboard-EnterKey.svg.import b/Runtime/Sensors/InputIcons/Graphics/Keyboard-EnterKey.svg.import index 9fe7cd3..5c00448 100644 --- a/Runtime/Sensors/InputIcons/Graphics/Keyboard-EnterKey.svg.import +++ b/Runtime/Sensors/InputIcons/Graphics/Keyboard-EnterKey.svg.import @@ -21,9 +21,9 @@ compress/lossy_quality=0.7 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 -roughness/mode=0 +roughness/mode=1 roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false diff --git a/Runtime/Sensors/InputIcons/Graphics/Keyboard-Indicator.svg.import b/Runtime/Sensors/InputIcons/Graphics/Keyboard-Indicator.svg.import index 46c8ac0..f1155a6 100644 --- a/Runtime/Sensors/InputIcons/Graphics/Keyboard-Indicator.svg.import +++ b/Runtime/Sensors/InputIcons/Graphics/Keyboard-Indicator.svg.import @@ -21,9 +21,9 @@ compress/lossy_quality=0.7 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 -roughness/mode=0 +roughness/mode=1 roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false diff --git a/Runtime/Sensors/InputIcons/Graphics/Keyboard-SpaceKey.svg.import b/Runtime/Sensors/InputIcons/Graphics/Keyboard-SpaceKey.svg.import index d97b860..0979928 100644 --- a/Runtime/Sensors/InputIcons/Graphics/Keyboard-SpaceKey.svg.import +++ b/Runtime/Sensors/InputIcons/Graphics/Keyboard-SpaceKey.svg.import @@ -21,9 +21,9 @@ compress/lossy_quality=0.7 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 -roughness/mode=0 +roughness/mode=1 roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false diff --git a/Runtime/Sensors/InputIcons/Graphics/Keyboard.svg.import b/Runtime/Sensors/InputIcons/Graphics/Keyboard.svg.import index bfac839..1179b07 100644 --- a/Runtime/Sensors/InputIcons/Graphics/Keyboard.svg.import +++ b/Runtime/Sensors/InputIcons/Graphics/Keyboard.svg.import @@ -21,9 +21,9 @@ compress/lossy_quality=0.7 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 -roughness/mode=0 +roughness/mode=1 roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false diff --git a/Runtime/Sensors/InputIcons/Graphics/Mouse-Left Button.svg.import b/Runtime/Sensors/InputIcons/Graphics/Mouse-Left Button.svg.import index 46f52f8..aa4d159 100644 --- a/Runtime/Sensors/InputIcons/Graphics/Mouse-Left Button.svg.import +++ b/Runtime/Sensors/InputIcons/Graphics/Mouse-Left Button.svg.import @@ -21,9 +21,9 @@ compress/lossy_quality=0.7 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 -roughness/mode=0 +roughness/mode=1 roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false diff --git a/Runtime/Sensors/InputIcons/Graphics/Mouse-Middle Button.svg.import b/Runtime/Sensors/InputIcons/Graphics/Mouse-Middle Button.svg.import index ee084a7..ac942b1 100644 --- a/Runtime/Sensors/InputIcons/Graphics/Mouse-Middle Button.svg.import +++ b/Runtime/Sensors/InputIcons/Graphics/Mouse-Middle Button.svg.import @@ -21,9 +21,9 @@ compress/lossy_quality=0.7 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 -roughness/mode=0 +roughness/mode=1 roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false diff --git a/Runtime/Sensors/InputIcons/Graphics/Mouse-Right Button.svg.import b/Runtime/Sensors/InputIcons/Graphics/Mouse-Right Button.svg.import index 738c3c5..e929248 100644 --- a/Runtime/Sensors/InputIcons/Graphics/Mouse-Right Button.svg.import +++ b/Runtime/Sensors/InputIcons/Graphics/Mouse-Right Button.svg.import @@ -21,9 +21,9 @@ compress/lossy_quality=0.7 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 -roughness/mode=0 +roughness/mode=1 roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false diff --git a/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Down.svg.import b/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Down.svg.import index 6d4d707..b6b4952 100644 --- a/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Down.svg.import +++ b/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Down.svg.import @@ -21,9 +21,9 @@ compress/lossy_quality=0.7 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 -roughness/mode=0 +roughness/mode=1 roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false diff --git a/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Up & Down.svg.import b/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Up & Down.svg.import index 92226a7..f85cef1 100644 --- a/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Up & Down.svg.import +++ b/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Up & Down.svg.import @@ -21,9 +21,9 @@ compress/lossy_quality=0.7 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 -roughness/mode=0 +roughness/mode=1 roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false diff --git a/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Up.svg.import b/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Up.svg.import index 771a000..7ba5ec6 100644 --- a/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Up.svg.import +++ b/Runtime/Sensors/InputIcons/Graphics/Mouse-Wheel Up.svg.import @@ -21,9 +21,9 @@ compress/lossy_quality=0.7 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 -roughness/mode=0 +roughness/mode=1 roughness/src_normal="" process/fix_alpha_border=true process/premult_alpha=false diff --git a/Runtime/Shading/Library/Colors.gdshaderinc b/Runtime/Shading/Library/Colors.gdshaderinc index 149f653..18c8932 100644 --- a/Runtime/Shading/Library/Colors.gdshaderinc +++ b/Runtime/Shading/Library/Colors.gdshaderinc @@ -305,6 +305,11 @@ vec4 desaturate( vec4 color, float amount ) vec4 blendMode_alpha( vec4 bottom, vec4 top ) { + if ( bottom.a <= 0.0 ) + { + return top; + } + float fade = ( 1.0 - top.a ); float alpha = top.a + bottom.a * fade; @@ -313,44 +318,285 @@ vec4 blendMode_alpha( vec4 bottom, vec4 top ) vec3 color = topPM.rgb + bottomPM.rgb * fade; - return vec4( color, 1 ) / alpha; + vec4 result = alpha > 0.0 ? vec4( color / alpha, alpha ) : vec4( color, 0 ); + + result = clamp( result, 0, 1 ); + return result; +} + +vec3 blendFunction_multiply( vec3 bottom, vec3 top ) +{ + return bottom * top; +} + +vec4 blendMode_multiply( vec4 bottom, vec4 top ) +{ + if ( bottom.a <= 0.0 ) + { + return top; + } + + return blendMode_alpha( bottom, vec4( blendFunction_multiply( bottom.rgb, top.rgb ), top.a ) ); } -vec4 blendMode_colorHSL( vec4 bottom, vec4 top ) +vec3 blendFunction_screen( vec3 bottom, vec3 top ) +{ + return 1.0 - ( 1.0 - bottom ) * ( 1.0 - top ); +} + +vec4 blendMode_screen( vec4 bottom, vec4 top ) +{ + if ( bottom.a <= 0.0 ) + { + return top; + } + + return blendMode_alpha( bottom, vec4( blendFunction_screen( bottom.rgb, top.rgb ), top.a ) ); +} + +vec3 blendFunction_add( vec3 bottom, vec3 top ) +{ + return bottom + top; +} + +vec4 blendMode_add( vec4 bottom, vec4 top ) +{ + if ( bottom.a <= 0.0 ) + { + return top; + } + + return blendMode_alpha( bottom, vec4( blendFunction_add( bottom.rgb, top.rgb ), top.a ) ); +} + +vec3 blendFunction_overlay( vec3 bottom, vec3 top ) +{ + return mix( + 2.0 * bottom * top, + 1.0 - 2.0 * ( 1.0 - bottom ) * ( 1.0 - top ), + step( 0.5, bottom ) + ); +} + +vec4 blendMode_overlay( vec4 bottom, vec4 top ) +{ + if ( bottom.a <= 0.0 ) + { + return top; + } + + return blendMode_alpha( bottom, vec4( blendFunction_overlay( bottom.rgb, top.rgb ), top.a ) ); +} + +vec3 blendFunction_hardLight( vec3 bottom, vec3 top ) +{ + return mix( + 2.0 * bottom * top, + 1.0 - 2.0 * ( 1.0 - bottom ) * ( 1.0 - top ), + step( 0.5, top ) + ); +} + +vec4 blendMode_hardLight( vec4 bottom, vec4 top ) +{ + if ( bottom.a <= 0.0 ) + { + return top; + } + + + return blendMode_alpha( bottom, vec4( blendFunction_hardLight( bottom.rgb, top.rgb ), top.a ) ); +} + +vec3 blendFunction_darken( vec3 bottom, vec3 top ) +{ + return min( bottom, top ); +} + +vec4 blendMode_darken( vec4 bottom, vec4 top ) +{ + if ( bottom.a <= 0.0 ) + { + return top; + } + + return blendMode_alpha( bottom, vec4( blendFunction_darken( bottom.rgb, top.rgb ), top.a ) ); +} + +vec3 blendFunction_lighten( vec3 bottom, vec3 top ) +{ + return max( bottom, top ); +} + +vec4 blendMode_lighten( vec4 bottom, vec4 top ) +{ + if ( bottom.a <= 0.0 ) + { + return top; + } + + return blendMode_alpha( bottom, vec4( blendFunction_lighten( bottom.rgb, top.rgb ), top.a ) ); +} + + +vec3 blendFunction_difference( vec3 bottom, vec3 top ) +{ + return abs( bottom - top ); +} + +vec4 blendMode_difference( vec4 bottom, vec4 top ) +{ + if ( bottom.a <= 0.0 ) + { + return top; + } + + + return blendMode_alpha( bottom, vec4( blendFunction_difference( bottom.rgb, top.rgb ), top.a ) ); +} + +vec3 blendFunction_exclusion( vec3 bottom, vec3 top ) +{ + return bottom + top - 2.0 * bottom * top; +} + +vec4 blendMode_exclusion( vec4 bottom, vec4 top ) +{ + if ( bottom.a <= 0.0 ) + { + return top; + } + + return blendMode_alpha( bottom, vec4( blendFunction_exclusion( bottom.rgb, top.rgb ), top.a ) ); +} + +vec3 blendFunction_colorDodge( vec3 bottom, vec3 top ) +{ + return bottom / ( 1.0 - top ); +} + +vec4 blendMode_colorDodge( vec4 bottom, vec4 top ) +{ + if ( bottom.a <= 0.0 ) + { + return top; + } + + + return blendMode_alpha( bottom, vec4( blendFunction_colorDodge( bottom.rgb, top.rgb ), top.a ) ); +} + +vec3 blendFunction_burn( vec3 bottom, vec3 top ) +{ + return 1.0 - ( 1.0 - bottom ) / top; +} + +vec4 blendMode_burn( vec4 bottom, vec4 top ) +{ + if ( bottom.a <= 0.0 ) + { + return top; + } + + return blendMode_alpha( bottom, vec4( blendFunction_burn( bottom.rgb, top.rgb ), top.a ) ); +} + + +vec3 blendFunction_linearBurn( vec3 bottom, vec3 top ) +{ + return bottom + top - 1.0; +} + +vec4 blendMode_linearBurn( vec4 bottom, vec4 top ) +{ + if ( bottom.a <= 0.0 ) + { + return top; + } + + return blendMode_alpha( bottom, vec4( blendFunction_linearBurn( bottom.rgb, top.rgb ), top.a ) ); +} + + +vec3 blendFunction_hue( vec3 bottom, vec3 top ) +{ + vec3 topHSL = RGBtoHSL( top.rgb ); + vec3 bottomHSL = RGBtoHSL( bottom.rgb ); + + vec3 resultHSL = clamp( vec3( topHSL.x, bottomHSL.y, bottomHSL.z ), 0, 1 ); + vec3 resultRBG = clamp( HSLtoRGB( resultHSL ), 0, 1 ); + + return resultRBG; +} + +vec4 blendMode_hue( vec4 bottom, vec4 top ) +{ + if ( bottom.a <= 0.0 ) + { + return top; + } + + + return blendMode_alpha( bottom, vec4( blendFunction_hue( bottom.rgb, top.rgb ), top.a ) ); +} + +vec3 blendFunction_colorHSL( vec3 bottom, vec3 top ) { vec3 topHSL = RGBtoHSL( top.rgb ); vec3 bottomHSL = RGBtoHSL( bottom.rgb ); vec3 resultHSL = vec3( topHSL.x, topHSL.y, bottomHSL.z ); vec3 resultRBG = clamp( HSLtoRGB( resultHSL ), 0, 1 ); - vec4 result = bottom.a == 0.0 ? bottom : vec4( resultRBG, top.a ); - return blendMode_alpha( bottom, result ); + return resultRBG; } -vec4 blendMode_colorHSL( vec4 bottom, vec4 top, float topOpacity ) +vec4 blendMode_colorHSL( vec4 bottom, vec4 top ) { - vec4 blendedColor = blendMode_colorHSL( bottom, top ); - blendedColor.a *= topOpacity; - return blendMode_alpha( bottom, blendedColor ); + if ( bottom.a <= 0.0 ) + { + return top; + } + + + return blendMode_alpha( bottom, vec4( blendFunction_colorHSL( bottom.rgb, top.rgb ), top.a ) ); + // vec3 topHSL = RGBtoHSL( top.rgb ); + // vec3 bottomHSL = RGBtoHSL( bottom.rgb ); + + // vec3 resultHSL = vec3( topHSL.x, topHSL.y, bottomHSL.z ); + // vec3 resultRBG = clamp( HSLtoRGB( resultHSL ), 0, 1 ); + // vec4 result = bottom.a == 0.0 ? top : vec4( resultRBG, top.a ); + + // return blendMode_alpha( bottom, result ); } -vec4 blendMode_colorHSV( vec4 bottom, vec4 top ) +vec3 blendFunction_colorHSV( vec3 bottom, vec3 top ) { vec3 topHSL = RGBtoHSV( top.rgb ); vec3 bottomHSL = RGBtoHSV( bottom.rgb ); vec3 resultHSL = vec3( topHSL.x, topHSL.y, bottomHSL.z ); vec3 resultRBG = clamp( HSVtoRGB( resultHSL ), 0, 1 ); - vec4 result = bottom.a == 0.0 ? bottom : vec4( resultRBG, top.a ); - return blendMode_alpha( bottom, result ); + return resultRBG; } -vec4 blendMode_colorHSV( vec4 bottom, vec4 top, float topOpacity ) + +vec4 blendMode_colorHSV( vec4 bottom, vec4 top ) { - vec4 blendedColor = blendMode_colorHSV( bottom, top ); - blendedColor.a *= topOpacity; - return blendMode_alpha( bottom, blendedColor ); -} \ No newline at end of file + if ( bottom.a <= 0.0 ) + { + return top; + } + + return blendMode_alpha( bottom, vec4( blendFunction_colorHSV( bottom.rgb, top.rgb ), top.a ) ); + // vec3 topHSL = RGBtoHSV( top.rgb ); + // vec3 bottomHSL = RGBtoHSV( bottom.rgb ); + + // vec3 resultHSL = vec3( topHSL.x, topHSL.y, bottomHSL.z ); + // vec3 resultRBG = clamp( HSVtoRGB( resultHSL ), 0, 1 ); + // vec4 result = bottom.a == 0.0 ? top : vec4( resultRBG, top.a ); + + // return blendMode_alpha( bottom, result ); +} diff --git a/Runtime/Shading/Library/Normals.gdshaderinc b/Runtime/Shading/Library/Normals.gdshaderinc index 5381e5d..3f32ff0 100644 --- a/Runtime/Shading/Library/Normals.gdshaderinc +++ b/Runtime/Shading/Library/Normals.gdshaderinc @@ -17,4 +17,29 @@ vec3 addNormalMaps( vec3 a, vec3 b ) vec3 result = a + b; return result + 0.5; -} \ No newline at end of file +} + +vec3 getNormal( sampler2D _normalTexture, vec2 screenUV ) +{ + return textureLod( _normalTexture, screenUV, 0.0 ).rgb * 2.0 - vec3( 1.0 ); +} + +vec3 getNormalAtViewPosition( sampler2D _normalTexture, vec3 viewPosition, mat4 _PROJECTION_MATRIX ) +{ + vec2 screenPosition = viewToScreen( viewPosition, _PROJECTION_MATRIX ); + + return getNormal( _normalTexture, screenPosition ); +} + +vec4 getNormalRoughness( sampler2D _normalTexture, vec2 screenUV ) +{ + vec4 sample = textureLod( _normalTexture, screenUV, 0.0 ); + return vec4( sample.rgb * 2.0 - vec3( 1.0 ), sample.a ); +} + +vec4 getNormalRoughnessAtViewPosition( sampler2D _normalTexture, vec3 viewPosition, mat4 _PROJECTION_MATRIX ) +{ + vec2 screenPosition = viewToScreen( viewPosition, _PROJECTION_MATRIX ); + + return getNormalRoughness( _normalTexture, screenPosition ); +} diff --git a/Runtime/Shading/Library/SDF.gdshaderinc b/Runtime/Shading/Library/SDF.gdshaderinc index 8688838..9246b57 100644 --- a/Runtime/Shading/Library/SDF.gdshaderinc +++ b/Runtime/Shading/Library/SDF.gdshaderinc @@ -1,4 +1,5 @@ // #include "res://addons/rokojori_action_library/Runtime/Shading/Library/SDF.gdshaderinc" +#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Colors.gdshaderinc" void computeRectangleBounds( float in_offset, float in_radius, float in_maxRadius, vec2 size, out vec2 minP, out vec2 maxP, out float out_radius ) { @@ -28,4 +29,81 @@ float roundedRectangle( vec2 minP, vec2 maxP, vec2 point, float borderSize, floa rectangleDistance = clamp( rectangleDistance, 0.0, 1.0 ); return 1.0 - rectangleDistance; +} + + +float sdf_fill( float sd ) +{ + return 1.0 - clamp( sd, 0, 1 ); +} + +float sdf_stroke( float sd, float strokeWidth ) +{ + return sdf_fill( abs( sd ) - strokeWidth ); +} + +vec2 sdf_shape( float sd, float strokeWidth ) +{ + float fill = sdf_fill( sd + strokeWidth ); + float stroke = sdf_stroke( sd, strokeWidth ); + + return vec2( fill, stroke ); +} + +vec4 sdf_coloredShape( float _sd, float _strokeWidth, vec4 _fillColor, vec4 _strokeColor ) +{ + vec2 _sdf_shape = sdf_shape( _sd, _strokeWidth ); + vec4 _fill = fade( _fillColor, _sdf_shape.x ); + vec4 _stroke = fade( _strokeColor, _sdf_shape.y ); + + return blendMode_alpha( _fill, _stroke ); +} + +/* + +TAKEN FROM +[ Inigo Quilez ] + +https://iquilezles.org/articles/distfunctions2d/ + +*/ + + + + +float sdCircle( vec2 p, float r ) +{ + return length(p) - r; +} + +float sdRoundedBox( in vec2 p, in vec2 b, in vec4 r ) +{ + r.xy = (p.x>0.0)?r.xy : r.zw; + r.x = (p.y>0.0)?r.x : r.y; + vec2 q = abs(p)-b+r.x; + return min(max(q.x,q.y),0.0) + length(max(q,0.0)) - r.x; +} + + +float sdChamferBox( in vec2 p, in vec2 b, in float chamfer ) +{ + p = abs(p)-b; + + p = (p.y>p.x) ? p.yx : p.xy; + p.y += chamfer; + + const float k = 1.0-sqrt(2.0); + if( p.y<0.0 && p.y+p.x*k<0.0 ) + return p.x; + + if( p.x( material ); + + if ( Variant.Type.Vector2 == materialValue.VariantType ) + { + var v2 = materialValue.AsVector3(); + v2[ componentIndex ] = value; + member.Set( material, v2 ); + } + else if ( Variant.Type.Vector3 == materialValue.VariantType ) + { + var v3 = materialValue.AsVector3(); + v3[ componentIndex ] = value; + member.Set( material, v3 ); + } + else if ( Variant.Type.Vector4 == materialValue.VariantType ) + { + var v4 = materialValue.AsVector4(); + v4[ componentIndex ] = value; + member.Set( material, v4 ); + } + else if ( Variant.Type.Color == materialValue.VariantType ) + { + var color = materialValue.AsColor(); + color[ componentIndex ] = value; + member.Set( material, color ); + } + + return; + + + } + _Set( material, value ); + + } public float Get( Material material ) { + if ( isComponent ) + { + var member = Shaders.GetUniformMemberByName( material, GetComponentParentName() ); + + if ( member == null ) + { + return 0; + } + + var materialValue = member.Get( material ); + + if ( Variant.Type.Vector2 == materialValue.VariantType ) + { + var v2 = materialValue.AsVector3(); + return v2[ componentIndex ]; + } + else if ( Variant.Type.Vector3 == materialValue.VariantType ) + { + var v3 = materialValue.AsVector3(); + return v3[ componentIndex ]; + } + else if ( Variant.Type.Vector4 == materialValue.VariantType ) + { + var v4 = materialValue.AsVector4(); + return v4[ componentIndex ]; + } + else if ( Variant.Type.Color == materialValue.VariantType ) + { + var color = materialValue.AsColor(); + return color[ componentIndex ]; + } + + + } + return _Get( material, 0f ); } diff --git a/Runtime/Shading/Properties/Vector2PropertyName.cs b/Runtime/Shading/Properties/Vector2PropertyName.cs index 5e93a35..f31a9ec 100644 --- a/Runtime/Shading/Properties/Vector2PropertyName.cs +++ b/Runtime/Shading/Properties/Vector2PropertyName.cs @@ -8,6 +8,9 @@ namespace Rokojori [GlobalClass] public partial class Vector2PropertyName : ShaderPropertyName { + public string propertyNameX => propertyName + ".x"; + public string propertyNameY => propertyName + ".y"; + public void Set( Material material, Vector2 value ) { _Set( material, value ); diff --git a/Runtime/Shading/Properties/Vector3PropertyName.cs b/Runtime/Shading/Properties/Vector3PropertyName.cs index ee8685e..5db2e6e 100644 --- a/Runtime/Shading/Properties/Vector3PropertyName.cs +++ b/Runtime/Shading/Properties/Vector3PropertyName.cs @@ -8,6 +8,10 @@ namespace Rokojori [GlobalClass] public partial class Vector3PropertyName : ShaderPropertyName { + public string propertyNameX => propertyName + ".x"; + public string propertyNameY => propertyName + ".y"; + public string propertyNameZ => propertyName + ".z"; + public void Set( Material material, Vector3 value ) { _Set( material, value ); diff --git a/Runtime/Shading/Properties/Vector4PropertyName.cs b/Runtime/Shading/Properties/Vector4PropertyName.cs index 7c34a0a..6646e43 100644 --- a/Runtime/Shading/Properties/Vector4PropertyName.cs +++ b/Runtime/Shading/Properties/Vector4PropertyName.cs @@ -8,6 +8,11 @@ namespace Rokojori [GlobalClass] public partial class Vector4PropertyName : ShaderPropertyName { + public string propertyNameX => propertyName + ".x"; + public string propertyNameY => propertyName + ".y"; + public string propertyNameZ => propertyName + ".z"; + public string propertyNameW => propertyName + ".w"; + public void Set( Material material, Vector4 value ) { _Set( material, value ); diff --git a/Runtime/Shading/Shaders/Shaders.cs b/Runtime/Shading/Shaders/Shaders.cs index 1f09aa9..973b695 100644 --- a/Runtime/Shading/Shaders/Shaders.cs +++ b/Runtime/Shading/Shaders/Shaders.cs @@ -27,9 +27,51 @@ namespace Rokojori ) ); + list.AddRange( + Lists.Map( + ReflectionHelper.GetDataMemberInfos( m ), + c => UniformMember.Create( c.Name, Variant.Type.Bool ) + ) + ); + + list.AddRange( + Lists.Map( + ReflectionHelper.GetDataMemberInfos( m ), + c => UniformMember.Create( c.Name, Variant.Type.Vector2 ) + ) + ); + + list.AddRange( + Lists.Map( + ReflectionHelper.GetDataMemberInfos( m ), + c => UniformMember.Create( c.Name, Variant.Type.Vector3 ) + ) + ); + + list.AddRange( + Lists.Map( + ReflectionHelper.GetDataMemberInfos( m ), + c => UniformMember.Create( c.Name, Variant.Type.Vector4 ) + ) + ); + + list.AddRange( + Lists.Map( + ReflectionHelper.GetDataMemberInfos( m ), + c => UniformMember.Create( c.Name, Variant.Type.Color ) + ) + ); + return list; } + public static UniformMember GetUniformMemberByName( Material material, string name ) + { + var members = GetUniformMembers( material ); + + return members.Find( m => m.name == name ); + } + public static List GetUniformMembers( Material material ) { if ( material is StandardMaterial3D ) diff --git a/Runtime/Shading/Shaders/UniformMember.cs b/Runtime/Shading/Shaders/UniformMember.cs index fd58ae1..4997e04 100644 --- a/Runtime/Shading/Shaders/UniformMember.cs +++ b/Runtime/Shading/Shaders/UniformMember.cs @@ -61,5 +61,24 @@ namespace Rokojori shaderMaterial.SetShaderParameter( name, value ); } + public void Set( StandardMaterial3D standardMaterial, Variant value ) + { + var property = new ShaderPropertyName(); + property.propertyName = name; + property._Set( standardMaterial, value ); + } + + public void Set( Material material, Variant value ) + { + if ( material is ShaderMaterial sm ) + { + Set( sm, value ); + } + else + { + Set( (StandardMaterial3D) material, value ); + } + } + } } \ No newline at end of file diff --git a/Runtime/Text/Lexing/LexerLibrary/WordLexer.cs b/Runtime/Text/Lexing/LexerLibrary/WordLexer.cs new file mode 100644 index 0000000..f446486 --- /dev/null +++ b/Runtime/Text/Lexing/LexerLibrary/WordLexer.cs @@ -0,0 +1,46 @@ +using System.Collections; +using System.Collections.Generic; +using System.Text.RegularExpressions; + +namespace Rokojori +{ + public class WordLexer:Lexer + { + public static readonly LexerMatcher LineBreak = new LexerMatcher( "LineBreak", @"\r\n|\n|\r" ); + public static readonly LexerMatcher Space = new LexerMatcher( "Space", @"\s" ); + public static readonly LexerMatcher Number =new LexerMatcher( "Number", @"[+-]?\d{1,3}(?:[.,]\d{3})*(?:[.,]\d+)?" ); + public static readonly LexerMatcher Word = new LexerMatcher( "Word", @"\p{L}+(?:[-’']\p{L}+)*" ); + public static readonly LexerMatcher Currency = new LexerMatcher( "Currency", @"[\p{Sc}]\s?\d+(?:[.,]\d+)?" ); + public static readonly LexerMatcher Punctuation = new LexerMatcher( "Punctuation", @"[\p{P}]" ); + public static readonly LexerMatcher Other = new LexerMatcher( "Other", @"." ); + + public static List Lex( string source ) + { + var lexer = new WordLexer(); + var events = lexer.LexToList( source ); + + if ( lexer.hasError ) + { + return null; + } + + events.ForEach( ev => { ev.GrabMatch( source ); } ); + return events; + } + + public WordLexer() + { + + AddAllMatchers( + LineBreak, + Space, + Number, + Word, + Currency, + Punctuation, + Other + ); + + } + } +} \ No newline at end of file diff --git a/Runtime/Text/Lexing/LexerLibrary/WordLexer.cs.uid b/Runtime/Text/Lexing/LexerLibrary/WordLexer.cs.uid new file mode 100644 index 0000000..160ba3a --- /dev/null +++ b/Runtime/Text/Lexing/LexerLibrary/WordLexer.cs.uid @@ -0,0 +1 @@ +uid://dkai7aktpbheh diff --git a/Runtime/Text/Text.cs b/Runtime/Text/Text.cs index dd9af19..ddfbf26 100644 --- a/Runtime/Text/Text.cs +++ b/Runtime/Text/Text.cs @@ -8,6 +8,55 @@ namespace Rokojori { public static class Text { + + public static string MapCharacterToName( this char c ) + { + if ( char.IsLetter( c ) ) + { + if ( char.IsUpper( c ) ) + { + return "uppercase letter " + (c + "").ToLower(); + } + + return "lowercase letter " + c; + } + + if ( char.IsNumber( c ) ) + { + return "number " + c; + } + + + var input = c + ""; + + + var result = Regex.Replace( input, @"[!?.\-#+\[\]:,;_/]", + m => m.Value switch + { + " " => "space", + "!" => "exclamation mark", + "?" => "question mark", + "." => "dot", + "-" => "minus", + "+" => "plus", + "#" => "hash", + "[" => "opening square bracket", + "]" => "closing square bracket", + "{" => "opening curly bracket", + "}" => "closing curly bracket", + "(" => "opening round bracket", + ")" => "closing round bracket", + ":" => "colon", + "," => "comma", + ";" => "semicolon", + "_" => "underscore", + "/" => "slash", + _ => "u" + ( (int) m.Value[ 0 ] ).ToString( "X4" ) + } + ); + + return result; + } public static string WithLeadingZeros( int value, int minDigits = 2 ) { var label = value + ""; diff --git a/Runtime/Time/Duration/Duration.cs b/Runtime/Time/Duration/Duration.cs index 1584c71..736c43f 100644 --- a/Runtime/Time/Duration/Duration.cs +++ b/Runtime/Time/Duration/Duration.cs @@ -20,6 +20,20 @@ namespace Rokojori return 0; } + public virtual float GetLoopPosition() + { + var tl = TimeLineManager.Ensure( timeLine ); + + var duration = GetDurationInSeconds(); + + return tl.position % duration; + } + + public virtual float GetLoopPhase() + { + return GetLoopPosition() / GetDurationInSeconds(); + } + public static string GetTimerLabel( float seconds ) { var secondsAmount = seconds % 60; diff --git a/Runtime/Tools/Lists.cs b/Runtime/Tools/Lists.cs index 6979de4..3bfadd9 100644 --- a/Runtime/Tools/Lists.cs +++ b/Runtime/Tools/Lists.cs @@ -859,6 +859,25 @@ namespace Rokojori return default( T ); } + public static List MultiMap( this List list, Func> mapper ) + { + var outputList = new List(); + + for ( int i = 0; i < list.Count; i++ ) + { + var range = mapper( list[ i ], i ); + + if ( range.Count == 0 ) + { + continue; + } + + outputList.AddRange( range ); + } + + return outputList; + } + public static List Map( this List list, Func mapper ) { return Map( list, mapper, new List() ); diff --git a/Runtime/UI/Components/UISlider.cs b/Runtime/UI/Components/OldUISlider.cs similarity index 98% rename from Runtime/UI/Components/UISlider.cs rename to Runtime/UI/Components/OldUISlider.cs index a225ddd..c3b38ba 100644 --- a/Runtime/UI/Components/UISlider.cs +++ b/Runtime/UI/Components/OldUISlider.cs @@ -6,7 +6,7 @@ using System.IO; namespace Rokojori { [Tool][GlobalClass] - public partial class UISlider : Node, IAssemblyReload + public partial class OldUISlider : Node, IAssemblyReload { [Export] @@ -176,7 +176,11 @@ namespace Rokojori void AddDraggingListener() { - + if ( button == null || scrollContainer == null ) + { + return; + } + leftMouseCallbacks = UIDragging.OnLeftMouseButton( button, ( ev )=> { diff --git a/Runtime/UI/Components/UISlider.cs.uid b/Runtime/UI/Components/OldUISlider.cs.uid similarity index 100% rename from Runtime/UI/Components/UISlider.cs.uid rename to Runtime/UI/Components/OldUISlider.cs.uid diff --git a/Runtime/UI/Components/UIDragging.cs b/Runtime/UI/Components/UIDragging.cs index 6bc0d40..a810fe3 100644 --- a/Runtime/UI/Components/UIDragging.cs +++ b/Runtime/UI/Components/UIDragging.cs @@ -57,6 +57,12 @@ namespace Rokojori callbacks.control = c; callbacks.ui = c.FindParentThatIs(); + if ( callbacks.ui == null ) + { + RJLog.Log( HierarchyName.Of( c ), ">> no UI" ); + return; + } + callbacks.ui.AddForDisposing( callbacks ); info = HierarchyName.Of( c ); diff --git a/Runtime/UI/Layouts/UIFlowLayout.cs b/Runtime/UI/Layouts/UIFlowLayout.cs index 1b4e1d1..7e209de 100644 --- a/Runtime/UI/Layouts/UIFlowLayout.cs +++ b/Runtime/UI/Layouts/UIFlowLayout.cs @@ -191,11 +191,24 @@ namespace Rokojori var nextEndX = x + cWidth + elementSpacing; - var lineWrap = UIStyle.LineWrap( styleContainer ); + if ( child is UIBreak ) + { + nextEndX = 0; + } - lineWrap = lineWrap == UILineWrap.___ ? UILineWrap.Wrap_On_Overflow : lineWrap; - - if ( UILineWrap.Wrap_Never != lineWrap && ( UILineWrap.Wrap_Always == lineWrap || nextEndX > width ) ) + var lineWrapValue = UIStyle.LineWrap( styleContainer ); + + lineWrapValue = lineWrapValue == UILineWrap.___ ? UILineWrap.Wrap_On_Overflow : lineWrapValue; + + var wrapsLine = UILineWrap.Wrap_Never != lineWrapValue && + ( + UILineWrap.Wrap_Always == lineWrapValue || + nextEndX > width || + child is UIBreak + ) + ; + + if ( wrapsLine ) { lines.Add( currentLine ); currentLine = new Line(); diff --git a/Runtime/UI/Layouts/UILayouting.cs b/Runtime/UI/Layouts/UILayouting.cs index b925d15..584df55 100644 --- a/Runtime/UI/Layouts/UILayouting.cs +++ b/Runtime/UI/Layouts/UILayouting.cs @@ -48,6 +48,14 @@ namespace Rokojori uiText.Update(); uiText.CommitUpdateInfo(); } + else if ( control is UIBreak uiBreak ) + { + uiBreak.Update(); + } + else if ( control is UISpace uiSpace ) + { + uiSpace.Update(); + } else { @@ -166,6 +174,16 @@ namespace Rokojori } + if ( c is UIBreak br ) + { + return 0; + } + + if ( c is UISpace sp ) + { + return UINumber.em( c ) * 0.29f; + } + return c.Size.X; } diff --git a/Runtime/UI/Nodes/UIBreak.cs b/Runtime/UI/Nodes/UIBreak.cs new file mode 100644 index 0000000..cd6275d --- /dev/null +++ b/Runtime/UI/Nodes/UIBreak.cs @@ -0,0 +1,94 @@ + +using Godot; +using Rokojori; +using System.Collections.Generic; +using System.Linq; + +namespace Rokojori +{ + [Tool] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/UIBreak.svg")] + public partial class UIBreak:Control, UIHolderControl + { + UI ui; + + int _uiAncestorDepth; + + public void ComputeUIAncestorDepth() + { + SetUIAncestorDepth( NodesWalker.Get().GetAncestorDistance( this, GetUI( false ) ) ); + } + + public void SetUIAncestorDepth( int depth ) + { + _uiAncestorDepth = depth; + } + + public int GetUIAncestorDepth() + { + return _uiAncestorDepth; + } + + public override void _EnterTree() + { + ComputeUIAncestorDepth(); + } + + public override void _ExitTree() + { + ui = null; + _uiAncestorDepth = -1; + } + + public void SetUI( UI ui,bool computeDepth = true ) + { + this.ui = ui; + + if ( computeDepth ) + { + ComputeUIAncestorDepth(); + } + } + + public UI GetUI( bool computeDepth = true ) + { + if ( this.ui != null ) + { + return this.ui; + } + + var ui = this.FindParentThatIs(); + + if ( ui == null ) + { + _uiAncestorDepth = -1; + // this.LogInfo( "No UI in parents >", HierarchyName.Of( this ) ); + + return null; + } + + if ( computeDepth ) + { + ComputeUIAncestorDepth(); + } + + return ui; + } + + public void Update() + { + var ui = GetUI(); + + if ( ! ui.fontSizeChanged ) + { + return; + } + + + var currentFontSize = UIStyle.GetCurrentFontSize( this ); + Size = new Vector2( 0, currentFontSize ); + + this.LogInfo( "Updating Break", currentFontSize ); + } + } +} \ No newline at end of file diff --git a/Runtime/UI/Nodes/UIBreak.cs.uid b/Runtime/UI/Nodes/UIBreak.cs.uid new file mode 100644 index 0000000..58f832c --- /dev/null +++ b/Runtime/UI/Nodes/UIBreak.cs.uid @@ -0,0 +1 @@ +uid://b4yhlfad24pvh diff --git a/Runtime/UI/Nodes/UIImage.cs b/Runtime/UI/Nodes/UIImage.cs index 6e83ec6..aa1abf2 100644 --- a/Runtime/UI/Nodes/UIImage.cs +++ b/Runtime/UI/Nodes/UIImage.cs @@ -10,7 +10,7 @@ namespace Rokojori [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/UIImage.svg")] public partial class UIImage:TextureRect, UIStylePropertyContainerNode, UIHolderControl, IAssemblyReload { - UIImageType _imageType; + protected UIImageType _imageType; [Export] public UIImageType imageType { @@ -73,7 +73,7 @@ namespace Rokojori return ui; } - void UpdateImageType() + protected void UpdateImageType() { ResetImageType(); @@ -113,6 +113,7 @@ namespace Rokojori public override void _ExitTree() { + ui = null; _uiAncestorDepth = -1; } @@ -412,6 +413,15 @@ namespace Rokojori return UILayout.___; } + [ExportGroup( "Pointer" )] + [Export] + public UICursor hoverCursor; + + public UICursor GetHoverCursor( UIStylePropertyContainer container ) + { + return hoverCursor; + } + public ShaderUIColor[] GetShaderUIColors() { @@ -453,17 +463,29 @@ namespace Rokojori case UIStyleNumberProperty.ScaleY: return scaleY; } - if ( UIStyleNumberProperty.FloatShaderProperty == property ) + + if ( UIStyleNumberProperty.FloatShaderProperty != property ) { - var numberProperty = numberProperties.Find( n => n.floatPropertyName.propertyName == shaderPropertyName ); - - if ( numberProperty != null ) - { - return numberProperty.number; - } - + return null; } - + + if ( imageType != null ) + { + var uiNumber = imageType.GetUIStyleNumberProperty( property, shaderPropertyName ); + + if ( uiNumber != null ) + { + return uiNumber; + } + } + + var numberProperty = numberProperties.Find( n => n.floatPropertyName.propertyName == shaderPropertyName ); + + if ( numberProperty != null ) + { + return numberProperty.number; + } + return null; } @@ -558,6 +580,7 @@ namespace Rokojori return; } + ui.settings.sizePropertyName.Set( Material, Size ); var colorProperties = imageType != null ? imageType.GetColorShaderProperties() : []; @@ -575,13 +598,27 @@ namespace Rokojori foreach ( var n in numberProperties ) { - var value = UINumber.Compute( this, UIStyleNumberProperty.FloatShaderProperty, n ); + var relative = 100f; + + if ( n.EndsWith( ".x" ) ) + { + relative = w; + } + else if ( n.EndsWith( ".y" ) ) + { + relative = h; + } + + + var value = UINumber.Compute( this, UIStyleNumberProperty.FloatShaderProperty, n, 0, relative ); numberPropertyName.propertyName = n; numberPropertyName.Set( Material, value ); } } + + public UIColor GetUIStyleColorProperty( UIStyleColorProperty property, string shaderPropertyName, UIStylePropertyContainer source ) { if ( property != UIStyleColorProperty.ColorShaderProperty ) diff --git a/Runtime/UI/Nodes/UIImageTypes/RoundedRectangleUIImageType.cs b/Runtime/UI/Nodes/UIImageTypes/RoundedRectangleUIImageType.cs index 8840e06..1ca2cfb 100644 --- a/Runtime/UI/Nodes/UIImageTypes/RoundedRectangleUIImageType.cs +++ b/Runtime/UI/Nodes/UIImageTypes/RoundedRectangleUIImageType.cs @@ -111,6 +111,21 @@ namespace Rokojori return null; } + public override UINumber GetUIStyleNumberProperty( UIStyleNumberProperty property, string shaderPropertyName ) + { + if ( RoundedRectangleShader.borderRadius.propertyName == shaderPropertyName ) + { + return borderRadius; + } + + if ( RoundedRectangleShader.offset.propertyName == shaderPropertyName ) + { + return offset; + } + + return null; + } + protected override void _Assign( UIImage image ) { if ( _materials.ContainsKey( image ) ) diff --git a/Runtime/UI/Nodes/UIImageTypes/SliderUIImageType.cs b/Runtime/UI/Nodes/UIImageTypes/SliderUIImageType.cs new file mode 100644 index 0000000..29ec7f4 --- /dev/null +++ b/Runtime/UI/Nodes/UIImageTypes/SliderUIImageType.cs @@ -0,0 +1,255 @@ + +using Godot; +using Rokojori; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/UIImage.svg")] + public partial class SliderUIImageType:UIImageType + { + Dictionary _materials = new Dictionary(); + + static readonly string[] colorProperties = [ + SliderShader.fillColor.propertyName, + SliderShader.strokeColor.propertyName, + SliderShader.sliderFillColor.propertyName, + SliderShader.sliderStrokeColor.propertyName, + ]; + + public override string[] GetColorShaderProperties() + { + return colorProperties; + } + + static readonly string[] numberProperties = [ + SliderShader.borderRadius.propertyName, + SliderShader.strokeSize.propertyName, + SliderShader.offset.propertyName, + SliderShader.sliderStrokeSize.propertyName, + SliderShader.sliderSize.propertyName + ".x", + SliderShader.sliderSize.propertyName + ".y", + SliderShader.sliderBorders.propertyName + ]; + + public override string[] GetNumberShaderProperties() + { + return numberProperties; + } + + UIColor _fillColor; + [Export] + public UIColor fillColor + { + get => _fillColor; + set { _fillColor = value; onChange.DispatchEvent( null ); } + } + + UIColor _strokeColor; + [Export] + public UIColor strokeColor + { + get => _strokeColor; + set { _strokeColor = value; onChange.DispatchEvent( null ); } + } + + UINumber _borderRadius; + [Export] + public UINumber borderRadius + { + get => _borderRadius; + set { _borderRadius = value; onChange.DispatchEvent( null ); } + } + + UINumber _strokeSize; + [Export] + public UINumber strokeSize + { + get => _strokeSize; + set { _strokeSize = value; onChange.DispatchEvent( null ); } + } + + UINumber _offset; + [Export] + public UINumber offset + { + get => _offset; + set { _offset = value; onChange.DispatchEvent( null ); } + } + + UINumber _sliderSizeX; + [Export] + public UINumber sliderSizeX + { + get => _sliderSizeX; + set { _sliderSizeX = value; onChange.DispatchEvent( null ); } + } + + UINumber _sliderSizeY; + [Export] + public UINumber sliderSizeY + { + get => _sliderSizeY; + set { _sliderSizeY = value; onChange.DispatchEvent( null ); } + } + + UINumber _sliderBorderRadius; + [Export] + public UINumber sliderBorderRadius + { + get => _sliderBorderRadius; + set { _sliderBorderRadius = value; onChange.DispatchEvent( null ); } + } + + UIColor _sliderFillColor; + [Export] + public UIColor sliderFillColor + { + get => _sliderFillColor; + set { _sliderFillColor = value; onChange.DispatchEvent( null ); } + } + + UIColor _sliderStrokeColor; + [Export] + public UIColor sliderStrokeColor + { + get => _sliderStrokeColor; + set { _sliderStrokeColor = value; onChange.DispatchEvent( null ); } + } + + UINumber _sliderStrokeSize; + [Export] + public UINumber sliderStrokeSize + { + get => _sliderStrokeSize; + set { _sliderStrokeSize = value; onChange.DispatchEvent( null ); } + } + + public override UIColor GetUIStyleColorProperty( UIStyleColorProperty property, string shaderPropertyName ) + { + if ( SliderShader.fillColor.propertyName == shaderPropertyName ) + { + return fillColor; + } + + if ( SliderShader.strokeColor.propertyName == shaderPropertyName ) + { + return strokeColor; + } + + if ( SliderShader.sliderFillColor.propertyName == shaderPropertyName ) + { + return sliderFillColor; + } + + if ( SliderShader.sliderStrokeColor.propertyName == shaderPropertyName ) + { + return sliderStrokeColor; + } + + return null; + } + + public override UINumber GetUIStyleNumberProperty( UIStyleNumberProperty property, string shaderPropertyName ) + { + if ( SliderShader.borderRadius.propertyName == shaderPropertyName ) + { + return borderRadius; + } + + if ( SliderShader.offset.propertyName == shaderPropertyName ) + { + return offset; + } + + if ( SliderShader.sliderSize.propertyName + ".x" == shaderPropertyName ) + { + return sliderSizeX; + } + + if ( SliderShader.sliderSize.propertyName + ".y" == shaderPropertyName ) + { + return sliderSizeY; + } + + if ( SliderShader.sliderStrokeSize.propertyName == shaderPropertyName ) + { + return sliderStrokeSize; + } + + if ( SliderShader.sliderBorders.propertyName == shaderPropertyName ) + { + return sliderBorderRadius; + } + + + + return null; + } + + protected override void _Assign( UIImage image ) + { + if ( _materials.ContainsKey( image ) ) + { + this.LogInfo( "Has Image in cached materials", HierarchyName.Of( image ) ); + + if ( image.Material == null ) + { + this.LogInfo( "Material was null, assigned Image from cached materials" ); + image.Material = _materials[ image ]; + } + else + { + this.LogInfo( "Did not assigned material, already exists" ); + } + + return; + } + else + { + this.LogInfo( "Image had no material and was not cached, caching & creating material", HierarchyName.Of( image ) ); + } + + _materials[ image ] = new SliderMaterial(); + + image.Material = _materials[ image ]; + + } + + protected override void _Clear( UIImage image ) + { + if ( image != null && _materials.ContainsKey( image ) && image.Material == _materials[ image ] ) + { + image.Material = null; + } + + _materials.Remove( image ); + + } + + protected override void _Sync( UIImage image ) + { + // if ( image ) + } + + protected override void _ApplyChange( UIImage image ) + { + var material = _materials[ image ]; + + // AssignColor( image, material.fillColor, _fillColor ); + // // image.CopyColorShaderPropertyFrom( material.fillColor, GetUIColor( _fillColor, image, material.fillColor.propertyName ) ); + // AssignColor( image, material.strokeColor, _strokeColor ); + + + // image.CopyNumberShaderPropertyFrom( material.borderRadius, _borderRadius, _borderRadiusTransition ); + // image.CopyNumberShaderPropertyFrom( material.strokeSize, _strokeSize, _strokeSizeTransition ); + // image.CopyNumberShaderPropertyFrom( material.offset, _offset, _offsetTransition ); + } + + + + + + } +} \ No newline at end of file diff --git a/Runtime/UI/Nodes/UIImageTypes/SliderUIImageType.cs.uid b/Runtime/UI/Nodes/UIImageTypes/SliderUIImageType.cs.uid new file mode 100644 index 0000000..38c5fce --- /dev/null +++ b/Runtime/UI/Nodes/UIImageTypes/SliderUIImageType.cs.uid @@ -0,0 +1 @@ +uid://cwcm7eu486tr4 diff --git a/Runtime/UI/Nodes/UIImageTypes/UIImageType.cs b/Runtime/UI/Nodes/UIImageTypes/UIImageType.cs index 49b5fea..ab9980f 100644 --- a/Runtime/UI/Nodes/UIImageTypes/UIImageType.cs +++ b/Runtime/UI/Nodes/UIImageTypes/UIImageType.cs @@ -8,7 +8,7 @@ namespace Rokojori { [Tool] [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/UIImage.svg")] - public partial class UIImageType:Resource + public abstract partial class UIImageType:Resource { public readonly EventSlot onChange = new EventSlot(); List _images = new List(); @@ -21,7 +21,11 @@ namespace Rokojori public void Assign( UIImage image ) { - _images.Add( image ); + if ( ! _images.Contains( image ) ) + { + _images.Add( image ); + } + _Assign( image ); _ApplyChange( image ); } @@ -32,6 +36,16 @@ namespace Rokojori _Clear( image ); } + public void Sync( UIImage image ) + { + _Sync( image ); + } + + protected virtual void _Sync( UIImage image ) + { + + } + public void ApplyChanges() { _images.ForEach( i => _ApplyChange( i ) ); @@ -42,6 +56,11 @@ namespace Rokojori return null; } + public virtual UINumber GetUIStyleNumberProperty( UIStyleNumberProperty property, string shaderPropertyName ) + { + return null; + } + protected virtual void _ApplyChange( UIImage image ) { diff --git a/Runtime/UI/Nodes/UIInputInfo.cs b/Runtime/UI/Nodes/UIInputInfo.cs index b26fd36..5045bed 100644 --- a/Runtime/UI/Nodes/UIInputInfo.cs +++ b/Runtime/UI/Nodes/UIInputInfo.cs @@ -10,7 +10,7 @@ namespace Rokojori [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/UIInputIcon.svg")] public partial class UIInputInfo: UIRegion { - InputIcon[] _inputIcons = new InputIcon[ 0 ]; + InputIcon[] _inputIcons = []; [Export] public InputIcon[] inputIcons diff --git a/Runtime/UI/Nodes/UIRegion.cs b/Runtime/UI/Nodes/UIRegion.cs index 132e7bb..59f474f 100644 --- a/Runtime/UI/Nodes/UIRegion.cs +++ b/Runtime/UI/Nodes/UIRegion.cs @@ -176,6 +176,11 @@ namespace Rokojori { return null; } + + public UICursor GetHoverCursor( UIStylePropertyContainer container ) + { + return null; + } public Font GetFont() { @@ -315,6 +320,7 @@ namespace Rokojori RemoveUISelectorFlag( UISelectorFlag.Hover, hoverID ); this.SetDirty(); }; + } int _uiAncestorDepth; @@ -341,6 +347,7 @@ namespace Rokojori public override void _ExitTree() { + ui = null; _uiAncestorDepth = -1; } diff --git a/Runtime/UI/Nodes/UIScrollContainer.cs b/Runtime/UI/Nodes/UIScrollContainer.cs new file mode 100644 index 0000000..2da30f9 --- /dev/null +++ b/Runtime/UI/Nodes/UIScrollContainer.cs @@ -0,0 +1,39 @@ + +using Godot; +using Rokojori; +using System.Collections.Generic; +using System.Linq; + +namespace Rokojori +{ + [Tool] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/UIRegion.svg")] + public partial class UIScrollContainer:UIRegion + { + [Export] + public Control horizontalSlider; + + [Export] + public Control verticalSlider; + + [Export] + public Control content; + + public override void _Ready() + { + + } + + bool _initialized = false; + + void Initialize() + { + if ( _initialized ) + { + return; + } + + + } + } +} \ No newline at end of file diff --git a/Runtime/UI/Nodes/UIScrollContainer.cs.uid b/Runtime/UI/Nodes/UIScrollContainer.cs.uid new file mode 100644 index 0000000..32b5443 --- /dev/null +++ b/Runtime/UI/Nodes/UIScrollContainer.cs.uid @@ -0,0 +1 @@ +uid://btmqvwluvjwo0 diff --git a/Runtime/UI/Nodes/UISlider.cs b/Runtime/UI/Nodes/UISlider.cs new file mode 100644 index 0000000..2e7269f --- /dev/null +++ b/Runtime/UI/Nodes/UISlider.cs @@ -0,0 +1,302 @@ + + + + +using Godot; +using Rokojori; +using System.Collections.Generic; +using System.Linq; + +namespace Rokojori +{ + [Tool] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/UIImage.svg")] + public partial class UISlider:UIImage + { + public enum Direction + { + Vertical, + Horizontal, + Both + } + + [Export] + public Direction direction = Direction.Vertical; + + [Export] + public Smoothing smoothing; + + Vector2 _sliderValue; + + [Export] + public Vector2 sliderValue + { + get { return _sliderValue; } + set + { + _sliderValue = value; + SyncSliderValue(); + } + } + + void SyncSliderValue() + { + SliderShader.sliderValue.Set( Material, sliderValue ); + } + + public override void _Ready() + { + base._Ready(); + + if ( imageType == null ) + { + imageType = new SliderUIImageType(); + } + + if ( Texture == null ) + { + Texture = UI.whiteTexture.Get(); + } + + var uiSliderImageType = _imageType as SliderUIImageType; + + if ( uiSliderImageType != null ) + { + uiSliderImageType.Clear( this ); + uiSliderImageType.Assign( this ); + + } + + ComputeUIAncestorDepth(); + + SyncSliderValue(); + + + AssignListener(); + } + + [Export] + public bool debugInfo = false; + + [Export] + public string[] propertyInfos = []; + + public override void _Process( double delta ) + { + if ( ! debugInfo ) + { + return; + } + + var it = imageType as SliderUIImageType; + + if ( it == null ) + { + return; + } + + var propNames = it.GetNumberShaderProperties(); + + var tw = Texture.GetWidth(); + var th = Texture.GetHeight(); + + var w = UINumber.Compute( this, UIStyleNumberProperty.Width, tw, tw / 100f ); + var h = UINumber.Compute( this, UIStyleNumberProperty.Height, th, th / 100f ); + + var infos = new List(); + for ( int i = 0; i < propNames.Length; i++ ) + { + var n = propNames[ i ]; + var p = it.GetUIStyleNumberProperty( UIStyleNumberProperty.FloatShaderProperty, n ); + + if ( p == null ) + { + continue; + } + + var relative = 100f; + + if ( n.EndsWith( ".x" ) ) + { + relative = w; + } + else if ( n.EndsWith( ".y" ) ) + { + relative = h; + } + + + var value = UINumber.Compute( this, UIStyleNumberProperty.FloatShaderProperty, n, 0, relative ); + infos.Add( "[" + n + "] (" + p.value._FFF() + " * " + p.unit +") :" + value._FFF() ); + } + + propertyInfos = infos.ToArray(); + + this.LogInfo( propertyInfos ); + + + debugInfo = false; + + } + + + + UIDragging.UIDraggingCallbacks leftMouseCallbacks; + Vector2 cachedMouseOffset; + Vector2 cachedButtonPosition; + + bool _dragging = false; + bool _updatingPosition = false; + + string scrollID = IDGenerator.GenerateID(); + + float ComputeShaderProperty( string n, float relative = 100 ) + { + return UINumber.Compute( this, UIStyleNumberProperty.FloatShaderProperty, n, 0, relative ); + } + + Vector2 sliderSize + { + get + { + var tw = Texture.GetWidth(); + var th = Texture.GetHeight(); + + var w = UINumber.Compute( this, UIStyleNumberProperty.Width, tw, tw / 100f ); + var h = UINumber.Compute( this, UIStyleNumberProperty.Height, th, th / 100f ); + + var valueX = ComputeShaderProperty( SliderShader.sliderSize.propertyNameX, w ); + var valueY = ComputeShaderProperty( SliderShader.sliderSize.propertyNameY, h ); + + return new Vector2( valueX, valueY ); + } + } + + Vector2 sliderSizeMargins + { + get + { + var tw = Texture.GetWidth(); + var th = Texture.GetHeight(); + + var w = UINumber.Compute( this, UIStyleNumberProperty.Width, tw, tw / 100f ); + var h = UINumber.Compute( this, UIStyleNumberProperty.Height, th, th / 100f ); + + var valueX = ComputeShaderProperty( SliderShader.sliderSizeMargins.propertyNameX, w ); + var valueY = ComputeShaderProperty( SliderShader.sliderSizeMargins.propertyNameY, h ); + + return new Vector2( valueX, valueY ); + } + } + + Vector2 sliderRange => Size - ( sliderSize + sliderSizeMargins ); + Vector2 sliderOffset => sliderSize; + + Vector2 buttonPositionMin + { + get { return NormalizedToButtonPosition( Vector2.Zero ); } + } + + Vector2 buttonPositionMax + { + get { return NormalizedToButtonPosition( Vector2.One ); } + } + + + Vector2 NormalizedToButtonPosition( Vector2 normalized ) + { + return normalized * sliderRange + sliderOffset; + } + + Vector2 ButtonPositionToNormalized( Vector2 buttonPosition ) + { + return ( buttonPosition - sliderOffset ) / sliderRange; + } + + + bool _listenerAssigned = false; + + void AssignListener() + { + if ( _listenerAssigned ) + { + return; + } + + leftMouseCallbacks = UIDragging.OnLeftMouseButton( this, + ( ev )=> + { + if ( ev.isStart ) + { + cachedButtonPosition = NormalizedToButtonPosition( sliderValue ); + smoothing.SetCurrent( cachedButtonPosition ); + + _dragging = true; + _updatingPosition = true; + + ev.ui.onProcess.AddAction( UpdatePosition ); + } + else if ( ev.isEnd ) + { + _dragging = false; + } + + var nextPosition = cachedButtonPosition + ev.distanceToStart; + nextValue = nextPosition.Clamp( buttonPositionMin, buttonPositionMax ); + + } + ); + + _listenerAssigned = true; + } + + Vector2 nextValue; + + Vector2 GetButtonScrollRange() + { + return Vector2.Zero; + // return ( Size - button.Size ).Max( Vector2.Zero ); + } + + Vector2 cachedOffset = Vector2.Zero; + + void UpdatePosition( float delta ) + { + // this.LogInfo( "UpdatePosition" ); + var value = Smoothing.Apply( smoothing, nextValue, delta ); + + var uiStyleContainer = ( UIStylePropertyContainerNode ) this; + + uiStyleContainer.SetLayoutDirtyFlag(); + + if ( ! _dragging && ( value - nextValue ).Length() < 1 ) + { + var ui = UIHolder.GetUI( this ); + ui.onProcess.RemoveAction( UpdatePosition ); + _updatingPosition = false; + // this.LogInfo( "Removed Processing" ); + + value = nextValue; + + uiStyleContainer.RemoveUISelectorFlag( UISelectorFlag.Scrolling, scrollID ); + + } + + var currentSliderValue = ButtonPositionToNormalized( value ); + + if ( Direction.Vertical == direction ) + { + currentSliderValue.X = 0.5f; + } + else if ( Direction.Vertical == direction ) + { + currentSliderValue.Y = 0.5f; + } + + _sliderValue = currentSliderValue; + SyncSliderValue(); + + } + + } +} \ No newline at end of file diff --git a/Runtime/UI/Nodes/UISlider.cs.uid b/Runtime/UI/Nodes/UISlider.cs.uid new file mode 100644 index 0000000..0952ffd --- /dev/null +++ b/Runtime/UI/Nodes/UISlider.cs.uid @@ -0,0 +1 @@ +uid://b70vvwlh501d5 diff --git a/Runtime/UI/Nodes/UISpace.cs b/Runtime/UI/Nodes/UISpace.cs new file mode 100644 index 0000000..ea40bbd --- /dev/null +++ b/Runtime/UI/Nodes/UISpace.cs @@ -0,0 +1,94 @@ + +using Godot; +using Rokojori; +using System.Collections.Generic; +using System.Linq; + +namespace Rokojori +{ + [Tool] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/UISpace.svg")] + public partial class UISpace:Control, UIHolderControl + { + UI ui; + + int _uiAncestorDepth; + + public void ComputeUIAncestorDepth() + { + SetUIAncestorDepth( NodesWalker.Get().GetAncestorDistance( this, GetUI( false ) ) ); + } + + public void SetUIAncestorDepth( int depth ) + { + _uiAncestorDepth = depth; + } + + public int GetUIAncestorDepth() + { + return _uiAncestorDepth; + } + + public override void _EnterTree() + { + ComputeUIAncestorDepth(); + } + + public override void _ExitTree() + { + ui = null; + _uiAncestorDepth = -1; + } + + public void SetUI( UI ui,bool computeDepth = true ) + { + this.ui = ui; + + if ( computeDepth ) + { + ComputeUIAncestorDepth(); + } + } + + public UI GetUI( bool computeDepth = true ) + { + if ( this.ui != null ) + { + return this.ui; + } + + var ui = this.FindParentThatIs(); + + if ( ui == null ) + { + _uiAncestorDepth = -1; + // this.LogInfo( "No UI in parents >", HierarchyName.Of( this ) ); + + return null; + } + + if ( computeDepth ) + { + ComputeUIAncestorDepth(); + } + + return ui; + } + + public void Update() + { + var ui = GetUI(); + + if ( ! ui.fontSizeChanged ) + { + return; + } + + var currentFontSize = UIStyle.GetCurrentFontSize( this ); + Size = new Vector2( currentFontSize * 0.29f, 0 ); + + // this.LogInfo( "Updating Space", currentFontSize ); + } + + } +} \ No newline at end of file diff --git a/Runtime/UI/Nodes/UISpace.cs.uid b/Runtime/UI/Nodes/UISpace.cs.uid new file mode 100644 index 0000000..c10dabc --- /dev/null +++ b/Runtime/UI/Nodes/UISpace.cs.uid @@ -0,0 +1 @@ +uid://b8lwwrdspkf1f diff --git a/Runtime/UI/Nodes/UIText.cs b/Runtime/UI/Nodes/UIText.cs index b39f657..2e22efa 100644 --- a/Runtime/UI/Nodes/UIText.cs +++ b/Runtime/UI/Nodes/UIText.cs @@ -172,6 +172,8 @@ namespace Rokojori string hoverID = IDGenerator.GenerateID(); + + UICursor appliedCursor = null; public override void _Ready() { @@ -179,13 +181,31 @@ namespace Rokojori { AddUISelectorFlag( UISelectorFlag.Hover, hoverID ); this.SetDirty(); + + var currentHoverCursor = UIStyle.ResolveHoverCursor( this ); + + if ( currentHoverCursor != null ) + { + currentHoverCursor.ApplyCursor( this ); + appliedCursor = currentHoverCursor; + this.LogInfo( "Set Cursor on Hover:", appliedCursor ); + // Input.SetDefaultCursorShape( hoverCursorShape ); + // MouseDefaultCursorShape = hoverCursorShape; + } }; MouseExited += ()=> { + RemoveUISelectorFlag( UISelectorFlag.Hover, hoverID ); - this.SetDirty(); + this.SetDirty(); + + if ( appliedCursor != null ) + { + this.LogInfo( "Reset Cursor on Exit"); + appliedCursor.ClearCursor( this ); + } }; } @@ -213,6 +233,7 @@ namespace Rokojori public override void _ExitTree() { + ui = null; _uiAncestorDepth = -1; } @@ -361,7 +382,17 @@ namespace Rokojori } } - [ExportGroup("Events")] + [ExportGroup("Pointer")] + + [Export] + public UICursor hoverCursor; + + public UICursor GetHoverCursor( UIStylePropertyContainer container ) + { + return hoverCursor; + } + + [Export] public bool handleMouseEvents = false; @@ -394,6 +425,7 @@ namespace Rokojori return UILayout.___; } + public ShaderUIColor[] GetShaderUIColors() { return null; @@ -703,7 +735,7 @@ namespace Rokojori return null; } - UI ui; + UI ui; public void SetUI( UI ui,bool computeDepth = true ) { diff --git a/Runtime/UI/Shaders/Slider/Slider.gdshader b/Runtime/UI/Shaders/Slider/Slider.gdshader new file mode 100644 index 0000000..6d5f972 --- /dev/null +++ b/Runtime/UI/Shaders/Slider/Slider.gdshader @@ -0,0 +1,134 @@ +shader_type canvas_item; + +#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Colors.gdshaderinc" +#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Math.gdshaderinc" +#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Transform.gdshaderinc" +#include "res://addons/rokojori_action_library/Runtime/Shading/Library/SDF.gdshaderinc" + +uniform float opacity:hint_range(0,1) = 1; +uniform bool blendLinear = false; +uniform vec2 size; + +group_uniforms Background; +uniform float sharpness = 5; +uniform float borderRadius = 5; +uniform float offset; +group_uniforms; + +group_uniforms BackgroundFill; +uniform vec4 fillColor:source_color; +uniform sampler2D fill; +uniform vec4 fillUVTransform; +uniform sampler2D screenFillMultiply; +uniform vec4 screenfillMultiplyUVTransform; +uniform vec2 screenfillMultiplyUVMovement; +group_uniforms; + +group_uniforms BackgroundStroke; +uniform float strokeSize = 5; +uniform vec4 strokeColor:source_color; +uniform sampler2D stroke; +uniform vec4 strokeUVTransform; +uniform sampler2D screenStrokeMultiply; +uniform vec4 screenStrokeMultiplyUVTransform; +uniform vec2 screenStrokeMultiplyUVMovment; +group_uniforms; + +group_uniforms Slider; +uniform vec2 sliderSize; +uniform vec2 sliderSizeMargins; +uniform float sliderBorders; +uniform vec2 sliderValue; +group_uniforms; + +group_uniforms SliderFill; +uniform vec4 sliderFillColor:source_color; +group_uniforms; + +group_uniforms SliderStroke; +uniform vec4 sliderStrokeColor:source_color; +uniform float sliderStrokeSize = 2; +group_uniforms; + + +vec4 createBorders( float borderSize, vec2 rectSize ) +{ + float minS = min( rectSize.x, rectSize.y ); + vec4 borders = vec4( min( minS, borderSize ) ); + // borders.xz = min( borders.xz, vec2( rectSize.x / 4.0 ) ); + // borders.yw = min( borders.yw, vec2( rectSize.y / 4.0 ) ); + + return borders; +} + +vec4 getSliderLayer( vec2 pixelPosition ) +{ + vec2 sliderValueRange = size - ( sliderSize + sliderSizeMargins ); + vec2 sliderValueOffset = ( sliderSize + sliderSizeMargins ) / 2.0; + vec2 sliderPosition = sliderValueOffset + sliderValueRange * sliderValue; + + + + vec4 borders = createBorders( sliderBorders, sliderSize ); + + float sd = sdRoundedBox( pixelPosition - sliderPosition, sliderSize / 2.0, borders ); + + // vec4 sliderLayer = sdf_coloredShape( sd, sliderStrokeSize, sliderFillColor, sliderStrokeColor ); + + vec2 sliderShape = sdf_shape( sd, sliderStrokeSize ); + vec4 sliderFill = fade( sliderFillColor, sliderShape.x ); + vec4 sliderStroke = fade( sliderStrokeColor, sliderShape.y ); + + vec4 sliderLayer = blendMode_alpha( sliderFill, sliderStroke ); + sliderLayer = sdf_coloredShape( sd, sliderStrokeSize, sliderFillColor, sliderStrokeColor ); + // float sliderMask = sdf_stroke( sdRoundedBox( pixelPosition - sliderPosition, sliderSize2, borders ) ); + // vec4 sliderLayer = vec4( _sliderColor.rgb, _sliderColor.a * sliderMask ); + + return sliderLayer; +} + +void fragment() +{ + // Fill + vec2 fillUV = tilingOffsetRepeat( UV, fillUVTransform ); + vec2 fillMoved = screenfillMultiplyUVMovement * TIME; + vec4 screenFillMovement = vec4( 0,0, fillMoved.x, fillMoved.y ); + vec2 screenFillMultiplyUV = tilingOffsetRepeat( SCREEN_UV, screenfillMultiplyUVTransform + screenFillMovement ); + vec4 combinedfillColor = fillColor * texture( fill, fillUV ) * texture( screenFillMultiply, screenFillMultiplyUV ); + + // Stroke + vec2 strokeUV = tilingOffsetRepeat( UV, strokeUVTransform ); + vec2 strokeMoved = screenStrokeMultiplyUVMovment * TIME; + vec4 screenstrokeMovement = vec4( 0,0, strokeMoved.x, strokeMoved.y ); + vec2 screenStrokeMultiplyUV = tilingOffsetRepeat( SCREEN_UV, screenStrokeMultiplyUVTransform + screenstrokeMovement ); + vec4 combinedStrokeColor = strokeColor * texture( stroke, strokeUV ) * texture( screenStrokeMultiply, screenStrokeMultiplyUV ); + + vec2 pixelPosition = size * UV; + + vec4 bgBorders = createBorders( borderRadius, size / 2.0 - vec2( offset ) ); + + float bgSD = sdRoundedBox( pixelPosition - size / 2.0, size / 2.0 - vec2( offset ), bgBorders ); + vec4 bgLayer = sdf_coloredShape( bgSD, strokeSize, combinedfillColor, combinedStrokeColor ); + + float sliderDistance = length( pixelPosition - sliderValue ); + vec4 sliderLayer = getSliderLayer( pixelPosition ); + + if ( blendLinear ) + { + bgLayer.rgb = SRGBtoLINEAR( bgLayer.rgb ); + sliderLayer.rgb = SRGBtoLINEAR( sliderLayer.rgb ); + } + + vec4 outputColor = blendMode_alpha( bgLayer, sliderLayer ); + + if ( blendLinear ) + { + outputColor.rgb = LINEARtoSRGB( outputColor.rgb ); + } + + vec4 tex = texture( TEXTURE, UV ); + + COLOR = vec4( outputColor.rgb * tex.rgb, outputColor.a * opacity * tex.a); + + +} diff --git a/Runtime/UI/Shaders/Slider/Slider.gdshader.uid b/Runtime/UI/Shaders/Slider/Slider.gdshader.uid new file mode 100644 index 0000000..11c6277 --- /dev/null +++ b/Runtime/UI/Shaders/Slider/Slider.gdshader.uid @@ -0,0 +1 @@ +uid://drifsskg885sj diff --git a/Runtime/UI/Shaders/Slider/SliderMaterial.cs b/Runtime/UI/Shaders/Slider/SliderMaterial.cs new file mode 100644 index 0000000..66cc63e --- /dev/null +++ b/Runtime/UI/Shaders/Slider/SliderMaterial.cs @@ -0,0 +1,108 @@ +using Godot; + +namespace Rokojori +{ + // Generated by ShaderClassGenerator + + public class SliderShader + { + public static readonly CachedResource shader = new CachedResource( + "res://addons/rokojori_action_library/Runtime/UI/Shaders/Slider/Slider.gdshader" + ); + + public static readonly FloatPropertyName opacity = FloatPropertyName.Create( "opacity" ); + public static readonly BoolPropertyName blendLinear = BoolPropertyName.Create( "blendLinear" ); + public static readonly Vector2PropertyName size = Vector2PropertyName.Create( "size" ); + public static readonly FloatPropertyName sharpness = FloatPropertyName.Create( "sharpness" ); + public static readonly FloatPropertyName borderRadius = FloatPropertyName.Create( "borderRadius" ); + public static readonly FloatPropertyName offset = FloatPropertyName.Create( "offset" ); + public static readonly ColorPropertyName fillColor = ColorPropertyName.Create( "fillColor" ); + public static readonly Texture2DPropertyName fill = Texture2DPropertyName.Create( "fill" ); + public static readonly Vector4PropertyName fillUvTransform = Vector4PropertyName.Create( "fillUVTransform" ); + public static readonly Texture2DPropertyName screenFillMultiply = Texture2DPropertyName.Create( "screenFillMultiply" ); + public static readonly Vector4PropertyName screenfillMultiplyUvTransform = Vector4PropertyName.Create( "screenfillMultiplyUVTransform" ); + public static readonly Vector2PropertyName screenfillMultiplyUvMovement = Vector2PropertyName.Create( "screenfillMultiplyUVMovement" ); + public static readonly FloatPropertyName strokeSize = FloatPropertyName.Create( "strokeSize" ); + public static readonly ColorPropertyName strokeColor = ColorPropertyName.Create( "strokeColor" ); + public static readonly Texture2DPropertyName stroke = Texture2DPropertyName.Create( "stroke" ); + public static readonly Vector4PropertyName strokeUvTransform = Vector4PropertyName.Create( "strokeUVTransform" ); + public static readonly Texture2DPropertyName screenStrokeMultiply = Texture2DPropertyName.Create( "screenStrokeMultiply" ); + public static readonly Vector4PropertyName screenStrokeMultiplyUvTransform = Vector4PropertyName.Create( "screenStrokeMultiplyUVTransform" ); + public static readonly Vector2PropertyName screenStrokeMultiplyUvMovment = Vector2PropertyName.Create( "screenStrokeMultiplyUVMovment" ); + public static readonly Vector2PropertyName sliderSize = Vector2PropertyName.Create( "sliderSize" ); + public static readonly Vector2PropertyName sliderSizeMargins = Vector2PropertyName.Create( "sliderSizeMargins" ); + public static readonly FloatPropertyName sliderBorders = FloatPropertyName.Create( "sliderBorders" ); + public static readonly Vector2PropertyName sliderValue = Vector2PropertyName.Create( "sliderValue" ); + public static readonly ColorPropertyName sliderFillColor = ColorPropertyName.Create( "sliderFillColor" ); + public static readonly ColorPropertyName sliderStrokeColor = ColorPropertyName.Create( "sliderStrokeColor" ); + public static readonly FloatPropertyName sliderStrokeSize = FloatPropertyName.Create( "sliderStrokeSize" ); + + } + + [Tool] + public partial class SliderMaterial:CustomMaterial + { + + + public readonly CustomMaterialProperty opacity; + public readonly CustomMaterialProperty blendLinear; + public readonly CustomMaterialProperty size; + public readonly CustomMaterialProperty sharpness; + public readonly CustomMaterialProperty borderRadius; + public readonly CustomMaterialProperty offset; + public readonly CustomMaterialProperty fillColor; + public readonly CustomMaterialProperty fill; + public readonly CustomMaterialProperty fillUvTransform; + public readonly CustomMaterialProperty screenFillMultiply; + public readonly CustomMaterialProperty screenfillMultiplyUvTransform; + public readonly CustomMaterialProperty screenfillMultiplyUvMovement; + public readonly CustomMaterialProperty strokeSize; + public readonly CustomMaterialProperty strokeColor; + public readonly CustomMaterialProperty stroke; + public readonly CustomMaterialProperty strokeUvTransform; + public readonly CustomMaterialProperty screenStrokeMultiply; + public readonly CustomMaterialProperty screenStrokeMultiplyUvTransform; + public readonly CustomMaterialProperty screenStrokeMultiplyUvMovment; + public readonly CustomMaterialProperty sliderSize; + public readonly CustomMaterialProperty sliderSizeMargins; + public readonly CustomMaterialProperty sliderBorders; + public readonly CustomMaterialProperty sliderValue; + public readonly CustomMaterialProperty sliderFillColor; + public readonly CustomMaterialProperty sliderStrokeColor; + public readonly CustomMaterialProperty sliderStrokeSize; + + public SliderMaterial() + { + Shader = SliderShader.shader.Get(); + + opacity = new CustomMaterialProperty( this, SliderShader.opacity ); + blendLinear = new CustomMaterialProperty( this, SliderShader.blendLinear ); + size = new CustomMaterialProperty( this, SliderShader.size ); + sharpness = new CustomMaterialProperty( this, SliderShader.sharpness ); + borderRadius = new CustomMaterialProperty( this, SliderShader.borderRadius ); + offset = new CustomMaterialProperty( this, SliderShader.offset ); + fillColor = new CustomMaterialProperty( this, SliderShader.fillColor ); + fill = new CustomMaterialProperty( this, SliderShader.fill ); + fillUvTransform = new CustomMaterialProperty( this, SliderShader.fillUvTransform ); + screenFillMultiply = new CustomMaterialProperty( this, SliderShader.screenFillMultiply ); + screenfillMultiplyUvTransform = new CustomMaterialProperty( this, SliderShader.screenfillMultiplyUvTransform ); + screenfillMultiplyUvMovement = new CustomMaterialProperty( this, SliderShader.screenfillMultiplyUvMovement ); + strokeSize = new CustomMaterialProperty( this, SliderShader.strokeSize ); + strokeColor = new CustomMaterialProperty( this, SliderShader.strokeColor ); + stroke = new CustomMaterialProperty( this, SliderShader.stroke ); + strokeUvTransform = new CustomMaterialProperty( this, SliderShader.strokeUvTransform ); + screenStrokeMultiply = new CustomMaterialProperty( this, SliderShader.screenStrokeMultiply ); + screenStrokeMultiplyUvTransform = new CustomMaterialProperty( this, SliderShader.screenStrokeMultiplyUvTransform ); + screenStrokeMultiplyUvMovment = new CustomMaterialProperty( this, SliderShader.screenStrokeMultiplyUvMovment ); + sliderSize = new CustomMaterialProperty( this, SliderShader.sliderSize ); + sliderSizeMargins = new CustomMaterialProperty( this, SliderShader.sliderSizeMargins ); + sliderBorders = new CustomMaterialProperty( this, SliderShader.sliderBorders ); + sliderValue = new CustomMaterialProperty( this, SliderShader.sliderValue ); + sliderFillColor = new CustomMaterialProperty( this, SliderShader.sliderFillColor ); + sliderStrokeColor = new CustomMaterialProperty( this, SliderShader.sliderStrokeColor ); + sliderStrokeSize = new CustomMaterialProperty( this, SliderShader.sliderStrokeSize ); + } + + } + +} \ No newline at end of file diff --git a/Runtime/UI/Shaders/Slider/SliderMaterial.cs.uid b/Runtime/UI/Shaders/Slider/SliderMaterial.cs.uid new file mode 100644 index 0000000..33b5f5c --- /dev/null +++ b/Runtime/UI/Shaders/Slider/SliderMaterial.cs.uid @@ -0,0 +1 @@ +uid://1pymvcckklic diff --git a/Runtime/UI/Styling/UICursor.cs b/Runtime/UI/Styling/UICursor.cs new file mode 100644 index 0000000..7316b1e --- /dev/null +++ b/Runtime/UI/Styling/UICursor.cs @@ -0,0 +1,24 @@ + +using Godot; +using Rokojori; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class UICursor : Resource + { + [Export] + public Control.CursorShape cursorShape = Control.CursorShape.PointingHand; + + public void ApplyCursor( Control control ) + { + control.MouseDefaultCursorShape = cursorShape; + } + + public void ClearCursor( Control control ) + { + control.MouseDefaultCursorShape = Control.CursorShape.Arrow; + } + } +} \ No newline at end of file diff --git a/Runtime/UI/Styling/UICursor.cs.uid b/Runtime/UI/Styling/UICursor.cs.uid new file mode 100644 index 0000000..e1b417a --- /dev/null +++ b/Runtime/UI/Styling/UICursor.cs.uid @@ -0,0 +1 @@ +uid://cdsqunj017b7y diff --git a/Runtime/UI/Styling/UINumber.cs b/Runtime/UI/Styling/UINumber.cs index 209ad72..cf5c434 100644 --- a/Runtime/UI/Styling/UINumber.cs +++ b/Runtime/UI/Styling/UINumber.cs @@ -179,6 +179,8 @@ namespace Rokojori return Compute( control, property, "", alternative, relative ); } + + public static float Compute( Control control, UIStyleNumberProperty property, string shaderPropertyName = "", float alternative = 0, float relative = 100 ) { var container = control as UIStylePropertyContainerNode; @@ -292,7 +294,7 @@ namespace Rokojori static ActiveStyleTransition EnsureTransitionObject( ActiveStyleTransition propertyTransition, - Control control, UINumber uiNUmber, UIStyleNumberProperty property, string shaderPropertyName ) + Control control, UINumber uiNumber, UIStyleNumberProperty property, string shaderPropertyName ) { if ( propertyTransition != null ) @@ -305,8 +307,8 @@ namespace Rokojori propertyTransition.propertyType = UIStyleNumberPropertyAndName.Create( property, shaderPropertyName ); var transitionSettings = UIStyle.GetTransitionSettings( container, property, shaderPropertyName ); - propertyTransition.value = uiNUmber; - propertyTransition.timeLine = UI.GetTimeLine( control, transitionSettings.timeLine ); + propertyTransition.value = uiNumber; + propertyTransition.timeLine = UI.GetTimeLine( control, transitionSettings == null ? null : transitionSettings.timeLine ); propertyTransition.transitioning = false; container.GetActiveUINumberTransitions().Add( propertyTransition ); @@ -416,7 +418,113 @@ namespace Rokojori { return cachedExpressions.FindIndex( c => c.Matches( number, inputs ) ); } - + + static float ComputeBaseValue( Control control, UINumber number, float width, float height, float relative, string numberUnit = null ) + { + if ( number == null && numberUnit == null ) + { + return 1; + } + + var unit = numberUnit != null ? numberUnit : number.unit; + + switch ( unit ) + { + case "em": + { + return em( control ); + } + + case "vw": + { + return width / 100f; + } + + case "vh": + { + return height / 100f; + } + + case "pw": + { + var parent = control.GetParent() as Control; + var rawValue = parent == null ? width : parent.Size.X; + var margins = + UINumber.Compute( parent, UIStyleNumberProperty.Margin, 0 ) * 2 + + UINumber.Compute( parent, UIStyleNumberProperty.MarginLeft, 0 ) + + UINumber.Compute( parent, UIStyleNumberProperty.MarginRight, 0 ); + + return ( rawValue - margins ) / 100f; + + } + + case "ph": + { + var parent = control.GetParent() as Control; + var rawValue = parent == null ? height : parent.Size.Y; + var margins = + UINumber.Compute( parent, UIStyleNumberProperty.Margin, 0 ) * 2 + + UINumber.Compute( parent, UIStyleNumberProperty.MarginTop, 0 ) + + UINumber.Compute( parent, UIStyleNumberProperty.MarginBottom, 0 ); + + return ( rawValue - margins ) / 100f; + } + + case "cw": + { + var parent = control.GetParent() as Control; + return ( parent == null ? width : UILayouting.GetContentSize( parent ).X ) / 100f; + } + + case "ch": + { + var parent = control.GetParent() as Control; + return ( parent == null ? height : UILayouting.GetContentSize( parent ).Y ) / 100f; + } + + case "cx": + { + var parent = control.GetParent() as Control; + return ( parent == null ? 0 : UILayouting.GetContentOffset( parent ).X ) / 100f; + } + + case "cy": + { + var parent = control.GetParent() as Control; + return ( parent == null ? 0 : UILayouting.GetContentOffset( parent ).Y ) / 100f; + } + + case "uiw": + { + return uiw( control ) / 100f; + } + + case "uih": + { + return uih( control ) / 100f; + } + + case "%":case "relative": + { + return relative / 100f; + } + + case "px": + { + return 1; + } + + case "value": + { + return number.value; + } + + + } + + return 1f; + } + static float ComputeFormulaValue( Control control, UINumber number, float width, float height, float relative ) { if ( number == null ) @@ -424,84 +532,12 @@ namespace Rokojori return 0; } - switch ( number.unit ) + + if ( number.unit.Length <= 3 && ( number.unit == "%" || number.unit == "px" || _variables.Contains( number.unit ) ) ) { - case "em": - { - return number.value * em( control ); - } - - case "vw": - { - return number.value * width / 100f; - } - - case "vh": - { - return number.value * height / 100f; - } - - case "pw": - { - var parent = control.GetParent() as Control; - return number.value / 100f * ( parent == null ? width : parent.Size.X ); - } - - case "ph": - { - var parent = control.GetParent() as Control; - return number.value / 100f * ( parent == null ? height : parent.Size.Y ); - } - - case "cw": - { - var parent = control.GetParent() as Control; - return number.value / 100f * ( parent == null ? width : UILayouting.GetContentSize( parent ).X ); - } - - case "ch": - { - var parent = control.GetParent() as Control; - return number.value / 100f * ( parent == null ? height : UILayouting.GetContentSize( parent ).Y ); - } - - case "cx": - { - var parent = control.GetParent() as Control; - return number.value / 100f * ( parent == null ? 0 : UILayouting.GetContentOffset( parent ).X ); - } - - case "cy": - { - var parent = control.GetParent() as Control; - return number.value / 100f * ( parent == null ? 0 : UILayouting.GetContentOffset( parent ).Y ); - } - - case "uiw": - { - return number.value * uiw( control ); - } - - case "uih": - { - return number.value * uih( control ); - } - - - - - case "": - { - return number.value; - } - - case "%": - { - return number.value * relative / 100f; - } + return number.value * ComputeBaseValue( control, number, width, height, relative ); } - var parentControl = control.GetParent() as Control;; var inputs = GetInputs( control, number, parentControl, width, height, relative ); @@ -572,33 +608,12 @@ namespace Rokojori { var inputs = new Godot.Collections.Array(); - // em - inputs.Add( em( control ) ); - - // vw, vh - inputs.Add( width / 100f ); inputs.Add( height / 100f ); - - // pw, ph - inputs.Add( ( parentControl == null ? width : parentControl.Size.X ) / 100f ); - inputs.Add( ( parentControl == null ? height : parentControl.Size.Y ) / 100f ); - - // cw, ch - inputs.Add( ( parentControl == null ? width : UILayouting.GetContentSize( parentControl ).X ) / 100f ); - inputs.Add( ( parentControl == null ? height : UILayouting.GetContentSize( parentControl ).Y ) / 100f ); - - // cx, cy - inputs.Add( ( parentControl == null ? 0 : UILayouting.GetContentOffset( parentControl ).X ) / 100f ); - inputs.Add( ( parentControl == null ? 0 : UILayouting.GetContentOffset( parentControl ).Y ) / 100f ); - - // uiw, uih - inputs.Add( uiw( control ) ); - inputs.Add( uih( control ) ); - - // "relative" - inputs.Add( relative / 100f ); - - // value - inputs.Add( number.value ); + _variables.ForEach( + ( variableUnit )=> + { + inputs.Add( ComputeBaseValue( control, number, width, height, relative, variableUnit ) ); + } + ); return inputs; } diff --git a/Runtime/UI/Styling/UIStyle.cs b/Runtime/UI/Styling/UIStyle.cs index bd82077..f0008e2 100644 --- a/Runtime/UI/Styling/UIStyle.cs +++ b/Runtime/UI/Styling/UIStyle.cs @@ -161,6 +161,60 @@ namespace Rokojori } + [ExportGroup("Pointer")] + [Export] + public UICursor hoverCursor; + + // public UICursor GetOwnUICursor( Control control ) + // { + // if ( ) + // } + + public UICursor GetHoverCursor( UIStylePropertyContainer container ) + { + for ( int i = 0; i < selectorStyles.Length; i++ ) + { + if ( selectorStyles[ i ] == null || selectorStyles[ i ].style == null ) + { + continue; + } + + if ( selectorStyles[ i ].selector == null || selectorStyles[ i ].selector.Selects( container ) ) + { + var uiCursor = selectorStyles[ i ].style.GetHoverCursor( container ); + + if ( uiCursor != null ) + { + return uiCursor; + } + } + } + + return hoverCursor; + } + + + public static UICursor ResolveHoverCursor( Control control ) + { + var container = control as UIStylePropertyContainer; + + var ownCursor = container.GetHoverCursor( container ); + + if ( ownCursor != null ) + { + return ownCursor; + } + + var parentStyle = container.GetUIStyleParent(); + + if ( parentStyle == null ) + { + return null; + } + + return parentStyle.GetHoverCursor( container ); + } + public UIStyle GetUIStyleParent() { return parentStyle; @@ -446,6 +500,11 @@ namespace Rokojori static UINumberTransition _GetTransition( bool inheritable, UIStylePropertyContainer container, UIStyleNumberProperty property, string shaderPropertyName ) { + if ( container == null ) + { + return null; + } + var transitions = container.GetNumberTransitions(); var index = transitions == null ? -1 : Arrays.FindIndex( transitions, t => t != null && t.property == property ); @@ -498,6 +557,11 @@ namespace Rokojori public static TransitionSettingsAll GetTransitionSettingsAll( UIStylePropertyContainer container ) { + if ( container == null ) + { + return null; + } + var settings = container.GetTransitionSettingsAll(); if ( settings != null ) @@ -670,6 +734,42 @@ namespace Rokojori } + public static float GetCurrentFontSize( Control n ) + { + if ( n == null ) + { + return 12; + } + + var ui = UIHolder.GetUI( n ); + + if ( ui == null ) + { + return 12; + } + + var container = n as UIStylePropertyContainer; + + if ( container == null ) + { + container = UIStylePropertyContainer.FindInParents( n ); + } + + if ( container == null ) + { + return ui.X_computedFontSizePixels; + } + + // RJLog.Log( "Computing font size from:", HierarchyName.Of( container as Node ) ); + // debugInheritable = true; + var size = UINumber.Compute( container as Control, UIStyleNumberProperty.FontSize, 0, 100 ); + + // RJLog.Log( "Computed font size:", size ); + // debugInheritable = false; + return size; + } + + // static bool debugInheritable = false; public static UINumber GetInheritableNumberProperty( UIStylePropertyContainer container, UIStyleNumberProperty property, string shaderPropertyName, UIStylePropertyContainer source ) @@ -702,9 +802,33 @@ namespace Rokojori var control = container as Control; UINumber parentNumber = null; + // if ( debugInheritable ) + // { + // RJLog.Log( "Searching inheritable:", property, HierarchyName.Of( container as Node ) ); + // } + + NodesWalker.Get().GetInParents( control, it => { + // if ( debugInheritable && UIStyleNumberProperty.FontSize == property ) + // { + // RJLog.Log( "Searching inheritable:", property, HierarchyName.Of( it ) ); + // } + + if ( it is UI ui ) + { + var uiNumber = ui.GetUINumber( property ); + + if ( uiNumber != null ) + { + parentNumber = uiNumber; + // RJLog.Log( "Found ui number in UI:", uiNumber ); + + return true; + } + } + if ( ! ( it is UIStylePropertyContainer ) ) { return false; @@ -716,7 +840,7 @@ namespace Rokojori return parentNumber != null; } ); - + return parentNumber; } diff --git a/Runtime/UI/Styling/UIStylePropertyContainer.cs b/Runtime/UI/Styling/UIStylePropertyContainer.cs index c0eafda..7f2fad2 100644 --- a/Runtime/UI/Styling/UIStylePropertyContainer.cs +++ b/Runtime/UI/Styling/UIStylePropertyContainer.cs @@ -12,6 +12,8 @@ namespace Rokojori UIPosition GetUIPosition(); UILayout GetUILayout(); UILineWrap GetUILineWrap(); + UICursor GetHoverCursor( UIStylePropertyContainer container ); + Vector2 GetUISize(); @@ -40,6 +42,10 @@ namespace Rokojori void AddUISelectorFlag( UISelectorFlag flag, string reference = "" ); void RemoveUISelectorFlag( UISelectorFlag flag, string reference = "" ); + public static UIStylePropertyContainer FindInParents( Node n ) + { + return Nodes.FindInParents( n ); + } } public interface UIStylePropertyContainerNode:UIStylePropertyContainer diff --git a/Runtime/UI/UI-Settings-Default.tres b/Runtime/UI/UI-Settings-Default.tres index 540ead5..bf70d92 100644 --- a/Runtime/UI/UI-Settings-Default.tres +++ b/Runtime/UI/UI-Settings-Default.tres @@ -10,7 +10,7 @@ [sub_resource type="Resource" id="Resource_wm644"] script = ExtResource("3_xon8j") -value = 1.5 +value = 1.0 unit = "vw" isAnimated = false animationDuration = 0.0 diff --git a/Runtime/UI/UI.cs b/Runtime/UI/UI.cs index 5c14292..ba07d81 100644 --- a/Runtime/UI/UI.cs +++ b/Runtime/UI/UI.cs @@ -11,6 +11,14 @@ namespace Rokojori public partial class UI : Control, IDisposable { + public static readonly CachedResource whiteTexture = new CachedResource( + "res://addons/rokojori_action_library/Assets/Textures/white.svg" + ); + + public static readonly CachedResource blackTexture = new CachedResource( + "res://addons/rokojori_action_library/Assets/Textures/black.svg" + ); + [Export] public UISettings settings; @@ -29,6 +37,9 @@ namespace Rokojori [Export] public bool useParentSize = false; + [Export] + public Vector2 uiSize = Vector2.Zero; + [ExportGroup("Functions")] [ExportToolButton( "Mouse:Stop => Pass")] public Callable StopToPassButton => Callable.From( ()=>{ MakeStopToPass(); } ); @@ -58,6 +69,21 @@ namespace Rokojori public string[] customDisposerIDs = []; + public UINumber GetUINumber( UIStyleNumberProperty property ) + { + if ( UIStyleNumberProperty.FontSize == property ) + { + var uiNumber = new UINumber(); + uiNumber.value = X_computedFontSizePixels; + uiNumber.unit = "px"; + + // this.LogInfo( "Font Size:", uiNumber.value, uiNumber.unit ); + return uiNumber; + } + + return null; + } + public void MakeStopToPass() { var roots = stopToPassRoots; @@ -154,10 +180,13 @@ namespace Rokojori public bool sizeChanged => _resizeFlag; public bool fontSizeChanged => _fontSizeFlag; + + public override void _Process( double delta ) { if ( settings == null ) { + uiSize = Vector2.Zero; return; } @@ -171,7 +200,7 @@ namespace Rokojori _resizeFlag = true; } - if ( useParentSize ) + if ( useParentSize && GetParent() as Control != null ) { var parentSize = GetParent().Size; @@ -188,6 +217,8 @@ namespace Rokojori UpdateFontSize(); UpdateUIElements(); + uiSize = Size; + // customDisposerIDs = _customDisposers.Map( c => c.GetUID() + ":" + c.GetInfo() ).ToArray(); } diff --git a/Runtime/WorldMap/Layers/Grid/GridWorldMapLayer.cs b/Runtime/WorldMap/Layers/Grid/GridWorldMapLayer.cs new file mode 100644 index 0000000..28f41c6 --- /dev/null +++ b/Runtime/WorldMap/Layers/Grid/GridWorldMapLayer.cs @@ -0,0 +1,284 @@ +using Godot; +using System.Collections; +using System.Collections.Generic; +using System.Text.RegularExpressions; + +namespace Rokojori +{ + [Tool] + [GlobalClass] + public partial class GridWorldMapLayer:WorldMapLayerType + { + [Export] + public float regionSize = 250; + + [Export] + public float hueScale; + + public override void Update( WorldMapLayer layer, WorldMap map ) + { + UpdateLayer( layer, map ); + } + + public enum LoadingStatus + { + Not_Loaded, + Loading, + Loaded, + Unloading, + Error + } + + public class WorldMapRegionInfo + { + public float loadingTime; + public string id; + public LoadingStatus status; + public GridWorldRegion region; + public List layerInfos = new List(); + } + + public class WorldMapLayerInfo + { + public LoadingStatus status; + public WorldMapLayer layer; + } + + public override void OnWorldEditorNodeUpdate( NodeUpdate update, WorldMapLayer mapLayer, Node node ) + { + var position = GetPositionOfNode( node ); + var regionID = WorldToRegions( position ); + var parentRegion = node.FindParentThatIs(); + + + if ( NodeUpdate.Deleted == update ) + { + node.RemoveFromParent(); + + if ( parentRegion != null ) + { + parentRegion.UpdateRegion(); + } + + return; + } + + var region = mapLayer.FindDirectChild( r => r.regionID == regionID ); + + if ( region == null ) + { + region = mapLayer.CreateChild( "Region-" + regionID.X + "-" + regionID.Y ); + } + + if ( region == parentRegion ) + { + parentRegion.UpdateRegion(); + return; + } + + node.RemoveFromParent(); + parentRegion.UpdateRegion(); + region.AddChild( node ); + region.UpdateRegion(); + } + + public string CreateRegionID( Vector2 regionsPosition ) + { + var x = Mathf.RoundToInt( regionsPosition.X ); + var y = Mathf.RoundToInt( regionsPosition.Y ); + + return CreateRegionID( x, y ); + } + + public string CreateRegionID( int x, int y) + { + return x + "," + y; + } + + public Vector2I ParseID( string id ) + { + var numbers = id.Split( "," ); + + var x = RegexUtility.ParseInt( numbers[ 0 ] ); + var y = RegexUtility.ParseInt( numbers[ 1 ] ); + + return new Vector2I( x, y ); + } + + public Box2 GetXZWorldBoxOfRegion( int regionX, int regionY ) + { + var boxStart = RegionsToWorld( new Vector2( regionX, regionY ) ) ; + var boxEnd = boxStart + new Vector3( regionSize, 0, regionSize ); + + return new Box2( Math2D.XZ( boxStart ), Math2D.XZ( boxEnd ) ); + } + + + + + protected Dictionary _loadedRegions = new Dictionary(); + protected WorldMapLayer _layer; + + protected void ClearRegions() + { + Nodes.RemoveAndDeleteChildren( _layer ); + _loadedRegions.Clear(); + } + + void UpdateLayer( WorldMapLayer layer, WorldMap map ) + { + _layer = layer; + var streamTargets = map.streamers; + + var regionsToStream = new HashSet(); + + for ( int i = 0; i < streamTargets.Length; i++ ) + { + GetStreamRegions( streamTargets[ i ], regionsToStream ); + } + + foreach ( var s in regionsToStream ) + { + if ( _loadedRegions.ContainsKey( s ) ) + { + continue; + } + + LoadRegion( s ); + } + + foreach ( var s in _loadedRegions ) + { + if ( regionsToStream.Contains( s.Key ) ) + { + continue; + } + + UnloadRegion( s.Key ); + } + } + + public Vector2 WorldToRegions( Vector3 worldPosition ) + { + return Math2D.XZ( worldPosition / regionSize ); + } + + public Vector3 RegionsToWorld( Vector2 regionsPosition ) + { + return Math3D.XYasXZ( regionsPosition ) * regionSize; + } + + + void GetStreamRegions( WorldStreamer streamer, HashSet regions ) + { + var streamPosition = streamer.GetStreamCenter(); + var streamRadius = streamer.GetStreamRadius(); + + var streamMin = streamPosition - Vector3.One * streamRadius; + var streamMax = streamPosition + Vector3.One * streamRadius; + + var positionMin = WorldToRegions( streamPosition - Vector3.One * streamRadius ); + var positionMax = WorldToRegions( streamPosition + Vector3.One * streamRadius ); + + + positionMin = positionMin.Floor(); + positionMax = positionMax.Ceil(); + + // RJLog.Log( "CheckRegions", streamMin, streamMax, positionMin, positionMax ); + + var min = new Vector2I( (int)positionMin.X, (int)positionMin.Y ); + var max = new Vector2I( (int)positionMax.X, (int)positionMax.Y ); + + var index = 0; + + var streamPositionXZ = Math2D.XZ( streamPosition ); + + for ( int i = min.X; i <= max.X; i++ ) + { + for ( int j = min.Y; j <= max.Y; j++ ) + { + var regionID = CreateRegionID( i, j ); + + if ( regions.Contains( regionID ) ) + { + continue; + } + + var boxXZ = GetXZWorldBoxOfRegion( i, j ); + + var distance = boxXZ.DistanceTo( streamPositionXZ ); + + if ( index < 3 ) + { + // RJLog.Log( i, j, boxXZ.center, distance ); + index++; + } + + + if ( distance > streamRadius ) + { + continue; + } + + regions.Add( regionID ); + } + } + + } + + void LoadRegion( string regionID ) + { + var regionIndex = ParseID( regionID ); + + // RJLog.Log( "Loading regionID:", regionID, regionIndex.X, regionIndex.Y ); + var regionInfo = new WorldMapRegionInfo(); + regionInfo.id = regionID; + regionInfo.loadingTime = Time.GetTicksMsec() / 1000f; + + _loadedRegions[ regionID ] = regionInfo; + + var worldRegion = _layer.CreateChild( regionID ); + worldRegion.indexX = regionIndex.X; + worldRegion.indexZ = regionIndex.Y; + + var s = regionSize; + var h = s / 2f; + var hue = Noise.PerlinXZ( RegionsToWorld( regionIndex ) * hueScale ); + + var material = new StandardMaterial3D(); + material.AlbedoColor = new HSLColor( hue * 360, 1, 0.5f ); + material.Metallic = 0.2f; + material.Roughness = 0.6f; + + worldRegion.GlobalPosition = RegionsToWorld( regionIndex ) + new Vector3( h, 0, h ); + + // var lodHM = worldRegion.CreateChild(); + // lodHM.material = material; + // lodHM.Create(); + + + var box = worldRegion.CreateChild( "Box" ); + box.Size = new Vector3( s, 1, s ); + box.Material = material; + + + + regionInfo.region = worldRegion; + + + + + } + + void UnloadRegion( string regionID ) + { + // RJLog.Log( "Unloading regionID:", regionID ); + + var info = _loadedRegions[ regionID ]; + + Nodes.RemoveAndDelete( info.region ); + + _loadedRegions.Remove( regionID ); + } + } +} \ No newline at end of file diff --git a/Runtime/WorldMap/Layers/Grid/GridWorldMapLayer.cs.uid b/Runtime/WorldMap/Layers/Grid/GridWorldMapLayer.cs.uid new file mode 100644 index 0000000..bef1d6c --- /dev/null +++ b/Runtime/WorldMap/Layers/Grid/GridWorldMapLayer.cs.uid @@ -0,0 +1 @@ +uid://brfrk1ent8ic2 diff --git a/Runtime/WorldMap/WorldRegion.cs b/Runtime/WorldMap/Layers/Grid/GridWorldRegion.cs similarity index 59% rename from Runtime/WorldMap/WorldRegion.cs rename to Runtime/WorldMap/Layers/Grid/GridWorldRegion.cs index 93e5eb5..c435e69 100644 --- a/Runtime/WorldMap/WorldRegion.cs +++ b/Runtime/WorldMap/Layers/Grid/GridWorldRegion.cs @@ -7,12 +7,20 @@ namespace Rokojori { [Tool] [GlobalClass] - public partial class WorldRegion:Node3D - { + public partial class GridWorldRegion:Node3D + { [Export] public int indexX = 0; [Export] public int indexZ = 0; + + public Vector2I regionID => new Vector2I( indexX, indexZ ); + + + public void UpdateRegion() + { + + } } } \ No newline at end of file diff --git a/Runtime/WorldMap/WorldRegion.cs.uid b/Runtime/WorldMap/Layers/Grid/GridWorldRegion.cs.uid similarity index 100% rename from Runtime/WorldMap/WorldRegion.cs.uid rename to Runtime/WorldMap/Layers/Grid/GridWorldRegion.cs.uid diff --git a/Runtime/WorldMap/Layers/WorldMapLayer.cs b/Runtime/WorldMap/Layers/WorldMapLayer.cs new file mode 100644 index 0000000..b820015 --- /dev/null +++ b/Runtime/WorldMap/Layers/WorldMapLayer.cs @@ -0,0 +1,74 @@ +using Godot; +using System.Collections; +using System.Collections.Generic; +using System.Text.RegularExpressions; + +namespace Rokojori +{ + [Tool] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/WorldMapLayer.svg")] + public partial class WorldMapLayer:Node + { + [Export] + public WorldMapLayerType layerType; + + public void Update( WorldMap map ) + { + layerType.Update( this, map ); + } + + #if TOOLS + public override void _Ready() + { + this._OnSignal( Node.SignalName.ChildEnteredTree, + Callable.From( + ( Node node ) => + { + if ( layerType == null ) + { + return; + } + layerType.OnWorldEditorNodeUpdate( WorldMapLayerType.NodeUpdate.Added, this, node ); + } + ) + ); + + this._OnSignal( Node.SignalName.ChildExitingTree, + Callable.From( + ( Node node ) => + { + if ( layerType == null ) + { + return; + } + + layerType.OnWorldEditorNodeUpdate( WorldMapLayerType.NodeUpdate.Deleted, this, node ); + } + ) + ); + + this._OnSignal( Node.SignalName.ChildOrderChanged, + Callable.From( + ( Node node ) => + { + if ( layerType == null ) + { + return; + } + + layerType.OnWorldEditorNodeUpdate( WorldMapLayerType.NodeUpdate.Moved, this, node ); + } + ) + ); + } + + public override void _Process( double delta ) + { + + } + + #endif + + + } +} \ No newline at end of file diff --git a/Runtime/WorldMap/WorldMapLayer.cs.uid b/Runtime/WorldMap/Layers/WorldMapLayer.cs.uid similarity index 100% rename from Runtime/WorldMap/WorldMapLayer.cs.uid rename to Runtime/WorldMap/Layers/WorldMapLayer.cs.uid diff --git a/Runtime/WorldMap/Layers/WorldMapLayerType.cs b/Runtime/WorldMap/Layers/WorldMapLayerType.cs new file mode 100644 index 0000000..c8c2345 --- /dev/null +++ b/Runtime/WorldMap/Layers/WorldMapLayerType.cs @@ -0,0 +1,48 @@ +using Godot; +using System.Collections; +using System.Collections.Generic; +using System.Text.RegularExpressions; + +namespace Rokojori +{ + [Tool] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/WorldMapLayer.svg")] + public abstract partial class WorldMapLayerType:Resource + { + [Export] + public string layerName; + + public enum LayerEditType + { + Editor_And_Runtime, + Editor_Only, + Runtime_Only + } + + [Export] + public LayerEditType editType; + + public abstract void Update( WorldMapLayer layer, WorldMap map ); + + public enum NodeUpdate + { + Added, + Deleted, + Moved + } + + public abstract void OnWorldEditorNodeUpdate( NodeUpdate update, WorldMapLayer mapLayer, Node node ); + + + public Vector3 GetPositionOfNode( Node node ) + { + if ( node is Node3D node3D) + { + return node3D.GlobalPosition; + } + + return Vector3.Zero; + } + + } +} \ No newline at end of file diff --git a/Runtime/WorldMap/WorldMapLayerDefinition.cs.uid b/Runtime/WorldMap/Layers/WorldMapLayerType.cs.uid similarity index 100% rename from Runtime/WorldMap/WorldMapLayerDefinition.cs.uid rename to Runtime/WorldMap/Layers/WorldMapLayerType.cs.uid diff --git a/Runtime/WorldMap/Streamers/WorldStreamer.cs b/Runtime/WorldMap/Streamers/WorldStreamer.cs new file mode 100644 index 0000000..561ea91 --- /dev/null +++ b/Runtime/WorldMap/Streamers/WorldStreamer.cs @@ -0,0 +1,26 @@ +using Godot; +using System.Collections; +using System.Collections.Generic; +using System.Text.RegularExpressions; + +namespace Rokojori +{ + + [Tool] + [GlobalClass] + public partial class WorldStreamer:Node3D + { + [Export] + public float streamRadius = 500; + + public Vector3 GetStreamCenter() + { + return GlobalPosition; + } + + public float GetStreamRadius() + { + return streamRadius; + } + } +} \ No newline at end of file diff --git a/Runtime/WorldMap/Streamers/WorldStreamer.cs.uid b/Runtime/WorldMap/Streamers/WorldStreamer.cs.uid new file mode 100644 index 0000000..f6fd994 --- /dev/null +++ b/Runtime/WorldMap/Streamers/WorldStreamer.cs.uid @@ -0,0 +1 @@ +uid://c4f7cfaw2lt01 diff --git a/Runtime/WorldMap/WorldMap.cs b/Runtime/WorldMap/WorldMap.cs index ed1ff6c..bb25bad 100644 --- a/Runtime/WorldMap/WorldMap.cs +++ b/Runtime/WorldMap/WorldMap.cs @@ -7,248 +7,43 @@ namespace Rokojori { [Tool] - [GlobalClass] + [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/WorldMap.svg")] public partial class WorldMap:Node { [Export] public WorldMapDefinition worldMapDefinition; [Export] - public Node regionsContainer; + public WorldStreamer[] streamers = []; + + List _layers = []; - [Export] - public Node3D[] streamTargets = new Node3D[ 0 ]; + [ExportToolButton( "Initialize Layers" )] + public Callable initializeLayersButton => Callable.From( ()=> { InitializeLayers(); } ); - [Export] - public float streamTargetRadius = 500; - - [Export] - public WorldMapLayerSetting[] layerSettings = new WorldMapLayerSetting[ 0 ]; - - [Export] - public float hueScale = 0.01f; - - public enum LoadingStatus + public void InitializeLayers() { - Not_Loaded, - Loading, - Loaded, - Unloading, - Error + foreach ( var ld in worldMapDefinition.layers ) + { + var layer = this.CreateChild( ld.layerName ); + layer.layerType = ld; + } } - public class WorldMapRegionInfo - { - public float loadingTime; - public string id; - public LoadingStatus status; - public WorldRegion region; - public List layerInfos = new List(); - } - - public class WorldMapLayerInfo - { - public LoadingStatus status; - public WorldMapLayer layer; - } - - protected Dictionary _loadedRegions = new Dictionary(); - public override void _Process( double delta ) { - StreamRegions(); - } - - public Vector2 WorldToRegions( Vector3 worldPosition ) - { - return Math2D.XZ( worldPosition / worldMapDefinition.regionSize ); + UpdateLayers(); } - public Vector3 RegionsToWorld( Vector2 regionsPosition ) + public void UpdateLayers() { - return Math3D.XYasXZ( regionsPosition ) * worldMapDefinition.regionSize; + _layers.ForEach( l => l.Update( this ) ); } - public string CreateRegionID( Vector2 regionsPosition ) - { - var x = Mathf.RoundToInt( regionsPosition.X ); - var y = Mathf.RoundToInt( regionsPosition.Y ); - - return CreateRegionID( x, y ); - } - - public string CreateRegionID( int x, int y) - { - return x + "," + y; - } - - public Vector2I ParseID( string id ) - { - var numbers = id.Split( "," ); - - var x = RegexUtility.ParseInt( numbers[ 0 ] ); - var y = RegexUtility.ParseInt( numbers[ 1 ] ); - - return new Vector2I( x, y ); - } - - public Box2 GetXZWorldBoxOfRegion( int regionX, int regionY ) - { - var boxStart = RegionsToWorld( new Vector2( regionX, regionY ) ) ; - var boxEnd = boxStart + new Vector3( worldMapDefinition.regionSize, 0, worldMapDefinition.regionSize ); - - return new Box2( Math2D.XZ( boxStart ), Math2D.XZ( boxEnd ) ); - } - - protected void ClearRegions() - { - Nodes.RemoveAndDeleteChildren( regionsContainer ); - _loadedRegions.Clear(); - } - - protected void StreamRegions() - { - var regionsToStream = new HashSet(); - - for ( int i = 0; i < streamTargets.Length; i++ ) - { - GetStreamRegions( streamTargets[ i ], regionsToStream ); - } - - foreach ( var s in regionsToStream ) - { - if ( _loadedRegions.ContainsKey( s ) ) - { - continue; - } - - LoadRegion( s ); - } - - foreach ( var s in _loadedRegions ) - { - if ( regionsToStream.Contains( s.Key ) ) - { - continue; - } - - UnloadRegion( s.Key ); - } - } + - void GetStreamRegions( Node3D streamTarget, HashSet regions ) - { - var streamPosition = streamTarget.GlobalPosition; - - var streamMin = streamPosition - Vector3.One * streamTargetRadius; - var streamMax = streamPosition + Vector3.One * streamTargetRadius; - - var positionMin = WorldToRegions( streamPosition - Vector3.One * streamTargetRadius ); - var positionMax = WorldToRegions( streamPosition + Vector3.One * streamTargetRadius ); - - - positionMin = positionMin.Floor(); - positionMax = positionMax.Ceil(); - - // RJLog.Log( "CheckRegions", streamMin, streamMax, positionMin, positionMax ); - - var min = new Vector2I( (int)positionMin.X, (int)positionMin.Y ); - var max = new Vector2I( (int)positionMax.X, (int)positionMax.Y ); - - var index = 0; - - var streamPositionXZ = Math2D.XZ( streamPosition ); - - for ( int i = min.X; i <= max.X; i++ ) - { - for ( int j = min.Y; j <= max.Y; j++ ) - { - var regionID = CreateRegionID( i, j ); - - if ( regions.Contains( regionID ) ) - { - continue; - } - - var boxXZ = GetXZWorldBoxOfRegion( i, j ); - - var distance = boxXZ.DistanceTo( streamPositionXZ ); - - if ( index < 3 ) - { - // RJLog.Log( i, j, boxXZ.center, distance ); - index++; - } - - - if ( distance > streamTargetRadius ) - { - continue; - } - - regions.Add( regionID ); - } - } - - } - - void LoadRegion( string regionID ) - { - var regionIndex = ParseID( regionID ); - - // RJLog.Log( "Loading regionID:", regionID, regionIndex.X, regionIndex.Y ); - var regionInfo = new WorldMapRegionInfo(); - regionInfo.id = regionID; - regionInfo.loadingTime = Time.GetTicksMsec() / 1000f; - - _loadedRegions[ regionID ] = regionInfo; - - var worldRegion = regionsContainer.CreateChild( regionID ); - worldRegion.indexX = regionIndex.X; - worldRegion.indexZ = regionIndex.Y; - - var s = worldMapDefinition.regionSize; - var h = s / 2f; - var hue = Noise.PerlinXZ( RegionsToWorld( regionIndex ) * hueScale ); - - var material = new StandardMaterial3D(); - material.AlbedoColor = new HSLColor( hue * 360, 1, 0.5f ); - material.Metallic = 0.2f; - material.Roughness = 0.6f; - - worldRegion.GlobalPosition = RegionsToWorld( regionIndex ) + new Vector3( h, 0, h ); - - // var lodHM = worldRegion.CreateChild(); - // lodHM.material = material; - // lodHM.Create(); - - - var box = worldRegion.CreateChild( "Box" ); - box.Size = new Vector3( s, 1, s ); - box.Material = material; - - - - regionInfo.region = worldRegion; - - - - - } - - void UnloadRegion( string regionID ) - { - // RJLog.Log( "Unloading regionID:", regionID ); - - var info = _loadedRegions[ regionID ]; - - Nodes.RemoveAndDelete( info.region ); - - _loadedRegions.Remove( regionID ); - } - } } \ No newline at end of file diff --git a/Runtime/WorldMap/WorldMapDefinition.cs b/Runtime/WorldMap/WorldMapDefinition.cs index aba852e..ea924bf 100644 --- a/Runtime/WorldMap/WorldMapDefinition.cs +++ b/Runtime/WorldMap/WorldMapDefinition.cs @@ -10,13 +10,10 @@ namespace Rokojori public partial class WorldMapDefinition:Resource { [Export] - public string worldMapPath; + public string worldMapPath = "WorldMap"; [Export] - public float regionSize = 250; - - [Export] - public WorldMapLayerDefinition[] layers = new WorldMapLayerDefinition[ 0 ]; + public WorldMapLayerType[] layers = []; } } \ No newline at end of file diff --git a/Runtime/WorldMap/WorldMapEditor.cs b/Runtime/WorldMap/WorldMapEditor.cs deleted file mode 100644 index aca19a6..0000000 --- a/Runtime/WorldMap/WorldMapEditor.cs +++ /dev/null @@ -1,51 +0,0 @@ -using Godot; -using System.Collections; -using System.Collections.Generic; -using System.Text.RegularExpressions; - -namespace Rokojori -{ - [Tool] - [GlobalClass] - public partial class WorldMapEditor:WorldMap - { - [Export] - public Node layerEditorsContainer; - - [Export] - public bool streaming = true; - - [Export] - public bool createEmptyRegions = false; - - [Export] - public PackedScene emptyRegion; - - [ExportGroup("Debugging")] - [Export] - public int numTiles = 0; - - bool wasStreaming = false; - - public override void _Process( double delta ) - { - if ( ! streaming ) - { - wasStreaming = false; - return; - } - - numTiles = _loadedRegions.Count; - - if ( ! wasStreaming ) - { - ClearRegions(); - } - - StreamRegions(); - - wasStreaming = true; - } - - } -} \ No newline at end of file diff --git a/Runtime/WorldMap/WorldMapEditor.cs.uid b/Runtime/WorldMap/WorldMapEditor.cs.uid deleted file mode 100644 index 1d8fce1..0000000 --- a/Runtime/WorldMap/WorldMapEditor.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://5d7rd68av68u diff --git a/Runtime/WorldMap/WorldMapLayer.cs b/Runtime/WorldMap/WorldMapLayer.cs deleted file mode 100644 index 0d207cd..0000000 --- a/Runtime/WorldMap/WorldMapLayer.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Godot; -using System.Collections; -using System.Collections.Generic; -using System.Text.RegularExpressions; - -namespace Rokojori -{ - [Tool] - [GlobalClass] - public partial class WorldMapLayer:Node - { - [Export] - public WorldMapLayerDefinition layerDefinition; - - } -} \ No newline at end of file diff --git a/Runtime/WorldMap/WorldMapLayerEditor.cs b/Runtime/WorldMap/WorldMapLayerEditor.cs deleted file mode 100644 index 477dec3..0000000 --- a/Runtime/WorldMap/WorldMapLayerEditor.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Godot; -using System.Collections; -using System.Collections.Generic; -using System.Text.RegularExpressions; - -namespace Rokojori -{ - [Tool] - [GlobalClass] - public partial class WorldMapLayerEditor:Node - { - [Export] - public WorldMapLayerDefinition layerDefinition; - - } -} \ No newline at end of file diff --git a/Runtime/WorldMap/WorldMapLayerEditor.cs.uid b/Runtime/WorldMap/WorldMapLayerEditor.cs.uid deleted file mode 100644 index 85e51c5..0000000 --- a/Runtime/WorldMap/WorldMapLayerEditor.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://bbntamdkvsdia diff --git a/Runtime/WorldMap/WorldMapLayerSetting.cs b/Runtime/WorldMap/WorldMapLayerSetting.cs deleted file mode 100644 index a21edeb..0000000 --- a/Runtime/WorldMap/WorldMapLayerSetting.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Godot; -using System.Collections; -using System.Collections.Generic; -using System.Text.RegularExpressions; - -namespace Rokojori -{ - [Tool] - [GlobalClass] - public partial class WorldMapLayerSetting:Resource - { - [Export] - public WorldMapLayerDefinition layerDefinition; - - [Export] - public bool active = true; - } -} \ No newline at end of file diff --git a/Runtime/WorldMap/WorldMapLayerSetting.cs.uid b/Runtime/WorldMap/WorldMapLayerSetting.cs.uid deleted file mode 100644 index 570ab5a..0000000 --- a/Runtime/WorldMap/WorldMapLayerSetting.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://co5wfb35osnvq