Compare commits

...

12 Commits

Author SHA1 Message Date
Agnis "NeZvērs" Aldiņš
2d4d23302a 3D physics tests - Moving platform (#623) 2021-06-09 20:57:49 -04:00
Aaron Franke
4456027f91 Merge pull request #625 from aaronfranke/3d2d-robot
Simplify 3D robot in the 3D in 2D demo
2021-06-07 09:40:49 -04:00
Aaron Franke
19312b2899 Simplify 3D robot in the 3D in 2D demo 2021-06-06 23:28:53 -04:00
Aaron Franke
ca17967de1 Merge pull request #622 from aaronfranke/waypoint-camera-current
Have waypoints check if the camera is current
2021-05-29 03:19:57 -04:00
Aaron Franke
491fb265b1 Have waypoints check if the camera is current
If not, get the current camera.
2021-05-29 03:16:07 -04:00
Agnis "NeZvērs" Aldiņš
08be1b7f03 Additional 3D physics tests - RigidBody impact and ground check (#619)
Co-authored-by: Camille Mohr-Daurat <pouleyKetchoup@gmail.com>
2021-05-29 02:58:01 -04:00
Aaron Franke
4ef90a836a Merge pull request #621 from nellodotca/master
Fixed project settings to match tutorial
2021-05-24 21:09:43 -04:00
nello
bfd903a933 Fixed project settings to match tutorial 2021-05-24 19:14:12 -03:00
Aaron Franke
e0db0b8f6d Merge pull request #615 from nekomatata/physics-tests-draw-shape-clean
Fix hack to draw shapes in 3D physics tests
2021-05-19 15:45:22 -04:00
PouleyKetchoupp
4d21951b71 Fix hack to draw shapes in 3D physics tests
Using Shape::get_debug_mesh instead of the previous hack to draw a mesh
instance based on a collision shape.
2021-05-05 13:41:51 -07:00
Aaron Franke
7656c08454 Merge pull request #614 from aaronfranke/gridmap-perf
Improve performance in GridMap demos by adjusting octant size
2021-05-04 15:22:10 -04:00
Aaron Franke
e894e4655a Improve performance in GridMap demos 2021-05-04 02:48:32 -04:00
20 changed files with 593 additions and 177 deletions

View File

@@ -24,6 +24,8 @@ config/icon="res://icon.png"
window/size/width=480
window/size/height=720
window/stretch/mode="2d"
window/stretch/aspect="keep"
[input]

View File

@@ -52,7 +52,6 @@ __meta__ = {
[node name="GridMap" type="GridMap" parent="."]
mesh_library = ExtResource( 1 )
cell_size = Vector3( 1, 1, 1 )
cell_octant_size = 4
data = {
"cells": PoolIntArray( 0, 0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0, 65530, 0, 0, 65531, 0, 0, 65532, 0, 0, 65533, 0, 0, 65534, 0, 0, 65535, 0, 0, 196603, 0, 0, 196604, 0, 0, 524292, 0, 0, 589820, 0, 0, 786432, 0, 0, 851967, 0, 0, 0, 1, 0, 1, 1, 0, 2, 1, 0, 3, 1, 0, 4, 1, 0, 65530, 1, 0, 65531, 1, 0, 65532, 1, 0, 65533, 1, 0, 65534, 1, 0, 65535, 1, 0, 131075, 1, 0, 196603, 1, 0, 196604, 1, 0, 524292, 1, 0, 589820, 1, 0, 786432, 1, 0, 851967, 1, 0, 0, 2, 0, 1, 2, 0, 2, 2, 0, 3, 2, 0, 4, 2, 0, 65530, 2, 0, 65531, 2, 0, 65532, 2, 0, 65533, 2, 0, 65534, 2, 0, 65535, 2, 0, 131075, 2, 0, 196603, 2, 0, 196604, 2, 0, 524292, 2, 0, 589820, 2, 0, 786432, 2, 0, 786433, 2, 0, 851966, 2, 0, 851967, 2, 0, 0, 3, 0, 1, 3, 0, 2, 3, 0, 3, 3, 0, 4, 3, 0, 65530, 3, 0, 65531, 3, 0, 65532, 3, 0, 65533, 3, 0, 65534, 3, 0, 65535, 3, 0, 196603, 3, 0, 524291, 3, 0, 524292, 3, 0, 589820, 3, 0, 786432, 3, 0, 786433, 3, 0, 851966, 3, 0, 851967, 3, 0, 0, 4, 0, 1, 4, 0, 2, 4, 0, 3, 4, 0, 4, 4, 0, 65530, 4, 0, 65531, 4, 0, 65532, 4, 0, 65533, 4, 0, 65534, 4, 0, 65535, 4, 0, 196603, 4, 0, 786432, 4, 0, 851967, 4, 0, 0, 5, 0, 1, 5, 0, 2, 5, 0, 3, 5, 0, 4, 5, 0, 65530, 5, 0, 65531, 5, 0, 65532, 5, 0, 65533, 5, 0, 65534, 5, 0, 65535, 5, 0, 131075, 5, 0, 0, 6, 0, 1, 6, 0, 2, 6, 0, 3, 6, 0, 4, 6, 0, 65530, 6, 0, 65531, 6, 0, 65532, 6, 0, 65533, 6, 0, 65534, 6, 0, 65535, 6, 0, 131075, 6, 0, 196603, 6, 0, 0, 7, 0, 1, 7, 0, 2, 7, 0, 3, 7, 0, 4, 7, 0, 65530, 7, 0, 65531, 7, 0, 65532, 7, 0, 65533, 7, 0, 65534, 7, 0, 65535, 7, 0, 131075, 7, 0, 196603, 7, 0, 0, 8, 0, 1, 8, 0, 2, 8, 0, 3, 8, 0, 4, 8, 0, 65530, 8, 0, 65531, 8, 0, 65532, 8, 0, 65533, 8, 0, 65534, 8, 0, 65535, 8, 0, 131075, 8, 0, 196603, 8, 0, 196604, 8, 0, 0, 9, 0, 1, 9, 0, 2, 9, 0, 3, 9, 0, 4, 9, 0, 65530, 9, 0, 65531, 9, 0, 65532, 9, 0, 65533, 9, 0, 65534, 9, 0, 65535, 9, 0, 131073, 9, 0, 131074, 9, 0, 131075, 9, 0, 196603, 9, 0, 196604, 9, 0, 196605, 9, 0, 196608, 9, 0, 262142, 9, 0, 0, 10, 0, 1, 10, 0, 2, 10, 0, 3, 10, 0, 4, 10, 0, 65530, 10, 0, 65531, 10, 0, 65532, 10, 0, 65533, 10, 0, 65534, 10, 0, 65535, 10, 0, 0, 11, 0, 1, 11, 0, 2, 11, 0, 3, 11, 0, 4, 11, 0, 65530, 11, 0, 65531, 11, 0, 65532, 11, 0, 65533, 11, 0, 65534, 11, 0, 65535, 11, 0, 0, 65532, 0, 1, 65532, 0, 2, 65532, 0, 3, 65532, 0, 4, 65532, 0, 65530, 65532, 0, 65531, 65532, 0, 65532, 65532, 0, 65533, 65532, 0, 65534, 65532, 0, 65535, 65532, 0, 0, 65533, 0, 1, 65533, 0, 2, 65533, 0, 3, 65533, 0, 4, 65533, 0, 65530, 65533, 0, 65531, 65533, 0, 65532, 65533, 0, 65533, 65533, 0, 65534, 65533, 0, 65535, 65533, 0, 262145, 65533, 0, 262146, 65533, 0, 262147, 65533, 0, 589822, 65533, 0, 589823, 65533, 0, 655363, 65533, 0, 655364, 65533, 0, 720897, 65533, 0, 720898, 65533, 0, 786432, 65533, 0, 851967, 65533, 0, 0, 65534, 0, 1, 65534, 0, 2, 65534, 0, 3, 65534, 0, 4, 65534, 0, 65530, 65534, 0, 65531, 65534, 0, 65532, 65534, 0, 65533, 65534, 0, 65534, 65534, 0, 65535, 65534, 0, 65536, 65534, 0, 131071, 65534, 0, 196603, 65534, 0, 196604, 65534, 0, 196605, 65534, 0, 196606, 65534, 0, 196607, 65534, 0, 589822, 65534, 0, 589828, 65534, 0, 786432, 65534, 0, 851967, 65534, 0, 0, 65535, 0, 1, 65535, 0, 2, 65535, 0, 3, 65535, 0, 4, 65535, 0, 65530, 65535, 0, 65531, 65535, 0, 65532, 65535, 0, 65533, 65535, 0, 65534, 65535, 0, 65535, 65535, 0, 196603, 65535, 0, 196604, 65535, 0, 196611, 65535, 0, 589820, 65535, 0, 589821, 65535, 0, 589822, 65535, 0, 589828, 65535, 0, 786432, 65535, 0, 851967, 65535, 0 )
}

View File

@@ -16,6 +16,7 @@ nodes/root_name="Cube"
nodes/root_scale=1.0
nodes/custom_script=""
nodes/storage=0
nodes/use_legacy_names=true
materials/location=1
materials/storage=2
materials/keep_on_reimport=true

View File

@@ -16,6 +16,7 @@ nodes/root_name="Mushroom"
nodes/root_scale=1.0
nodes/custom_script=""
nodes/storage=0
nodes/use_legacy_names=true
materials/location=1
materials/storage=0
materials/keep_on_reimport=true

View File

@@ -88,6 +88,24 @@ toggle_pause={
"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":80,"unicode":0,"echo":false,"script":null)
]
}
character_right={
"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":68,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"unicode":0,"echo":false,"script":null)
]
}
character_left={
"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":65,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"unicode":0,"echo":false,"script":null)
]
}
character_jump={
"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":87,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"unicode":0,"echo":false,"script":null)
]
}
[rendering]

View File

@@ -46,29 +46,20 @@ func add_sphere(pos, radius, color):
func add_shape(shape, transform, color):
var body = StaticBody.new()
body.collision_layer = 0
body.collision_mask = 0
var debug_mesh = shape.get_debug_mesh()
var collision = CollisionShape.new()
collision.transform = transform
collision.shape = shape
var mesh_instance = MeshInstance.new()
mesh_instance.transform = transform
mesh_instance.mesh = debug_mesh
body.add_child(collision)
add_child(body)
_drawn_nodes.push_back(body)
call_deferred("initialize_shape_material", body, color)
func initialize_shape_material(body, color):
var mesh_instance = body.get_child(1)
var material = SpatialMaterial.new()
material.flags_unshaded = true
material.albedo_color = color
mesh_instance.material_override = material
add_child(mesh_instance)
_drawn_nodes.push_back(mesh_instance)
func clear_drawn_nodes():
for node in _drawn_nodes:

View File

@@ -34,6 +34,18 @@ var _tests = [
"id": "Functional Tests/Raycasting",
"path": "res://tests/functional/test_raycasting.tscn",
},
{
"id": "Functional Tests/RigidBody Impact",
"path": "res://tests/functional/test_rigidbody_impact.tscn",
},
{
"id": "Functional Tests/RigidBody Ground Check",
"path": "res://tests/functional/test_rigidbody_ground_check.tscn",
},
{
"id": "Functional Tests/Moving Platform",
"path": "res://tests/functional/test_moving_platform.tscn",
},
{
"id": "Performance Tests/Broadphase",
"path": "res://tests/performance/test_perf_broadphase.tscn",

View File

@@ -0,0 +1,137 @@
extends Test
const OPTION_BODY_TYPE = "Body Type/%s (%d)"
const OPTION_GRAVITY = "Physics options/Gravity on floor (Kinematic only)"
const OPTION_SLOPE = "Physics options/Stop on slope (Kinematic only)"
const OPTION_SNAP = "Physics options/Use snap (Kinematic only)"
const OPTION_FRICTION = "Physics options/Friction (Rigid only)"
const OPTION_ROUGH = "Physics options/Rough (Rigid only)"
const OPTION_PROCESS_PHYSICS = "Physics options/AnimationPlayer physics process mode"
var _gravity = false
var _slope = false
var _snap = false
var _friction = false
var _rough = false
var _animation_physics = false
var _body_scene = {}
var _key_list = []
var _current_body_index = 0
var _current_body_key = ""
var _current_body = null
var _body_type = ["KinematicBody", "RigidBody"]
func _ready():
var options = $Options
var bodies = $Bodies.get_children()
for i in bodies.size():
var body = bodies[i]
var option_name = OPTION_BODY_TYPE % [body.name, i + 1]
options.add_menu_item(option_name)
_key_list.append(option_name)
_body_scene[option_name] = get_packed_scene(body)
body.queue_free()
options.add_menu_item(OPTION_GRAVITY, true, false)
options.add_menu_item(OPTION_SLOPE, true, false)
options.add_menu_item(OPTION_SNAP, true, false)
options.add_menu_item(OPTION_FRICTION, true, false)
options.add_menu_item(OPTION_ROUGH, true, false)
options.add_menu_item(OPTION_PROCESS_PHYSICS, true, false)
options.connect("option_selected", self, "_on_option_selected")
options.connect("option_changed", self, "_on_option_changed")
spawn_body_index(_current_body_index)
func _input(event):
var key_event = event as InputEventKey
if key_event and not key_event.pressed:
var _index = key_event.scancode - KEY_1
if _index >= 0 and _index < _key_list.size():
spawn_body_index(_index)
func _on_option_selected(option):
if _body_scene.has(option):
spawn_body_key(option)
func _on_option_changed(option, checked):
match option:
OPTION_GRAVITY:
_gravity = checked
spawn_body_index(_current_body_index)
OPTION_SLOPE:
_slope = checked
spawn_body_index(_current_body_index)
OPTION_SNAP:
_snap = checked
spawn_body_index(_current_body_index)
OPTION_FRICTION:
_friction = checked
spawn_body_index(_current_body_index)
OPTION_ROUGH:
_rough = checked
spawn_body_index(_current_body_index)
OPTION_PROCESS_PHYSICS:
_animation_physics = checked
spawn_body_index(_current_body_index)
func spawn_body_index(body_index):
if _current_body:
_current_body.queue_free()
_current_body_index = body_index
_current_body_key = _key_list[body_index]
var body_parent = $Bodies
var body = _body_scene[_key_list[body_index]].instance()
body_parent.add_child(body)
_current_body = body
init_body()
func spawn_body_key(body_key):
if _current_body:
_current_body.queue_free()
_current_body_key = body_key
_current_body_index = _key_list.find(body_key)
var body_parent = $Bodies
var body = _body_scene[body_key].instance()
body_parent.add_child(body)
_current_body = body
init_body()
func init_body():
if _current_body is KinematicBody:
_current_body._gravity_on_floor = _gravity
_current_body._stop_on_slopes = _slope
_current_body._use_snap = _snap
elif _current_body is RigidBody:
_current_body.physics_material_override.rough = _rough
_current_body.physics_material_override.friction = 1.0 if _friction else 0.0
var animation_player = $Platforms/KinematicPlatform/AnimationPlayer
animation_player.stop()
if _animation_physics:
animation_player.playback_process_mode = AnimationPlayer.ANIMATION_PROCESS_PHYSICS
else:
animation_player.playback_process_mode = AnimationPlayer.ANIMATION_PROCESS_IDLE
animation_player.play("Move")
$LabelBodyType.text = "Body Type: " + _body_type[_current_body_index]
func get_packed_scene(node):
node.owner = self
for child in node.get_children():
child.owner = node
var packed_scene = PackedScene.new()
packed_scene.pack(node)
return packed_scene

View File

@@ -0,0 +1,86 @@
[gd_scene load_steps=9 format=2]
[ext_resource path="res://utils/camera_orbit.gd" type="Script" id=1]
[ext_resource path="res://tests/functional/test_moving_platform.gd" type="Script" id=2]
[ext_resource path="res://tests/test_options.tscn" type="PackedScene" id=3]
[ext_resource path="res://utils/kinematicbody_physics.gd" type="Script" id=4]
[sub_resource type="CapsuleShape" id=1]
radius = 0.3
[sub_resource type="PhysicsMaterial" id=2]
[sub_resource type="BoxShape" id=3]
extents = Vector3( 2, 0.2, 1 )
[sub_resource type="Animation" id=4]
length = 4.0
tracks/0/type = "bezier"
tracks/0/path = NodePath(".:translation:x")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"points": PoolRealArray( -7, -0.25, 0, 0.25, 0, -7, -0.25, 0, 0.245766, 0.531658, 6, -0.132614, -0.374802, 0.25, 0 ),
"times": PoolRealArray( 0, 0.5, 4 )
}
[node name="Test" type="Spatial"]
script = ExtResource( 2 )
[node name="LabelBodyType" type="Label" parent="."]
margin_left = 14.0
margin_top = 78.0
margin_right = 171.0
margin_bottom = 92.0
text = "Body Type: "
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Options" parent="." instance=ExtResource( 3 )]
[node name="Bodies" type="Spatial" parent="."]
[node name="KinematicBody" type="KinematicBody" parent="Bodies"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -7, -1.95, 0 )
collision_layer = 2
script = ExtResource( 4 )
_stop_on_slopes = true
_use_snap = true
[node name="CollisionShape" type="CollisionShape" parent="Bodies/KinematicBody"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0.8, 0 )
shape = SubResource( 1 )
[node name="RigidBody" type="RigidBody" parent="Bodies"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -7, -1.95, 0 )
collision_layer = 4
physics_material_override = SubResource( 2 )
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
[node name="CollisionShape" type="CollisionShape" parent="Bodies/RigidBody"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0.8, 0 )
shape = SubResource( 1 )
[node name="Platforms" type="Spatial" parent="."]
[node name="KinematicPlatform" type="KinematicBody" parent="Platforms"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -7, -2, 0 )
[node name="CollisionShape" type="CollisionShape" parent="Platforms/KinematicPlatform"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.2, 0 )
shape = SubResource( 3 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="Platforms/KinematicPlatform"]
anims/Move = SubResource( 4 )
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 10 )
script = ExtResource( 1 )
[node name="OmniLight" type="OmniLight" parent="Camera"]
omni_range = 50.0

