Commit dd43f717 authored by Gavin An's avatar Gavin An

작업 중

parent 06984fd9
[gd_resource type="ShaderMaterial" load_steps=4 format=3 uid="uid://el5y10hnh13g"] [gd_resource type="ShaderMaterial" format=3 uid="uid://el5y10hnh13g"]
[ext_resource type="Shader" uid="uid://dce675i014xcn" path="res://addons/terrain_3d/extras/particle_example/particles.gdshader" id="1_t55me"] [ext_resource type="Shader" uid="uid://dce675i014xcn" path="res://addons/terrain_3d/extras/particle_example/particles.gdshader" id="1_t55me"]
...@@ -8,8 +8,8 @@ frequency = 0.0145 ...@@ -8,8 +8,8 @@ frequency = 0.0145
cellular_return_type = 4 cellular_return_type = 4
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_544iv"] [sub_resource type="NoiseTexture2D" id="NoiseTexture2D_544iv"]
seamless = true
noise = SubResource("FastNoiseLite_544iv") noise = SubResource("FastNoiseLite_544iv")
seamless = true
[resource] [resource]
shader = ExtResource("1_t55me") shader = ExtResource("1_t55me")
......
[gd_scene load_steps=8 format=3 uid="uid://cofnhdcclon1w"] [gd_scene format=3 uid="uid://cofnhdcclon1w"]
[ext_resource type="Script" path="res://demo/src/CodeGenerated.gd" id="1_h7vyv"] [ext_resource type="Script" uid="uid://dakis6gu8b7nm" path="res://demo/src/CodeGenerated.gd" id="1_h7vyv"]
[ext_resource type="PackedScene" uid="uid://domhm87hbhbg1" path="res://demo/components/Player.tscn" id="2_3v2uf"] [ext_resource type="PackedScene" uid="uid://domhm87hbhbg1" path="res://demo/components/Player.tscn" id="2_3v2uf"]
[ext_resource type="PackedScene" uid="uid://bb2lp50sjndus" path="res://demo/components/Environment.tscn" id="3_71ikj"] [ext_resource type="PackedScene" uid="uid://bb2lp50sjndus" path="res://demo/components/Environment.tscn" id="3_71ikj"]
[ext_resource type="PackedScene" uid="uid://di5fovhcyd7re" path="res://demo/components/Enemy.tscn" id="4_p8qry"] [ext_resource type="PackedScene" uid="uid://di5fovhcyd7re" path="res://demo/components/Enemy.tscn" id="4_p8qry"]
[ext_resource type="PackedScene" uid="uid://d2jihfohphuue" path="res://demo/components/UI.tscn" id="4_x5ge4"] [ext_resource type="PackedScene" uid="uid://d2jihfohphuue" path="res://demo/components/UI.tscn" id="4_x5ge4"]
[ext_resource type="Script" path="res://demo/src/RuntimeNavigationBaker.gd" id="5_445ur"] [ext_resource type="Script" uid="uid://brh8x1wnycrl5" path="res://demo/src/RuntimeNavigationBaker.gd" id="5_445ur"]
[sub_resource type="NavigationMesh" id="NavigationMesh_vs6am"] [sub_resource type="NavigationMesh" id="NavigationMesh_vs6am"]
geometry_parsed_geometry_type = 1 geometry_parsed_geometry_type = 1
agent_height = 2.0 agent_height = 2.0
agent_max_slope = 30.0 agent_max_slope = 30.0
[node name="CodeGenerated" type="Node"] [node name="CodeGenerated" type="Node" unique_id=241546107]
script = ExtResource("1_h7vyv") script = ExtResource("1_h7vyv")
[node name="Environment" parent="." instance=ExtResource("3_71ikj")] [node name="Environment" parent="." unique_id=399881060 instance=ExtResource("3_71ikj")]
[node name="Player" parent="." instance=ExtResource("2_3v2uf")] [node name="Player" parent="." unique_id=947092461 instance=ExtResource("2_3v2uf")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 50, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 50, 0)
[node name="Enemy" parent="." node_paths=PackedStringArray("target") instance=ExtResource("4_p8qry")] [node name="Enemy" parent="." unique_id=470570682 node_paths=PackedStringArray("target") instance=ExtResource("4_p8qry")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 10, 50, -10) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 10, 50, -10)
target = NodePath("../Player") target = NodePath("../Player")
[node name="UI" parent="." instance=ExtResource("4_x5ge4")] [node name="UI" parent="." unique_id=1439217852 instance=ExtResource("4_x5ge4")]
[node name="RuntimeNavigationBaker" type="Node" parent="." node_paths=PackedStringArray("player")] [node name="RuntimeNavigationBaker" type="Node" parent="." unique_id=67681880 node_paths=PackedStringArray("player")]
script = ExtResource("5_445ur") script = ExtResource("5_445ur")
enabled = false enabled = false
template = SubResource("NavigationMesh_vs6am") template = SubResource("NavigationMesh_vs6am")
player = NodePath("../Player") player = NodePath("../Player")
[node name="RunThisSceneLabel3D" type="Label3D" parent="."] [node name="RunThisSceneLabel3D" type="Label3D" parent="." unique_id=323616349]
pixel_size = 0.001 pixel_size = 0.001
billboard = 1 billboard = 1
no_depth_test = true no_depth_test = true
......
This diff is collapsed.
[gd_resource type="Terrain3DAssets" load_steps=11 format=3 uid="uid://dal3jhw6241qg"] [gd_resource type="Terrain3DAssets" format=3 uid="uid://dal3jhw6241qg"]
[ext_resource type="PackedScene" uid="uid://bn5nf4esciwex" path="res://demo/assets/models/LODExample.tscn" id="1_4jrdu"] [ext_resource type="PackedScene" uid="uid://bn5nf4esciwex" path="res://demo/assets/models/LODExample.tscn" id="1_4jrdu"]
[ext_resource type="Texture2D" uid="uid://c88j3oj0lf6om" path="res://demo/assets/textures/rock023_alb_ht.png" id="2_pog6b"] [ext_resource type="Texture2D" uid="uid://c88j3oj0lf6om" path="res://demo/assets/textures/rock023_alb_ht.png" id="2_pog6b"]
......
...@@ -8,6 +8,10 @@ func _enter_tree() -> void: ...@@ -8,6 +8,10 @@ func _enter_tree() -> void:
if GameManager.selected_stage_map_path != "": if GameManager.selected_stage_map_path != "":
map_path = GameManager.selected_stage_map_path map_path = GameManager.selected_stage_map_path
_load_stage_background(map_path)
_load_stage_map(map_path)
func _load_stage_map(map_path: String) -> void:
var map_scene: PackedScene = load(map_path) as PackedScene var map_scene: PackedScene = load(map_path) as PackedScene
if map_scene: if map_scene:
var map_inst: Node = map_scene.instantiate() var map_inst: Node = map_scene.instantiate()
...@@ -20,3 +24,26 @@ func _enter_tree() -> void: ...@@ -20,3 +24,26 @@ func _enter_tree() -> void:
push_error("Main: NavigationRegion3D not found.") push_error("Main: NavigationRegion3D not found.")
else: else:
push_error("Main: Failed to load map scene: " + map_path) push_error("Main: Failed to load map scene: " + map_path)
func _load_stage_background(map_path: String) -> void:
var background_path: String = _get_background_path_for_map(map_path)
if background_path == "":
return
var background_scene: PackedScene = load(background_path) as PackedScene
if not background_scene:
push_error("Main: Failed to load background scene: " + background_path)
return
var background_inst: Node = background_scene.instantiate()
background_inst.name = "StageBackground"
add_child(background_inst)
func _get_background_path_for_map(map_path: String) -> String:
match map_path:
"res://src/map/stages/stage_1_map.tscn":
return "res://src/map/background/desert.tscn"
"res://src/map/stages/stage_2_map.tscn":
return "res://src/map/background/swamp.tscn"
_:
return ""
...@@ -4,23 +4,6 @@ extends Camera3D ...@@ -4,23 +4,6 @@ extends Camera3D
## RTS 스타일 탑다운 3D 카메라 컨트롤러 ## RTS 스타일 탑다운 3D 카메라 컨트롤러
## 키보드(WASD) 및 마우스 경계 스크롤로 평면을 이동하고 마우스 휠로 줌 조작이 가능합니다. ## 키보드(WASD) 및 마우스 경계 스크롤로 평면을 이동하고 마우스 휠로 줌 조작이 가능합니다.
# 이동 및 줌 속도 설정
@export var move_speed: float = 25.0
@export var zoom_speed: float = 10.0
@export var zoom_step: float = 2.0
# 줌 범위 설정
@export var min_zoom: float = 5.0
@export var max_zoom: float = 15.0
# 화면 가장자리 마우스 감지 여백 (픽셀 단위)
@export var edge_margin: float = 15.0
@export var enable_edge_scroll: bool = true
# 맵 카메라 이동 한계 설정 (바닥 크기 20x20 기준)
@export var limit_min: Vector2 = Vector2(-8.0, -8.0)
@export var limit_max: Vector2 = Vector2(8.0, 8.0)
# 현재 카메라가 바라보고 있는 바닥의 포커스 좌표 (이곳을 중심으로 회전 및 줌이 일어남) # 현재 카메라가 바라보고 있는 바닥의 포커스 좌표 (이곳을 중심으로 회전 및 줌이 일어남)
var _target_focus: Vector3 = Vector3.ZERO var _target_focus: Vector3 = Vector3.ZERO
var _current_zoom: float = 10.0 var _current_zoom: float = 10.0
...@@ -31,86 +14,83 @@ func _ready() -> void: ...@@ -31,86 +14,83 @@ func _ready() -> void:
# pitch 각도를 60도로 설정 (main.tscn 기본값) # pitch 각도를 60도로 설정 (main.tscn 기본값)
var angle_rad: float = deg_to_rad(60.0) var angle_rad: float = deg_to_rad(60.0)
# 초기 줌 레벨을 최대 줌 아웃(max_zoom, 가장 축소된 뷰) 상태로 설정 # 초기 줌 레벨을 최대 줌 아웃(max_zoom, 가장 축소된 뷰) 상태로 설정
_current_zoom = max_zoom
_target_zoom = _current_zoom
# Z 오프셋 = Y / tan(60) 이므로, 포커스 타겟 Z = 카메라 Z - Z 오프셋 # Z 오프셋 = Y / tan(60) 이므로, 포커스 타겟 Z = 카메라 Z - Z 오프셋
var z_offset: float = _current_zoom / tan(angle_rad) var z_offset: float = _current_zoom / tan(angle_rad)
_target_focus = Vector3(global_position.x, 0.0, global_position.z - z_offset) _target_focus = Vector3(global_position.x, 0.0, global_position.z - z_offset)
# 초기 셋업 적용 # 초기 셋업 적용
_update_camera_transform(0.0) _update_camera_transform(60)
func _physics_process(delta: float) -> void: func _physics_process(delta: float) -> void:
pass
# 1. 입력 방향 계산 # 1. 입력 방향 계산
var direction: Vector3 = _get_input_direction() #var direction: Vector3 = _get_input_direction()
# 줌아웃이 최대치(max_zoom) 근처일 때는 카메라 이동을 차단하고 맵 중앙으로 초점을 부드럽게 복구 # 줌아웃이 최대치(max_zoom) 근처일 때는 카메라 이동을 차단하고 맵 중앙으로 초점을 부드럽게 복구
var is_max_zoom: bool = _target_zoom >= (max_zoom - 0.1) #var is_max_zoom: bool = _target_zoom >= (max_zoom - 0.1)
# 2. 포커스 타겟 이동 # 2. 포커스 타겟 이동
if is_max_zoom: #if is_max_zoom:
_target_focus = _target_focus.lerp(Vector3.ZERO, delta * move_speed * 0.2) #_target_focus = _target_focus.lerp(Vector3.ZERO, delta * move_speed * 0.2)
elif direction != Vector3.ZERO: #elif direction != Vector3.ZERO:
_target_focus += direction * move_speed * delta #_target_focus += direction * move_speed * delta
_target_focus.x = clampf(_target_focus.x, limit_min.x, limit_max.x) #_target_focus.x = clampf(_target_focus.x, limit_min.x, limit_max.x)
_target_focus.z = clampf(_target_focus.z, limit_min.y, limit_max.y) #_target_focus.z = clampf(_target_focus.z, limit_min.y, limit_max.y)
# 3. 줌 레벨 선형 보간 # 3. 줌 레벨 선형 보간
if not is_equal_approx(_current_zoom, _target_zoom): #if not is_equal_approx(_current_zoom, _target_zoom):
_current_zoom = lerpf(_current_zoom, _target_zoom, delta * zoom_speed) #_current_zoom = lerpf(_current_zoom, _target_zoom, delta * zoom_speed)
#
# 4. 카메라 위치 및 회전 업데이트 ## 4. 카메라 위치 및 회전 업데이트
_update_camera_transform(delta) #_update_camera_transform(delta)
func _unhandled_input(event: InputEvent) -> void: func _unhandled_input(event: InputEvent) -> void:
pass
# 마우스 휠을 통한 줌 조작 # 마우스 휠을 통한 줌 조작
if event is InputEventMouseButton: #if event is InputEventMouseButton:
var mouse_event: InputEventMouseButton = event as InputEventMouseButton #var mouse_event: InputEventMouseButton = event as InputEventMouseButton
if mouse_event.is_pressed(): #if mouse_event.is_pressed():
if mouse_event.button_index == MOUSE_BUTTON_WHEEL_UP: #if mouse_event.button_index == MOUSE_BUTTON_WHEEL_UP:
_target_zoom = clampf(_target_zoom - zoom_step, min_zoom, max_zoom) #_target_zoom = clampf(_target_zoom - zoom_step, min_zoom, max_zoom)
elif mouse_event.button_index == MOUSE_BUTTON_WHEEL_DOWN: #elif mouse_event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
_target_zoom = clampf(_target_zoom + zoom_step, min_zoom, max_zoom) #_target_zoom = clampf(_target_zoom + zoom_step, min_zoom, max_zoom)
## 입력 방향 계산 (키보드 WASD/방향키 + 마우스 경계 스크롤) ## 입력 방향 계산 (키보드 WASD/방향키 + 마우스 경계 스크롤)
func _get_input_direction() -> Vector3: #func _get_input_direction() -> Vector3:
var dir: Vector3 = Vector3.ZERO #var dir: Vector3 = Vector3.ZERO
## 키보드 입력 체크
# 키보드 입력 체크 #if Input.is_key_pressed(KEY_A) or Input.is_action_pressed("ui_left"):
if Input.is_key_pressed(KEY_A) or Input.is_action_pressed("ui_left"): #dir.x -= 1.0
dir.x -= 1.0 #if Input.is_key_pressed(KEY_D) or Input.is_action_pressed("ui_right"):
if Input.is_key_pressed(KEY_D) or Input.is_action_pressed("ui_right"): #dir.x += 1.0
dir.x += 1.0 #if Input.is_key_pressed(KEY_W) or Input.is_action_pressed("ui_up"):
if Input.is_key_pressed(KEY_W) or Input.is_action_pressed("ui_up"): #dir.z -= 1.0
dir.z -= 1.0 #if Input.is_key_pressed(KEY_S) or Input.is_action_pressed("ui_down"):
if Input.is_key_pressed(KEY_S) or Input.is_action_pressed("ui_down"): #dir.z += 1.0
dir.z += 1.0
# 마우스 경계 스크롤 체크 ## 마우스 경계 스크롤 체크
if enable_edge_scroll: #if enable_edge_scroll:
var viewport: Viewport = get_viewport() #var viewport: Viewport = get_viewport()
if viewport: #if viewport:
var mouse_pos: Vector2 = viewport.get_mouse_position() #var mouse_pos: Vector2 = viewport.get_mouse_position()
var viewport_size: Vector2 = viewport.get_visible_rect().size #var viewport_size: Vector2 = viewport.get_visible_rect().size
#
# 마우스 포인터가 화면 크기 안에 있을 때만 스크롤 수행 (창 밖 이탈 방지) ## 마우스 포인터가 화면 크기 안에 있을 때만 스크롤 수행 (창 밖 이탈 방지)
if mouse_pos.x >= 0.0 and mouse_pos.y >= 0.0 and mouse_pos.x <= viewport_size.x and mouse_pos.y <= viewport_size.y: #if mouse_pos.x >= 0.0 and mouse_pos.y >= 0.0 and mouse_pos.x <= viewport_size.x and mouse_pos.y <= viewport_size.y:
if mouse_pos.x < edge_margin: #if mouse_pos.x < edge_margin:
dir.x -= 1.0 #dir.x -= 1.0
elif mouse_pos.x > viewport_size.x - edge_margin: #elif mouse_pos.x > viewport_size.x - edge_margin:
dir.x += 1.0 #dir.x += 1.0
if mouse_pos.y < edge_margin: #if mouse_pos.y < edge_margin:
dir.z -= 1.0 #dir.z -= 1.0
elif mouse_pos.y > viewport_size.y - edge_margin: #elif mouse_pos.y > viewport_size.y - edge_margin:
dir.z += 1.0 #dir.z += 1.0
return dir.normalized() #return dir.normalized()
## 카메라의 Position과 Rotation을 업데이트 ## 카메라의 Position과 Rotation을 업데이트
func _update_camera_transform(_delta: float) -> void: func _update_camera_transform(_delta: float) -> void:
# 피치 각도 60도 고정 # 피치 각도 60도 고정
var angle_rad: float = deg_to_rad(60.0) var angle_rad: float = deg_to_rad(_delta)
var z_offset: float = _current_zoom / tan(angle_rad) var z_offset: float = _current_zoom / tan(angle_rad)
# 카메라 글로벌 좌표 설정 # 카메라 글로벌 좌표 설정
......
[gd_scene format=3 uid="uid://bqtcnfyfplvsr"]
[sub_resource type="Gradient" id="Gradient_dc7hf"]
offsets = PackedFloat32Array(0.2, 1)
colors = PackedColorArray(1, 1, 1, 1, 0, 0, 0, 1)
[sub_resource type="FastNoiseLite" id="FastNoiseLite_11m5b"]
noise_type = 2
frequency = 0.03
cellular_jitter = 3.0
cellular_return_type = 0
domain_warp_enabled = true
domain_warp_type = 1
domain_warp_amplitude = 50.0
domain_warp_fractal_type = 2
domain_warp_fractal_lacunarity = 1.5
domain_warp_fractal_gain = 1.0
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_htwul"]
noise = SubResource("FastNoiseLite_11m5b")
color_ramp = SubResource("Gradient_dc7hf")
seamless = true
[sub_resource type="Terrain3DMaterial" id="Terrain3DMaterial_1of3m"]
_shader_parameters = {
&"bias_distance": null,
&"blend_sharpness": null,
&"depth_blur": null,
&"enable_macro_variation": null,
&"enable_projection": null,
&"flat_terrain_normals": null,
&"macro_variation1": null,
&"macro_variation2": null,
&"macro_variation_slope": null,
&"mipmap_bias": null,
&"noise1_angle": null,
&"noise1_offset": null,
&"noise1_scale": null,
&"noise2_scale": null,
&"noise_texture": SubResource("NoiseTexture2D_htwul"),
&"projection_threshold": null
}
show_checkered = true
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_8t5t6"]
transparency = 4
cull_mode = 2
vertex_color_use_as_albedo = true
backlight_enabled = true
backlight = Color(0.5, 0.5, 0.5, 1)
distance_fade_mode = 1
distance_fade_min_distance = 128.0
distance_fade_max_distance = 96.0
[sub_resource type="Terrain3DMeshAsset" id="Terrain3DMeshAsset_o05ja"]
generated_type = 1
height_offset = 0.5
material_override = SubResource("StandardMaterial3D_8t5t6")
last_lod = 0
last_shadow_lod = 0
lod0_range = 128.0
[sub_resource type="Terrain3DAssets" id="Terrain3DAssets_h3i0q"]
mesh_list = Array[Terrain3DMeshAsset]([SubResource("Terrain3DMeshAsset_o05ja")])
[node name="SwampBackground" type="Terrain3D" unique_id=2116734893]
material = SubResource("Terrain3DMaterial_1of3m")
assets = SubResource("Terrain3DAssets_h3i0q")
show_checkered = true
top_level = true
metadata/_edit_lock_ = true
[gd_scene format=3 uid="uid://dypoks0inawgc"]
[sub_resource type="Gradient" id="Gradient_6edqv"]
offsets = PackedFloat32Array(0.2, 1)
colors = PackedColorArray(1, 1, 1, 1, 0, 0, 0, 1)
[sub_resource type="FastNoiseLite" id="FastNoiseLite_u12lg"]
noise_type = 2
frequency = 0.03
cellular_jitter = 3.0
cellular_return_type = 0
domain_warp_enabled = true
domain_warp_type = 1
domain_warp_amplitude = 50.0
domain_warp_fractal_type = 2
domain_warp_fractal_lacunarity = 1.5
domain_warp_fractal_gain = 1.0
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_yflbm"]
noise = SubResource("FastNoiseLite_u12lg")
color_ramp = SubResource("Gradient_6edqv")
seamless = true
[sub_resource type="Terrain3DMaterial" id="Terrain3DMaterial_vg6tp"]
_shader_parameters = {
&"bias_distance": null,
&"blend_sharpness": null,
&"depth_blur": null,
&"enable_macro_variation": null,
&"enable_projection": null,
&"flat_terrain_normals": null,
&"macro_variation1": null,
&"macro_variation2": null,
&"macro_variation_slope": null,
&"mipmap_bias": null,
&"noise1_angle": null,
&"noise1_offset": null,
&"noise1_scale": null,
&"noise2_scale": null,
&"noise_texture": SubResource("NoiseTexture2D_yflbm"),
&"projection_threshold": null
}
show_checkered = true
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_e17wc"]
transparency = 4
cull_mode = 2
vertex_color_use_as_albedo = true
backlight_enabled = true
backlight = Color(0.5, 0.5, 0.5, 1)
distance_fade_mode = 1
distance_fade_min_distance = 128.0
distance_fade_max_distance = 96.0
[sub_resource type="Terrain3DMeshAsset" id="Terrain3DMeshAsset_beaot"]
generated_type = 1
height_offset = 0.5
material_override = SubResource("StandardMaterial3D_e17wc")
last_lod = 0
last_shadow_lod = 0
lod0_range = 128.0
[sub_resource type="Terrain3DAssets" id="Terrain3DAssets_146h8"]
mesh_list = Array[Terrain3DMeshAsset]([SubResource("Terrain3DMeshAsset_beaot")])
[node name="DesertBackground" type="Terrain3D" unique_id=2095568987]
material = SubResource("Terrain3DMaterial_vg6tp")
assets = SubResource("Terrain3DAssets_146h8")
show_checkered = true
top_level = true
metadata/_edit_lock_ = true
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment