Added new 2d navpoly baking demo.

This commit is contained in:
Relintai 2023-06-07 15:51:17 +02:00
parent 25ed4070b2
commit 3fc3933921
9 changed files with 228 additions and 0 deletions

View File

@ -0,0 +1,23 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://new_tileset.tres" type="TileSet" id=1]
[sub_resource type="NavigationPolygon" id=1]
vertices = PoolVector2Array( 802, -24, 885, 649, -125, 572, -512, 166, -125, -196 )
polygons = [ PoolIntArray( 0, 1, 2, 3, 4 ) ]
outlines = [ PoolVector2Array( -512, 166, -125, 572, 885, 649, 802, -24, -125, -196 ) ]
baked_outlines = [ PoolVector2Array( 802, -24, 885, 649, -125, 572, -512, 166, -125, -196 ) ]
polygon_bake_fillrule = 1
[node name="Node2D" type="Node2D"]
[node name="TileMap" type="TileMap" parent="."]
tile_set = ExtResource( 1 )
cell_size = Vector2( 54, 53 )
bake_navigation = true
format = 1
tile_data = PoolIntArray( 65533, 0, 0, 65534, 0, 0, 65535, 0, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 3, 1, 0, 4, 1, 0, 5, 1, 0, 131069, 0, 0, 131070, 0, 0, 131071, 0, 0, 65536, 0, 0, 65537, 0, 0, 65538, 0, 0, 65539, 0, 0, 65540, 0, 0, 65541, 1, 0, 65542, 1, 0, 65543, 1, 0, 65544, 1, 0, 196605, 0, 0, 196606, 0, 0, 196607, 0, 0, 131072, 0, 0, 131073, 0, 0, 131074, 0, 0, 131075, 0, 0, 131076, 0, 0, 131077, 0, 0, 131078, 0, 0, 131079, 1, 0, 131080, 1, 0, 262141, 0, 0, 262142, 0, 0, 262143, 0, 0, 196608, 0, 0, 196609, 0, 0, 196610, 0, 0, 196611, 0, 0, 196612, 0, 0, 196613, 0, 0, 196614, 0, 0, 196615, 1, 0, 196616, 1, 0, 327678, 0, 0, 327679, 0, 0, 262144, 0, 0, 262145, 0, 0, 262146, 0, 0, 262147, 0, 0, 262148, 1, 0, 262149, 1, 0, 262150, 1, 0, 262151, 1, 0, 262152, 1, 0, 327681, 1, 0, 327682, 1, 0, 327683, 1, 0, 327684, 1, 0, 327685, 1, 0, 327686, 1, 0, 393217, 1, 0, 393218, 1, 0, 393219, 1, 0, 393220, 1, 0 )
[node name="NavigationPolygonInstance" type="NavigationPolygonInstance" parent="."]
visible = false
navpoly = SubResource( 1 )

View File