View File

@@ -0,0 +1,159 @@
[gd_scene load_steps=25 format=2]
[ext_resource path="res://utils/rigidbody_ground_check.gd" type="Script" id=1]
[ext_resource path="res://test.gd" type="Script" id=2]
[ext_resource path="res://tests/static_scene_plane.tscn" type="PackedScene" id=3]
[ext_resource path="res://utils/camera_orbit.gd" type="Script" id=4]
[sub_resource type="PhysicsMaterial" id=1]
friction = 0.0
[sub_resource type="BoxShape" id=2]
[sub_resource type="CubeMesh" id=3]
[sub_resource type="SpatialMaterial" id=4]
[sub_resource type="PhysicsMaterial" id=5]
friction = 0.0
[sub_resource type="CapsuleShape" id=6]
[sub_resource type="CapsuleMesh" id=7]
[sub_resource type="SpatialMaterial" id=8]
[sub_resource type="PhysicsMaterial" id=9]
friction = 0.0
[sub_resource type="CylinderShape" id=10]
[sub_resource type="CylinderMesh" id=11]
[sub_resource type="SpatialMaterial" id=12]
[sub_resource type="PhysicsMaterial" id=13]
friction = 0.0
[sub_resource type="ConvexPolygonShape" id=14]
points = PoolVector3Array( -0.7, 0, -0.7, -0.3, 0, 0.8, 0.8, 0, -0.3, 0, -1, 0 )
[sub_resource type="ArrayMesh" id=15]
surfaces/0 = {
"aabb": AABB( -0.7, -1, -0.7, 1.5, 1.00001, 1.5 ),
"array_data": PoolByteArray( 51, 51, 51, 191, 0, 0, 0, 0, 51, 51, 51, 191, 167, 0, 167, 0, 154, 153, 153, 190, 0, 0, 0, 0, 205, 204, 76, 63, 212, 0, 118, 0, 205, 204, 76, 63, 0, 0, 0, 0, 154, 153, 153, 190, 118, 0, 212, 0, 0, 0, 0, 0, 0, 0, 128, 191, 0, 0, 0, 0, 0, 129, 0, 0 ),
"array_index_data": PoolByteArray( 0, 0, 1, 0, 3, 0, 1, 0, 2, 0, 3, 0, 2, 0, 0, 0, 3, 0, 2, 0, 1, 0, 0, 0 ),
"blend_shape_data": [ ],
"format": 97539,
"index_count": 12,
"primitive": 4,
"skeleton_aabb": [ ],
"vertex_count": 4
}
[sub_resource type="SpatialMaterial" id=16]
[sub_resource type="PhysicsMaterial" id=17]
friction = 0.0
[sub_resource type="SphereShape" id=18]
[sub_resource type="SphereMesh" id=19]
[sub_resource type="SpatialMaterial" id=20]
[node name="Test" type="Spatial"]
script = ExtResource( 2 )
[node name="DynamicShapes" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 9.35591, 0 )
[node name="RigidBodyBox" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -6, 0, 0 )
physics_material_override = SubResource( 1 )
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyBox"]
transform = Transform( 0.6, 0, 0, 0, 1, 0, 0, 0, 0.6, 0, 0, 0 )
shape = SubResource( 2 )
[node name="MeshInstance" type="MeshInstance" parent="DynamicShapes/RigidBodyBox/CollisionShape"]
mesh = SubResource( 3 )
material/0 = SubResource( 4 )
[node name="RigidBodyCapsule" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -3, 0, 0 )
physics_material_override = SubResource( 5 )
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyCapsule"]
transform = Transform( 0.8, 0, 0, 0, -3.49691e-08, -0.8, 0, 0.8, -3.49691e-08, 0, 0, 0 )
shape = SubResource( 6 )
[node name="MeshInstance" type="MeshInstance" parent="DynamicShapes/RigidBodyCapsule/CollisionShape"]
mesh = SubResource( 7 )
material/0 = SubResource( 8 )
[node name="RigidBodyCylinder" type="RigidBody" parent="DynamicShapes"]
physics_material_override = SubResource( 9 )
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyCylinder"]
transform = Transform( 0.8, 0, 0, 0, 1, 0, 0, 0, 0.8, 0, 0, 0 )
shape = SubResource( 10 )
[node name="MeshInstance" type="MeshInstance" parent="DynamicShapes/RigidBodyCylinder/CollisionShape"]
mesh = SubResource( 11 )
material/0 = SubResource( 12 )
[node name="RigidBodyConvex" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0.974548, 0 )
physics_material_override = SubResource( 13 )
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyConvex"]
transform = Transform( 1.5, 0, 0, 0, 2, 0, 0, 0, 1.5, 0, 0, 0 )
shape = SubResource( 14 )
[node name="MeshInstance" type="MeshInstance" parent="DynamicShapes/RigidBodyConvex/CollisionShape"]
mesh = SubResource( 15 )
material/0 = SubResource( 16 )
[node name="RigidBodySphere" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 6, 0, 0 )
physics_material_override = SubResource( 17 )
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodySphere"]
transform = Transform( 0.8, 0, 0, 0, 0.8, 0, 0, 0, 0.8, 0, 0, 0 )
shape = SubResource( 18 )
[node name="MeshInstance" type="MeshInstance" parent="DynamicShapes/RigidBodySphere/CollisionShape"]
mesh = SubResource( 19 )
material/0 = SubResource( 20 )
[node name="StaticBodyPlane" parent="." instance=ExtResource( 3 )]
collision_layer = 2
collision_mask = 3
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3.604, 22.124 )
script = ExtResource( 4 )
[node name="OmniLight" type="OmniLight" parent="Camera"]
omni_range = 50.0

View File

@@ -0,0 +1,87 @@
[gd_scene load_steps=10 format=2]
[ext_resource path="res://utils/rigidbody_pick.gd" type="Script" id=1]
[ext_resource path="res://test.gd" type="Script" id=2]
[ext_resource path="res://tests/static_scene_plane.tscn" type="PackedScene" id=3]
[ext_resource path="res://utils/camera_orbit.gd" type="Script" id=4]
[sub_resource type="BoxShape" id=1]
[sub_resource type="CapsuleShape" id=2]
[sub_resource type="CylinderShape" id=3]
[sub_resource type="ConvexPolygonShape" id=4]
points = PoolVector3Array( -0.7, 0, -0.7, -0.3, 0, 0.8, 0.8, 0, -0.3, 0, -1, 0 )
[sub_resource type="SphereShape" id=5]
[node name="Test" type="Spatial"]
script = ExtResource( 2 )
[node name="DynamicShapes" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 9.35591, 0 )
[node name="RigidBodyBox" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -6, 0, 0 )
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyBox"]
transform = Transform( 0.6, 0, 0, 0, 1, 0, 0, 0, 0.6, 0, 0, 0 )
shape = SubResource( 1 )
[node name="RigidBodyCapsule" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -3, 0, 0 )
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyCapsule"]
transform = Transform( 0.8, 0, 0, 0, -3.49691e-08, -0.8, 0, 0.8, -3.49691e-08, 0, 0, 0 )
shape = SubResource( 2 )
[node name="RigidBodyCylinder" type="RigidBody" parent="DynamicShapes"]
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyCylinder"]
transform = Transform( 0.8, 0, 0, 0, 1, 0, 0, 0, 0.8, 0, 0, 0 )
shape = SubResource( 3 )
[node name="RigidBodyConvex" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0.974548, 0 )
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodyConvex"]
transform = Transform( 1.5, 0, 0, 0, 2, 0, 0, 0, 1.5, 0, 0, 0 )
shape = SubResource( 4 )
[node name="RigidBodySphere" type="RigidBody" parent="DynamicShapes"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 6, 0, 0 )
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="DynamicShapes/RigidBodySphere"]
transform = Transform( 0.8, 0, 0, 0, 0.8, 0, 0, 0, 0.8, 0, 0, 0 )
shape = SubResource( 5 )
[node name="StaticBodyPlane" parent="." instance=ExtResource( 3 )]
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3.604, 22.124 )
fov = 35.0
script = ExtResource( 4 )
[node name="OmniLight" type="OmniLight" parent="Camera"]
omni_range = 50.0

View File

@@ -0,0 +1,23 @@
extends KinematicBody
export(bool) var _gravity_on_floor = true
export(bool) var _stop_on_slopes = false
export(bool) var _use_snap = false
var _gravity = 20.0
var _velocity = Vector3.ZERO
func _physics_process(delta):
var snap = Vector3.DOWN * 0.2
if is_on_floor() and _gravity_on_floor:
_velocity += Vector3.DOWN * _gravity * delta
else:
_velocity += Vector3.DOWN * _gravity * delta
snap = Vector3.ZERO
if _use_snap:
_velocity = move_and_slide_with_snap(_velocity, snap, Vector3.UP, _stop_on_slopes)
else:
_velocity = move_and_slide(_velocity, Vector3.UP, _stop_on_slopes)

View File

@@ -0,0 +1,46 @@
extends RigidBody
onready var _forward = - transform.basis.z
onready var _collision_shape = $CollisionShape
onready var _material = $CollisionShape/MeshInstance.get_surface_material(0)
var _dir = 1.0
var _distance = 10.0
var _walk_spd = 100.0
var _acceleration = 22.0
var _gravity_impulse = 30.0
var _is_on_floor = false
func _process(_delta):
if _is_on_floor:
_material.albedo_color = Color.white
else:
_material.albedo_color = Color.red
func _integrate_forces(state):
var delta = state.step
var velocity = (_forward * _dir * _walk_spd * delta) + (state.linear_velocity * Vector3.UP)
state.linear_velocity = state.linear_velocity.move_toward(velocity, _acceleration * delta)
if state.transform.origin.z < -_distance:
_dir = -1
if state.transform.origin.z > _distance:
_dir = 1
ground_check()
func ground_check():
var space_state = get_world().direct_space_state
var shape = PhysicsShapeQueryParameters.new()
shape.transform = _collision_shape.global_transform
shape.shape_rid = _collision_shape.shape.get_rid()
shape.collision_mask = 2
var result = space_state.get_rest_info(shape)
if result:
_is_on_floor = true
else:
_is_on_floor = false

View File

@@ -47,7 +47,8 @@ func _physics_process(delta):
world_delta = camera_basis * world_delta
var camera_dist = camera.global_transform.origin.distance_to(global_transform.origin)
world_delta *= CAMERA_DISTANCE_COEFFICIENT * camera_dist
var fov_coefficient = camera.fov / 70.0
world_delta *= CAMERA_DISTANCE_COEFFICIENT * camera_dist * fov_coefficient
if mode == MODE_STATIC:
global_transform.origin += world_delta

File diff suppressed because one or more lines are too long

View File

@@ -13,6 +13,7 @@ atlas = ExtResource( 2 )
region = Rect2( 0, 0, 64, 64 )
[node name="Player" type="KinematicBody"]
collision_layer = 0
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="."]

View File

@@ -160,8 +160,8 @@ common/physics_fps=120
quality/driver/driver_name="GLES2"
vram_compression/import_etc=true
vram_compression/import_etc2=false
quality/filters/anisotropic_filter_level=16
quality/filters/msaa=2
environment/default_environment="res://default_env.tres"
quality/filters/anisotropic_filter_level=16
gles2/debug/disable_half_float=true
quality/filters/anisotropic_filter_level.mobile=4

View File

@@ -23,6 +23,9 @@ func _ready() -> void:
func _process(_delta):
if not camera.current:
# If the camera we have isn't the current one, get the current camera.
camera = get_viewport().get_camera()
var parent_translation = parent.global_transform.origin
var camera_transform = camera.global_transform
var camera_translation = camera_transform.origin

View File

