diff --git a/ui/map/cursor/Cursor.gd b/ui/map/cursor/Cursor.gd new file mode 100644 index 0000000..e4d7547 --- /dev/null +++ b/ui/map/cursor/Cursor.gd @@ -0,0 +1,8 @@ +extends Sprite + +func _on_Camera_camera_moved(new_location): + var map_x = new_location.x + var map_y = new_location.z + position.x = map_x + position.y = map_y + pass # Replace with function body. diff --git a/ui/map/cursor/cursor.png b/ui/map/cursor/cursor.png new file mode 100644 index 0000000..7b1ce1a Binary files /dev/null and b/ui/map/cursor/cursor.png differ diff --git a/ui/map/cursor/cursor.png.import b/ui/map/cursor/cursor.png.import new file mode 100644 index 0000000..881ad88 --- /dev/null +++ b/ui/map/cursor/cursor.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/cursor.png-c6b2f949aa939fd4f4289acd7e6ebaee.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ui/map/cursor/cursor.png" +dest_files=[ "res://.import/cursor.png-c6b2f949aa939fd4f4289acd7e6ebaee.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/ui/map/map.gd b/ui/map/map.gd index bddf3f7..aff2199 100644 --- a/ui/map/map.gd +++ b/ui/map/map.gd @@ -1,5 +1,7 @@ extends Node2D +signal map_clicked + var terrain func heightmap(): @@ -102,6 +104,12 @@ func _draw(): # draw_voronoi_cells_convex_hull() # draw_voronoi_edges(Color("#ff0000")) +func _process(delta): + if Input.is_action_pressed("alt_command"): + var new_position = get_viewport().get_mouse_position() / scale + if new_position.x <= 2000 and new_position.y <= 2000: + emit_signal("map_clicked", new_position) + func _on_Game_world_loaded(game_terrain): terrain = game_terrain update() diff --git a/ui/map/map.tscn b/ui/map/map.tscn index 3ad22d3..31f5e94 100644 --- a/ui/map/map.tscn +++ b/ui/map/map.tscn @@ -1,6 +1,12 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=4 format=2] [ext_resource path="res://ui/map/map.gd" type="Script" id=1] +[ext_resource path="res://ui/map/cursor/cursor.png" type="Texture" id=2] +[ext_resource path="res://ui/map/cursor/Cursor.gd" type="Script" id=3] [node name="Map" type="Node2D"] script = ExtResource( 1 ) + +[node name="Cursor" type="Sprite" parent="."] +texture = ExtResource( 2 ) +script = ExtResource( 3 ) diff --git a/utils/camera/CamBase.tscn b/utils/camera/CamBase.tscn index 78190c1..7e9ecb6 100644 --- a/utils/camera/CamBase.tscn +++ b/utils/camera/CamBase.tscn @@ -6,10 +6,11 @@ [ext_resource path="res://utils/camera/CameraInput.gd" type="Script" id=4] [node name="CamBase" type="Spatial"] -transform = Transform( 1, 0, 0, 0, 0.34202, 0.939693, 0, -0.939693, 0.34202, 0, 0, 0 ) +transform = Transform( 1, 0, 0, 0, 0.0238738, 0.999715, 0, -0.999715, 0.0238738, 0, 0, 16.935 ) script = ExtResource( 2 ) [node name="Camera" type="Camera" parent="."] +transform = Transform( 1, 0, 0, 0, 0.910272, -0.41401, 0, 0.41401, 0.910272, 0, 0, 6.618 ) size = 20.0 near = 0.01 far = 8192.0 diff --git a/world/World.gd b/world/World.gd index b1fd2f8..cf9299f 100644 --- a/world/World.gd +++ b/world/World.gd @@ -16,7 +16,7 @@ func draw_world(): st.add_vertex(point.point3d() * Vector3(1, 24*5, 1)) st.generate_normals() - st.generate_tangents() + # st.generate_tangents() st.index() # Commit to a mesh. var mesh = st.commit() @@ -33,3 +33,4 @@ func draw_world(): func _on_Game_world_loaded(game_terrain): terrain = game_terrain draw_world() + diff --git a/world/game.tscn b/world/game.tscn index 00c45f4..c142434 100644 --- a/world/game.tscn +++ b/world/game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=7 format=2] +[gd_scene load_steps=8 format=2] [ext_resource path="res://ui/ui.tscn" type="PackedScene" id=1] [ext_resource path="res://world/game.gd" type="Script" id=2] @@ -9,6 +9,9 @@ [sub_resource type="PlaneMesh" id=1] size = Vector2( 2000, 2000 ) +[sub_resource type="SpatialMaterial" id=2] +albedo_color = Color( 0.054902, 0.533333, 0.741176, 1 ) + [node name="Game" type="Node"] script = ExtResource( 2 ) @@ -17,24 +20,38 @@ script = ExtResource( 2 ) [node name="Map" parent="UI" index="0"] scale = Vector2( 0.25, 0.25 ) +[node name="Cursor" parent="UI/Map" index="0"] +scale = Vector2( 4, 4 ) +z_index = 3 + [node name="World" type="Spatial" parent="."] script = ExtResource( 4 ) [node name="Water" type="MeshInstance" parent="World"] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 1000, 0, 1000 ) +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 1000, -0.1, 1000 ) mesh = SubResource( 1 ) +material/0 = SubResource( 2 ) [node name="WorldEnvironment" type="WorldEnvironment" parent="World"] environment = ExtResource( 3 ) [node name="CamBase" parent="World" instance=ExtResource( 5 )] +[node name="Camera" parent="World/CamBase" index="0"] +movement_speed = 48.076 +min_zoom = 10.0 +zoom_sensibility = 1.436 +rotation_sensibility = 3.0 + [node name="DirectionalLight" type="DirectionalLight" parent="World"] transform = Transform( 1, 0, 0, 0, 0.41636, 0.9092, 0, -0.9092, 0.41636, 0, 1.41623, 0 ) light_energy = 0.1 [connection signal="world_loaded" from="." to="UI/Map" method="_on_Game_world_loaded"] [connection signal="world_loaded" from="." to="World" method="_on_Game_world_loaded"] +[connection signal="map_clicked" from="UI/Map" to="World/CamBase/Camera" method="_on_Map_map_clicked"] +[connection signal="camera_moved" from="World/CamBase/Camera" to="UI/Map/Cursor" method="_on_Camera_camera_moved"] [editable path="UI"] +[editable path="UI/Map"] [editable path="World/CamBase"]