@ -0,0 +1,64 @@
[gd_scene load_steps=8 format=2]
[ext_resource path="res://icon.png" type="Texture" id=1]
[ext_resource path="res://new_multimesh.tres" type="MultiMesh" id=2]
[ext_resource path="res://new_arraymesh.tres" type="ArrayMesh" id=3]
[sub_resource type="NavigationPolygon" id=1]
vertices = PoolVector2Array( 138, -41, 138, -180, 361.3, -208, 546.9, -208, 230, 149.3, 219, 130, 582, -244.5, 582, -428.7, 838, -670, 1003, 533, -176, 33, -147.986, -0.20149, -110.799, 36.9856, -177.261, 42.5763, -176, -11, -161.597, -51, 337, -223.9, -177.261, -20.5763, -180.957, -29.5, 570.2, -223, 230, 333.5, 218.2, 355, 568.8, -223, 560.8, -215, 558.5, -215, -194, 289.5, -26, 149.9, -26, 334.7, -205.8, 311, -194, 105.3, -22.4, 140, -50, -180, -50, -149.918, -60, -152.597, -322, -249, -186.837, -37.1629, 571, -445.6, 571, -448, -355, -446, 326, -428.1, 326, -243.3, 337, -226.4, -110.798, -138.986, -147.986, -101.799, -493, -150, 556, -459, 556, -460.4, 10.3, 114, 27.9856, -0.20149, 38.9175, -41, 194.1, 114, 329.6, -438, -545, -652, -203.424, -46.7393, -213, -48, -789, 516, -872, -477, -587, -359, -194.5, -43.0429, -180.957, 51.5, 546.1, -464, 362.3, -464, 355.7, -461, 353.2, -461, 344.3, -453, 342, -453, 331, -438, -491, -392, -446.4, 96, -450, 105.9, 204, 119, 204, 117.6, -10, 125, -21, 140, -205, 88.4, -205, 86, -203.424, 68.7393, -220, 75, -220, 73.6, -213, 70, -434, 81, -445, 96, -15, 351.6, -15, 354.1, -215.2, 319, -207.2, 311, 208.8, 363, 216.8, 355, -186.837, 59.1629, -60, 50.597, 1.19999, 117, -7.69999, 125, -194.5, 65.0429, -422.8, 73, -431.7, 81, -222.576, -46.7393, -231.5, -43.0429, -239.163, -37.1629, -245.043, -29.5, -248.739, -20.5763, -250, -11, -250, 33, -248.739, 42.5763, -413.7, 70, -450, 290.7, -439, 307.6, -439, 310.1, 219, 132.4, -9.2015, 36.9856, 3.69999, 117, -222.576, 68.7393, -229.9, 70, -231.5, 65.0429, -239.163, 59.1629, -245.043, 51.5, -420.3, 73, -414.7, 326, 9.3, 370, -229.1, 326, -217.5, 319, 194.9, 370, 206.5, 363 )
polygons = [ PoolIntArray( 0, 1, 2, 3, 4, 5 ), PoolIntArray( 6, 7, 8, 9 ), PoolIntArray( 10, 11, 12, 13 ), PoolIntArray( 11, 10, 14, 15 ), PoolIntArray( 16, 2, 1 ), PoolIntArray( 15, 14, 17 ), PoolIntArray( 15, 17, 18 ), PoolIntArray( 19, 6, 9 ), PoolIntArray( 20, 19, 9, 21 ), PoolIntArray( 22, 19, 20, 4, 23 ), PoolIntArray( 24, 23, 4, 3 ), PoolIntArray( 25, 26, 27, 28 ), PoolIntArray( 26, 25, 29, 30 ), PoolIntArray( 31, 32, 33, 34 ), PoolIntArray( 15, 18, 35 ), PoolIntArray( 8, 7, 36, 37 ), PoolIntArray( 34, 38, 39, 40, 1, 31 ), PoolIntArray( 41, 16, 1, 40 ), PoolIntArray( 34, 33, 42 ), PoolIntArray( 34, 42, 43, 44 ), PoolIntArray( 8, 37, 45, 46 ), PoolIntArray( 47, 48, 49, 0, 50 ), PoolIntArray( 51, 39, 38, 52 ), PoolIntArray( 44, 43, 15, 53, 54 ), PoolIntArray( 55, 56, 52, 57 ), PoolIntArray( 15, 35, 58 ), PoolIntArray( 59, 13, 12 ), PoolIntArray( 8, 46, 60 ), PoolIntArray( 52, 8, 60, 61 ), PoolIntArray( 52, 61, 62, 63 ), PoolIntArray( 52, 63, 64, 65 ), PoolIntArray( 52, 65, 66, 51 ), PoolIntArray( 52, 38, 67, 57 ), PoolIntArray( 55, 57, 44, 68, 69 ), PoolIntArray( 5, 70, 71 ), PoolIntArray( 72, 73, 30, 29, 74, 75 ), PoolIntArray( 76, 75, 77, 78, 79 ), PoolIntArray( 80, 81, 68, 44 ), PoolIntArray( 28, 27, 82, 83, 84, 85 ), PoolIntArray( 86, 87, 21, 9 ), PoolIntArray( 88, 12, 89, 90, 91, 72, 75, 92 ), PoolIntArray( 93, 94, 80, 44 ), PoolIntArray( 88, 59, 12 ), PoolIntArray( 15, 58, 53 ), PoolIntArray( 44, 54, 95 ), PoolIntArray( 44, 95, 96 ), PoolIntArray( 44, 96, 97 ), PoolIntArray( 44, 97, 98 ), PoolIntArray( 44, 98, 99 ), PoolIntArray( 44, 99, 100 ), PoolIntArray( 44, 100, 101 ), PoolIntArray( 44, 101, 102, 103 ), PoolIntArray( 104, 105, 106, 55 ), PoolIntArray( 4, 107, 5 ), PoolIntArray( 0, 5, 71 ), PoolIntArray( 0, 71, 50 ), PoolIntArray( 108, 48, 47 ), PoolIntArray( 89, 108, 47, 109, 90 ), PoolIntArray( 76, 92, 75 ), PoolIntArray( 110, 79, 78, 111 ), PoolIntArray( 112, 110, 111, 103 ), PoolIntArray( 113, 112, 103 ), PoolIntArray( 114, 113, 103 ), PoolIntArray( 102, 114, 103 ), PoolIntArray( 44, 103, 115, 93 ), PoolIntArray( 55, 69, 104 ), PoolIntArray( 55, 106, 116 ), PoolIntArray( 9, 55, 116, 117 ), PoolIntArray( 118, 119, 84, 83, 117 ), PoolIntArray( 120, 121, 86, 9 ), PoolIntArray( 117, 120, 9 ), PoolIntArray( 117, 116, 118 ) ]
outlines = [ PoolVector2Array( -545, -652, 838, -670, 1003, 533, -789, 516, -872, -477 ) ]
baked_outlines = [ PoolVector2Array( 1003, 533, -789, 516, -872, -477, -545, -652, 838, -670 ), PoolVector2Array( 10.3, 114, 3.69999, 117, 1.19999, 117, -7.69999, 125, -10, 125, -21, 140, -22.4, 140, -26, 149.9, -26, 334.7, -15, 351.6, -15, 354.1, 9.3, 370, 194.9, 370, 206.5, 363, 208.8, 363, 216.8, 355, 218.2, 355, 230, 333.5, 230, 149.3, 219, 132.4, 219, 130, 204, 119, 204, 117.6, 194.1, 114 ), PoolVector2Array( -413.7, 70, -420.3, 73, -422.8, 73, -431.7, 81, -434, 81, -445, 96, -446.4, 96, -450, 105.9, -450, 290.7, -439, 307.6, -439, 310.1, -414.7, 326, -229.1, 326, -217.5, 319, -215.2, 319, -207.2, 311, -205.8, 311, -194, 289.5, -194, 105.3, -205, 88.4, -205, 86, -220, 75, -220, 73.6, -229.9, 70 ), PoolVector2Array( -222.576, -46.7393, -231.5, -43.0429, -239.163, -37.1629, -245.043, -29.5, -248.739, -20.5763, -250, -11, -250, 33, -248.739, 42.5763, -245.043, 51.5, -239.163, 59.1629, -231.5, 65.0429, -222.576, 68.7393, -213, 70, -203.424, 68.7393, -194.5, 65.0429, -186.837, 59.1629, -180.957, 51.5, -177.261, 42.5763, -176, 33, -176, -11, -177.261, -20.5763, -180.957, -29.5, -186.837, -37.1629, -194.5, -43.0429, -203.424, -46.7393, -213, -48 ), PoolVector2Array( -50, -180, -50, -149.918, -60, -152.597, -110.798, -138.986, -147.986, -101.799, -161.597, -51, -147.986, -0.20149, -110.799, 36.9856, -60, 50.597, -9.2015, 36.9856, 27.9856, -0.20149, 38.9175, -41, 138, -41, 138, -180 ), PoolVector2Array( -491, -392, -587, -359, -493, -150, -322, -249, -355, -446 ), PoolVector2Array( 362.3, -464, 355.7, -461, 353.2, -461, 344.3, -453, 342, -453, 331, -438, 329.6, -438, 326, -428.1, 326, -243.3, 337, -226.4, 337, -223.9, 361.3, -208, 546.9, -208, 558.5, -215, 560.8, -215, 568.8, -223, 570.2, -223, 582, -244.5, 582, -428.7, 571, -445.6, 571, -448, 556, -459, 556, -460.4, 546.1, -464 ) ]
geometry_parsed_geometry_type = 2
[sub_resource type="CircleShape2D" id=3]
radius = 101.597
[sub_resource type="RectangleShape2D" id=4]
extents = Vector2( 94, 69.5 )
[sub_resource type="CapsuleShape2D" id=5]
radius = 37.0
height = 44.0
[node name="Node2D" type="Node2D"]
[node name="NavigationPolygonInstance" type="NavigationPolygonInstance" parent="."]
navpoly = SubResource( 1 )
[node name="StaticBody2D" type="StaticBody2D" parent="NavigationPolygonInstance"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="NavigationPolygonInstance/StaticBody2D"]
position = Vector2( -60, -51 )
shape = SubResource( 3 )
[node name="CollisionShape2D2" type="CollisionShape2D" parent="NavigationPolygonInstance/StaticBody2D"]
position = Vector2( 44, -110.5 )
shape = SubResource( 4 )
[node name="CollisionShape2D3" type="CollisionShape2D" parent="NavigationPolygonInstance/StaticBody2D"]
position = Vector2( -213, 11 )
shape = SubResource( 5 )
[node name="Polygon2D" type="Polygon2D" parent="NavigationPolygonInstance"]
position = Vector2( -152, -160 )
polygon = PoolVector2Array( -339, -232, -203, -286, -170, -89, -341, 10, -435, -199 )
[node name="Sprite" type="Sprite" parent="NavigationPolygonInstance"]
position = Vector2( 637, 377 )
texture = ExtResource( 1 )
[node name="Sprite2" type="MeshInstance2D" parent="NavigationPolygonInstance"]
position = Vector2( 454, -336 )
mesh = ExtResource( 3 )
texture = ExtResource( 1 )
[node name="MultiMeshInstance2D" type="MultiMeshInstance2D" parent="NavigationPolygonInstance"]
position = Vector2( 102, 242 )
multimesh = ExtResource( 2 )
texture = ExtResource( 1 )
[node name="MultiMeshInstance2D2" type="MultiMeshInstance2D" parent="NavigationPolygonInstance"]
position = Vector2( -322, 198 )
multimesh = ExtResource( 2 )
texture = ExtResource( 1 )

