diff --git a/General/M_TestGridUV.tres b/General/M_TestGridUV.tres new file mode 100644 index 0000000..07d661b --- /dev/null +++ b/General/M_TestGridUV.tres @@ -0,0 +1,10 @@ +[gd_resource type="ShaderMaterial" load_steps=3 format=3 uid="uid://doj16325e56qm"] + +[ext_resource type="Texture2D" uid="uid://cywlxpcb22pgp" path="res://General/T_TestGrid.png" id="1_78t2d"] +[ext_resource type="Shader" path="res://General/S_TestGridUV.gdshader" id="1_iaos4"] + +[resource] +render_priority = 0 +shader = ExtResource("1_iaos4") +shader_parameter/uv_scale = Vector2(100, 100) +shader_parameter/albedo = ExtResource("1_78t2d") diff --git a/Planetside/Environment/M_TestGrid.tres b/General/M_TestGridWS.tres similarity index 81% rename from Planetside/Environment/M_TestGrid.tres rename to General/M_TestGridWS.tres index 84815bb..23e1488 100644 --- a/Planetside/Environment/M_TestGrid.tres +++ b/General/M_TestGridWS.tres @@ -1,6 +1,6 @@ [gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://bts702ltutin6"] -[ext_resource type="Texture2D" uid="uid://cywlxpcb22pgp" path="res://Environment/T_TestGrid.png" id="1_uabna"] +[ext_resource type="Texture2D" uid="uid://cywlxpcb22pgp" path="res://General/T_TestGrid.png" id="1_uabna"] [resource] albedo_texture = ExtResource("1_uabna") diff --git a/General/Mesh_CubeSphere.tscn b/General/Mesh_CubeSphere.tscn new file mode 100644 index 0000000..ffa2ee5 --- /dev/null +++ b/General/Mesh_CubeSphere.tscn @@ -0,0 +1,9 @@ +[gd_scene load_steps=3 format=3 uid="uid://byqft1h0ys7v8"] + +[ext_resource type="PackedScene" uid="uid://dy766wl2cvjf" path="res://General/SM_CubeSphere.blend" id="1_4o3hn"] +[ext_resource type="Material" uid="uid://doj16325e56qm" path="res://General/M_TestGridUV.tres" id="2_julkn"] + +[node name="SM_CubeSphere" instance=ExtResource("1_4o3hn")] + +[node name="Cube" parent="." index="0"] +surface_material_override/0 = ExtResource("2_julkn") diff --git a/General/SM_CubeSphere.blend b/General/SM_CubeSphere.blend new file mode 100644 index 0000000..f40b062 Binary files /dev/null and b/General/SM_CubeSphere.blend differ diff --git a/General/SM_CubeSphere.blend.import b/General/SM_CubeSphere.blend.import new file mode 100644 index 0000000..8f24bd3 --- /dev/null +++ b/General/SM_CubeSphere.blend.import @@ -0,0 +1,48 @@ +[remap] + +importer="scene" +importer_version=1 +type="PackedScene" +uid="uid://dy766wl2cvjf" +path="res://.godot/imported/SM_CubeSphere.blend-0ed41a56b53a9ddf3c0b514354d012ea.scn" + +[deps] + +source_file="res://General/SM_CubeSphere.blend" +dest_files=["res://.godot/imported/SM_CubeSphere.blend-0ed41a56b53a9ddf3c0b514354d012ea.scn"] + +[params] + +nodes/root_type="Node3D" +nodes/root_name="Scene Root" +nodes/apply_root_scale=true +nodes/root_scale=1.0 +meshes/ensure_tangents=true +meshes/generate_lods=true +meshes/create_shadow_meshes=true +meshes/light_baking=1 +meshes/lightmap_texel_size=0.2 +skins/use_named_skins=true +animation/import=true +animation/fps=30 +animation/trimming=false +animation/remove_immutable_tracks=true +import_script/path="" +_subresources={} +gltf/embedded_image_handling=1 +blender/nodes/visible=0 +blender/nodes/punctual_lights=true +blender/nodes/cameras=true +blender/nodes/custom_properties=true +blender/nodes/modifiers=1 +blender/meshes/colors=false +blender/meshes/uvs=true +blender/meshes/normals=true +blender/meshes/tangents=true +blender/meshes/skins=2 +blender/meshes/export_bones_deforming_mesh_only=false +blender/materials/unpack_enabled=true +blender/materials/export_materials=1 +blender/animation/limit_playback=true +blender/animation/always_sample=true +blender/animation/group_tracks=true diff --git a/General/SM_CubeSphere.blend1 b/General/SM_CubeSphere.blend1 new file mode 100644 index 0000000..3823468 Binary files /dev/null and b/General/SM_CubeSphere.blend1 differ diff --git a/General/S_TestGridUV.gdshader b/General/S_TestGridUV.gdshader new file mode 100644 index 0000000..ae5cd09 --- /dev/null +++ b/General/S_TestGridUV.gdshader @@ -0,0 +1,8 @@ +shader_type spatial; + +uniform sampler2D albedo : source_color,filter_nearest_mipmap_anisotropic; +uniform vec2 uv_scale; + +void fragment() { + ALBEDO = texture(albedo, UV * uv_scale).xyz; +} diff --git a/Planetside/Environment/S_TestGrid.gdshader b/General/S_TestGridWS.gdshader similarity index 100% rename from Planetside/Environment/S_TestGrid.gdshader rename to General/S_TestGridWS.gdshader diff --git a/Planetside/Environment/T_TestGrid.png b/General/T_TestGrid.png similarity index 100% rename from Planetside/Environment/T_TestGrid.png rename to General/T_TestGrid.png diff --git a/Planetside/Environment/T_TestGrid.png.import b/General/T_TestGrid.png.import similarity index 70% rename from Planetside/Environment/T_TestGrid.png.import rename to General/T_TestGrid.png.import index 875aef3..4fb50bd 100644 --- a/Planetside/Environment/T_TestGrid.png.import +++ b/General/T_TestGrid.png.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://cywlxpcb22pgp" -path="res://.godot/imported/T_TestGrid.png-ebd533d215a8ac8ec541cf0294a0054c.ctex" +path="res://.godot/imported/T_TestGrid.png-393ac48eeed82835ca57c5131d7d9a96.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://Planetside/Environment/T_TestGrid.png" -dest_files=["res://.godot/imported/T_TestGrid.png-ebd533d215a8ac8ec541cf0294a0054c.ctex"] +source_file="res://General/T_TestGrid.png" +dest_files=["res://.godot/imported/T_TestGrid.png-393ac48eeed82835ca57c5131d7d9a96.ctex"] [params] diff --git a/Spaceflight/Prefabs/SpacePlayer.tscn b/Spaceflight/Prefabs/SpacePlayer.tscn index c9e412e..af85bd3 100644 --- a/Spaceflight/Prefabs/SpacePlayer.tscn +++ b/Spaceflight/Prefabs/SpacePlayer.tscn @@ -1,8 +1,14 @@ -[gd_scene load_steps=2 format=3 uid="uid://mffl7glgme2h"] +[gd_scene load_steps=3 format=3 uid="uid://mffl7glgme2h"] [ext_resource type="Script" path="res://Spaceflight/Scripts/FlightController.cs" id="1_t3b02"] +[ext_resource type="PackedScene" uid="uid://diixaewdb6uws" path="res://Spaceflight/UI/SK_Axes.blend" id="2_h1fcl"] [node name="SpacePlayer" type="Node3D"] script = ExtResource("1_t3b02") [node name="MainCamera" type="Camera3D" parent="."] + +[node name="CockpitBase" type="Node3D" parent="."] + +[node name="SK_Axes" parent="CockpitBase" instance=ExtResource("2_h1fcl")] +transform = Transform3D(0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, -0.0765332, -0.0404728, -0.0689048) diff --git a/Spaceflight/Scripts/FlightController.cs b/Spaceflight/Scripts/FlightController.cs index 059888b..357395e 100644 --- a/Spaceflight/Scripts/FlightController.cs +++ b/Spaceflight/Scripts/FlightController.cs @@ -4,25 +4,23 @@ using System; public partial class FlightController : Node3D { Camera3D PlayerCam; Vector3 AngularVelocity; - + Vector3 LinearVelocity; public override void _Ready() { this.PlayerCam = this.GetNode("MainCamera"); this.PlayerCam.Current = true; - Input.MouseMode = Input.MouseModeEnum.Hidden; } public override void _Process(double deltaSeconds) { - Vector2 currentMousePos = GetViewport().GetMousePosition(); - Vector2I center = GetViewport().GetWindow().Size / 2; - Vector2 centerFloat = new(center.X, center.Y); - Vector2 delta = (currentMousePos - centerFloat) * (float)deltaSeconds; - Input.WarpMouse(center); - - if (delta != Vector2.Zero) { + float FlightPitch = Input.GetAxis("FlightPitch-", "FlightPitch+"); + float FlightYaw = Input.GetAxis("FlightYaw-", "FlightYaw+"); + float FlightRoll = Input.GetAxis("FlightRoll-", "FlightRoll+"); + Vector3 FlightSpin = new Vector3(-FlightPitch, FlightYaw, FlightRoll) * (float)deltaSeconds; + + if (FlightSpin != Vector3.Zero) { Quaternion quat = new Quaternion(this.GlobalTransform.Basis); - Vector3 LocalAccel = new Vector3(delta.Y, delta.X, 0f) * 3f * (float)deltaSeconds; + Vector3 LocalAccel = FlightSpin * 100f * (float)deltaSeconds; if (quat.GetAxis().LengthSquared() != 0f) { this.AngularVelocity -= LocalAccel.Rotated(quat.GetAxis().Normalized(), quat.GetAngle()); } @@ -30,6 +28,7 @@ public partial class FlightController : Node3D { this.AngularVelocity -= LocalAccel; } } + this.AngularVelocity *= (float)(1.0 - deltaSeconds * 2.0); if (this.AngularVelocity.Length() > 0f) { Quaternion rotationThisFrame = Quaternion.FromEuler(this.AngularVelocity * (float)deltaSeconds); @@ -37,8 +36,28 @@ public partial class FlightController : Node3D { this.GlobalRotate(rotationThisFrame.GetAxis().Normalized(), rotationThisFrame.GetAngle()); } } - } + float FlightStrafe = Input.GetAxis("FlightStrafe-", "FlightStrafe+"); + float FlightElevate = Input.GetAxis("FlightElevate-", "FlightElevate+"); + float FlightThrust = Input.GetAxis("FlightThrust-", "FlightThrust+"); + Vector3 FlightMovement = new Vector3(FlightStrafe, FlightElevate, -FlightThrust) * (float)deltaSeconds; + + if (FlightMovement != Vector3.Zero) { + Quaternion quat = new Quaternion(this.GlobalTransform.Basis); + Vector3 LocalAccel = FlightMovement * 100f * (float)deltaSeconds; + if (quat.GetAxis().LengthSquared() != 0f) { + this.LinearVelocity += LocalAccel.Rotated(quat.GetAxis().Normalized(), quat.GetAngle()); + } + else { + this.LinearVelocity += LocalAccel; + } + } + + if (this.LinearVelocity.Length() > 0f) { + Vector3 movementThisFrame = this.LinearVelocity * (float)deltaSeconds; + this.GlobalTranslate(movementThisFrame); + } + } public override void _Input(InputEvent @event) { base._Input(@event); diff --git a/Spaceflight/SpaceTest.tscn b/Spaceflight/SpaceTest.tscn index dbe67af..d1132fa 100644 --- a/Spaceflight/SpaceTest.tscn +++ b/Spaceflight/SpaceTest.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=4 format=3 uid="uid://681x341bmq7u"] +[gd_scene load_steps=5 format=3 uid="uid://681x341bmq7u"] [ext_resource type="PackedScene" uid="uid://mffl7glgme2h" path="res://Spaceflight/Prefabs/SpacePlayer.tscn" id="1_cwxy4"] [ext_resource type="PackedScene" uid="uid://bgqhmlshc8pu" path="res://Spaceflight/Environment/SM_SpaceSkybox.blend" id="2_3sifq"] +[ext_resource type="PackedScene" uid="uid://byqft1h0ys7v8" path="res://General/Mesh_CubeSphere.tscn" id="3_bhtq2"] [sub_resource type="Environment" id="Environment_owpo5"] @@ -14,3 +15,6 @@ environment = SubResource("Environment_owpo5") [node name="SM_SpaceSkybox" parent="." instance=ExtResource("2_3sifq")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.221079, 0, 0.640379) + +[node name="SM_CubeSphere" parent="." instance=ExtResource("3_bhtq2")] +transform = Transform3D(100, 0, 0, 0, 100, 0, 0, 0, 100, 118.458, 0, -175.593) diff --git a/Planetside/Environment/Floor.blend1 b/Spaceflight/UI/SK_Axes.blend similarity index 55% rename from Planetside/Environment/Floor.blend1 rename to Spaceflight/UI/SK_Axes.blend index 3abdaad..57e8fac 100644 Binary files a/Planetside/Environment/Floor.blend1 and b/Spaceflight/UI/SK_Axes.blend differ diff --git a/Spaceflight/UI/SK_Axes.blend.import b/Spaceflight/UI/SK_Axes.blend.import new file mode 100644 index 0000000..1face0b --- /dev/null +++ b/Spaceflight/UI/SK_Axes.blend.import @@ -0,0 +1,48 @@ +[remap] + +importer="scene" +importer_version=1 +type="PackedScene" +uid="uid://diixaewdb6uws" +path="res://.godot/imported/SK_Axes.blend-b853d1f65a4a9ed68cae3f7ded63e8de.scn" + +[deps] + +source_file="res://Spaceflight/UI/SK_Axes.blend" +dest_files=["res://.godot/imported/SK_Axes.blend-b853d1f65a4a9ed68cae3f7ded63e8de.scn"] + +[params] + +nodes/root_type="Node3D" +nodes/root_name="Scene Root" +nodes/apply_root_scale=true +nodes/root_scale=1.0 +meshes/ensure_tangents=true +meshes/generate_lods=true +meshes/create_shadow_meshes=true +meshes/light_baking=1 +meshes/lightmap_texel_size=0.2 +skins/use_named_skins=true +animation/import=true +animation/fps=30 +animation/trimming=false +animation/remove_immutable_tracks=true +import_script/path="" +_subresources={} +gltf/embedded_image_handling=1 +blender/nodes/visible=0 +blender/nodes/punctual_lights=true +blender/nodes/cameras=true +blender/nodes/custom_properties=true +blender/nodes/modifiers=1 +blender/meshes/colors=false +blender/meshes/uvs=true +blender/meshes/normals=true +blender/meshes/tangents=true +blender/meshes/skins=2 +blender/meshes/export_bones_deforming_mesh_only=false +blender/materials/unpack_enabled=true +blender/materials/export_materials=1 +blender/animation/limit_playback=true +blender/animation/always_sample=true +blender/animation/group_tracks=true diff --git a/Spaceflight/UI/SK_Axes.blend1 b/Spaceflight/UI/SK_Axes.blend1 new file mode 100644 index 0000000..b549c6b Binary files /dev/null and b/Spaceflight/UI/SK_Axes.blend1 differ diff --git a/project.godot b/project.godot index 2393c25..142e9cc 100644 --- a/project.godot +++ b/project.godot @@ -17,3 +17,66 @@ config/features=PackedStringArray("4.1", "C#", "Forward Plus") [dotnet] project/assembly_name="spes" + +[input] + +FlightPitch+={ +"deadzone": 0.33, +"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":-1.0,"script":null) +] +} +FlightPitch-={ +"deadzone": 0.33, +"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":1.0,"script":null) +] +} +FlightYaw+={ +"deadzone": 0.33, +"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":1.0,"script":null) +] +} +FlightYaw-={ +"deadzone": 0.33, +"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":-1.0,"script":null) +] +} +FlightRoll+={ +"deadzone": 0.33, +"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":10,"pressure":0.0,"pressed":true,"script":null) +] +} +FlightRoll-={ +"deadzone": 0.33, +"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":9,"pressure":0.0,"pressed":true,"script":null) +] +} +FlightThrust+={ +"deadzone": 0.33, +"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":-1.0,"script":null) +] +} +FlightThrust-={ +"deadzone": 0.33, +"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":1.0,"script":null) +] +} +FlightStrafe+={ +"deadzone": 0.33, +"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":1.0,"script":null) +] +} +FlightStrafe-={ +"deadzone": 0.33, +"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":-1.0,"script":null) +] +} +FlightElevate+={ +"deadzone": 0.33, +"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":5,"axis_value":1.0,"script":null) +] +} +FlightElevate-={ +"deadzone": 0.33, +"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":4,"axis_value":1.0,"script":null) +] +}