@@ -1,8 +1,7 @@
extends KinematicBody
extends Node
# A simple script to rotate the model.
onready var model = $Armature
const SPEED = 40
onready var model = $Model
func _process(delta):
model.rotation_degrees.y += delta * SPEED
model.rotate_y(delta * 0.7)

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=9 format=2]
[gd_scene load_steps=8 format=2]
[ext_resource path="res://robot_3d.gd" type="Script" id=1]
@@ -65,157 +65,11 @@ emission_energy = 1.0
emission_operator = 0
emission_on_uv2 = false
[sub_resource type="CapsuleShape" id=7]
radius = 0.7
height = 0.6
[node name="Robot3D" type="KinematicBody"]
[node name="Robot3D" type="Spatial"]
script = ExtResource( 1 )
__meta__ = {
"__editor_plugin_screen__": "3D"
}
[node name="Armature" type="Spatial" parent="."]
[node name="Model" type="MeshInstance" parent="."]
transform = Transform( 0.3, 0, 0, 0, 0.3, 0, 0, 0, 0.3, 0, 0, 0 )
[node name="Skeleton" type="Skeleton" parent="Armature"]
bones/0/name = "MASTER"
bones/0/parent = -1
bones/0/rest = Transform( 1, 0, 0, 0, 7.54979e-08, 1, 0, -1, 7.54979e-08, 0, -0.011277, 0 )
bones/0/enabled = true
bones/0/bound_children = [ ]
bones/1/name = "hip"
bones/1/parent = 0
bones/1/rest = Transform( 1, -1.50996e-07, -3.60002e-14, -1.50996e-07, -1, -3.01992e-07, 9.59926e-15, 3.01992e-07, -1, -3.38813e-21, 2.58363e-07, 2.10612 )
bones/1/enabled = true
bones/1/bound_children = [ ]
bones/2/name = "waist"
bones/2/parent = 1
bones/2/rest = Transform( 1, 1.50996e-07, 1.80001e-14, -1.50996e-07, 1, 0, -1.80001e-14, 0, 1, 3.38813e-21, 2.84217e-14, -0.384614 )
bones/2/enabled = true
bones/2/bound_children = [ ]
bones/3/name = "chest"
bones/3/parent = 2
bones/3/rest = Transform( 1, -7.31455e-16, 4.86029e-17, 7.28861e-16, 0.999166, 0.040823, -7.84198e-17, -0.040823, 0.999166, 0, 4.84022e-11, -0.8217 )
bones/3/enabled = true
bones/3/bound_children = [ ]
bones/4/name = "neck"
bones/4/parent = 3
bones/4/rest = Transform( -1, -1.10548e-06, -9.37766e-09, 1.08766e-06, -0.985328, 0.170671, -1.97913e-07, 0.170671, 0.985328, -1.64727e-13, 5.96046e-08, -1.24906 )
bones/4/enabled = true
bones/4/bound_children = [ ]
bones/5/name = "headtracker"
bones/5/parent = 4
bones/5/rest = Transform( 1, 9.87793e-08, -1.09789e-06, 1.09743e-06, 0.00449866, 0.99999, 1.03717e-07, -0.99999, 0.00449866, 0, 5.96046e-08, -0.491774 )
bones/5/enabled = true
bones/5/bound_children = [ ]
bones/6/name = "head"
bones/6/parent = 5
bones/6/rest = Transform( -1, 2.36978e-07, 1.97097e-07, -2.5035e-07, -0.25144, -0.967873, -1.79807e-07, -0.967873, 0.25144, -2.94648e-10, 4.76837e-07, 0.00400549 )
bones/6/enabled = true
bones/6/bound_children = [ ]
bones/7/name = "vent"
bones/7/parent = 6
bones/7/rest = Transform( 1, -2.54965e-07, -1.4699e-08, 2.55005e-07, 0.999996, 0.00282324, 1.39791e-08, -0.00282325, 0.999996, -7.04808e-08, 0.270992, -1.2429 )
bones/7/enabled = true
bones/7/bound_children = [ ]
bones/8/name = "r-arm"
bones/8/parent = 3
bones/8/rest = Transform( 0.11477, -0.699489, -0.705367, -0.802661, -0.483653, 0.349021, -0.585289, 0.526113, -0.616961, 0.940786, 0.107144, -0.773564 )
bones/8/enabled = true
bones/8/bound_children = [ ]
bones/9/name = "r-forearm"
bones/9/parent = 8
bones/9/rest = Transform( -0.859542, 0.0564943, 0.507934, 0.107631, -0.951571, 0.287973, 0.499604, 0.302194, 0.811834, 2.38419e-07, -4.76837e-07, -0.935513 )
bones/9/enabled = true
bones/9/bound_children = [ ]
bones/10/name = "l-arm"
bones/10/parent = 3
bones/10/rest = Transform( 0.11477, 0.699489, 0.705367, 0.802661, -0.483653, 0.349021, 0.585289, 0.526113, -0.616961, -0.940786, 0.107144, -0.773564 )
bones/10/enabled = true
bones/10/bound_children = [ ]
bones/11/name = "l-forearm"
bones/11/parent = 10
bones/11/rest = Transform( -0.859542, -0.0564943, -0.507934, -0.107631, -0.951571, 0.287973, -0.499604, 0.302194, 0.811834, -2.38419e-07, -4.76837e-07, -0.935513 )
bones/11/enabled = true
bones/11/bound_children = [ ]
bones/12/name = "r-thigh"
bones/12/parent = 1
bones/12/rest = Transform( 0.994883, -0.0545632, -0.085028, -0.0580629, -0.997541, -0.0392442, -0.0826777, 0.0439804, -0.995605, 0.349652, 0.0628238, -0.163877 )
bones/12/enabled = true
bones/12/bound_children = [ ]
bones/13/name = "r-leg"
bones/13/parent = 12
bones/13/rest = Transform( -0.999508, -0.031366, -0.000870243, 0.0312939, -0.994411, -0.100835, 0.00229738, -0.100812, 0.994903, 5.96046e-08, 5.96046e-08, -0.644636 )
bones/13/enabled = true
bones/13/bound_children = [ ]
bones/14/name = "r-foot"
bones/14/parent = 13
bones/14/rest = Transform( 0.996208, -0.0766666, -0.0411273, -0.0442384, -0.0393329, -0.998246, 0.0749145, 0.996281, -0.0425754, -5.96046e-08, 4.19095e-09, -1.43073 )
bones/14/enabled = true
bones/14/bound_children = [ ]
bones/15/name = "l-thigh"
bones/15/parent = 1
bones/15/rest = Transform( 0.994883, 0.0545632, 0.085028, 0.0580633, -0.997541, -0.0392452, 0.0826776, 0.0439813, -0.995606, -0.349652, 0.0628238, -0.163877 )
bones/15/enabled = true
bones/15/bound_children = [ ]
bones/16/name = "l-leg"
bones/16/parent = 15
bones/16/rest = Transform( -0.999508, 0.0313662, 0.000870456, -0.0312941, -0.994411, -0.100836, -0.00229725, -0.100814, 0.994903, 0, 1.49012e-08, -0.644636 )
bones/16/enabled = true
bones/16/bound_children = [ ]
bones/17/name = "l-foot"
bones/17/parent = 16
bones/17/rest = Transform( 0.996208, 0.0766668, 0.0411275, 0.0442386, -0.0393327, -0.998246, -0.0749147, 0.996281, -0.0425752, 0, -8.3819e-09, -1.43073 )
bones/17/enabled = true
bones/17/bound_children = [ ]
bones/18/name = "HEAD"
bones/18/parent = 0
bones/18/rest = Transform( 1, -1.50996e-07, 0, -1.50996e-07, -1, 0, 0, 0, -1, 5.68434e-14, -5.79659, 6.35228 )
bones/18/enabled = true
bones/18/bound_children = [ ]
bones/19/name = "r-LEGCONTROL"
bones/19/parent = 0
bones/19/rest = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.518863, 3.72276e-07, 0.204768 )
bones/19/enabled = true
bones/19/bound_children = [ ]
bones/20/name = "l-LEGCONTROL"
bones/20/parent = 0
bones/20/rest = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.518863, 3.72276e-07, 0.204768 )
bones/20/enabled = true
bones/20/bound_children = [ ]
bones/21/name = "r-LEGORIENT"
bones/21/parent = 0
bones/21/rest = Transform( -1, -1.50996e-07, -5.03577e-15, -3.75647e-14, 2.15429e-07, 1, -1.50996e-07, 1, -2.15429e-07, 0.411677, -0.66395, 1.62881 )
bones/21/enabled = true
bones/21/bound_children = [ ]
bones/22/name = "l-LEGORIENT"
bones/22/parent = 0
bones/22/rest = Transform( -1, -1.50996e-07, -5.03577e-15, -3.75647e-14, 2.15429e-07, 1, -1.50996e-07, 1, -2.15429e-07, -0.411677, -0.66395, 1.62881 )
bones/22/enabled = true
bones/22/bound_children = [ ]
bones/23/name = "r-ARMCONTROL"
bones/23/parent = 0
bones/23/rest = Transform( 1, 0, 0, 0, 7.54979e-08, -1, 0, 1, 7.54979e-08, 2.62535, -0.186879, 2.59016 )
bones/23/enabled = true
bones/23/bound_children = [ ]
bones/24/name = "l-ARMCONTROL"
bones/24/parent = 0
bones/24/rest = Transform( 1, 0, 0, 0, 7.54979e-08, -1, 0, 1, 7.54979e-08, -2.62535, -0.186879, 2.59016 )
bones/24/enabled = true
bones/24/bound_children = [ ]
bones/25/name = "r-ARMORIENT"
bones/25/parent = 0
bones/25/rest = Transform( 1, 0, 0, 0, 7.54979e-08, -1, 0, 1, 7.54979e-08, 1.57185, 0.510255, 3.44768 )
bones/25/enabled = true
bones/25/bound_children = [ ]
bones/26/name = "l-ARMORIENT"
bones/26/parent = 0
bones/26/rest = Transform( 1, 0, 0, 0, 7.54979e-08, -1, 0, 1, 7.54979e-08, -1.57185, 0.510255, 3.44768 )
bones/26/enabled = true
bones/26/bound_children = [ ]
[node name="Robot" type="MeshInstance" parent="Armature/Skeleton"]
mesh = SubResource( 3 )
material/0 = SubResource( 5 )
material/1 = SubResource( 6 )
@@ -232,7 +86,3 @@ light_color = Color( 1, 0.915375, 0.816406, 1 )
[node name="OmniLight2" type="OmniLight" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 2.5788, 1.43155, 2.43657 )
light_color = Color( 0.816406, 1, 0.995697, 1 )
[node name="CollisionShape" type="CollisionShape" parent="."]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 1, 0 )
shape = SubResource( 7 )