diff --git a/godot/astream/road/markings.material b/godot/astream/road/markings.material new file mode 100644 index 0000000..5122a5c Binary files /dev/null and b/godot/astream/road/markings.material differ diff --git a/godot/astream/road/road-lanes.bin b/godot/astream/road/road-lanes.bin new file mode 100644 index 0000000..1460e8f Binary files /dev/null and b/godot/astream/road/road-lanes.bin differ diff --git a/godot/astream/road/road-lanes.gltf b/godot/astream/road/road-lanes.gltf new file mode 100644 index 0000000..ddb4279 --- /dev/null +++ b/godot/astream/road/road-lanes.gltf @@ -0,0 +1,315 @@ +{ + "asset" : { + "generator" : "Khronos glTF Blender I/O v3.3.32", + "version" : "2.0" + }, + "extensionsUsed" : [ + "KHR_materials_specular", + "KHR_materials_ior" + ], + "scene" : 0, + "scenes" : [ + { + "name" : "Scene", + "nodes" : [ + 0, + 1, + 2 + ] + } + ], + "nodes" : [ + { + "mesh" : 0, + "name" : "road-lane-center" + }, + { + "mesh" : 1, + "name" : "road-lane-mid", + "translation" : [ + 1.100000023841858, + 0, + 0 + ] + }, + { + "mesh" : 2, + "name" : "roadd-sidewalk", + "translation" : [ + 2.200000047683716, + 0, + 0 + ] + } + ], + "materials" : [ + { + "extensions" : { + "KHR_materials_specular" : { + "specularColorFactor" : [ + 0.474271529955476, + 0.474271529955476, + 0.474271529955476 + ] + }, + "KHR_materials_ior" : { + "ior" : 1.4500000476837158 + } + }, + "name" : "road-material", + "pbrMetallicRoughness" : { + "baseColorTexture" : { + "index" : 0 + }, + "metallicFactor" : 0.20000000298023224 + } + } + ], + "meshes" : [ + { + "name" : "road-lane-center", + "primitives" : [ + { + "attributes" : { + "POSITION" : 0, + "NORMAL" : 1, + "TEXCOORD_0" : 2 + }, + "indices" : 3, + "material" : 0 + } + ] + }, + { + "name" : "road-lane-mid", + "primitives" : [ + { + "attributes" : { + "POSITION" : 4, + "NORMAL" : 5, + "TEXCOORD_0" : 6 + }, + "indices" : 7, + "material" : 0 + } + ] + }, + { + "name" : "road-sidewalk", + "primitives" : [ + { + "attributes" : { + "POSITION" : 8, + "NORMAL" : 9, + "TEXCOORD_0" : 10 + }, + "indices" : 11, + "material" : 0 + } + ] + } + ], + "textures" : [ + { + "sampler" : 0, + "source" : 0 + } + ], + "images" : [ + { + "mimeType" : "image/png", + "name" : "road", + "uri" : "road.png" + } + ], + "accessors" : [ + { + "bufferView" : 0, + "componentType" : 5126, + "count" : 32, + "max" : [ + -8.847564458847046e-09, + 0.12099996209144592, + 5.960464477539063e-08 + ], + "min" : [ + -0.9999999403953552, + -0.09999995678663254, + -0.5 + ], + "type" : "VEC3" + }, + { + "bufferView" : 1, + "componentType" : 5126, + "count" : 32, + "type" : "VEC3" + }, + { + "bufferView" : 2, + "componentType" : 5126, + "count" : 32, + "type" : "VEC2" + }, + { + "bufferView" : 3, + "componentType" : 5123, + "count" : 48, + "type" : "SCALAR" + }, + { + "bufferView" : 4, + "componentType" : 5126, + "count" : 80, + "max" : [ + 9.921204764395952e-07, + 0.1214386522769928, + -6.735790520906448e-07 + ], + "min" : [ + -0.9999990463256836, + -0.09999995678663254, + -0.5000007152557373 + ], + "type" : "VEC3" + }, + { + "bufferView" : 5, + "componentType" : 5126, + "count" : 80, + "type" : "VEC3" + }, + { + "bufferView" : 6, + "componentType" : 5126, + "count" : 80, + "type" : "VEC2" + }, + { + "bufferView" : 7, + "componentType" : 5123, + "count" : 126, + "type" : "SCALAR" + }, + { + "bufferView" : 8, + "componentType" : 5126, + "count" : 42, + "max" : [ + 2.5033950805664062e-05, + 0.19999995827674866, + 0 + ], + "min" : [ + -1.100000023841858, + -0.10000000149011612, + -0.5 + ], + "type" : "VEC3" + }, + { + "bufferView" : 9, + "componentType" : 5126, + "count" : 42, + "type" : "VEC3" + }, + { + "bufferView" : 10, + "componentType" : 5126, + "count" : 42, + "type" : "VEC2" + }, + { + "bufferView" : 11, + "componentType" : 5123, + "count" : 66, + "type" : "SCALAR" + } + ], + "bufferViews" : [ + { + "buffer" : 0, + "byteLength" : 384, + "byteOffset" : 0, + "target" : 34962 + }, + { + "buffer" : 0, + "byteLength" : 384, + "byteOffset" : 384, + "target" : 34962 + }, + { + "buffer" : 0, + "byteLength" : 256, + "byteOffset" : 768, + "target" : 34962 + }, + { + "buffer" : 0, + "byteLength" : 96, + "byteOffset" : 1024, + "target" : 34963 + }, + { + "buffer" : 0, + "byteLength" : 960, + "byteOffset" : 1120, + "target" : 34962 + }, + { + "buffer" : 0, + "byteLength" : 960, + "byteOffset" : 2080, + "target" : 34962 + }, + { + "buffer" : 0, + "byteLength" : 640, + "byteOffset" : 3040, + "target" : 34962 + }, + { + "buffer" : 0, + "byteLength" : 252, + "byteOffset" : 3680, + "target" : 34963 + }, + { + "buffer" : 0, + "byteLength" : 504, + "byteOffset" : 3932, + "target" : 34962 + }, + { + "buffer" : 0, + "byteLength" : 504, + "byteOffset" : 4436, + "target" : 34962 + }, + { + "buffer" : 0, + "byteLength" : 336, + "byteOffset" : 4940, + "target" : 34962 + }, + { + "buffer" : 0, + "byteLength" : 132, + "byteOffset" : 5276, + "target" : 34963 + } + ], + "samplers" : [ + { + "magFilter" : 9729, + "minFilter" : 9987 + } + ], + "buffers" : [ + { + "byteLength" : 5408, + "uri" : "road-lanes.bin" + } + ] +} diff --git a/godot/astream/road/road-lanes.gltf.import b/godot/astream/road/road-lanes.gltf.import new file mode 100644 index 0000000..6e64002 --- /dev/null +++ b/godot/astream/road/road-lanes.gltf.import @@ -0,0 +1,1066 @@ +[remap] + +importer="scene" +type="PackedScene" +path="res://.import/road-lanes.gltf-e60d42e8d61f51c602976bf5ed29eb06.scn" + +[deps] + +source_file="res://astream/road/road-lanes.gltf" +dest_files=[ "res://.import/road-lanes.gltf-e60d42e8d61f51c602976bf5ed29eb06.scn" ] + +[params] + +nodes/root_type="Spatial" +nodes/root_name="Scene Root" +nodes/root_scale=1.0 +nodes/custom_script="" +nodes/storage=0 +nodes/use_legacy_names=false +materials/location=1 +materials/storage=1 +materials/keep_on_reimport=true +meshes/compress=4286 +meshes/ensure_tangents=true +meshes/octahedral_compression=true +meshes/vertex_cache_optimization=true +meshes/storage=1 +meshes/light_baking=0 +meshes/lightmap_texel_size=0.1 +skins/use_named_skins=true +external_files/store_in_subdir=false +animation/import=true +animation/fps=15 +animation/filter_script="" +animation/storage=false +animation/keep_custom_tracks=false +animation/optimizer/enabled=true +animation/optimizer/max_linear_error=0.05 +animation/optimizer/max_angular_error=0.01 +animation/optimizer/max_angle=22 +animation/optimizer/remove_unused_tracks=true +animation/clips/amount=0 +animation/clip_1/name="" +animation/clip_1/start_frame=0 +animation/clip_1/end_frame=0 +animation/clip_1/loops=false +animation/clip_2/name="" +animation/clip_2/start_frame=0 +animation/clip_2/end_frame=0 +animation/clip_2/loops=false +animation/clip_3/name="" +animation/clip_3/start_frame=0 +animation/clip_3/end_frame=0 +animation/clip_3/loops=false +animation/clip_4/name="" +animation/clip_4/start_frame=0 +animation/clip_4/end_frame=0 +animation/clip_4/loops=false +animation/clip_5/name="" +animation/clip_5/start_frame=0 +animation/clip_5/end_frame=0 +animation/clip_5/loops=false +animation/clip_6/name="" +animation/clip_6/start_frame=0 +animation/clip_6/end_frame=0 +animation/clip_6/loops=false +animation/clip_7/name="" +animation/clip_7/start_frame=0 +animation/clip_7/end_frame=0 +animation/clip_7/loops=false +animation/clip_8/name="" +animation/clip_8/start_frame=0 +animation/clip_8/end_frame=0 +animation/clip_8/loops=false +animation/clip_9/name="" +animation/clip_9/start_frame=0 +animation/clip_9/end_frame=0 +animation/clip_9/loops=false +animation/clip_10/name="" +animation/clip_10/start_frame=0 +animation/clip_10/end_frame=0 +animation/clip_10/loops=false +animation/clip_11/name="" +animation/clip_11/start_frame=0 +animation/clip_11/end_frame=0 +animation/clip_11/loops=false +animation/clip_12/name="" +animation/clip_12/start_frame=0 +animation/clip_12/end_frame=0 +animation/clip_12/loops=false +animation/clip_13/name="" +animation/clip_13/start_frame=0 +animation/clip_13/end_frame=0 +animation/clip_13/loops=false +animation/clip_14/name="" +animation/clip_14/start_frame=0 +animation/clip_14/end_frame=0 +animation/clip_14/loops=false +animation/clip_15/name="" +animation/clip_15/start_frame=0 +animation/clip_15/end_frame=0 +animation/clip_15/loops=false +animation/clip_16/name="" +animation/clip_16/start_frame=0 +animation/clip_16/end_frame=0 +animation/clip_16/loops=false +animation/clip_17/name="" +animation/clip_17/start_frame=0 +animation/clip_17/end_frame=0 +animation/clip_17/loops=false +animation/clip_18/name="" +animation/clip_18/start_frame=0 +animation/clip_18/end_frame=0 +animation/clip_18/loops=false +animation/clip_19/name="" +animation/clip_19/start_frame=0 +animation/clip_19/end_frame=0 +animation/clip_19/loops=false +animation/clip_20/name="" +animation/clip_20/start_frame=0 +animation/clip_20/end_frame=0 +animation/clip_20/loops=false +animation/clip_21/name="" +animation/clip_21/start_frame=0 +animation/clip_21/end_frame=0 +animation/clip_21/loops=false +animation/clip_22/name="" +animation/clip_22/start_frame=0 +animation/clip_22/end_frame=0 +animation/clip_22/loops=false +animation/clip_23/name="" +animation/clip_23/start_frame=0 +animation/clip_23/end_frame=0 +animation/clip_23/loops=false +animation/clip_24/name="" +animation/clip_24/start_frame=0 +animation/clip_24/end_frame=0 +animation/clip_24/loops=false +animation/clip_25/name="" +animation/clip_25/start_frame=0 +animation/clip_25/end_frame=0 +animation/clip_25/loops=false +animation/clip_26/name="" +animation/clip_26/start_frame=0 +animation/clip_26/end_frame=0 +animation/clip_26/loops=false +animation/clip_27/name="" +animation/clip_27/start_frame=0 +animation/clip_27/end_frame=0 +animation/clip_27/loops=false +animation/clip_28/name="" +animation/clip_28/start_frame=0 +animation/clip_28/end_frame=0 +animation/clip_28/loops=false +animation/clip_29/name="" +animation/clip_29/start_frame=0 +animation/clip_29/end_frame=0 +animation/clip_29/loops=false +animation/clip_30/name="" +animation/clip_30/start_frame=0 +animation/clip_30/end_frame=0 +animation/clip_30/loops=false +animation/clip_31/name="" +animation/clip_31/start_frame=0 +animation/clip_31/end_frame=0 +animation/clip_31/loops=false +animation/clip_32/name="" +animation/clip_32/start_frame=0 +animation/clip_32/end_frame=0 +animation/clip_32/loops=false +animation/clip_33/name="" +animation/clip_33/start_frame=0 +animation/clip_33/end_frame=0 +animation/clip_33/loops=false +animation/clip_34/name="" +animation/clip_34/start_frame=0 +animation/clip_34/end_frame=0 +animation/clip_34/loops=false +animation/clip_35/name="" +animation/clip_35/start_frame=0 +animation/clip_35/end_frame=0 +animation/clip_35/loops=false +animation/clip_36/name="" +animation/clip_36/start_frame=0 +animation/clip_36/end_frame=0 +animation/clip_36/loops=false +animation/clip_37/name="" +animation/clip_37/start_frame=0 +animation/clip_37/end_frame=0 +animation/clip_37/loops=false +animation/clip_38/name="" +animation/clip_38/start_frame=0 +animation/clip_38/end_frame=0 +animation/clip_38/loops=false +animation/clip_39/name="" +animation/clip_39/start_frame=0 +animation/clip_39/end_frame=0 +animation/clip_39/loops=false +animation/clip_40/name="" +animation/clip_40/start_frame=0 +animation/clip_40/end_frame=0 +animation/clip_40/loops=false +animation/clip_41/name="" +animation/clip_41/start_frame=0 +animation/clip_41/end_frame=0 +animation/clip_41/loops=false +animation/clip_42/name="" +animation/clip_42/start_frame=0 +animation/clip_42/end_frame=0 +animation/clip_42/loops=false +animation/clip_43/name="" +animation/clip_43/start_frame=0 +animation/clip_43/end_frame=0 +animation/clip_43/loops=false +animation/clip_44/name="" +animation/clip_44/start_frame=0 +animation/clip_44/end_frame=0 +animation/clip_44/loops=false +animation/clip_45/name="" +animation/clip_45/start_frame=0 +animation/clip_45/end_frame=0 +animation/clip_45/loops=false +animation/clip_46/name="" +animation/clip_46/start_frame=0 +animation/clip_46/end_frame=0 +animation/clip_46/loops=false +animation/clip_47/name="" +animation/clip_47/start_frame=0 +animation/clip_47/end_frame=0 +animation/clip_47/loops=false +animation/clip_48/name="" +animation/clip_48/start_frame=0 +animation/clip_48/end_frame=0 +animation/clip_48/loops=false +animation/clip_49/name="" +animation/clip_49/start_frame=0 +animation/clip_49/end_frame=0 +animation/clip_49/loops=false +animation/clip_50/name="" +animation/clip_50/start_frame=0 +animation/clip_50/end_frame=0 +animation/clip_50/loops=false +animation/clip_51/name="" +animation/clip_51/start_frame=0 +animation/clip_51/end_frame=0 +animation/clip_51/loops=false +animation/clip_52/name="" +animation/clip_52/start_frame=0 +animation/clip_52/end_frame=0 +animation/clip_52/loops=false +animation/clip_53/name="" +animation/clip_53/start_frame=0 +animation/clip_53/end_frame=0 +animation/clip_53/loops=false +animation/clip_54/name="" +animation/clip_54/start_frame=0 +animation/clip_54/end_frame=0 +animation/clip_54/loops=false +animation/clip_55/name="" +animation/clip_55/start_frame=0 +animation/clip_55/end_frame=0 +animation/clip_55/loops=false +animation/clip_56/name="" +animation/clip_56/start_frame=0 +animation/clip_56/end_frame=0 +animation/clip_56/loops=false +animation/clip_57/name="" +animation/clip_57/start_frame=0 +animation/clip_57/end_frame=0 +animation/clip_57/loops=false +animation/clip_58/name="" +animation/clip_58/start_frame=0 +animation/clip_58/end_frame=0 +animation/clip_58/loops=false +animation/clip_59/name="" +animation/clip_59/start_frame=0 +animation/clip_59/end_frame=0 +animation/clip_59/loops=false +animation/clip_60/name="" +animation/clip_60/start_frame=0 +animation/clip_60/end_frame=0 +animation/clip_60/loops=false +animation/clip_61/name="" +animation/clip_61/start_frame=0 +animation/clip_61/end_frame=0 +animation/clip_61/loops=false +animation/clip_62/name="" +animation/clip_62/start_frame=0 +animation/clip_62/end_frame=0 +animation/clip_62/loops=false +animation/clip_63/name="" +animation/clip_63/start_frame=0 +animation/clip_63/end_frame=0 +animation/clip_63/loops=false +animation/clip_64/name="" +animation/clip_64/start_frame=0 +animation/clip_64/end_frame=0 +animation/clip_64/loops=false +animation/clip_65/name="" +animation/clip_65/start_frame=0 +animation/clip_65/end_frame=0 +animation/clip_65/loops=false +animation/clip_66/name="" +animation/clip_66/start_frame=0 +animation/clip_66/end_frame=0 +animation/clip_66/loops=false +animation/clip_67/name="" +animation/clip_67/start_frame=0 +animation/clip_67/end_frame=0 +animation/clip_67/loops=false +animation/clip_68/name="" +animation/clip_68/start_frame=0 +animation/clip_68/end_frame=0 +animation/clip_68/loops=false +animation/clip_69/name="" +animation/clip_69/start_frame=0 +animation/clip_69/end_frame=0 +animation/clip_69/loops=false +animation/clip_70/name="" +animation/clip_70/start_frame=0 +animation/clip_70/end_frame=0 +animation/clip_70/loops=false +animation/clip_71/name="" +animation/clip_71/start_frame=0 +animation/clip_71/end_frame=0 +animation/clip_71/loops=false +animation/clip_72/name="" +animation/clip_72/start_frame=0 +animation/clip_72/end_frame=0 +animation/clip_72/loops=false +animation/clip_73/name="" +animation/clip_73/start_frame=0 +animation/clip_73/end_frame=0 +animation/clip_73/loops=false +animation/clip_74/name="" +animation/clip_74/start_frame=0 +animation/clip_74/end_frame=0 +animation/clip_74/loops=false +animation/clip_75/name="" +animation/clip_75/start_frame=0 +animation/clip_75/end_frame=0 +animation/clip_75/loops=false +animation/clip_76/name="" +animation/clip_76/start_frame=0 +animation/clip_76/end_frame=0 +animation/clip_76/loops=false +animation/clip_77/name="" +animation/clip_77/start_frame=0 +animation/clip_77/end_frame=0 +animation/clip_77/loops=false +animation/clip_78/name="" +animation/clip_78/start_frame=0 +animation/clip_78/end_frame=0 +animation/clip_78/loops=false +animation/clip_79/name="" +animation/clip_79/start_frame=0 +animation/clip_79/end_frame=0 +animation/clip_79/loops=false +animation/clip_80/name="" +animation/clip_80/start_frame=0 +animation/clip_80/end_frame=0 +animation/clip_80/loops=false +animation/clip_81/name="" +animation/clip_81/start_frame=0 +animation/clip_81/end_frame=0 +animation/clip_81/loops=false +animation/clip_82/name="" +animation/clip_82/start_frame=0 +animation/clip_82/end_frame=0 +animation/clip_82/loops=false +animation/clip_83/name="" +animation/clip_83/start_frame=0 +animation/clip_83/end_frame=0 +animation/clip_83/loops=false +animation/clip_84/name="" +animation/clip_84/start_frame=0 +animation/clip_84/end_frame=0 +animation/clip_84/loops=false +animation/clip_85/name="" +animation/clip_85/start_frame=0 +animation/clip_85/end_frame=0 +animation/clip_85/loops=false +animation/clip_86/name="" +animation/clip_86/start_frame=0 +animation/clip_86/end_frame=0 +animation/clip_86/loops=false +animation/clip_87/name="" +animation/clip_87/start_frame=0 +animation/clip_87/end_frame=0 +animation/clip_87/loops=false +animation/clip_88/name="" +animation/clip_88/start_frame=0 +animation/clip_88/end_frame=0 +animation/clip_88/loops=false +animation/clip_89/name="" +animation/clip_89/start_frame=0 +animation/clip_89/end_frame=0 +animation/clip_89/loops=false +animation/clip_90/name="" +animation/clip_90/start_frame=0 +animation/clip_90/end_frame=0 +animation/clip_90/loops=false +animation/clip_91/name="" +animation/clip_91/start_frame=0 +animation/clip_91/end_frame=0 +animation/clip_91/loops=false +animation/clip_92/name="" +animation/clip_92/start_frame=0 +animation/clip_92/end_frame=0 +animation/clip_92/loops=false +animation/clip_93/name="" +animation/clip_93/start_frame=0 +animation/clip_93/end_frame=0 +animation/clip_93/loops=false +animation/clip_94/name="" +animation/clip_94/start_frame=0 +animation/clip_94/end_frame=0 +animation/clip_94/loops=false +animation/clip_95/name="" +animation/clip_95/start_frame=0 +animation/clip_95/end_frame=0 +animation/clip_95/loops=false +animation/clip_96/name="" +animation/clip_96/start_frame=0 +animation/clip_96/end_frame=0 +animation/clip_96/loops=false +animation/clip_97/name="" +animation/clip_97/start_frame=0 +animation/clip_97/end_frame=0 +animation/clip_97/loops=false +animation/clip_98/name="" +animation/clip_98/start_frame=0 +animation/clip_98/end_frame=0 +animation/clip_98/loops=false +animation/clip_99/name="" +animation/clip_99/start_frame=0 +animation/clip_99/end_frame=0 +animation/clip_99/loops=false +animation/clip_100/name="" +animation/clip_100/start_frame=0 +animation/clip_100/end_frame=0 +animation/clip_100/loops=false +animation/clip_101/name="" +animation/clip_101/start_frame=0 +animation/clip_101/end_frame=0 +animation/clip_101/loops=false +animation/clip_102/name="" +animation/clip_102/start_frame=0 +animation/clip_102/end_frame=0 +animation/clip_102/loops=false +animation/clip_103/name="" +animation/clip_103/start_frame=0 +animation/clip_103/end_frame=0 +animation/clip_103/loops=false +animation/clip_104/name="" +animation/clip_104/start_frame=0 +animation/clip_104/end_frame=0 +animation/clip_104/loops=false +animation/clip_105/name="" +animation/clip_105/start_frame=0 +animation/clip_105/end_frame=0 +animation/clip_105/loops=false +animation/clip_106/name="" +animation/clip_106/start_frame=0 +animation/clip_106/end_frame=0 +animation/clip_106/loops=false +animation/clip_107/name="" +animation/clip_107/start_frame=0 +animation/clip_107/end_frame=0 +animation/clip_107/loops=false +animation/clip_108/name="" +animation/clip_108/start_frame=0 +animation/clip_108/end_frame=0 +animation/clip_108/loops=false +animation/clip_109/name="" +animation/clip_109/start_frame=0 +animation/clip_109/end_frame=0 +animation/clip_109/loops=false +animation/clip_110/name="" +animation/clip_110/start_frame=0 +animation/clip_110/end_frame=0 +animation/clip_110/loops=false +animation/clip_111/name="" +animation/clip_111/start_frame=0 +animation/clip_111/end_frame=0 +animation/clip_111/loops=false +animation/clip_112/name="" +animation/clip_112/start_frame=0 +animation/clip_112/end_frame=0 +animation/clip_112/loops=false +animation/clip_113/name="" +animation/clip_113/start_frame=0 +animation/clip_113/end_frame=0 +animation/clip_113/loops=false +animation/clip_114/name="" +animation/clip_114/start_frame=0 +animation/clip_114/end_frame=0 +animation/clip_114/loops=false +animation/clip_115/name="" +animation/clip_115/start_frame=0 +animation/clip_115/end_frame=0 +animation/clip_115/loops=false +animation/clip_116/name="" +animation/clip_116/start_frame=0 +animation/clip_116/end_frame=0 +animation/clip_116/loops=false +animation/clip_117/name="" +animation/clip_117/start_frame=0 +animation/clip_117/end_frame=0 +animation/clip_117/loops=false +animation/clip_118/name="" +animation/clip_118/start_frame=0 +animation/clip_118/end_frame=0 +animation/clip_118/loops=false +animation/clip_119/name="" +animation/clip_119/start_frame=0 +animation/clip_119/end_frame=0 +animation/clip_119/loops=false +animation/clip_120/name="" +animation/clip_120/start_frame=0 +animation/clip_120/end_frame=0 +animation/clip_120/loops=false +animation/clip_121/name="" +animation/clip_121/start_frame=0 +animation/clip_121/end_frame=0 +animation/clip_121/loops=false +animation/clip_122/name="" +animation/clip_122/start_frame=0 +animation/clip_122/end_frame=0 +animation/clip_122/loops=false +animation/clip_123/name="" +animation/clip_123/start_frame=0 +animation/clip_123/end_frame=0 +animation/clip_123/loops=false +animation/clip_124/name="" +animation/clip_124/start_frame=0 +animation/clip_124/end_frame=0 +animation/clip_124/loops=false +animation/clip_125/name="" +animation/clip_125/start_frame=0 +animation/clip_125/end_frame=0 +animation/clip_125/loops=false +animation/clip_126/name="" +animation/clip_126/start_frame=0 +animation/clip_126/end_frame=0 +animation/clip_126/loops=false +animation/clip_127/name="" +animation/clip_127/start_frame=0 +animation/clip_127/end_frame=0 +animation/clip_127/loops=false +animation/clip_128/name="" +animation/clip_128/start_frame=0 +animation/clip_128/end_frame=0 +animation/clip_128/loops=false +animation/clip_129/name="" +animation/clip_129/start_frame=0 +animation/clip_129/end_frame=0 +animation/clip_129/loops=false +animation/clip_130/name="" +animation/clip_130/start_frame=0 +animation/clip_130/end_frame=0 +animation/clip_130/loops=false +animation/clip_131/name="" +animation/clip_131/start_frame=0 +animation/clip_131/end_frame=0 +animation/clip_131/loops=false +animation/clip_132/name="" +animation/clip_132/start_frame=0 +animation/clip_132/end_frame=0 +animation/clip_132/loops=false +animation/clip_133/name="" +animation/clip_133/start_frame=0 +animation/clip_133/end_frame=0 +animation/clip_133/loops=false +animation/clip_134/name="" +animation/clip_134/start_frame=0 +animation/clip_134/end_frame=0 +animation/clip_134/loops=false +animation/clip_135/name="" +animation/clip_135/start_frame=0 +animation/clip_135/end_frame=0 +animation/clip_135/loops=false +animation/clip_136/name="" +animation/clip_136/start_frame=0 +animation/clip_136/end_frame=0 +animation/clip_136/loops=false +animation/clip_137/name="" +animation/clip_137/start_frame=0 +animation/clip_137/end_frame=0 +animation/clip_137/loops=false +animation/clip_138/name="" +animation/clip_138/start_frame=0 +animation/clip_138/end_frame=0 +animation/clip_138/loops=false +animation/clip_139/name="" +animation/clip_139/start_frame=0 +animation/clip_139/end_frame=0 +animation/clip_139/loops=false +animation/clip_140/name="" +animation/clip_140/start_frame=0 +animation/clip_140/end_frame=0 +animation/clip_140/loops=false +animation/clip_141/name="" +animation/clip_141/start_frame=0 +animation/clip_141/end_frame=0 +animation/clip_141/loops=false +animation/clip_142/name="" +animation/clip_142/start_frame=0 +animation/clip_142/end_frame=0 +animation/clip_142/loops=false +animation/clip_143/name="" +animation/clip_143/start_frame=0 +animation/clip_143/end_frame=0 +animation/clip_143/loops=false +animation/clip_144/name="" +animation/clip_144/start_frame=0 +animation/clip_144/end_frame=0 +animation/clip_144/loops=false +animation/clip_145/name="" +animation/clip_145/start_frame=0 +animation/clip_145/end_frame=0 +animation/clip_145/loops=false +animation/clip_146/name="" +animation/clip_146/start_frame=0 +animation/clip_146/end_frame=0 +animation/clip_146/loops=false +animation/clip_147/name="" +animation/clip_147/start_frame=0 +animation/clip_147/end_frame=0 +animation/clip_147/loops=false +animation/clip_148/name="" +animation/clip_148/start_frame=0 +animation/clip_148/end_frame=0 +animation/clip_148/loops=false +animation/clip_149/name="" +animation/clip_149/start_frame=0 +animation/clip_149/end_frame=0 +animation/clip_149/loops=false +animation/clip_150/name="" +animation/clip_150/start_frame=0 +animation/clip_150/end_frame=0 +animation/clip_150/loops=false +animation/clip_151/name="" +animation/clip_151/start_frame=0 +animation/clip_151/end_frame=0 +animation/clip_151/loops=false +animation/clip_152/name="" +animation/clip_152/start_frame=0 +animation/clip_152/end_frame=0 +animation/clip_152/loops=false +animation/clip_153/name="" +animation/clip_153/start_frame=0 +animation/clip_153/end_frame=0 +animation/clip_153/loops=false +animation/clip_154/name="" +animation/clip_154/start_frame=0 +animation/clip_154/end_frame=0 +animation/clip_154/loops=false +animation/clip_155/name="" +animation/clip_155/start_frame=0 +animation/clip_155/end_frame=0 +animation/clip_155/loops=false +animation/clip_156/name="" +animation/clip_156/start_frame=0 +animation/clip_156/end_frame=0 +animation/clip_156/loops=false +animation/clip_157/name="" +animation/clip_157/start_frame=0 +animation/clip_157/end_frame=0 +animation/clip_157/loops=false +animation/clip_158/name="" +animation/clip_158/start_frame=0 +animation/clip_158/end_frame=0 +animation/clip_158/loops=false +animation/clip_159/name="" +animation/clip_159/start_frame=0 +animation/clip_159/end_frame=0 +animation/clip_159/loops=false +animation/clip_160/name="" +animation/clip_160/start_frame=0 +animation/clip_160/end_frame=0 +animation/clip_160/loops=false +animation/clip_161/name="" +animation/clip_161/start_frame=0 +animation/clip_161/end_frame=0 +animation/clip_161/loops=false +animation/clip_162/name="" +animation/clip_162/start_frame=0 +animation/clip_162/end_frame=0 +animation/clip_162/loops=false +animation/clip_163/name="" +animation/clip_163/start_frame=0 +animation/clip_163/end_frame=0 +animation/clip_163/loops=false +animation/clip_164/name="" +animation/clip_164/start_frame=0 +animation/clip_164/end_frame=0 +animation/clip_164/loops=false +animation/clip_165/name="" +animation/clip_165/start_frame=0 +animation/clip_165/end_frame=0 +animation/clip_165/loops=false +animation/clip_166/name="" +animation/clip_166/start_frame=0 +animation/clip_166/end_frame=0 +animation/clip_166/loops=false +animation/clip_167/name="" +animation/clip_167/start_frame=0 +animation/clip_167/end_frame=0 +animation/clip_167/loops=false +animation/clip_168/name="" +animation/clip_168/start_frame=0 +animation/clip_168/end_frame=0 +animation/clip_168/loops=false +animation/clip_169/name="" +animation/clip_169/start_frame=0 +animation/clip_169/end_frame=0 +animation/clip_169/loops=false +animation/clip_170/name="" +animation/clip_170/start_frame=0 +animation/clip_170/end_frame=0 +animation/clip_170/loops=false +animation/clip_171/name="" +animation/clip_171/start_frame=0 +animation/clip_171/end_frame=0 +animation/clip_171/loops=false +animation/clip_172/name="" +animation/clip_172/start_frame=0 +animation/clip_172/end_frame=0 +animation/clip_172/loops=false +animation/clip_173/name="" +animation/clip_173/start_frame=0 +animation/clip_173/end_frame=0 +animation/clip_173/loops=false +animation/clip_174/name="" +animation/clip_174/start_frame=0 +animation/clip_174/end_frame=0 +animation/clip_174/loops=false +animation/clip_175/name="" +animation/clip_175/start_frame=0 +animation/clip_175/end_frame=0 +animation/clip_175/loops=false +animation/clip_176/name="" +animation/clip_176/start_frame=0 +animation/clip_176/end_frame=0 +animation/clip_176/loops=false +animation/clip_177/name="" +animation/clip_177/start_frame=0 +animation/clip_177/end_frame=0 +animation/clip_177/loops=false +animation/clip_178/name="" +animation/clip_178/start_frame=0 +animation/clip_178/end_frame=0 +animation/clip_178/loops=false +animation/clip_179/name="" +animation/clip_179/start_frame=0 +animation/clip_179/end_frame=0 +animation/clip_179/loops=false +animation/clip_180/name="" +animation/clip_180/start_frame=0 +animation/clip_180/end_frame=0 +animation/clip_180/loops=false +animation/clip_181/name="" +animation/clip_181/start_frame=0 +animation/clip_181/end_frame=0 +animation/clip_181/loops=false +animation/clip_182/name="" +animation/clip_182/start_frame=0 +animation/clip_182/end_frame=0 +animation/clip_182/loops=false +animation/clip_183/name="" +animation/clip_183/start_frame=0 +animation/clip_183/end_frame=0 +animation/clip_183/loops=false +animation/clip_184/name="" +animation/clip_184/start_frame=0 +animation/clip_184/end_frame=0 +animation/clip_184/loops=false +animation/clip_185/name="" +animation/clip_185/start_frame=0 +animation/clip_185/end_frame=0 +animation/clip_185/loops=false +animation/clip_186/name="" +animation/clip_186/start_frame=0 +animation/clip_186/end_frame=0 +animation/clip_186/loops=false +animation/clip_187/name="" +animation/clip_187/start_frame=0 +animation/clip_187/end_frame=0 +animation/clip_187/loops=false +animation/clip_188/name="" +animation/clip_188/start_frame=0 +animation/clip_188/end_frame=0 +animation/clip_188/loops=false +animation/clip_189/name="" +animation/clip_189/start_frame=0 +animation/clip_189/end_frame=0 +animation/clip_189/loops=false +animation/clip_190/name="" +animation/clip_190/start_frame=0 +animation/clip_190/end_frame=0 +animation/clip_190/loops=false +animation/clip_191/name="" +animation/clip_191/start_frame=0 +animation/clip_191/end_frame=0 +animation/clip_191/loops=false +animation/clip_192/name="" +animation/clip_192/start_frame=0 +animation/clip_192/end_frame=0 +animation/clip_192/loops=false +animation/clip_193/name="" +animation/clip_193/start_frame=0 +animation/clip_193/end_frame=0 +animation/clip_193/loops=false +animation/clip_194/name="" +animation/clip_194/start_frame=0 +animation/clip_194/end_frame=0 +animation/clip_194/loops=false +animation/clip_195/name="" +animation/clip_195/start_frame=0 +animation/clip_195/end_frame=0 +animation/clip_195/loops=false +animation/clip_196/name="" +animation/clip_196/start_frame=0 +animation/clip_196/end_frame=0 +animation/clip_196/loops=false +animation/clip_197/name="" +animation/clip_197/start_frame=0 +animation/clip_197/end_frame=0 +animation/clip_197/loops=false +animation/clip_198/name="" +animation/clip_198/start_frame=0 +animation/clip_198/end_frame=0 +animation/clip_198/loops=false +animation/clip_199/name="" +animation/clip_199/start_frame=0 +animation/clip_199/end_frame=0 +animation/clip_199/loops=false +animation/clip_200/name="" +animation/clip_200/start_frame=0 +animation/clip_200/end_frame=0 +animation/clip_200/loops=false +animation/clip_201/name="" +animation/clip_201/start_frame=0 +animation/clip_201/end_frame=0 +animation/clip_201/loops=false +animation/clip_202/name="" +animation/clip_202/start_frame=0 +animation/clip_202/end_frame=0 +animation/clip_202/loops=false +animation/clip_203/name="" +animation/clip_203/start_frame=0 +animation/clip_203/end_frame=0 +animation/clip_203/loops=false +animation/clip_204/name="" +animation/clip_204/start_frame=0 +animation/clip_204/end_frame=0 +animation/clip_204/loops=false +animation/clip_205/name="" +animation/clip_205/start_frame=0 +animation/clip_205/end_frame=0 +animation/clip_205/loops=false +animation/clip_206/name="" +animation/clip_206/start_frame=0 +animation/clip_206/end_frame=0 +animation/clip_206/loops=false +animation/clip_207/name="" +animation/clip_207/start_frame=0 +animation/clip_207/end_frame=0 +animation/clip_207/loops=false +animation/clip_208/name="" +animation/clip_208/start_frame=0 +animation/clip_208/end_frame=0 +animation/clip_208/loops=false +animation/clip_209/name="" +animation/clip_209/start_frame=0 +animation/clip_209/end_frame=0 +animation/clip_209/loops=false +animation/clip_210/name="" +animation/clip_210/start_frame=0 +animation/clip_210/end_frame=0 +animation/clip_210/loops=false +animation/clip_211/name="" +animation/clip_211/start_frame=0 +animation/clip_211/end_frame=0 +animation/clip_211/loops=false +animation/clip_212/name="" +animation/clip_212/start_frame=0 +animation/clip_212/end_frame=0 +animation/clip_212/loops=false +animation/clip_213/name="" +animation/clip_213/start_frame=0 +animation/clip_213/end_frame=0 +animation/clip_213/loops=false +animation/clip_214/name="" +animation/clip_214/start_frame=0 +animation/clip_214/end_frame=0 +animation/clip_214/loops=false +animation/clip_215/name="" +animation/clip_215/start_frame=0 +animation/clip_215/end_frame=0 +animation/clip_215/loops=false +animation/clip_216/name="" +animation/clip_216/start_frame=0 +animation/clip_216/end_frame=0 +animation/clip_216/loops=false +animation/clip_217/name="" +animation/clip_217/start_frame=0 +animation/clip_217/end_frame=0 +animation/clip_217/loops=false +animation/clip_218/name="" +animation/clip_218/start_frame=0 +animation/clip_218/end_frame=0 +animation/clip_218/loops=false +animation/clip_219/name="" +animation/clip_219/start_frame=0 +animation/clip_219/end_frame=0 +animation/clip_219/loops=false +animation/clip_220/name="" +animation/clip_220/start_frame=0 +animation/clip_220/end_frame=0 +animation/clip_220/loops=false +animation/clip_221/name="" +animation/clip_221/start_frame=0 +animation/clip_221/end_frame=0 +animation/clip_221/loops=false +animation/clip_222/name="" +animation/clip_222/start_frame=0 +animation/clip_222/end_frame=0 +animation/clip_222/loops=false +animation/clip_223/name="" +animation/clip_223/start_frame=0 +animation/clip_223/end_frame=0 +animation/clip_223/loops=false +animation/clip_224/name="" +animation/clip_224/start_frame=0 +animation/clip_224/end_frame=0 +animation/clip_224/loops=false +animation/clip_225/name="" +animation/clip_225/start_frame=0 +animation/clip_225/end_frame=0 +animation/clip_225/loops=false +animation/clip_226/name="" +animation/clip_226/start_frame=0 +animation/clip_226/end_frame=0 +animation/clip_226/loops=false +animation/clip_227/name="" +animation/clip_227/start_frame=0 +animation/clip_227/end_frame=0 +animation/clip_227/loops=false +animation/clip_228/name="" +animation/clip_228/start_frame=0 +animation/clip_228/end_frame=0 +animation/clip_228/loops=false +animation/clip_229/name="" +animation/clip_229/start_frame=0 +animation/clip_229/end_frame=0 +animation/clip_229/loops=false +animation/clip_230/name="" +animation/clip_230/start_frame=0 +animation/clip_230/end_frame=0 +animation/clip_230/loops=false +animation/clip_231/name="" +animation/clip_231/start_frame=0 +animation/clip_231/end_frame=0 +animation/clip_231/loops=false +animation/clip_232/name="" +animation/clip_232/start_frame=0 +animation/clip_232/end_frame=0 +animation/clip_232/loops=false +animation/clip_233/name="" +animation/clip_233/start_frame=0 +animation/clip_233/end_frame=0 +animation/clip_233/loops=false +animation/clip_234/name="" +animation/clip_234/start_frame=0 +animation/clip_234/end_frame=0 +animation/clip_234/loops=false +animation/clip_235/name="" +animation/clip_235/start_frame=0 +animation/clip_235/end_frame=0 +animation/clip_235/loops=false +animation/clip_236/name="" +animation/clip_236/start_frame=0 +animation/clip_236/end_frame=0 +animation/clip_236/loops=false +animation/clip_237/name="" +animation/clip_237/start_frame=0 +animation/clip_237/end_frame=0 +animation/clip_237/loops=false +animation/clip_238/name="" +animation/clip_238/start_frame=0 +animation/clip_238/end_frame=0 +animation/clip_238/loops=false +animation/clip_239/name="" +animation/clip_239/start_frame=0 +animation/clip_239/end_frame=0 +animation/clip_239/loops=false +animation/clip_240/name="" +animation/clip_240/start_frame=0 +animation/clip_240/end_frame=0 +animation/clip_240/loops=false +animation/clip_241/name="" +animation/clip_241/start_frame=0 +animation/clip_241/end_frame=0 +animation/clip_241/loops=false +animation/clip_242/name="" +animation/clip_242/start_frame=0 +animation/clip_242/end_frame=0 +animation/clip_242/loops=false +animation/clip_243/name="" +animation/clip_243/start_frame=0 +animation/clip_243/end_frame=0 +animation/clip_243/loops=false +animation/clip_244/name="" +animation/clip_244/start_frame=0 +animation/clip_244/end_frame=0 +animation/clip_244/loops=false +animation/clip_245/name="" +animation/clip_245/start_frame=0 +animation/clip_245/end_frame=0 +animation/clip_245/loops=false +animation/clip_246/name="" +animation/clip_246/start_frame=0 +animation/clip_246/end_frame=0 +animation/clip_246/loops=false +animation/clip_247/name="" +animation/clip_247/start_frame=0 +animation/clip_247/end_frame=0 +animation/clip_247/loops=false +animation/clip_248/name="" +animation/clip_248/start_frame=0 +animation/clip_248/end_frame=0 +animation/clip_248/loops=false +animation/clip_249/name="" +animation/clip_249/start_frame=0 +animation/clip_249/end_frame=0 +animation/clip_249/loops=false +animation/clip_250/name="" +animation/clip_250/start_frame=0 +animation/clip_250/end_frame=0 +animation/clip_250/loops=false +animation/clip_251/name="" +animation/clip_251/start_frame=0 +animation/clip_251/end_frame=0 +animation/clip_251/loops=false +animation/clip_252/name="" +animation/clip_252/start_frame=0 +animation/clip_252/end_frame=0 +animation/clip_252/loops=false +animation/clip_253/name="" +animation/clip_253/start_frame=0 +animation/clip_253/end_frame=0 +animation/clip_253/loops=false +animation/clip_254/name="" +animation/clip_254/start_frame=0 +animation/clip_254/end_frame=0 +animation/clip_254/loops=false +animation/clip_255/name="" +animation/clip_255/start_frame=0 +animation/clip_255/end_frame=0 +animation/clip_255/loops=false +animation/clip_256/name="" +animation/clip_256/start_frame=0 +animation/clip_256/end_frame=0 +animation/clip_256/loops=false diff --git a/godot/astream/road/road-lanes_road-lane-center.mesh b/godot/astream/road/road-lanes_road-lane-center.mesh new file mode 100644 index 0000000..67e3e16 Binary files /dev/null and b/godot/astream/road/road-lanes_road-lane-center.mesh differ diff --git a/godot/astream/road/road-lanes_road-lane-mid.mesh b/godot/astream/road/road-lanes_road-lane-mid.mesh new file mode 100644 index 0000000..66dc51e Binary files /dev/null and b/godot/astream/road/road-lanes_road-lane-mid.mesh differ diff --git a/godot/astream/road/road-lanes_road-sidewalk.mesh b/godot/astream/road/road-lanes_road-sidewalk.mesh new file mode 100644 index 0000000..fb8e06e Binary files /dev/null and b/godot/astream/road/road-lanes_road-sidewalk.mesh differ diff --git a/godot/astream/road/road-material.material b/godot/astream/road/road-material.material new file mode 100644 index 0000000..ee57f6e Binary files /dev/null and b/godot/astream/road/road-material.material differ diff --git a/godot/astream/road/road.png b/godot/astream/road/road.png new file mode 100644 index 0000000..061d261 Binary files /dev/null and b/godot/astream/road/road.png differ diff --git a/godot/astream/road/road.png.import b/godot/astream/road/road.png.import new file mode 100644 index 0000000..e0a91d3 --- /dev/null +++ b/godot/astream/road/road.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/road.png-fffb0f4010c0e3e4e2d8a7ecd084e72d.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://astream/road/road.png" +dest_files=[ "res://.import/road.png-fffb0f4010c0e3e4e2d8a7ecd084e72d.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 diff --git a/godot/config/stream.conf b/godot/config/stream.conf index 1f21bbe..fa85c08 100644 --- a/godot/config/stream.conf +++ b/godot/config/stream.conf @@ -45,3 +45,6 @@ tile_size = 128 view_distance = 2 [road] road_lines_path = "res://astream/road_lines.json" +center_mesh = "res://astream/road/road-lanes_road-lane-center.mesh" +mid_mesh = "res://astream/road/road-lanes_road-lane-mid.mesh" +sidewalk_mesh = "res://astream/road/road-lanes_road-sidewalk.mesh" diff --git a/kanpilot.toml b/kanpilot.toml new file mode 100644 index 0000000..0e0b40c --- /dev/null +++ b/kanpilot.toml @@ -0,0 +1,39 @@ +name = "project" +skipFolders = [ "node_modules", ".vscode", "out", "dist", ".vscode-test" ] +skipFiles = [ ".gitignore", "package.json" ] + +[[processes]] +id = "jpfqu4wnok04vkg1ojnhwl25" +name = "Todo" + + [[processes.tasks]] + id = "q57b8pyb97wzlahuaxjttlan" + title = "Fix nodes close to edges" + description = "Check that node is too close to edge and split it" + tag = "backlog" + linkFiles = [ ] + dueDate = "" + checkList = [ ] + priority = "" + linkCommits = [ ] + + [[processes.tasks]] + id = "xnxan65j063qs2wrvcquo8fc" + title = "Create building editing and road editing commands" + description = "Create building editing and road editing commands" + tag = "backlog" + linkFiles = [ ] + dueDate = "" + checkList = [ ] + priority = "" + linkCommits = [ ] + +[[processes]] +id = "process2" +name = "In Progress" +tasks = [ ] + +[[processes]] +id = "process3" +name = "Done" +tasks = [ ] diff --git a/src/godot b/src/godot index 5bdad32..0dcab10 160000 --- a/src/godot +++ b/src/godot @@ -1 +1 @@ -Subproject commit 5bdad327c0f328a7db5286e7589fac0e8baec180 +Subproject commit 0dcab10b410f73460de47ba4dea2c7290a0aab1a diff --git a/src/modules/stream/register_types.cpp b/src/modules/stream/register_types.cpp index e33a2d9..28cf8b6 100644 --- a/src/modules/stream/register_types.cpp +++ b/src/modules/stream/register_types.cpp @@ -1,5 +1,6 @@ #include "register_types.h" #include "stream.h" +#include "road_debug.h" void register_stream_types() { @@ -9,4 +10,5 @@ void register_stream_types() void unregister_stream_types() { + StreamWorld::cleanup(); } diff --git a/src/modules/stream/road_debug.cpp b/src/modules/stream/road_debug.cpp new file mode 100644 index 0000000..1fe80c0 --- /dev/null +++ b/src/modules/stream/road_debug.cpp @@ -0,0 +1,26 @@ +#include "road_debug.h" + +AABB RoadDebug::get_aabb() const +{ + return aabb; +} +PoolVector RoadDebug::get_faces(uint32_t p_usage_flags) const +{ + return PoolVector(); +} +RoadDebug::RoadDebug() +{ + imm = VisualServer::get_singleton()->immediate_create(); + set_base(imm); + material.instance(); + material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, + true); + material->set_flag(SpatialMaterial::FLAG_DISABLE_DEPTH_TEST, true); + material->set_flag(SpatialMaterial::FLAG_UNSHADED, true); + VisualServer::get_singleton()->immediate_set_material( + imm, material->get_rid()); +} +RoadDebug::~RoadDebug() +{ + VisualServer::get_singleton()->free(imm); +} \ No newline at end of file diff --git a/src/modules/stream/road_debug.h b/src/modules/stream/road_debug.h new file mode 100644 index 0000000..3fe39a6 --- /dev/null +++ b/src/modules/stream/road_debug.h @@ -0,0 +1,18 @@ +#ifndef ROAD_DEBUG_H_ +#define ROAD_DEBUG_H_ +#include +class RoadDebug : public VisualInstance { + GDCLASS(RoadDebug, VisualInstance) +protected: + RID imm; + Ref material; + void _notification(int which); + AABB aabb; + +public: + RoadDebug(); + ~RoadDebug(); + virtual AABB get_aabb() const; + virtual PoolVector get_faces(uint32_t p_usage_flags) const; +}; +#endif \ No newline at end of file diff --git a/src/modules/stream/road_processing.cpp b/src/modules/stream/road_processing.cpp new file mode 100644 index 0000000..5192bb4 --- /dev/null +++ b/src/modules/stream/road_processing.cpp @@ -0,0 +1,1099 @@ +#undef NDEBUG +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "from_string.h" +#include "road_debug.h" +#include "road_processing.h" + +struct wedge { + Vector3 p[3]; + Vector3 y[3]; + int width1, width2; +}; + +struct RoadLinesProcessing { + struct road_line { + std::vector points; + std::vector indices; + int lanes; + int flags; + }; + HashMap road_lines; + std::vector nodes; + struct edgedata { + std::vector neighbors; + }; + std::unordered_map edges; + std::unordered_map > wedges; + String road_center_mesh_path, road_mid_mesh_path, + road_sidewalk_mesh_path; + static struct RoadLinesProcessing *singleton; + static RoadLinesProcessing *get_singleton() + { + if (!singleton) + singleton = memnew(RoadLinesProcessing); + return singleton; + } + RoadLinesProcessing() + { + singleton = this; + } + + uint32_t road_lines_hash(const Vector3 &v) + { + int x = (int)(v.x / 100); + int y = (int)(v.y / 100); + int z = (int)(v.z / 100); + return x ^ (y * 100) ^ (z * 10000); + } + void create_segments(const String &road, std::vector &segments) + { + int i; + for (i = 0; i < (int)road_lines[road].indices.size() - 1; i++) { + int idx1 = road_lines[road].indices[i]; + int idx2 = road_lines[road].indices[i + 1]; + segments.push_back(idx1); + segments.push_back(idx2); + segments.push_back(i + 1); + } + } + + void road_lines_curve_index( + struct road_line &rline, + std::unordered_map > + &road_lines_nodes_hash, + std::vector &road_lines_nodes) + { + int i, j; + rline.indices.clear(); + for (i = 0; i < (int)rline.points.size(); i++) { + Vector3 pt = rline.points[i].origin; + int pt_hash = road_lines_hash(pt); + if (road_lines_nodes_hash.find(pt_hash) != + road_lines_nodes_hash.end()) { + bool ok = true; + for (j = 0; + j < + (int)road_lines_nodes_hash[pt_hash].size(); + j++) { + const Vector3 &xpt = + road_lines_nodes_hash[pt_hash] + [j]; + if (xpt.distance_squared_to(pt) < 160) { + ok = false; + pt = xpt; + break; + } + } + if (ok) { + road_lines_nodes_hash[pt_hash].push_back( + pt); + road_lines_nodes.push_back(pt); + } + } else { + road_lines_nodes.push_back(pt); + road_lines_nodes_hash[pt_hash] = { pt }; + } + std::vector::iterator it = + std::find(road_lines_nodes.begin(), + road_lines_nodes.end(), pt); + assert(it != road_lines_nodes.end()); + int index = it - road_lines_nodes.begin(); + rline.indices.push_back(index); + } + } + void index_lines(std::unordered_map > + &road_lines_nodes_hash, + std::vector &road_lines_nodes) + { + List keys; + road_lines.get_key_list(&keys); + List::Element *e = keys.front(); + while (e) { + String rkey = e->get(); + struct road_line &pt = road_lines[rkey]; + pt.indices.clear(); + e = e->next(); + } + e = keys.front(); + while (e) { + String rkey = e->get(); + struct road_line &pt = road_lines[rkey]; + road_lines_curve_index(pt, road_lines_nodes_hash, + road_lines_nodes); + e = e->next(); + } + } + /* add close points on each line to the line */ + void insert_close_points(std::vector &road_lines_nodes) + { + int i; + List keys; + road_lines.get_key_list(&keys); + List::Element *e = keys.front(); + for (i = 0; i < (int)road_lines_nodes.size(); i++) { + int idx3 = i; + while (e) { + int j; + std::vector segments; + String rkey = e->get(); + create_segments(rkey, segments); + for (j = 0; j < (int)segments.size(); j += 3) { + int idx1 = segments[j]; + int idx2 = segments[j + 1]; + int idx = segments[j + 2]; + /* Skip segment point */ + if (idx3 == idx1 || idx3 == idx2) + continue; + Vector3 p1 = road_lines_nodes[idx1]; + Vector3 p2 = road_lines_nodes[idx2]; + Vector3 p3 = road_lines_nodes[idx3]; + std::vector seg = { p1, p2 }; + Vector3 closest = Geometry:: + get_closest_point_to_segment( + p3, seg.data()); + if (p3.distance_squared_to(closest) < + 160) { + road_lines_nodes[idx3] = + closest; + road_lines[rkey].indices.insert( + road_lines[rkey].indices + .begin() + + idx, + idx3); + } + } + e = e->next(); + } + } + } + void update_road_lines_nodes(std::vector &road_lines_nodes) + { + List keys; + + road_lines.get_key_list(&keys); + std::unordered_map > kcmp; + { + List::Element *k = keys.front(); + List::Element *r = keys.front(); + while (k) { + String kkey = k->get(); + uint32_t kkey_hash = kkey.hash(); + while (r) { + String rkey = r->get(); + uint32_t rkey_hash = rkey.hash(); + uint32_t key = kkey_hash ^ rkey_hash; + uint32_t key2 = rkey_hash ^ kkey_hash; + if (kcmp.find(key) == kcmp.end() && + kcmp.find(key2) == kcmp.end()) + kcmp[key] = std::make_tuple( + k->get(), r->get()); + r = r->next(); + } + k = k->next(); + } + } + using checks_tuple = + std::tuple; + std::unordered_map checks; + std::unordered_map::iterator checks_it; + std::unordered_map >::iterator it; + for (it = kcmp.begin(); it != kcmp.end(); it++) { + int i, j; + std::tuple data = kcmp[it->first]; + const String &k = std::get<0>(data); + const String &r = std::get<1>(data); + if (road_lines[k].indices.size() < 2) + continue; + if (road_lines[r].indices.size() < 2) + continue; + for (i = 0; i < (int)road_lines[k].indices.size() - 1; + i++) { + for (j = 0; + j < (int)road_lines[k].indices.size() - 1; + j++) { + uint32_t key = k.hash() ^ i ^ r.hash() ^ + j ^ 2147483137; + uint32_t key2 = r.hash() ^ j ^ + k.hash() ^ i ^ + 2147463167; + if (checks.find(key) == checks.end() && + checks.find(key2) == checks.end()) { + int idx_a1 = + road_lines[k].indices[i]; + int idx_a2 = + road_lines[k] + .indices[i + 1]; + int idx_b1 = + road_lines[k].indices[j]; + int idx_b2 = + road_lines[k] + .indices[j + 1]; + std::vector cmp1 = { + idx_a1, idx_a2 + }; + if (std::find(cmp1.begin(), + cmp1.end(), + idx_b1) != + cmp1.end()) + continue; + if (std::find(cmp1.begin(), + cmp1.end(), + idx_b2) != + cmp1.end()) + continue; + checks[key] = std::make_tuple( + k, i, idx_a1, idx_a2, r, + j, idx_b1, idx_b2); + } + } + } + } + /* + for ch in checks.values(): + var k = ch[0] + var i1 = ch[1] + var idx_a1 = ch[2] + var idx_a2 = ch[3] + var r = ch[4] + var j1 = ch[5] + var idx_b1 = ch[6] + var idx_b2 = ch[7] + var p_a1 = road_lines_nodes[idx_a1] + var p_a2 = road_lines_nodes[idx_a2] + var p_b1 = road_lines_nodes[idx_b1] + var p_b2 = road_lines_nodes[idx_b2] + var px = Geometry.get_closest_points_between_segments(p_a1, p_a2, p_b1, p_b2) + var d = px[0].distance_squared_to(px[1]) + if d < 160: + var pxt = px[0].linear_interpolate(px[1], 0.5) + var nidx = road_lines_nodes.size() + road_lines_nodes.push_back(pxt) + var il = road_lines[k].indices.size() + assert(!nidx in road_lines[k].indices) + assert(!nidx in road_lines[r].indices) + road_lines[k].indices.insert(i1 + 1, nidx) + road_lines[r].indices.insert(j1 + 1, nidx) +##end + */ + for (checks_it = checks.begin(); checks_it != checks.end(); + checks_it++) { + String k = std::get<0>(checks_it->second); + int i = std::get<1>(checks_it->second); + int idx_a1 = std::get<2>(checks_it->second); + int idx_a2 = std::get<3>(checks_it->second); + String r = std::get<4>(checks_it->second); + int j = std::get<5>(checks_it->second); + int idx_b1 = std::get<6>(checks_it->second); + int idx_b2 = std::get<7>(checks_it->second); + Vector3 p_a1 = road_lines_nodes[idx_a1]; + Vector3 p_a2 = road_lines_nodes[idx_a2]; + Vector3 p_b1 = road_lines_nodes[idx_b1]; + Vector3 p_b2 = road_lines_nodes[idx_b2]; + Vector3 px, px2; + Geometry::get_closest_points_between_segments( + p_a1, p_a2, p_b1, p_b2, px, px2); + float d = px.distance_squared_to(px2); + if (d < 160) { + Vector3 pxt = px.linear_interpolate(px2, 0.5f); + int nidx = road_lines_nodes.size(); + road_lines_nodes.push_back(pxt); + // int il = (int)road_lines[k].indices.size(); + assert(std::find(road_lines[k].indices.begin(), + road_lines[k].indices.end(), + nidx) == + road_lines[k].indices.end()); + assert(std::find(road_lines[r].indices.begin(), + road_lines[r].indices.end(), + nidx) == + road_lines[r].indices.end()); + road_lines[k].indices.insert( + road_lines[k].indices.begin() + i + 1, + nidx); + road_lines[r].indices.insert( + road_lines[k].indices.begin() + j + 1, + nidx); + } + } + } + void create_nodes(const std::vector &road_lines_nodes) + { + nodes.resize(road_lines_nodes.size()); + memcpy(nodes.data(), road_lines_nodes.data(), + sizeof(Vector3) * road_lines_nodes.size()); + } + void create_edges() + { + int i; + List keys; + road_lines.get_key_list(&keys); + List::Element *e = keys.front(); + while (e) { + const String &key = e->get(); + if (road_lines[key].indices.size() < 2) { + e = e->next(); + continue; + } + for (i = 0; i < (int)road_lines[key].indices.size() - 1; + i++) { + int idx1 = road_lines[key].indices[i]; + int idx2 = road_lines[key].indices[i + 1]; + if (edges.find(idx1) == edges.end()) { + struct edgedata ed; + ed.neighbors.clear(); + edges[idx1] = ed; + } + if (edges.find(idx2) == edges.end()) { + struct edgedata ed; + ed.neighbors.clear(); + edges[idx2] = ed; + } + if (std::find(edges[idx1].neighbors.begin(), + edges[idx1].neighbors.end(), + idx2) == + edges[idx1].neighbors.end()) + edges[idx1].neighbors.push_back(idx2); + if (std::find(edges[idx2].neighbors.begin(), + edges[idx2].neighbors.end(), + idx1) == + edges[idx2].neighbors.end()) + edges[idx2].neighbors.push_back(idx1); + } + e = e->next(); + } + for (i = 0; i < (int)nodes.size(); i++) { + std::sort( + edges[i].neighbors.begin(), + edges[i].neighbors.end(), + [i, this](int a, int b) { + Vector3 na = nodes[a]; + Vector3 nb = nodes[b]; + Vector3 root = nodes[i]; + Vector3 xa = na - root; + Vector3 xb = nb - root; + float a1 = Vector2(xa.x, xa.z).angle(); + float a2 = Vector2(xb.x, xb.z).angle(); + return a1 < a2; + }); + } + } + Vector3 tangent(const Vector3 &v) + { + Vector2 rv = Vector2(v.x, v.z).tangent(); + return Vector3(rv.x, v.y, rv.y); + } + Vector3 normal(const Vector3 &v) + { + Vector3 rv = tangent(v); + rv.y = 0.0f; + return rv.normalized(); + } + + void build_wedges( + std::unordered_map > &wedges) + { + int i; + float road_side_width = 3.0f; + std::vector neighbors; + for (i = 0; i < (int)nodes.size(); i++) { + const Vector3 &node = nodes[i]; + Vector3 fkey = node; + fkey.y = 0.0f; + uint32_t key = (int)fkey.x ^ ((int)fkey.z * 10); + if (wedges.find(key) == wedges.end()) + wedges[key] = {}; + int j; + neighbors.resize(edges[i].neighbors.size()); + for (j = 0; j < (int)edges[i].neighbors.size(); j++) + neighbors[j] = nodes[edges[i].neighbors[j]]; + for (j = 0; j < (int)edges[i].neighbors.size(); j++) { + if (edges[i].neighbors.size() == 0) + continue; + int onext = (j + 1) % edges[i].neighbors.size(); + Vector3 n1 = normal(node - neighbors[j]); + Vector3 n2 = normal(neighbors[onext] - node); + Vector3 a0 = (neighbors[j] - node) * 0.5 + + node + n1 * 3.0f; + Vector3 a1 = node + n1 * road_side_width; + Vector3 b0 = node + n2 * road_side_width; + Vector3 b1 = (neighbors[onext] - node) * 0.5 + + node + n2 * 3.0f; + Vector3 q, r; + Geometry::get_closest_points_between_segments( + a0, a1, b0, b1, q, r); + Vector3 pr; + if (Vector2(q.x, q.z).distance_squared_to( + Vector2(r.x, r.z)) < 0.001f) + pr = q.linear_interpolate(r, 0.5f); + else + pr = node + n1 * road_side_width; + Vector3 o1 = (neighbors[j] - node) * 0.5 + node; + Vector3 o2 = node, + o3 = (neighbors[onext] - node) * 0.5 + + node; + struct wedge w; + w.p[0] = a0; + w.p[1] = pr; + w.p[2] = b1; + w.y[0] = o1; + w.y[1] = o2; + w.y[2] = o3; + w.width1 = 2.0f * 5.0f; + w.width2 = 2.0f * 5.0f; + wedges[i].push_back(w); + } + } + } + void dump_lines(const std::vector &road_lines_nodes) + { + int i; + List keys; + road_lines.get_key_list(&keys); + List::Element *e = keys.front(); + while (e) { + String rkey = e->get(); + struct road_line &pt = road_lines[rkey]; + String outline = rkey + ": "; + for (i = 0; i < (int)pt.indices.size(); i++) { + outline += " " + itos(pt.indices[i]); + } + for (i = 0; i < (int)pt.indices.size(); i++) { + outline += + " " + (road_lines_nodes[pt.indices[i]] + .operator String()); + } + e = e->next(); + } + } + ~RoadLinesProcessing() + { + } + static void cleanup() + { + if (singleton) { + memfree(singleton); + singleton = nullptr; + } + } + void road_setup(Node *base); + void read_road_lines_json(const String &road_lines_path); +}; +void RoadLinesProcessing::road_setup(Node *base) +{ + std::vector road_lines_nodes; + std::unordered_map > + road_lines_nodes_hash; + road_lines_nodes.clear(); + road_lines_nodes_hash.clear(); + index_lines(road_lines_nodes_hash, road_lines_nodes); + insert_close_points(road_lines_nodes); + update_road_lines_nodes(road_lines_nodes); + dump_lines(road_lines_nodes); + create_nodes(road_lines_nodes); + create_edges(); + build_wedges(wedges); + print_line("ROAD SETUP DONE"); +} +void RoadLinesProcessing::read_road_lines_json(const String &road_lines_path) +{ + int i; + String road_lines_json = + FileAccess::get_file_as_string(road_lines_path); + Variant json_v; + String es; + int eline; + Error status = JSON::parse(road_lines_json, json_v, es, eline); + ERR_FAIL_COND_MSG(status != OK, "Can't parse json: " + es + + " at line: " + itos(eline)); + + Dictionary json = json_v; + List keys; + json.get_key_list(&keys); + List::Element *e = keys.front(); + while (e) { + String key = e->get(); + if (!key.ends_with("_road")) { + e = e->next(); + continue; + } + struct road_line rline; + Array points = json[key].get("points"); + Array indices = json[key].get("indices"); + int lanes = json[key].get("lanes"); + rline.points.resize(points.size()); + rline.indices.resize(indices.size()); + for (i = 0; i < (int)points.size(); i++) { + String point_s = points[i]; + rline.points[i] = from_string(point_s); + } + for (i = 0; i < (int)indices.size(); i++) { + int index = indices[i]; + rline.indices[i] = index; + } + // TODO: wtf is flags? + rline.lanes = lanes; + road_lines[key] = rline; + e = e->next(); + } +} + +RoadLinesProcessing *RoadLinesProcessing::singleton; + +class RoadMeshProcessing { + struct mesh_data { + Vector > materials; + Vector arrays; + Ref create_mesh() + { + Ref mesh; + mesh.instance(); + int i; + for (i = 0; i < arrays.size(); i++) { + mesh->add_surface_from_arrays( + Mesh::PRIMITIVE_TRIANGLES, arrays[i]); + mesh->surface_set_material(i, materials[i]); + return mesh; + } + } + }; + HashMap road_meshes; + +public: + void load_road_mesh(const String &category, const String &name, + const String &path) + { + Error err; + int i; + Ref mesh = + ResourceLoader::load(path, "ArrayMesh", true, &err); + ERR_FAIL_COND_MSG(err != OK, "Failed to load: " + path); + struct mesh_data md; + int count = mesh->get_surface_count(); + md.materials.resize(count); + md.arrays.resize(count); + for (i = 0; i < count; i++) { + Ref mat = mesh->surface_get_material(i); + Array surfaces = mesh->surface_get_arrays(i); + md.materials.write[i] = mat; + md.arrays.write[i] = surfaces.duplicate(); + } + road_meshes[category + "/" + name] = md; + } + struct wedge_paths { + Vector3 path1[3]; + Vector3 path2[3]; + }; + void get_paths(struct wedge_paths &paths, const struct wedge &w) + { + Vector3 p1 = w.y[0] - w.y[1]; + Vector3 p2 = Vector3(); + Vector3 p3 = w.y[2] - w.y[1]; + Vector3 p1a = w.p[0] - w.y[1]; + Vector3 p2a = w.p[1] - w.y[1]; + Vector3 p3a = w.p[2] - w.y[1]; + paths.path1[0] = p1; + paths.path1[1] = p2; + paths.path1[2] = p3; + paths.path2[0] = p1a; + paths.path2[1] = p2a; + paths.path2[2] = p3a; + } + struct lane { + Vector3 p[3]; + String use_mesh; + Transform xform1, xform2; + Transform xform_m1, xform_m2; + float l_seg1[3]; + float l_seg2[3]; + }; + void build_segment(const Transform &xform1, const Transform xform2, + float l0, float l1, const Array &arrays, + Array &out_arrays) + { + PoolVector vertices = + arrays[ArrayMesh::ARRAY_VERTEX].duplicate(); + PoolVector normals = + arrays[ArrayMesh::ARRAY_NORMAL].duplicate(); + PoolVector tangents = + arrays[ArrayMesh::ARRAY_TANGENT].duplicate(); + PoolVector uvs = + arrays[ArrayMesh::ARRAY_TEX_UV].duplicate(); + PoolVector indices = + arrays[ArrayMesh::ARRAY_INDEX].duplicate(); + float dlen = xform1.origin.distance_to(xform2.origin); + int id; + for (id = 0; id < vertices.size(); id++) { + Vector3 p = vertices[id]; + Vector3 n = normals[id]; + Vector2 uv = uvs[id]; + if (p.z < -0.3f) { + // p.z = -dlen; + /* second segment */ + p.z = 0.0f; + p.x *= l1; + uv.y *= dlen; + p = xform2.xform(p); + n = Transform(xform2.basis, Vector3()).xform(n); + } else { + uv.y *= dlen; + p.z = 0; + // p.z = 0; + p.x *= l0; + p = xform1.xform(p); + n = Transform(xform1.basis, Vector3()).xform(n); + } + vertices.write()[id] = p; + normals.write()[id] = n; + uvs.write()[id] = uv; + } +#if 0 + for (i = 0; i < arrays.size(); i++) + out_arrays[i] = arrays[i]; + out_arrays[ArrayMesh::ARRAY_VERTEX] = vertices; + /* normals are bad */ + out_arrays[ArrayMesh::ARRAY_NORMAL] = normals; + out_arrays[ArrayMesh::ARRAY_TEX_UV] = uvs; + return; +#endif + PoolVector out_index; + out_index.resize(indices.size()); + assert(out_arrays.size() >= ArrayMesh::ARRAY_MAX); + PoolVector tg = out_arrays[ArrayMesh::ARRAY_TANGENT]; + tg.append_array(tangents); + out_arrays[ArrayMesh::ARRAY_TANGENT] = tg; + + PoolVector out_vertices_orig = + out_arrays[ArrayMesh::ARRAY_VERTEX]; + int index_offset = out_vertices_orig.size(); + out_vertices_orig.append_array(vertices); + out_arrays[ArrayMesh::ARRAY_VERTEX] = out_vertices_orig; + + PoolVector out_normals_orig = + out_arrays[ArrayMesh::ARRAY_NORMAL]; + out_normals_orig.append_array(normals); + out_arrays[ArrayMesh::ARRAY_NORMAL] = out_normals_orig; + + PoolVector out_uvs_orig = + out_arrays[ArrayMesh::ARRAY_TEX_UV]; + out_uvs_orig.append_array(uvs); + out_arrays[ArrayMesh::ARRAY_TEX_UV] = out_uvs_orig; + for (id = 0; id < indices.size(); id++) + out_index.write()[id] = indices[id] + index_offset; + + PoolVector out_index_orig = + out_arrays[ArrayMesh::ARRAY_INDEX]; + out_index_orig.append_array(out_index); + out_arrays[ArrayMesh::ARRAY_INDEX] = out_index_orig; + // out_arrays[ArrayMesh::ARRAY_INDEX] = indices; + } + + void init_surface(Array &surface) + { + surface.resize(ArrayMesh::ARRAY_MAX); + surface[ArrayMesh::ARRAY_VERTEX] = PoolVector(); + surface[ArrayMesh::ARRAY_NORMAL] = PoolVector(); + surface[ArrayMesh::ARRAY_TANGENT] = PoolVector(); + surface[ArrayMesh::ARRAY_TEX_UV] = PoolVector(); + surface[ArrayMesh::ARRAY_INDEX] = PoolVector(); + } + struct lane_params { + Vector3 xp1, xp2, xp3; + Vector3 xp1a, xp2a, xp3a; + Vector3 edge1, edge2, edge3; + Vector3 dir1, dir2; + float l1, l2, l3; + int nlanes, nlanes1, nlanes2; + String center, mid, edge; + lane_params(const struct wedge &wedge, + struct wedge_paths &paths, const String ¢er, + const String &mid, const String &edge) + { + nlanes1 = wedge.width1 / 5.0f; + nlanes2 = wedge.width2 / 5.0f; + nlanes = MAX(nlanes1, nlanes2); + assert(nlanes < 16); + xp1 = paths.path1[0]; + xp2 = paths.path1[1]; + xp3 = paths.path1[2]; + xp1a = paths.path2[0]; + xp2a = paths.path2[1]; + xp3a = paths.path2[2]; + dir1 = xp2 - xp1; + dir2 = xp3 - xp2; + edge1 = (xp1a - xp1).normalized(); + edge2 = (xp2a - xp2).normalized(); + edge3 = (xp3a - xp3).normalized(); + l1 = (xp1a - xp1).length(); + l2 = (xp2a - xp2).length(); + l3 = (xp3a - xp3).length(); + if (dir1.normalized().is_equal_approx( + dir2.normalized())) + l2 = 3.0; + this->center = center; + this->mid = mid; + this->edge = edge; + assert(l2 >= l1 - 0.0001f && l2 >= l3 - 0.0001f); + assert(l1 - 3.0f < 0.001f); + assert(l3 - 3.0f < 0.001f); + assert(center.length() > 0 && mid.length() > 0 && + edge.length() > 0); + } + }; + void setup_lane(struct lane &lane, int index, + const struct lane_params ¶ms) + { + Vector3 p1 = + params.xp1 + params.edge1 * float(index) * (params.l1); + Vector3 p2 = + params.xp2 + params.edge2 * float(index) * (params.l2); + Vector3 p3 = + params.xp3 + params.edge3 * float(index) * (params.l3); + if (index >= params.nlanes) { + p1 = params.xp1 + + params.edge1 * float(params.nlanes1) * (params.l1); + p2 = params.xp2 + + params.edge2 * float(index + 0) * (params.l2); + p3 = params.xp3 + + params.edge3 * float(params.nlanes2) * (params.l3); + } + lane.p[0] = p1; + lane.p[1] = p2; + lane.p[2] = p3; + String use_mesh = params.center; + if (index >= params.nlanes) + use_mesh = params.edge; + else if (params.nlanes > 1 && index == 0) + use_mesh = params.center; + else if (params.nlanes > 1 && index > 0) + use_mesh = params.mid; + lane.use_mesh = use_mesh; + assert(use_mesh.length() > 0); + assert(lane.use_mesh.length() > 0); +#if 0 + lane.xform1 = Transform(Basis(), lane.p[0]); + lane.xform_m1 = Transform(Basis(), lane.p[1]); + lane.xform_m2 = Transform(Basis(), lane.p[1]); + lane.xform2 = Transform(Basis(), lane.p[2]); +#endif + Transform xform1 = + Transform().looking_at(params.dir1, Vector3(0, 1, 0)); + xform1.origin = lane.p[0]; + lane.xform1 = xform1; + Transform xform2 = + Transform().looking_at(params.dir2, Vector3(0, 1, 0)); + xform2.origin = lane.p[2]; + lane.xform2 = xform2; + Vector3 dir_m1 = + params.edge2.rotated(Vector3(0, 1, 0), Math_PI / 2.0); + Transform xform_m1 = + Transform().looking_at(-dir_m1, Vector3(0, 1, 0)); + xform_m1.origin = lane.p[1]; + lane.xform_m1 = xform_m1; + Transform xform_m2 = + Transform().looking_at(-dir_m1, Vector3(0, 1, 0)); + xform_m2.origin = lane.p[1]; + lane.xform_m2 = xform_m2; + int i; + float l_s[] = { params.l1, params.l2, params.l3 }; + for (i = 0; + i < (int)(sizeof(lane.l_seg1) / sizeof(lane.l_seg1[0])); + i++) { + lane.l_seg1[i] = l_s[i]; + lane.l_seg2[i] = l_s[i]; + } + if (index > params.nlanes1 - 1 && index < params.nlanes1) + lane.l_seg1[0] = 0; + if (index > params.nlanes2 - 1 && index < params.nlanes2) + lane.l_seg2[2] = 0; + } + void build_wedge_mesh(const struct wedge &wedge, const String ¢er, + const String &mid, const String &edge, + std::vector &out_surfaces, + std::vector > &out_materials) + { + struct wedge_paths paths; + get_paths(paths, wedge); + int k; + int segment_count = 0; + std::vector lanes; + bool sidewalk = true; + struct lane_params params(wedge, paths, center, mid, edge); + int parts = params.nlanes; + if (sidewalk) + parts = params.nlanes + 1; + lanes.resize(parts); + for (k = 0; k < (int)lanes.size(); k++) { + setup_lane(lanes[k], k, params); + assert(lanes[k].use_mesh.length() > 0); + } + for (k = 0; k < (int)lanes.size(); k++) { + std::vector surfaces; + std::vector > materials; + int h; + surfaces.resize( + road_meshes[lanes[k].use_mesh].arrays.size()); + materials.resize( + road_meshes[lanes[k].use_mesh].arrays.size()); + assert(surfaces.size() > 0); + assert(materials.size() > 0); + for (h = 0; + h < road_meshes[lanes[k].use_mesh].arrays.size(); + h++) { + surfaces[h] = + road_meshes[lanes[k].use_mesh].arrays[h]; + materials[h] = road_meshes[lanes[k].use_mesh] + .materials[h]; + } + /* assuming the same surface count for all meshes */ + if (out_surfaces.size() > 0) { + for (h = 0; h < road_meshes[lanes[k].use_mesh] + .arrays.size(); + h++) { + if (out_surfaces[h].size() == 0) { + Array surface; + init_surface(surface); + out_surfaces[h] = surface; + out_materials[h] = materials[h]; + } + } + } else if (out_surfaces.size() == 0) { + for (h = 0; h < road_meshes[lanes[k].use_mesh] + .arrays.size(); + h++) { + Array surface; + init_surface(surface); + out_surfaces[h] = surface; + out_materials[h] = materials[h]; + } + assert(road_meshes[lanes[k].use_mesh] + .arrays.size() > 0); + } + assert(out_surfaces.size() > 0); + for (h = 0; + h < road_meshes[lanes[k].use_mesh].arrays.size(); + h++) { + assert(out_surfaces[h].size() >= + ArrayMesh::ARRAY_MAX); + build_segment(lanes[k].xform1, + lanes[k].xform_m1, + lanes[k].l_seg1[0], + lanes[k].l_seg1[1], surfaces[h], + out_surfaces[h]); + build_segment(lanes[k].xform_m2, + lanes[k].xform2, + lanes[k].l_seg2[1], + lanes[k].l_seg2[2], surfaces[h], + out_surfaces[h]); + } + segment_count++; + } + } + Ref build_road(const std::vector &wedges, + const String ¢er, const String &mid, + const String &edge) + { + int i; + std::vector out_surfaces; + std::vector > out_materials; + int surf_count = road_meshes[center].arrays.size(); + out_surfaces.resize(surf_count); + out_materials.resize(surf_count); + // Transform mesh_xform = + // Transform().rotated(Vector3(0, 1, 0), Math_PI); + for (i = 0; i < (int)wedges.size(); i++) { + build_wedge_mesh(wedges[i], center, mid, edge, + out_surfaces, out_materials); + } + Ref new_mesh; + new_mesh.instance(); + for (i = 0; i < (int)out_surfaces.size(); i++) { + if (out_surfaces[i].size() > 0) { + new_mesh->add_surface_from_arrays( + Mesh::PRIMITIVE_TRIANGLES, + out_surfaces[i]); + new_mesh->surface_set_material( + i, out_materials[i]); + } + } + new_mesh->surface_set_name(0, "main"); + return new_mesh; + } + void create_road_meshes(Node *base) + { + int i; + RoadLinesProcessing *r = RoadLinesProcessing::get_singleton(); + for (i = 0; i < (int)r->nodes.size(); i++) { + Ref mesh = + build_road(r->wedges[i], "common/center", + "common/mid", "common/sidewalk"); + MeshInstance *mi = memnew(MeshInstance); + mi->hide(); + mi->set_mesh(mesh); + Transform xform(Basis(), r->nodes[i]); + base->call_deferred("add_child", mi); + mi->set_transform(xform); + mi->call_deferred("show"); + } + } + static RoadMeshProcessing *singleton; + static RoadMeshProcessing *get_singleton() + { + if (!singleton) + singleton = memnew(RoadMeshProcessing); + return singleton; + } + RoadMeshProcessing() + { + singleton = this; + } + static void cleanup() + { + if (singleton) { + memdelete(singleton); + singleton = nullptr; + } + } +}; +RoadMeshProcessing *RoadMeshProcessing::singleton; + +void RoadProcessing::road_setup(Node *target) +{ + RoadLinesProcessing::get_singleton()->road_setup(target); + RoadMeshProcessing::get_singleton()->create_road_meshes(target); +} + +void RoadProcessing::load_data() +{ + ConfigFile config; + Error result = config.load("res://config/stream.conf"); + ERR_FAIL_COND_MSG(result != OK, "Failed to load config"); + String road_lines_path = config.get_value("road", "road_lines_path"); + RoadLinesProcessing::get_singleton()->read_road_lines_json( + road_lines_path); + RoadMeshProcessing::get_singleton()->load_road_mesh( + "common", "center", config.get_value("road", "center_mesh")); + RoadMeshProcessing::get_singleton()->load_road_mesh( + "common", "mid", config.get_value("road", "mid_mesh")); + RoadMeshProcessing::get_singleton()->load_road_mesh( + "common", "sidewalk", + config.get_value("road", "sidewalk_mesh")); +} + +void RoadDebug::_notification(int which) +{ + int i, j; + RoadLinesProcessing *r = RoadLinesProcessing::get_singleton(); + std::unordered_map::iterator it; + switch (which) { + case NOTIFICATION_ENTER_TREE: + set_process(true); + break; + case NOTIFICATION_PROCESS: + if (r->nodes.size() > 0 && r->edges.size() > 0) { + VisualServer::get_singleton()->immediate_clear(imm); + VisualServer::get_singleton()->immediate_begin( + imm, VisualServer::PRIMITIVE_LINES, RID()); + VisualServer::get_singleton()->immediate_color( + imm, Color(1.0f, 0.6f, 0.6f, 1.0f)); + for (it = r->edges.begin(); it != r->edges.end(); + it++) { + int idx1 = it->first; + if (it == r->edges.begin()) { + aabb.position = r->nodes[idx1]; + aabb.size = Vector3(); + } else + aabb.expand_to(r->nodes[idx1]); + struct RoadLinesProcessing::edgedata data = + it->second; + for (i = 0; i < (int)data.neighbors.size(); + i++) { + int idx2 = data.neighbors[i]; + aabb.expand_to(r->nodes[idx2]); + Vector3 d = (r->nodes[idx2] - + r->nodes[idx1]) + .normalized() * + 0.5f; + VisualServer::get_singleton() + ->immediate_vertex( + imm, + r->nodes[idx1] + d); + VisualServer::get_singleton() + ->immediate_vertex( + imm, + r->nodes[idx2] - d); + } + } + VisualServer::get_singleton()->immediate_color( + imm, Color(0.6f, 0.6f, 1.0f, 1.0f)); + for (it = r->edges.begin(); it != r->edges.end(); + it++) { + int idx1 = it->first; + VisualServer::get_singleton()->immediate_vertex( + imm, + r->nodes[idx1] - Vector3(0, 10, 0)); + VisualServer::get_singleton()->immediate_vertex( + imm, + r->nodes[idx1] + Vector3(0, 100, 0)); + } + VisualServer::get_singleton()->immediate_color( + imm, Color(0.6f, 1.0f, 0.6f, 1.0f)); + for (i = 0; i < (int)r->nodes.size(); i++) { + VisualServer::get_singleton()->immediate_vertex( + imm, r->nodes[i] - Vector3(0, 5, 0)); + VisualServer::get_singleton()->immediate_vertex( + imm, r->nodes[i] + Vector3(0, 80, 0)); + } + VisualServer::get_singleton()->immediate_color( + imm, Color(1.0f, 1.0f, 0.6f, 1.0f)); + Vector3 l(0, 1.0, 0); + for (i = 0; i < (int)r->nodes.size(); i++) { + for (j = 0; j < (int)r->wedges[i].size(); j++) { + VisualServer::get_singleton() + ->immediate_vertex( + imm, + r->wedges[i][j].p[0] + + l); + VisualServer::get_singleton() + ->immediate_vertex( + imm, + r->wedges[i][j].p[1] + + l); + VisualServer::get_singleton() + ->immediate_vertex( + imm, + r->wedges[i][j].p[1] + + l); + VisualServer::get_singleton() + ->immediate_vertex( + imm, + r->wedges[i][j].p[2] + + l); + } + } + VisualServer::get_singleton()->immediate_end(imm); + set_process(false); + } + break; + case NOTIFICATION_EXIT_TREE: + break; + } +} +void RoadProcessing::cleanup() +{ + RoadLinesProcessing::cleanup(); + RoadMeshProcessing::cleanup(); +} \ No newline at end of file diff --git a/src/modules/stream/road_processing.h b/src/modules/stream/road_processing.h new file mode 100644 index 0000000..4a494d7 --- /dev/null +++ b/src/modules/stream/road_processing.h @@ -0,0 +1,10 @@ +#ifndef ROAD_LINES_PROCESSING_H_ +#define ROAD_LINES_PROCESSSING_H_ +class Node; +class RoadProcessing { +public: + static void road_setup(Node *target); + static void load_data(); + static void cleanup(); +}; +#endif \ No newline at end of file diff --git a/src/modules/stream/stream.cpp b/src/modules/stream/stream.cpp index 4c794bc..e76e152 100644 --- a/src/modules/stream/stream.cpp +++ b/src/modules/stream/stream.cpp @@ -5,10 +5,13 @@ #include #include #include +#include #include #include #include "from_string.h" +#include "road_processing.h" #include "stream.h" +#include "road_debug.h" void StreamWorld::read_buildings_json(const String &buildings_path) { @@ -272,533 +275,6 @@ void StreamWorld::update_items() } } -struct RoadLinesProcessing { - struct road_line { - std::vector points; - std::vector indices; - int lanes; - int flags; - }; - HashMap road_lines; - std::vector nodes; - struct edgedata { - std::vector neighbors; - }; - std::unordered_map edges; - static struct RoadLinesProcessing *singleton; - static RoadLinesProcessing *get_singleton() - { - if (!singleton) - singleton = memnew(RoadLinesProcessing); - return singleton; - } - RoadLinesProcessing() - { - singleton = this; - } - - uint32_t road_lines_hash(const Vector3 &v) - { - int x = (int)(v.x / 100); - int y = (int)(v.y / 100); - int z = (int)(v.z / 100); - return x ^ (y * 100) ^ (z * 10000); - } - void create_segments(const String &road, std::vector &segments) - { - int i; - for (i = 0; i < (int)road_lines[road].indices.size() - 1; i++) { - int idx1 = road_lines[road].indices[i]; - int idx2 = road_lines[road].indices[i + 1]; - segments.push_back(idx1); - segments.push_back(idx2); - segments.push_back(i + 1); - } - } - - void road_lines_curve_index( - struct road_line &rline, - std::unordered_map > - &road_lines_nodes_hash, - std::vector &road_lines_nodes) - { - int i, j; - rline.indices.clear(); - for (i = 0; i < (int)rline.points.size(); i++) { - Vector3 pt = rline.points[i].origin; - int pt_hash = road_lines_hash(pt); - if (road_lines_nodes_hash.find(pt_hash) != - road_lines_nodes_hash.end()) { - bool ok = true; - for (j = 0; - j < - (int)road_lines_nodes_hash[pt_hash].size(); - j++) { - const Vector3 &xpt = - road_lines_nodes_hash[pt_hash] - [j]; - if (xpt.distance_squared_to(pt) < 160) { - ok = false; - pt = xpt; - break; - } - } - if (ok) { - road_lines_nodes_hash[pt_hash].push_back( - pt); - road_lines_nodes.push_back(pt); - } - } else { - road_lines_nodes.push_back(pt); - road_lines_nodes_hash[pt_hash] = { pt }; - } - std::vector::iterator it = - std::find(road_lines_nodes.begin(), - road_lines_nodes.end(), pt); - assert(it != road_lines_nodes.end()); - int index = it - road_lines_nodes.begin(); - rline.indices.push_back(index); - } - } - void index_lines(std::unordered_map > - &road_lines_nodes_hash, - std::vector &road_lines_nodes) - { - List keys; - road_lines.get_key_list(&keys); - List::Element *e = keys.front(); - while (e) { - String rkey = e->get(); - struct road_line &pt = road_lines[rkey]; - pt.indices.clear(); - e = e->next(); - } - e = keys.front(); - while (e) { - String rkey = e->get(); - struct road_line &pt = road_lines[rkey]; - road_lines_curve_index(pt, road_lines_nodes_hash, - road_lines_nodes); - e = e->next(); - } -#if 0 - /* deduplicate */ - e = keys.front(); - while (e) { - String rkey = e->get(); - std::vector index; - struct road_line &pt = road_lines[rkey]; - for (i = 0; i < (int)pt.indices.size() - 1; i++) { - int i1 = pt.indices[i]; - if (i1 == 0) - index.push_back(i1); - int i2 = pt.indices[i + 1]; - if (i1 != i2) - index.push_back(i2); - } - pt.indices = index; - e = e->next(); - } -#endif - } - /* add close points on each line to the line */ - void insert_close_points(std::vector &road_lines_nodes) - { - int i; - List keys; - road_lines.get_key_list(&keys); - List::Element *e = keys.front(); - for (i = 0; i < (int)road_lines_nodes.size(); i++) { - int idx3 = i; - while (e) { - int j; - std::vector segments; - String rkey = e->get(); - create_segments(rkey, segments); - for (j = 0; j < (int)segments.size(); j += 3) { - int idx1 = segments[j]; - int idx2 = segments[j + 1]; - int idx = segments[j + 2]; - /* Skip segment point */ - if (idx3 == idx1 || idx3 == idx2) - continue; - Vector3 p1 = road_lines_nodes[idx1]; - Vector3 p2 = road_lines_nodes[idx2]; - Vector3 p3 = road_lines_nodes[idx3]; - std::vector seg = { p1, p2 }; - Vector3 closest = Geometry:: - get_closest_point_to_segment( - p3, seg.data()); - if (p3.distance_squared_to(closest) < - 160) { - road_lines_nodes[idx3] = - closest; - road_lines[rkey].indices.insert( - road_lines[rkey].indices - .begin() + - idx, - idx3); - } - } - e = e->next(); - } - } - } - void update_road_lines_nodes(std::vector &road_lines_nodes) - { - List keys; - - road_lines.get_key_list(&keys); - std::unordered_map > kcmp; - { - List::Element *k = keys.front(); - List::Element *r = keys.front(); - while (k) { - String kkey = k->get(); - uint32_t kkey_hash = kkey.hash(); - while (r) { - String rkey = r->get(); - uint32_t rkey_hash = rkey.hash(); - uint32_t key = kkey_hash ^ rkey_hash; - uint32_t key2 = rkey_hash ^ kkey_hash; - if (kcmp.find(key) == kcmp.end() && - kcmp.find(key2) == kcmp.end()) - kcmp[key] = std::make_tuple( - k->get(), r->get()); - r = r->next(); - } - k = k->next(); - } - } - /* - var checks = {} - for cmp in compare.values(): - var k = cmp[0] - var r = cmp[1] - if road_lines[k].indices.size() < 2: - continue - if road_lines[r].indices.size() < 2: - continue - for i1 in range(road_lines[k].indices.size() - 1): - for j1 in range(road_lines[r].indices.size() - 1): - var key = k + str(i1) + "-" + r + str(j1) - var key2 = r + str(j1) + "-" + k + str(i1) - if !checks.has(key) && !checks.has(key2): - var idx_a1 = road_lines[k].indices[i1] - var idx_a2 = road_lines[k].indices[i1 + 1] - var idx_b1 = road_lines[r].indices[j1] - var idx_b2 = road_lines[r].indices[j1 + 1] - if idx_b1 in [idx_a1, idx_a2] || idx_b2 in [idx_a1, idx_a2]: - continue - checks[key] = [k, i1, idx_a1, idx_a2, r, j1, idx_b1, idx_b2] - - */ - using checks_tuple = - std::tuple; - std::unordered_map checks; - std::unordered_map::iterator checks_it; - std::unordered_map >::iterator it; - for (it = kcmp.begin(); it != kcmp.end(); it++) { - int i, j; - std::tuple data = kcmp[it->first]; - const String &k = std::get<0>(data); - const String &r = std::get<1>(data); - if (road_lines[k].indices.size() < 2) - continue; - if (road_lines[r].indices.size() < 2) - continue; - for (i = 0; i < (int)road_lines[k].indices.size() - 1; - i++) { - for (j = 0; - j < (int)road_lines[k].indices.size() - 1; - j++) { - uint32_t key = k.hash() ^ i ^ r.hash() ^ - j ^ 2147483137; - uint32_t key2 = r.hash() ^ j ^ - k.hash() ^ i ^ - 2147463167; - if (checks.find(key) == checks.end() && - checks.find(key2) == checks.end()) { - int idx_a1 = - road_lines[k].indices[i]; - int idx_a2 = - road_lines[k] - .indices[i + 1]; - int idx_b1 = - road_lines[k].indices[j]; - int idx_b2 = - road_lines[k] - .indices[j + 1]; - std::vector cmp1 = { - idx_a1, idx_a2 - }; - if (std::find(cmp1.begin(), - cmp1.end(), - idx_b1) != - cmp1.end()) - continue; - if (std::find(cmp1.begin(), - cmp1.end(), - idx_b2) != - cmp1.end()) - continue; - checks[key] = std::make_tuple( - k, i, idx_a1, idx_a2, r, - j, idx_b1, idx_b2); - } - } - } - } - /* - for ch in checks.values(): - var k = ch[0] - var i1 = ch[1] - var idx_a1 = ch[2] - var idx_a2 = ch[3] - var r = ch[4] - var j1 = ch[5] - var idx_b1 = ch[6] - var idx_b2 = ch[7] - var p_a1 = road_lines_nodes[idx_a1] - var p_a2 = road_lines_nodes[idx_a2] - var p_b1 = road_lines_nodes[idx_b1] - var p_b2 = road_lines_nodes[idx_b2] - var px = Geometry.get_closest_points_between_segments(p_a1, p_a2, p_b1, p_b2) - var d = px[0].distance_squared_to(px[1]) - if d < 160: - var pxt = px[0].linear_interpolate(px[1], 0.5) - var nidx = road_lines_nodes.size() - road_lines_nodes.push_back(pxt) - var il = road_lines[k].indices.size() - assert(!nidx in road_lines[k].indices) - assert(!nidx in road_lines[r].indices) - road_lines[k].indices.insert(i1 + 1, nidx) - road_lines[r].indices.insert(j1 + 1, nidx) -##end - */ - for (checks_it = checks.begin(); checks_it != checks.end(); - checks_it++) { - String k = std::get<0>(checks_it->second); - int i = std::get<1>(checks_it->second); - int idx_a1 = std::get<2>(checks_it->second); - int idx_a2 = std::get<3>(checks_it->second); - String r = std::get<4>(checks_it->second); - int j = std::get<5>(checks_it->second); - int idx_b1 = std::get<6>(checks_it->second); - int idx_b2 = std::get<7>(checks_it->second); - Vector3 p_a1 = road_lines_nodes[idx_a1]; - Vector3 p_a2 = road_lines_nodes[idx_a2]; - Vector3 p_b1 = road_lines_nodes[idx_b1]; - Vector3 p_b2 = road_lines_nodes[idx_b2]; - Vector3 px, px2; - Geometry::get_closest_points_between_segments( - p_a1, p_a2, p_b1, p_b2, px, px2); - float d = px.distance_squared_to(px2); - if (d < 160) { - Vector3 pxt = px.linear_interpolate(px2, 0.5f); - int nidx = road_lines_nodes.size(); - road_lines_nodes.push_back(pxt); - // int il = (int)road_lines[k].indices.size(); - assert(std::find(road_lines[k].indices.begin(), - road_lines[k].indices.end(), - nidx) == - road_lines[k].indices.end()); - assert(std::find(road_lines[r].indices.begin(), - road_lines[r].indices.end(), - nidx) == - road_lines[r].indices.end()); - road_lines[k].indices.insert( - road_lines[k].indices.begin() + i + 1, - nidx); - road_lines[r].indices.insert( - road_lines[k].indices.begin() + j + 1, - nidx); - } - } - /* - var nodes = [] - var edges = {} - - for n in road_lines_nodes: -# var pn = Vector3(n.x, n.y - 20.0, n.z) - var ndata = var2str(n) - nodes.push_back(ndata) - - for k in road_lines.keys(): - if road_lines[k].indices.size() < 2: - continue - for l in range(road_lines[k].indices.size() - 1): - var idx1 = road_lines[k].indices[l] - var idx2 = road_lines[k].indices[l + 1] - if !edges.has(str(idx1)): - edges[str(idx1)] = {"neighbors": []} - if !edges.has(str(idx2)): - edges[str(idx2)] = {"neighbors": []} - if !idx2 in edges[str(idx1)].neighbors: - edges[str(idx1)].neighbors.push_back(idx2) - if !idx1 in edges[str(idx2)].neighbors: - edges[str(idx2)].neighbors.push_back(idx1) - - var road_nodes = SceneComps.get_component("road_nodes") - var ndebug = { - "nodes": nodes, - "edges": edges - } -# print(ndebug) -## assert(false) - road_nodes.roads_data.nodes = nodes - road_nodes.roads_data.edges = edges -# print(nodes) -# print(edges) -# print(road_nodes.roads_data.nodes) - - */ - } - void create_nodes(const std::vector &road_lines_nodes) - { - nodes.resize(road_lines_nodes.size()); - memcpy(nodes.data(), road_lines_nodes.data(), - sizeof(Vector3) * road_lines_nodes.size()); - } - void create_edges() - { - int i; - List keys; - road_lines.get_key_list(&keys); - List::Element *e = keys.front(); - while (e) { - const String &key = e->get(); - if (road_lines[key].indices.size() < 2) { - e = e->next(); - continue; - } - for (i = 0; i < (int)road_lines[key].indices.size() - 1; - i++) { - int idx1 = road_lines[key].indices[i]; - int idx2 = road_lines[key].indices[i + 1]; - if (edges.find(idx1) == edges.end()) { - struct edgedata ed; - ed.neighbors.clear(); - edges[idx1] = ed; - } - if (edges.find(idx2) == edges.end()) { - struct edgedata ed; - ed.neighbors.clear(); - edges[idx2] = ed; - } - if (std::find(edges[idx1].neighbors.begin(), - edges[idx1].neighbors.end(), - idx2) == - edges[idx1].neighbors.end()) - edges[idx1].neighbors.push_back(idx2); - if (std::find(edges[idx2].neighbors.begin(), - edges[idx2].neighbors.end(), - idx1) == - edges[idx2].neighbors.end()) - edges[idx2].neighbors.push_back(idx1); - } - e = e->next(); - } - } - - void create_road_from_lines() - { - } - void dump_lines(const std::vector &road_lines_nodes) - { - int i; - List keys; - road_lines.get_key_list(&keys); - List::Element *e = keys.front(); - while (e) { - String rkey = e->get(); - struct road_line &pt = road_lines[rkey]; - String outline = rkey + ": "; - for (i = 0; i < (int)pt.indices.size(); i++) { - outline += " " + itos(pt.indices[i]); - } - for (i = 0; i < (int)pt.indices.size(); i++) { - outline += - " " + (road_lines_nodes[pt.indices[i]] - .operator String()); - } - print_line(outline); - e = e->next(); - } - } - - void road_setup() - { - std::vector road_lines_nodes; - std::unordered_map > - road_lines_nodes_hash; - print_line("ROAD SETUP"); - road_lines_nodes.clear(); - road_lines_nodes_hash.clear(); - index_lines(road_lines_nodes_hash, road_lines_nodes); - insert_close_points(road_lines_nodes); - update_road_lines_nodes(road_lines_nodes); - dump_lines(road_lines_nodes); - create_nodes(road_lines_nodes); - create_edges(); - print_line("NODES:" + itos(nodes.size())); - print_line("EDGES:" + itos(edges.size())); - create_road_from_lines(); - print_line("ROAD SETUP DONE"); - } - void read_road_lines_json(const String &road_lines_path) - { - int i; - String road_lines_json = - FileAccess::get_file_as_string(road_lines_path); - Variant json_v; - String es; - int eline; - Error status = JSON::parse(road_lines_json, json_v, es, eline); - ERR_FAIL_COND_MSG(status != OK, - "Can't parse json: " + es + - " at line: " + itos(eline)); - - Dictionary json = json_v; - List keys; - json.get_key_list(&keys); - List::Element *e = keys.front(); - while (e) { - String key = e->get(); - if (!key.ends_with("_road")) { - e = e->next(); - continue; - } - struct road_line rline; - Array points = json[key].get("points"); - Array indices = json[key].get("indices"); - int lanes = json[key].get("lanes"); - rline.points.resize(points.size()); - rline.indices.resize(indices.size()); - for (i = 0; i < (int)points.size(); i++) { - String point_s = points[i]; - rline.points[i] = - from_string(point_s); - } - for (i = 0; i < (int)indices.size(); i++) { - int index = indices[i]; - rline.indices[i] = index; - } - // TODO: wtf is flags? - rline.lanes = lanes; - road_lines[key] = rline; - print_line("added line: " + key + - " nodes: " + itos(rline.points.size()) + - " " + itos(rline.indices.size()) + - " lanes: " + itos(rline.lanes)); - e = e->next(); - } - } -}; - -RoadLinesProcessing *RoadLinesProcessing::singleton; - void StreamWorld::_notification(int which) { switch (which) { @@ -814,7 +290,7 @@ void StreamWorld::_notification(int which) else current_scene = get_tree()->get_current_scene(); ERR_FAIL_COND_MSG(!current_scene, "No current scene"); - RoadLinesProcessing::get_singleton()->road_setup(); + RoadProcessing::road_setup(this); set_process(true); } break; @@ -886,10 +362,7 @@ StreamWorld::StreamWorld() } String buildings_path = config.get_value("buildings", "buildings_path"); read_buildings_json(buildings_path); - String road_lines_path = config.get_value("road", "road_lines_path"); - RoadLinesProcessing::get_singleton()->read_road_lines_json( - road_lines_path); - + RoadProcessing::load_data(); world_extent = config.get_value("world", "world_extent"); tile_size = config.get_value("world", "tile_size"); ERR_FAIL_COND_MSG(tile_size <= 0 || world_extent <= 0 || @@ -908,108 +381,11 @@ StreamWorld::StreamWorld() view_distance = config.get_value("world", "view_distance"); initialized = true; } - -void RoadDebug::_notification(int which) +void StreamWorld::cleanup() { - int i; - RoadLinesProcessing *r = RoadLinesProcessing::get_singleton(); - std::unordered_map::iterator it; - switch (which) { - case NOTIFICATION_ENTER_TREE: - set_process(true); - break; - case NOTIFICATION_PROCESS: - if (r->nodes.size() > 0 && r->edges.size() > 0) { - VisualServer::get_singleton()->immediate_clear(imm); - VisualServer::get_singleton()->immediate_begin( - imm, VisualServer::PRIMITIVE_LINES, RID()); - VisualServer::get_singleton()->immediate_color( - imm, Color(1.0f, 0.6f, 0.6f, 1.0f)); - for (it = r->edges.begin(); it != r->edges.end(); - it++) { - int idx1 = it->first; - if (it == r->edges.begin()) { - aabb.position = r->nodes[idx1]; - aabb.size = Vector3(); - } else - aabb.expand_to(r->nodes[idx1]); - struct RoadLinesProcessing::edgedata data = - it->second; - for (i = 0; i < (int)data.neighbors.size(); - i++) { - int idx2 = data.neighbors[i]; - aabb.expand_to(r->nodes[idx2]); - Vector3 d = (r->nodes[idx2] - - r->nodes[idx1]) - .normalized() * - 0.5f; - VisualServer::get_singleton() - ->immediate_vertex( - imm, - r->nodes[idx1] + d); - VisualServer::get_singleton() - ->immediate_vertex( - imm, - r->nodes[idx2] - d); - print_line( - "draw line: " + itos(idx1) + - " " + itos(idx2) + - (r->nodes[idx1] - .operator String()) + - " " + - (r->nodes[idx2] - .operator String())); - } - } - VisualServer::get_singleton()->immediate_color( - imm, Color(0.6f, 0.6f, 1.0f, 1.0f)); - for (it = r->edges.begin(); it != r->edges.end(); - it++) { - int idx1 = it->first; - VisualServer::get_singleton()->immediate_vertex( - imm, - r->nodes[idx1] - Vector3(0, 10, 0)); - VisualServer::get_singleton()->immediate_vertex( - imm, - r->nodes[idx1] + Vector3(0, 100, 0)); - } - VisualServer::get_singleton()->immediate_color( - imm, Color(0.6f, 1.0f, 0.6f, 1.0f)); - for (i = 0; i < (int)r->nodes.size(); i++) { - VisualServer::get_singleton()->immediate_vertex( - imm, r->nodes[i] - Vector3(0, 5, 0)); - VisualServer::get_singleton()->immediate_vertex( - imm, r->nodes[i] + Vector3(0, 80, 0)); - } - VisualServer::get_singleton()->immediate_end(imm); - set_process(false); - } - break; - case NOTIFICATION_EXIT_TREE: - break; - } + RoadProcessing::cleanup(); } -AABB RoadDebug::get_aabb() const +StreamWorld::~StreamWorld() { - return aabb; -} -PoolVector RoadDebug::get_faces(uint32_t p_usage_flags) const -{ - return PoolVector(); -} -RoadDebug::RoadDebug() -{ - imm = VisualServer::get_singleton()->immediate_create(); - set_base(imm); - material.instance(); - material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, - true); - material->set_flag(SpatialMaterial::FLAG_DISABLE_DEPTH_TEST, true); - material->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - VisualServer::get_singleton()->immediate_set_material( - imm, material->get_rid()); -} -RoadDebug::~RoadDebug() -{ - VisualServer::get_singleton()->free(imm); + RoadProcessing::cleanup(); } \ No newline at end of file diff --git a/src/modules/stream/stream.h b/src/modules/stream/stream.h index a6349b6..8e859fd 100644 --- a/src/modules/stream/stream.h +++ b/src/modules/stream/stream.h @@ -5,7 +5,6 @@ #include #include #include -#include class VoxelViewer; class VoxelLodTerrain; class StreamWorld : public Spatial { @@ -62,19 +61,7 @@ private: public: StreamWorld(); -}; -class RoadDebug : public VisualInstance { - GDCLASS(RoadDebug, VisualInstance) -protected: - RID imm; - Ref material; - void _notification(int which); - AABB aabb; - -public: - RoadDebug(); - ~RoadDebug(); - virtual AABB get_aabb() const; - virtual PoolVector get_faces(uint32_t p_usage_flags) const; + ~StreamWorld(); + static void cleanup(); }; #endif \ No newline at end of file