Compare commits

...

6 commits

6 changed files with 111 additions and 22 deletions

View file

@ -1,19 +1,43 @@
[gd_scene load_steps=9 format=3 uid="uid://eiaw4xbs3suk"]
[gd_scene load_steps=16 format=3 uid="uid://eiaw4xbs3suk"]
[ext_resource type="PackedScene" uid="uid://qb8cbljxgnub" path="res://world/killbrick.tscn" id="1_h2yge"]
[ext_resource type="PackedScene" uid="uid://cfceg80unq0pe" path="res://player/player.tscn" id="1_ig7tw"]
[ext_resource type="PackedScene" uid="uid://bcmrj6qkemrll" path="res://world/radiohead_cube.tscn" id="2_0xm2m"]
[ext_resource type="Texture2D" uid="uid://wdjmyv260he1" path="res://world/textures/grass.jpg" id="2_272bh"]
[ext_resource type="PackedScene" uid="uid://of6tq8gpjxtu" path="res://gears/gear_pickup.tscn" id="3_lquwl"]
[ext_resource type="PackedScene" uid="uid://bafl8q0r61xrg" path="res://gears/gear.tscn" id="4_7mycd"]
[ext_resource type="Texture2D" uid="uid://2ku62tk8r74x" path="res://world/textures/sky.hdr" id="8_5vw27"]
[sub_resource type="BoxShape3D" id="BoxShape3D_7dm0k"]
size = Vector3(100, 2, 100)
size = Vector3(1000, 2, 1000)
[sub_resource type="BoxMesh" id="BoxMesh_ig7tw"]
size = Vector3(100, 2, 100)
size = Vector3(1000, 2, 1000)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ig7tw"]
albedo_color = Color(0.49454, 0.79, 0.4424, 1)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_272bh"]
albedo_color = Color(0, 1, 0, 1)
albedo_texture = ExtResource("2_272bh")
uv1_scale = Vector3(300, 300, 300)
[sub_resource type="PanoramaSkyMaterial" id="PanoramaSkyMaterial_272bh"]
panorama = ExtResource("8_5vw27")
[sub_resource type="Sky" id="Sky_7mycd"]
sky_material = SubResource("PanoramaSkyMaterial_272bh")
[sub_resource type="Environment" id="Environment_7mycd"]
background_mode = 2
sky = SubResource("Sky_7mycd")
sky_rotation = Vector3(6.2831855, 0, 0)
glow_enabled = true
glow_intensity = 0.1
glow_bloom = 0.02
glow_blend_mode = 0
glow_hdr_luminance_cap = 0.0
[sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_272bh"]
[sub_resource type="Compositor" id="Compositor_5vw27"]
[node name="Main" type="Node3D"]
@ -26,11 +50,7 @@ shape = SubResource("BoxShape3D_7dm0k")
[node name="MeshInstance3D" type="MeshInstance3D" parent="Baseplate"]
mesh = SubResource("BoxMesh_ig7tw")
surface_material_override/0 = SubResource("StandardMaterial3D_ig7tw")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(0.7071068, -0.49999994, 0.49999994, 0, 0.7071067, 0.7071067, -0.7071068, -0.49999994, 0.49999994, 50, 50, 50)
shadow_enabled = true
surface_material_override/0 = SubResource("StandardMaterial3D_272bh")
[node name="radiohead cube" parent="." instance=ExtResource("2_0xm2m")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -16, 3, 0)
@ -52,3 +72,13 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -12, 2, -21)
[node name="Gear" parent="GearPickup" instance=ExtResource("4_7mycd")]
transform = Transform3D(1, 0, 0, 0, -0.012967386, 0.9999159, 0, -0.9999159, -0.012967386, 0, 0.5, 0)
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_7mycd")
camera_attributes = SubResource("CameraAttributesPractical_272bh")
compositor = SubResource("Compositor_5vw27")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(0.70710665, 0.5, -0.5, 0, 0.7071067, 0.7071067, 0.7071069, -0.49999988, 0.49999988, -500, 200, 500)
light_color = Color(1, 0.87058824, 0.12941177, 1)
shadow_enabled = true

