From 7d771c6fc670fe2a4f92cda30cb6585c8f91314a Mon Sep 17 00:00:00 2001 From: osquallo Date: Thu, 26 Jul 2018 19:15:50 +0200 Subject: [PATCH] divers test. --- project.godot | 3 + scenes/Game/Box.gd | 20 +-- scenes/Game/Character/Character.gd | 12 +- scenes/Game/CubeShaderTest.tscn | 115 +++++++++-------- scenes/Game/Game.tscn | 198 +++++++++++++++++++++++++---- scenes/Main.tscn | 2 +- 6 files changed, 254 insertions(+), 96 deletions(-) diff --git a/project.godot b/project.godot index 42f9dc5..9c36872 100644 --- a/project.godot +++ b/project.godot @@ -77,6 +77,9 @@ file_logging/enable_file_logging=true [rendering] quality/filters/use_nearest_mipmap_filter=true +quality/filters/anisotropic_filter_level=8 quality/shadows/filter_mode=2 +quality/subsurface_scattering/quality=2 +quality/subsurface_scattering/follow_surface=true quality/filters/msaa=3 environment/default_environment="res://default_env.tres" diff --git a/scenes/Game/Box.gd b/scenes/Game/Box.gd index e705054..b57948e 100644 --- a/scenes/Game/Box.gd +++ b/scenes/Game/Box.gd @@ -1,13 +1,15 @@ extends RigidBody -var hit_timer = 0 +func _on_Box_sleeping_state_changed(): +# pass + if self.sleeping: + $MeshInstance.get_surface_material(0).albedo_color = Color( 0.0, 1.0, 0.0, 1 ) + else: + $MeshInstance.get_surface_material(0).albedo_color = Color( 0.0, 0.0, 1.0, 1 ) -func _process(delta): - if hit_timer >0: - hit_timer -= delta - if hit_timer <= 0: - $MeshInstance.get_surface_material(0).albedo_color = Color(1,1,1,1) +func _on_Box_body_entered(body): + $MeshInstance.get_surface_material(0).albedo_color = Color( 0.0, 1.0, 0.0, 1 ) -func hit(): - $MeshInstance.get_surface_material(0).albedo_color = Color(1,0,0, 1) - hit_timer = 1 \ No newline at end of file + +func _on_Box_body_exited(body): + $MeshInstance.get_surface_material(0).albedo_color = Color( 0.0, 0.0, 1.0, 1 ) diff --git a/scenes/Game/Character/Character.gd b/scenes/Game/Character/Character.gd index 1f04b84..6d6cadc 100644 --- a/scenes/Game/Character/Character.gd +++ b/scenes/Game/Character/Character.gd @@ -84,12 +84,12 @@ func process_movement(delta): var collision_info = move_and_collide(vel * delta) if collision_info: vel = vel.bounce(collision_info.normal) - if collision_info.collider.is_class("Node"): - if collision_info.collider.name == "Box": - var obj = collision_info.collider - if obj.has_method( "hit" ): - obj.hit() - print(obj.name) + var obj = collision_info.collider + if obj.is_class( "RigidBody" ): + obj.sleeping = false +# obj.apply_impulse( collision_info.position, collision_info.collider_velocity ) +# if obj.has_method( "hit" ): +# obj.hit( collision_info.position, collision_info.collider_velocity ) # print(str(collision_info.collider.get_class())) diff --git a/scenes/Game/CubeShaderTest.tscn b/scenes/Game/CubeShaderTest.tscn index fc3983b..acc381e 100644 --- a/scenes/Game/CubeShaderTest.tscn +++ b/scenes/Game/CubeShaderTest.tscn @@ -1,6 +1,6 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=5 format=2] -[sub_resource type="SphereMesh" id=3] +[sub_resource type="SphereMesh" id=1] custom_aabb = AABB( 0, 0, 0, 0, 0, 0 ) radius = 1.0 @@ -9,59 +9,64 @@ radial_segments = 64 rings = 32 is_hemisphere = false -[sub_resource type="SpatialMaterial" id=4] +[sub_resource type="Shader" id=2] + +code = "shader_type spatial; +render_mode blend_mix,depth_draw_opaque,cull_back,diffuse_burley,specular_schlick_ggx; +uniform vec4 albedo : hint_color; +uniform sampler2D texture_albedo : hint_albedo; +uniform float specular; +uniform float metallic; +uniform float roughness : hint_range(0,1); +uniform float point_size : hint_range(0,128); +uniform sampler2D texture_metallic : hint_white; +uniform vec4 metallic_texture_channel; +uniform sampler2D texture_roughness : hint_white; +uniform vec4 roughness_texture_channel; +uniform vec3 uv1_scale; +uniform vec3 uv1_offset; +uniform vec3 uv2_scale; +uniform vec3 uv2_offset; + + +void vertex() { + UV=UV*uv1_scale.xy+uv1_offset.xy; +} + + + + +void fragment() { + vec2 base_uv = UV; + vec4 albedo_tex = texture(texture_albedo,base_uv); + ALBEDO = albedo.rgb * albedo_tex.rgb; + float metallic_tex = dot(texture(texture_metallic,base_uv),metallic_texture_channel); + METALLIC = metallic_tex * metallic; + float roughness_tex = dot(texture(texture_roughness,base_uv),roughness_texture_channel); + ROUGHNESS = roughness_tex * roughness; + SPECULAR = specular; +} +" +_sections_unfolded = [ "Resource" ] + +[sub_resource type="ShaderMaterial" id=3] render_priority = 0 -flags_transparent = false -flags_unshaded = false -flags_vertex_lighting = false -flags_no_depth_test = false -flags_use_point_size = false -flags_world_triplanar = false -flags_fixed_size = false -flags_albedo_tex_force_srgb = false -vertex_color_use_as_albedo = false -vertex_color_is_srgb = false -params_diffuse_mode = 0 -params_specular_mode = 0 -params_blend_mode = 0 -params_cull_mode = 0 -params_depth_draw_mode = 0 -params_line_width = 1.0 -params_point_size = 1.0 -params_billboard_mode = 0 -params_grow = false -params_use_alpha_scissor = false -albedo_color = Color( 1, 0.152344, 0.867554, 1 ) -metallic = 0.0 -metallic_specular = 0.5 -metallic_texture_channel = 0 -roughness = 0.0 -roughness_texture_channel = 0 -emission_enabled = false -normal_enabled = false -rim_enabled = false -clearcoat_enabled = false -anisotropy_enabled = false -ao_enabled = false -depth_enabled = false -subsurf_scatter_enabled = false -transmission_enabled = false -refraction_enabled = false -detail_enabled = false -uv1_scale = Vector3( 1, 1, 1 ) -uv1_offset = Vector3( 0, 0, 0 ) -uv1_triplanar = false -uv1_triplanar_sharpness = 1.0 -uv2_scale = Vector3( 1, 1, 1 ) -uv2_offset = Vector3( 0, 0, 0 ) -uv2_triplanar = false -uv2_triplanar_sharpness = 1.0 -proximity_fade_enable = false -distance_fade_enable = false -_sections_unfolded = [ "Albedo" ] +shader = SubResource( 2 ) +shader_param/albedo = Color( 0.513085, 0.250778, 0.675781, 1 ) +shader_param/specular = 1.0 +shader_param/metallic = 1.0 +shader_param/roughness = 0.5 +shader_param/point_size = 0.0 +shader_param/metallic_texture_channel = null +shader_param/roughness_texture_channel = null +shader_param/uv1_scale = null +shader_param/uv1_offset = null +shader_param/uv2_scale = null +shader_param/uv2_offset = null +_sections_unfolded = [ "shader_param" ] -[sub_resource type="ConvexPolygonShape" id=2] +[sub_resource type="ConvexPolygonShape" id=4] points = PoolVector3Array( -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1 ) @@ -104,14 +109,14 @@ lod_min_distance = 0.0 lod_min_hysteresis = 0.0 lod_max_distance = 0.0 lod_max_hysteresis = 0.0 -mesh = SubResource( 3 ) +mesh = SubResource( 1 ) skeleton = NodePath("..") -material/0 = SubResource( 4 ) +material/0 = SubResource( 3 ) _sections_unfolded = [ "material" ] [node name="CollisionShape" type="CollisionShape" parent="." index="1"] -shape = SubResource( 2 ) +shape = SubResource( 4 ) disabled = false diff --git a/scenes/Game/Game.tscn b/scenes/Game/Game.tscn index a503ac1..c323a45 100644 --- a/scenes/Game/Game.tscn +++ b/scenes/Game/Game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=22 format=2] +[gd_scene load_steps=23 format=2] [ext_resource path="res://scenes/Game/Character/Character.tscn" type="PackedScene" id=1] [ext_resource path="res://assets/Game/Brick08/Bricks08_col.jpg" type="Texture" id=2] @@ -88,7 +88,59 @@ _sections_unfolded = [ "Albedo", "Ambient Occlusion", "Anisotropy", "Clearcoat", points = PoolVector3Array( 1, 0, 1, -1, 0, 1, 1, 0, -1, -1, 0, -1 ) -[sub_resource type="CubeMesh" id=4] +[sub_resource type="SpatialMaterial" id=4] + +render_priority = 0 +flags_transparent = true +flags_unshaded = false +flags_vertex_lighting = false +flags_no_depth_test = false +flags_use_point_size = false +flags_world_triplanar = false +flags_fixed_size = false +flags_albedo_tex_force_srgb = false +vertex_color_use_as_albedo = false +vertex_color_is_srgb = false +params_diffuse_mode = 0 +params_specular_mode = 0 +params_blend_mode = 0 +params_cull_mode = 0 +params_depth_draw_mode = 0 +params_line_width = 1.0 +params_point_size = 1.0 +params_billboard_mode = 0 +params_grow = false +params_use_alpha_scissor = false +albedo_color = Color( 1, 1, 1, 0 ) +metallic = 0.0 +metallic_specular = 0.5 +metallic_texture_channel = 0 +roughness = 0.0 +roughness_texture_channel = 0 +emission_enabled = false +normal_enabled = false +rim_enabled = false +clearcoat_enabled = false +anisotropy_enabled = false +ao_enabled = false +depth_enabled = false +subsurf_scatter_enabled = false +transmission_enabled = false +refraction_enabled = false +detail_enabled = false +uv1_scale = Vector3( 1, 1, 1 ) +uv1_offset = Vector3( 0, 0, 0 ) +uv1_triplanar = false +uv1_triplanar_sharpness = 1.0 +uv2_scale = Vector3( 1, 1, 1 ) +uv2_offset = Vector3( 0, 0, 0 ) +uv2_triplanar = false +uv2_triplanar_sharpness = 1.0 +proximity_fade_enable = false +distance_fade_enable = false +_sections_unfolded = [ "Albedo", "Flags" ] + +[sub_resource type="CubeMesh" id=5] custom_aabb = AABB( 0, 0, 0, 0, 0, 0 ) size = Vector3( 2, 2, 2 ) @@ -96,7 +148,7 @@ subdivide_width = 0 subdivide_height = 0 subdivide_depth = 0 -[sub_resource type="SpatialMaterial" id=5] +[sub_resource type="SpatialMaterial" id=6] render_priority = 0 flags_transparent = false @@ -161,11 +213,11 @@ proximity_fade_enable = false distance_fade_enable = false _sections_unfolded = [ "Albedo", "Ambient Occlusion", "Clearcoat", "Depth", "Detail", "Distance Fade", "Flags", "NormalMap", "Proximity Fade", "Rim", "Roughness", "Subsurf Scatter", "Transmission", "Vertex Color" ] -[sub_resource type="ConvexPolygonShape" id=6] +[sub_resource type="ConvexPolygonShape" id=7] points = PoolVector3Array( -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1 ) -[sub_resource type="SpatialMaterial" id=7] +[sub_resource type="SpatialMaterial" id=8] render_priority = 0 flags_transparent = false @@ -225,13 +277,13 @@ proximity_fade_enable = false distance_fade_enable = false _sections_unfolded = [ "Albedo", "Emission", "Flags", "Parameters", "Particles Anim" ] -[sub_resource type="QuadMesh" id=8] +[sub_resource type="QuadMesh" id=9] -material = SubResource( 7 ) +material = SubResource( 8 ) custom_aabb = AABB( 0, 0, 0, 0, 0, 0 ) size = Vector2( 0.4, 0.4 ) -[sub_resource type="SpatialMaterial" id=9] +[sub_resource type="SpatialMaterial" id=10] render_priority = 0 flags_transparent = false @@ -292,9 +344,9 @@ proximity_fade_enable = false distance_fade_enable = false _sections_unfolded = [ "Albedo", "Emission", "Flags", "Parameters", "Particles Anim" ] -[sub_resource type="QuadMesh" id=10] +[sub_resource type="QuadMesh" id=11] -material = SubResource( 9 ) +material = SubResource( 10 ) custom_aabb = AABB( 0, 0, 0, 0, 0, 0 ) size = Vector2( 0.4, 0.4 ) @@ -308,7 +360,7 @@ size = Vector2( 0.4, 0.4 ) editor/display_folded = true -[node name="Ground" type="StaticBody" parent="World/Terrain" index="0"] +[node name="Floor" type="StaticBody" parent="World/Terrain" index="0"] input_ray_pickable = true input_capture_on_drag = false @@ -319,7 +371,7 @@ bounce = 0.0 constant_linear_velocity = Vector3( 0, 0, 0 ) constant_angular_velocity = Vector3( 0, 0, 0 ) -[node name="MeshInstance" type="MeshInstance" parent="World/Terrain/Ground" index="0"] +[node name="MeshInstance" type="MeshInstance" parent="World/Terrain/Floor" index="0"] transform = Transform( 10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0 ) layers = 1 @@ -336,13 +388,49 @@ skeleton = NodePath("..") material/0 = SubResource( 2 ) _sections_unfolded = [ "Transform", "material" ] -[node name="CollisionShape" type="CollisionShape" parent="World/Terrain/Ground" index="1"] +[node name="CollisionShape" type="CollisionShape" parent="World/Terrain/Floor" index="1"] transform = Transform( 10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0 ) shape = SubResource( 3 ) disabled = false -[node name="Wall1" type="StaticBody" parent="World/Terrain" index="1"] +[node name="Ceilling" type="StaticBody" parent="World/Terrain" index="1"] + +transform = Transform( 1, 0, 0, 0, -0.984809, -0.173641, 0, 0.173641, -0.984809, 0, 20, 0 ) +input_ray_pickable = true +input_capture_on_drag = false +collision_layer = 1 +collision_mask = 1 +friction = 1.0 +bounce = 0.0 +constant_linear_velocity = Vector3( 0, 0, 0 ) +constant_angular_velocity = Vector3( 0, 0, 0 ) +_sections_unfolded = [ "Transform" ] + +[node name="MeshInstance" type="MeshInstance" parent="World/Terrain/Ceilling" index="0"] + +transform = Transform( 10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0 ) +layers = 1 +material_override = null +cast_shadow = 1 +extra_cull_margin = 0.0 +use_in_baked_light = false +lod_min_distance = 0.0 +lod_min_hysteresis = 0.0 +lod_max_distance = 0.0 +lod_max_hysteresis = 0.0 +mesh = SubResource( 1 ) +skeleton = NodePath("..") +material/0 = SubResource( 4 ) +_sections_unfolded = [ "Transform", "material" ] + +[node name="CollisionShape" type="CollisionShape" parent="World/Terrain/Ceilling" index="1"] + +transform = Transform( 10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0 ) +shape = SubResource( 3 ) +disabled = false + +[node name="Wall1" type="StaticBody" parent="World/Terrain" index="2"] transform = Transform( -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0, 1, -10, 10, 0 ) input_ray_pickable = true @@ -379,7 +467,7 @@ shape = SubResource( 3 ) disabled = false _sections_unfolded = [ "Transform" ] -[node name="Wall2" type="StaticBody" parent="World/Terrain" index="2"] +[node name="Wall2" type="StaticBody" parent="World/Terrain" index="3"] transform = Transform( -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0, 1, 10, 10, 0 ) input_ray_pickable = true @@ -415,7 +503,7 @@ transform = Transform( 10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0 ) shape = SubResource( 3 ) disabled = false -[node name="Wall3" type="StaticBody" parent="World/Terrain" index="3"] +[node name="Wall3" type="StaticBody" parent="World/Terrain" index="4"] transform = Transform( 1.91069e-15, 4.37114e-08, 1, 1, -4.37114e-08, 0, 4.37114e-08, 1, -4.37114e-08, 0, 10, -10 ) input_ray_pickable = true @@ -451,7 +539,7 @@ transform = Transform( 10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0 ) shape = SubResource( 3 ) disabled = false -[node name="Wall4" type="StaticBody" parent="World/Terrain" index="4"] +[node name="Wall4" type="StaticBody" parent="World/Terrain" index="5"] transform = Transform( 1.91069e-15, 4.37114e-08, -1, 1, -4.37114e-08, 0, -4.37114e-08, -1, -4.37114e-08, 0, 10, 10 ) input_ray_pickable = true @@ -518,7 +606,7 @@ input_capture_on_drag = false collision_layer = 1 collision_mask = 1 mode = 0 -mass = 100.0 +mass = 1020.41 friction = 1.0 bounce = 0.0 gravity_scale = 1.0 @@ -539,6 +627,7 @@ linear_damp = -1.0 angular_velocity = Vector3( 0, 0, 0 ) angular_damp = -1.0 script = ExtResource( 7 ) +_sections_unfolded = [ "Collision" ] [node name="MeshInstance" type="MeshInstance" parent="World/Box" index="0"] @@ -552,30 +641,89 @@ lod_min_distance = 0.0 lod_min_hysteresis = 0.0 lod_max_distance = 0.0 lod_max_hysteresis = 0.0 -mesh = SubResource( 4 ) +mesh = SubResource( 5 ) skeleton = NodePath("..") -material/0 = SubResource( 5 ) +material/0 = SubResource( 6 ) _sections_unfolded = [ "Geometry", "LOD", "material" ] [node name="CollisionShape" type="CollisionShape" parent="World/Box" index="1"] transform = Transform( 1, 1.49012e-08, 0, 1.3411e-07, 1, 0, 2.98023e-08, -2.98023e-08, 1, 0, 0, 0 ) -shape = SubResource( 6 ) +shape = SubResource( 7 ) disabled = false _sections_unfolded = [ "Transform" ] -[node name="CubeShaderTest" parent="World" index="3" instance=ExtResource( 8 )] +[node name="Box2" type="RigidBody" parent="World" index="3"] + +transform = Transform( 0.640199, 0.768209, 0, -0.650662, 0.542239, -0.531616, -0.408393, 0.34034, 0.846985, -3.00203, 8.74323, -4.47902 ) +input_ray_pickable = true +input_capture_on_drag = false +collision_layer = 1 +collision_mask = 1 +mode = 0 +mass = 1020.41 +friction = 1.0 +bounce = 0.0 +gravity_scale = 1.0 +custom_integrator = false +continuous_cd = false +contacts_reported = 0 +contact_monitor = false +sleeping = false +can_sleep = true +axis_lock_linear_x = false +axis_lock_linear_y = false +axis_lock_linear_z = false +axis_lock_angular_x = false +axis_lock_angular_y = false +axis_lock_angular_z = false +linear_velocity = Vector3( 0, 0, 0 ) +linear_damp = -1.0 +angular_velocity = Vector3( 0, 0, 0 ) +angular_damp = -1.0 +script = ExtResource( 7 ) +_sections_unfolded = [ "Collision" ] + +[node name="MeshInstance" type="MeshInstance" parent="World/Box2" index="0"] + +transform = Transform( 1, 1.49012e-08, 0, 2.68221e-07, 1, -5.96046e-08, -2.98023e-08, 1.19209e-07, 1, 0.0656062, -0.054674, 0.0536029 ) +layers = 1 +material_override = null +cast_shadow = 1 +extra_cull_margin = 0.0 +use_in_baked_light = false +lod_min_distance = 0.0 +lod_min_hysteresis = 0.0 +lod_max_distance = 0.0 +lod_max_hysteresis = 0.0 +mesh = SubResource( 5 ) +skeleton = NodePath("..") +material/0 = SubResource( 6 ) +_sections_unfolded = [ "Geometry", "LOD", "material" ] + +[node name="CollisionShape" type="CollisionShape" parent="World/Box2" index="1"] + +transform = Transform( 1, 1.49012e-08, 0, 1.3411e-07, 1, 0, 2.98023e-08, -2.98023e-08, 1, 0, 0, 0 ) +shape = SubResource( 7 ) +disabled = false +_sections_unfolded = [ "Transform" ] + +[node name="CubeShaderTest" parent="World" index="4" instance=ExtResource( 8 )] transform = Transform( -0.471909, 0, -0.881647, 0, 1, 0, 0.881647, 0, -0.471909, 4, 2, 3.11353 ) friction = 0.2 bounce = 0.75 -[node name="fire_01" parent="World" index="4" instance=ExtResource( 9 )] +[node name="fire_01" parent="World" index="5" instance=ExtResource( 9 )] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -4.60514, 0.220215, -2.3728 ) visibility_aabb = AABB( -4, -4.04395, -3.96729, 8, 8, 8 ) draw_passes = 2 -draw_pass_1 = SubResource( 8 ) -draw_pass_2 = SubResource( 10 ) +draw_pass_1 = SubResource( 9 ) +draw_pass_2 = SubResource( 11 ) + +[connection signal="sleeping_state_changed" from="World/Box" to="World/Box" method="_on_Box_sleeping_state_changed"] + +[connection signal="sleeping_state_changed" from="World/Box2" to="World/Box2" method="_on_Box_sleeping_state_changed"] diff --git a/scenes/Main.tscn b/scenes/Main.tscn index 3b85a6e..c2785fd 100644 --- a/scenes/Main.tscn +++ b/scenes/Main.tscn @@ -4,7 +4,7 @@ [ext_resource path="res://scenes/GUI/GUI.tscn" type="PackedScene" id=2] [ext_resource path="res://scenes/Game/Game.tscn" type="PackedScene" id=3] -[node name="Main" type="Node"] +[node name="Main" type="Node" index="0"] script = ExtResource( 1 ) _sections_unfolded = [ "Pause" ]