Skip to content

Commit

Permalink
Add several balls to 3D collisions
Browse files Browse the repository at this point in the history
  • Loading branch information
acs committed Sep 28, 2020
1 parent 462e592 commit a1efb77
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 21 deletions.
32 changes: 14 additions & 18 deletions 3DCollisions/Collision.tscn
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
[gd_scene load_steps=7 format=2]
[gd_scene load_steps=6 format=2]

[sub_resource type="SphereMesh" id=1]
radius = 0.3
height = 0.9

[sub_resource type="SphereShape" id=2]
radius = 0.479823
[ext_resource path="res://RigidBall.tscn" type="PackedScene" id=1]

[sub_resource type="PhysicsMaterial" id=3]
bounce = 0.5
Expand All @@ -29,17 +24,6 @@ emission_on_uv2 = false
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 0.984808, 0.173648, 0, -0.173648, 0.984808, 0, 2, 8 )

[node name="BallRigid" type="RigidBody" parent="."]

[node name="Ball" type="MeshInstance" parent="BallRigid"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3, 0 )
mesh = SubResource( 1 )
material/0 = null

[node name="CollisionShape" type="CollisionShape" parent="BallRigid"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3, 0 )
shape = SubResource( 2 )

[node name="StaticBody" type="StaticBody" parent="."]
physics_material_override = SubResource( 3 )

Expand All @@ -49,3 +33,15 @@ shape = SubResource( 4 )
[node name="MeshInstance" type="MeshInstance" parent="StaticBody"]
mesh = SubResource( 5 )
material/0 = SubResource( 6 )

[node name="RigidBall1" parent="." instance=ExtResource( 1 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0 )

[node name="RigidBall2" parent="." instance=ExtResource( 1 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0 )

[node name="RigidBall3" parent="." instance=ExtResource( 1 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3, 0 )

[node name="RigidBall4" parent="." instance=ExtResource( 1 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4, 0 )
20 changes: 20 additions & 0 deletions 3DCollisions/RigidBall.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[gd_scene load_steps=3 format=2]

[sub_resource type="SphereShape" id=2]
radius = 0.3

[sub_resource type="SphereMesh" id=1]
radius = 0.3
height = 0.6

[node name="RigidBall" type="RigidBody"]
__meta__ = {
"_edit_group_": true
}

[node name="CollisionShape" type="CollisionShape" parent="."]
shape = SubResource( 2 )

[node name="MeshInstance" type="MeshInstance" parent="."]
mesh = SubResource( 1 )
material/0 = null
10 changes: 7 additions & 3 deletions shaders_samples/SpatialShader.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ subdivide_depth = 32

[sub_resource type="Shader" id=2]
code = "shader_type spatial;
render_mode diffuse_toon, specular_toon;

uniform sampler2D noise;
uniform sampler2D normalmap;
Expand All @@ -26,7 +27,10 @@ void vertex() {
}

void fragment() {
NORMALMAP = texture(normalmap, vertex_position).xyz;
ALBEDO = vec3(0.1, 0.3, 0.5);
METALLIC = 0.0;
ROUGHNESS = 0.01;
NORMALMAP = texture(normalmap, vertex_position).xyz;
}"

[sub_resource type="OpenSimplexNoise" id=4]
Expand All @@ -49,14 +53,14 @@ shader_param/normalmap = SubResource( 7 )
[node name="SpatialShader" type="Spatial"]

[node name="MeshInstance" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.103335, 0, 0 )
mesh = SubResource( 1 )
material/0 = SubResource( 3 )
script = ExtResource( 1 )

[node name="OmniLight" type="OmniLight" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0171311, 0.4, 0.0834915 )
visible = false
shadow_enabled = true

[node name="Camera" type="Camera" parent="."]
transform = Transform( -1.62921e-07, -0.573577, 0.819152, 0, 0.819152, 0.573577, -1, 9.34475e-08, -1.33457e-07, 2, 1, 0 )
transform = Transform( 1, 0, 0, 0, 0.984808, -0.173648, 0, 0.173648, 0.984808, 0, 0.5, 1.4 )

0 comments on commit a1efb77

Please sign in to comment.