View File

@ -0,0 +1,7 @@
[gd_resource type="Environment3D" load_steps=2 format=2]
[sub_resource type="ProceduralSky" id=1]
[resource]
background_mode = 2
background_sky = SubResource( 1 )

BIN
2d/navpoly_baking/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://icon.png"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@ -0,0 +1,14 @@
[gd_resource type="ArrayMesh" format=2]
[resource]
surfaces/0 = {
"aabb": AABB( -128, -128, 0, 256, 256, 0 ),
"array_data": PoolByteArray( 0, 0, 204, 66, 205, 204, 248, 194, 0, 0, 102, 63, 102, 102, 102, 60, 0, 0, 204, 66, 0, 0, 246, 194, 0, 0, 102, 63, 0, 0, 160, 60, 0, 0, 234, 66, 0, 0, 224, 194, 0, 0, 117, 63, 0, 0, 128, 61, 0, 0, 234, 66, 51, 51, 219, 194, 0, 0, 117, 63, 51, 51, 147, 61, 0, 0, 0, 67, 102, 102, 185, 194, 0, 0, 128, 63, 51, 51, 13, 62, 0, 0, 0, 67, 0, 0, 183, 66, 0, 0, 128, 63, 0, 128, 91, 63, 102, 102, 232, 66, 0, 0, 226, 66, 51, 51, 116, 63, 0, 0, 113, 63, 154, 153, 229, 66, 0, 0, 226, 66, 205, 204, 114, 63, 0, 0, 113, 63, 154, 153, 213, 66, 0, 0, 242, 66, 205, 204, 106, 63, 0, 0, 121, 63, 0, 0, 209, 66, 0, 0, 242, 66, 0, 128, 104, 63, 0, 0, 121, 63, 204, 204, 185, 66, 0, 0, 0, 67, 102, 230, 92, 63, 0, 0, 128, 63, 102, 102, 185, 194, 0, 0, 0, 67, 51, 51, 13, 62, 0, 0, 128, 63, 0, 0, 234, 194, 52, 51, 224, 66, 0, 0, 48, 61, 154, 25, 112, 63, 0, 0, 234, 194, 52, 51, 219, 66, 0, 0, 48, 61, 154, 153, 109, 63, 0, 0, 0, 195, 102, 102, 185, 66, 0, 0, 0, 0, 51, 179, 92, 63, 0, 0, 0, 195, 51, 51, 184, 194, 0, 0, 0, 0, 154, 153, 15, 62, 205, 204, 248, 194, 0, 0, 204, 194, 102, 102, 102, 60, 0, 0, 208, 61, 0, 0, 246, 194, 0, 0, 204, 194, 0, 0, 160, 60, 0, 0, 208, 61, 0, 0, 224, 194, 0, 0, 234, 194, 0, 0, 128, 61, 0, 0, 48, 61, 102, 102, 219, 194, 0, 0, 234, 194, 102, 102, 146, 61, 0, 0, 48, 61, 154, 153, 201, 194, 0, 0, 250, 194, 154, 153, 217, 61, 0, 0, 64, 60, 154, 153, 196, 194, 0, 0, 250, 194, 154, 153, 237, 61, 0, 0, 64, 60, 102, 102, 183, 194, 0, 0, 0, 195, 51, 51, 17, 62, 0, 0, 0, 0, 52, 51, 184, 66, 0, 0, 0, 195, 154, 25, 92, 63, 0, 0, 0, 0 ),
"array_index_data": PoolByteArray( 23, 0, 0, 0, 1, 0, 1, 0, 2, 0, 3, 0, 3, 0, 4, 0, 5, 0, 5, 0, 6, 0, 7, 0, 7, 0, 8, 0, 9, 0, 9, 0, 10, 0, 11, 0, 11, 0, 12, 0, 13, 0, 13, 0, 14, 0, 15, 0, 15, 0, 16, 0, 17, 0, 17, 0, 18, 0, 19, 0, 19, 0, 20, 0, 21, 0, 21, 0, 22, 0, 23, 0, 23, 0, 1, 0, 3, 0, 3, 0, 5, 0, 7, 0, 7, 0, 9, 0, 11, 0, 11, 0, 13, 0, 15, 0, 15, 0, 17, 0, 19, 0, 19, 0, 21, 0, 23, 0, 23, 0, 3, 0, 7, 0, 7, 0, 11, 0, 15, 0, 15, 0, 19, 0, 23, 0, 23, 0, 7, 0, 15, 0 ),
"blend_shape_data": [ ],
"format": 262417,
"index_count": 66,
"primitive": 4,
"skeleton_aabb": [ ],
"vertex_count": 24
}