View file

@ -1,6 +1,17 @@
class_name CameraGimbal extends Node3D
@export var rotation_speed = (PI / 180) * 120
@export var shift_lock = false
var locked_mouse_positon = Vector2(0,0)
var mouse_locked = false
var mouse_x_velocity = 0
var mouse_y_velocity = 0
var zoom_min = 4
var zoom_max = 80
var zoom_speed = 20
var current_zoom = 8
func reset():
basis = Basis()
@ -13,23 +24,52 @@ func rotate_camera_x(x, delta):
Vector3.RIGHT, x * rotation_speed * delta)
$InnerGimbal.rotation.x = clamp($InnerGimbal.rotation.x,-0.8,0.7)
func _input(event):
if event is InputEventMouseMotion:
mouse_x_velocity = event.relative.x
mouse_y_velocity = event.relative.y
elif event.is_action_pressed("zoom_out"):
current_zoom += 1
elif event.is_action_pressed("zoom_in"):
current_zoom -= 1
func _process(delta):
# rotate outer gimbal around y axis
var y = 0
if Input.is_action_pressed("cam_left"):
y += 1
if Input.is_action_pressed("cam_right"):
y -= 1
rotate_camera_y(y, delta)
# rotate inner gimbal around x axis
var x = 0
if Input.is_action_pressed("cam_up"):
x -= 1
if Input.is_action_pressed("cam_down"):
x += 1
if Input.is_action_just_pressed("shift_lock"):
if shift_lock == true:
shift_lock = false
else:
shift_lock = true
elif Input.is_mouse_button_pressed(MOUSE_BUTTON_RIGHT) or shift_lock == true:
if mouse_locked == false:
mouse_locked = true
locked_mouse_positon = get_viewport().get_mouse_position()
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
if mouse_x_velocity > 5 or mouse_x_velocity < -5:
y -= clamp(mouse_x_velocity / 12.5, -10, 10)
if mouse_y_velocity > 5 or mouse_y_velocity < -5:
x -= clamp(mouse_y_velocity / 12.5, -10, 10)
else:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
mouse_locked = false
mouse_x_velocity = 0
mouse_y_velocity = 0
rotate_camera_y(y, delta)
rotate_camera_x(x, delta)
# reset gimbals
if Input.is_action_pressed("cam_reset"):
reset()
current_zoom = clamp(current_zoom, zoom_min, zoom_max)
var pos = Vector3($InnerGimbal/Camera3D.position)
pos.y = lerp(pos.y, float(current_zoom), zoom_speed*delta)
pos.z = lerp(pos.z, float(current_zoom), zoom_speed*delta)
$InnerGimbal/Camera3D.position = pos

View file

@ -1,6 +1,6 @@
[gd_scene load_steps=8 format=4 uid="uid://cfceg80unq0pe"]
[ext_resource type="Script" uid="uid://djeyfi7vm2vw0" path="res://player/player.gd" id="1_onrkg"]
[ext_resource type="Script" uid="uid://bfflnag3p4gen" path="res://player/player.gd" id="1_onrkg"]
[ext_resource type="Script" uid="uid://oi6sint7jkc6" path="res://player/camera_gimbal.gd" id="2_onrkg"]
[ext_resource type="Texture2D" uid="uid://cfb0gbwm57hm4" path="res://models/player_0.png" id="3_hqtel"]

View file

@ -87,9 +87,28 @@ backpack_3={
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":51,"physical_keycode":0,"key_label":0,"unicode":51,"location":0,"echo":false,"script":null)
]
}
shift_lock={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194325,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}
zoom_in={
"deadzone": 0.2,
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":4,"canceled":false,"pressed":false,"double_click":false,"script":null)
]
}
zoom_out={
"deadzone": 0.2,
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":5,"canceled":false,"pressed":false,"double_click":false,"script":null)
]
}
[layer_names]
3d_physics/layer_1="World"
3d_physics/layer_2="Player"
3d_physics/layer_3="Object"
[physics]
3d/physics_interpolation/scene_traversal="Legacy"

BIN
world/textures/grass.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
world/textures/sky.hdr Normal file

Binary file not shown.