diff options
Diffstat (limited to 'godot')
| -rw-r--r-- | godot/addons/blend/import_blend.gd | 104 | ||||
| -rw-r--r-- | godot/addons/blend/plugin.cfg | 7 | ||||
| -rw-r--r-- | godot/addons/blend/plugin.gd | 35 | ||||
| -rw-r--r-- | godot/bin/networked_machine.gdnlib | 14 | ||||
| -rw-r--r-- | godot/bin/networked_machine.gdns | 8 | ||||
| -rwxr-xr-x | godot/bin/x11/libnetmachine.so | bin | 0 -> 4807272 bytes | |||
| -rw-r--r-- | godot/project.godot | 6 | ||||
| -rw-r--r-- | godot/scenes/characters/PlayerRigid.tscn | 2 | ||||
| -rw-r--r-- | godot/scenes/machines/Cannon.tscn | 2 | ||||
| -rw-r--r-- | godot/scripts/characters/player_controller_new.gd | 42 | ||||
| -rw-r--r-- | godot/scripts/machines/Cannon.gd | 2 | ||||
| -rw-r--r-- | godot/scripts/machines/NetworkedMachineGDS.gd (renamed from godot/scripts/machines/NetworkedMachine.gd) | 0 |
12 files changed, 200 insertions, 22 deletions
diff --git a/godot/addons/blend/import_blend.gd b/godot/addons/blend/import_blend.gd new file mode 100644 index 0000000..102b1fc --- /dev/null +++ b/godot/addons/blend/import_blend.gd @@ -0,0 +1,104 @@ +# Copyright (c) 2021 K. S. Ernest (iFire) Lee and V-Sekai Contributors. +# Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. +# Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +tool +extends EditorSceneImporter + +const settings_blender_path = "filesystem/import/blend/blender_path" + +var blender_path : String + +func _init(): + if not ProjectSettings.has_setting(settings_blender_path): + ProjectSettings.set_setting(settings_blender_path, "blender") + ProjectSettings.set_initial_value(settings_blender_path, "blender") + else: + blender_path = ProjectSettings.get_setting(settings_blender_path) + var property_info = { + "name": settings_blender_path, + "type": TYPE_STRING, + "hint": PROPERTY_HINT_GLOBAL_FILE, + "hint_string": "" + } + ProjectSettings.add_property_info(property_info) + + +func _get_extensions(): + return ["blend"] + + +func _get_import_flags(): + return EditorSceneImporter.IMPORT_SCENE + + +func _import_scene(path: String, flags: int, bake_fps: int): + var import_config_file = ConfigFile.new() + import_config_file.load(path + ".import") + var compression_flags: int = import_config_file.get_value("params", "meshes/compress", 0) + # ARRAY_COMPRESS_BASE = (ARRAY_INDEX + 1) + compression_flags = compression_flags << (VisualServer.ARRAY_INDEX + 1) + if import_config_file.get_value("params", "meshes/octahedral_compression", false): + compression_flags |= VisualServer.ARRAY_FLAG_USE_OCTAHEDRAL_COMPRESSION + + var path_global : String = ProjectSettings.globalize_path(path) + path_global = path_global.c_escape() + var output_path : String = "res://.import/" + path.get_file() + "-" + path.md5_text() + ".glb" + var output_path_global = ProjectSettings.globalize_path(output_path) + output_path_global = output_path_global.c_escape() + var stdout = [].duplicate() + var addon_path : String = blender_path + var addon_path_global = ProjectSettings.globalize_path(addon_path) + var params: PoolStringArray = [ + "filepath='%s'" % output_path_global, + "export_format='GLB'", + "export_colors=True", + "export_all_influences=False", + "export_extras=True", + "export_cameras=True", + "export_lights=True", + "export_apply=(len(bpy.data.shape_keys)==0)" + ] + var script : String = "import bpy; bpy.ops.export_scene.gltf(%s)" % params.join(",") + path_global = path_global.c_escape() + var args = PoolStringArray([ + path_global, + "--background", + "--python-expr", + script + ]) + var ret = OS.execute(addon_path_global, args, true, stdout, true) + if ret != OK: + push_error( + "Blender import failed with code=%d.\nCommand: %s\nOutput: %s" % [ + ret, + args.join(" "), + PoolStringArray(stdout).join("\n") + ] + ) + return null + + var root_node: Spatial = null + if Engine.get_version_info()["major"] <= 3 and Engine.get_version_info()["minor"] <= 3: + root_node = call("import_scene_from_other_importer", output_path, flags, bake_fps) + else: + root_node = call("import_scene_from_other_importer", output_path, flags, bake_fps, compression_flags) + return root_node diff --git a/godot/addons/blend/plugin.cfg b/godot/addons/blend/plugin.cfg new file mode 100644 index 0000000..3fe0961 --- /dev/null +++ b/godot/addons/blend/plugin.cfg @@ -0,0 +1,7 @@ +[plugin] + +name="Blend" +description="Blend Importer" +author="K. S. Ernest Lee and V-Sekai Contributors" +version="1.0.0" +script="plugin.gd" diff --git a/godot/addons/blend/plugin.gd b/godot/addons/blend/plugin.gd new file mode 100644 index 0000000..d399e67 --- /dev/null +++ b/godot/addons/blend/plugin.gd @@ -0,0 +1,35 @@ +# Copyright (c) 2021 K. S. Ernest (iFire) Lee and V-Sekai Contributors. +# Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. +# Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +tool +extends EditorPlugin + +var import_plugin + +func _enter_tree(): + import_plugin = preload("res://addons/blend/import_blend.gd").new() + add_scene_import_plugin(import_plugin) + + +func _exit_tree(): + remove_scene_import_plugin(import_plugin) + import_plugin = null diff --git a/godot/bin/networked_machine.gdnlib b/godot/bin/networked_machine.gdnlib new file mode 100644 index 0000000..b0d628e --- /dev/null +++ b/godot/bin/networked_machine.gdnlib @@ -0,0 +1,14 @@ +[general] + +singleton=false +load_once=false +symbol_prefix="godot_" +reloadable=true + +[entry] + +X11.64="res://bin/x11/libnetmachine.so" + +[dependencies] + +X11.64=[ ] diff --git a/godot/bin/networked_machine.gdns b/godot/bin/networked_machine.gdns new file mode 100644 index 0000000..10e3a5a --- /dev/null +++ b/godot/bin/networked_machine.gdns @@ -0,0 +1,8 @@ +[gd_resource type="NativeScript" load_steps=2 format=2] + +[ext_resource path="res://bin/networked_machine.gdnlib" type="GDNativeLibrary" id=1] + +[resource] +resource_name = "networked_machine" +class_name = "NetworkedMachine" +library = ExtResource( 1 ) diff --git a/godot/bin/x11/libnetmachine.so b/godot/bin/x11/libnetmachine.so Binary files differnew file mode 100755 index 0000000..c6fc078 --- /dev/null +++ b/godot/bin/x11/libnetmachine.so diff --git a/godot/project.godot b/godot/project.godot index e5bb440..9366827 100644 --- a/godot/project.godot +++ b/godot/project.godot @@ -20,6 +20,10 @@ config/icon="res://icon.png" window/vsync/use_vsync=false window/stretch/mode="2d" +[editor_plugins] + +enabled=PoolStringArray( "res://addons/blend/plugin.cfg" ) + [input] ui_accept={ @@ -125,7 +129,7 @@ move_jump={ "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":32,"unicode":0,"echo":false,"script":null) ] } -duck={ +move_duck={ "deadzone": 0.5, "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":16777238,"unicode":0,"echo":false,"script":null) ] diff --git a/godot/scenes/characters/PlayerRigid.tscn b/godot/scenes/characters/PlayerRigid.tscn index 3834ef2..8f61532 100644 --- a/godot/scenes/characters/PlayerRigid.tscn +++ b/godot/scenes/characters/PlayerRigid.tscn @@ -49,7 +49,7 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.44, 0 ) keep_aspect = 0 cull_mask = 524287 fov = 90.0 -near = 0.3 +near = 0.2 far = 1449.4 [node name="UseRay" type="RayCast" parent="Head/Camera"] diff --git a/godot/scenes/machines/Cannon.tscn b/godot/scenes/machines/Cannon.tscn index 15f1467..e84f74a 100644 --- a/godot/scenes/machines/Cannon.tscn +++ b/godot/scenes/machines/Cannon.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=11 format=2] -[ext_resource path="res://scripts/machines/Cannon.gd" type="Script" id=1] +[ext_resource path="res://bin/networked_machine.gdns" type="Script" id=1] [ext_resource path="res://sounds/explode.wav" type="AudioStream" id=2] [sub_resource type="PhysicsMaterial" id=8] diff --git a/godot/scripts/characters/player_controller_new.gd b/godot/scripts/characters/player_controller_new.gd index 6aec2d9..6df88f0 100644 --- a/godot/scripts/characters/player_controller_new.gd +++ b/godot/scripts/characters/player_controller_new.gd @@ -19,6 +19,7 @@ var direction := Vector3() var move_axis := Vector2() var floorspeed := Vector3() var jumping = false +var can_jump = true onready var nav = $NavigationAgent # Walk @@ -26,22 +27,21 @@ const FLOOR_MAX_ANGLE: float = deg2rad(46.0) export(float) var jump_height = 400.0 var in_water : bool = false var swim_speed : float = 400.0 +var climb_speed : float = 5.0 # Control var controlling_machine = false #whether character is riding/controlling something var machine = null export var is_player = false #whether character is currently controlled by a player -var should_move = false var ladder_m = null #physics var player_state : PhysicsDirectBodyState var is_on_floor:bool -export(float) var acceleration = 80.0 -export(int) var walk_speed = 6 -export(float) var c_friction = 4.0 -export(float) var _airspeed_cap = 1.0 -export(float) var air_control = 1.0 +var acceleration = 80.0 +export(int) var walk_speed = 5 +var c_friction = 4.0 +var air_control = 0.3 # Called when the node enters the scene tree func _ready() -> void: @@ -174,10 +174,13 @@ func on_floor_test() -> bool: func _integrate_forces(state) -> void: player_state = state velocity = state.get_linear_velocity() - if should_move: - nav.set_velocity(velocity) - if nav.is_target_reached(): - should_move = false + for i in range(player_state.get_contact_count()): + var contact_angle_from_up : float = Vector3.UP.angle_to(player_state.get_contact_local_normal(i)) + if contact_angle_from_up > FLOOR_MAX_ANGLE and !is_on_floor: + friction = 0 + break + if i == player_state.get_contact_count() - 1: + friction = 1 # on input event func _input(event: InputEvent) -> void: @@ -191,16 +194,12 @@ func walk(_delta:float) -> void: direction = Vector3() var aim: Basis = head.get_global_transform().basis direction += -move_axis.x * aim.z + move_axis.y * aim.x - if !is_player and should_move: - direction = nav.get_next_location() - global_transform.origin - if nav.get_next_location().y - global_transform.origin.y > 0.05 and is_on_floor: - apply_central_impulse(Vector3.UP*jump_height) direction.y = 0 direction = direction.normalized() # Jump - if is_on_floor and is_player and jumping: - apply_central_impulse(Vector3.UP*jump_height) + if is_player and jumping and is_on_floor and can_jump: + jump() #max walk speed var _speed = walk_speed @@ -213,13 +212,20 @@ func walk(_delta:float) -> void: var projVel = Vector2(velocity.x-floorspeed.x,velocity.z-floorspeed.z).dot(Vector2(direction.x,direction.z)) if is_on_floor: + add_central_force(-mass*linear_velocity.normalized()*c_friction)#friction if _speed - _cspeed > 0: add_central_force (mass*Vector3(direction.x*_temp_accel, 0, direction.z*_temp_accel))#velocity.x += direction.x*_temp_accel else: add_central_force(mass*Vector3(direction.x*(_speed-projVel), 0, direction.z*(_speed-projVel))) - elif _airspeed_cap - projVel > 0: + elif 1.0 - projVel > 0: add_central_force (mass*Vector3(direction.x*_temp_accel, 0, direction.z*_temp_accel)) +func jump(): + can_jump = false + apply_central_impulse(Vector3.UP*jump_height) + yield(get_tree().create_timer(0.05),"timeout") + can_jump = true + func swim(_delta): #drag and buoyancy add_central_force(Vector3.UP*weight*1.0) @@ -255,7 +261,7 @@ func mount_ladder(target_ladder): #called each frame while climbing ladder func climb_ladder(delta): - var new_ladder_pos = ladder_m.global_transform.origin + ladder_m.global_transform.basis.y.normalized() * move_axis.x * delta + var new_ladder_pos = ladder_m.global_transform.origin + ladder_m.global_transform.basis.y.normalized() * move_axis.x * delta * climb_speed var prog = ladder_m.get_parent().get_climb_scalar(new_ladder_pos) if prog >= 0.0 and prog <= 1.0: ladder_m.global_transform.origin = new_ladder_pos diff --git a/godot/scripts/machines/Cannon.gd b/godot/scripts/machines/Cannon.gd index 6b636c5..15807bf 100644 --- a/godot/scripts/machines/Cannon.gd +++ b/godot/scripts/machines/Cannon.gd @@ -1,4 +1,4 @@ -extends "res://scripts/machines/NetworkedMachine.gd" +extends "res://bin/networked_machine.gdns" var world_ballistics = null diff --git a/godot/scripts/machines/NetworkedMachine.gd b/godot/scripts/machines/NetworkedMachineGDS.gd index 5ce5cbe..5ce5cbe 100644 --- a/godot/scripts/machines/NetworkedMachine.gd +++ b/godot/scripts/machines/NetworkedMachineGDS.gd |