View File

@ -0,0 +1,9 @@
[gd_resource type="MultiMesh" load_steps=2 format=2]
[ext_resource path="res://new_arraymesh.tres" type="ArrayMesh" id=1]
[resource]
instance_count = 2
visible_instance_count = 2
mesh = ExtResource( 1 )
transform_2d_array = PoolVector2Array( 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0 )

View File

@ -0,0 +1,51 @@
[gd_resource type="TileSet" load_steps=4 format=2]
[ext_resource path="res://icon.png" type="Texture" id=1]
[sub_resource type="NavigationPolygon" id=1]
vertices = PoolVector2Array( 165, 196, 0, 196, 0, 0, 165, 0 )
polygons = [ PoolIntArray( 0, 1, 2, 3 ) ]
outlines = [ PoolVector2Array( 0, 0, 165, 0, 165, 196, 0, 196 ) ]
baked_outlines = [ PoolVector2Array( 165, 196, 0, 196, 0, 0, 165, 0 ) ]
agent_radius = 0.0
[sub_resource type="ConvexPolygonShape2D" id=2]
points = PoolVector2Array( 0, 0, 56, 0, 56, 53, 0, 53 )
[resource]
0/name = "icon.png 0"
0/texture = ExtResource( 1 )
0/tex_offset = Vector2( 0, 0 )
0/modulate = Color( 1, 1, 1, 1 )
0/region = Rect2( 5, 7, 55, 53 )
0/tile_mode = 0
0/occluder_offset = Vector2( 0, 0 )
0/navigation_offset = Vector2( 0, 0 )
0/navigation = SubResource( 1 )
0/shape_offset = Vector2( 0, 0 )
0/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
0/shape_one_way = false
0/shape_one_way_margin = 0.0
0/shapes = [ ]
0/z_index = 0
1/name = "icon.png 1"
1/texture = ExtResource( 1 )
1/tex_offset = Vector2( 0, 0 )
1/modulate = Color( 1, 1, 1, 1 )
1/region = Rect2( 2, 6, 56, 53 )
1/tile_mode = 0
1/occluder_offset = Vector2( 0, 0 )
1/navigation_offset = Vector2( 0, 0 )
1/shape_offset = Vector2( 0, 0 )
1/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
1/shape = SubResource( 2 )
1/shape_one_way = false
1/shape_one_way_margin = 1.0
1/shapes = [ {
"autotile_coord": Vector2( 0, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 2 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
1/z_index = 0

View File

@ -0,0 +1,25 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=4
[application]
config/name="NavPoly2DBaking"
run/main_scene="res://Node2dD.tscn"
config/icon="res://icon.png"
[physics]
common/enable_pause_aware_picking=true
[rendering]
vram_compression/import_etc=true
vram_compression/import_etc2=false
environment/default_environment="res://default_env.tres"