initial checkin

- tank + physics on an empty plane working
This commit is contained in:
Otto Naderer 2017-02-14 00:54:19 +01:00
commit e84a7a1cc9
13 changed files with 445 additions and 0 deletions

BIN
ball.tex Normal file

Binary file not shown.

BIN
blender/tbody.blend Normal file

Binary file not shown.

BIN
blender/wheel.blend Normal file

Binary file not shown.

14
engine.cfg Normal file
View File

@ -0,0 +1,14 @@
[application]
name="godot-testapp"
main_scene="res://map.tscn"
boot_splash=""
icon="res://icon.png"
[input]
ui_left=[key(Left), jbutton(0, 14), key(A)]
ui_right=[key(Right), jbutton(0, 15), key(D)]
ui_up=[key(Up), jbutton(0, 12), key(W)]
ui_down=[key(Down), jbutton(0, 13), key(S)]
driver_break=[key(Space)]

BIN
icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

1
icon.png.flags Normal file
View File

@ -0,0 +1 @@
gen_mipmaps=false

79
map.tscn Normal file
View File

@ -0,0 +1,79 @@
[gd_scene load_steps=3 format=1]
[ext_resource path="res://tank-base.tscn" type="PackedScene" id=1]
[sub_resource type="BoxShape" id=1]
extents = Vector3( 1, 1, 1 )
[node name="Spatial" type="Spatial"]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
[node name="TestCube" type="TestCube" parent="."]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
transform/local = Transform( 100, 0, 0, 0, 0.1, 0, 0, 0, 100, 0, -2.53486, 0 )
layers = 1
geometry/visible = true
geometry/material_override = null
geometry/cast_shadow = 1
geometry/receive_shadows = true
geometry/range_begin = 0.0
geometry/range_end = 0.0
geometry/extra_cull_margin = 0.0
geometry/billboard = false
geometry/billboard_y = false
geometry/depth_scale = false
geometry/visible_in_all_rooms = false
geometry/use_baked_light = false
geometry/baked_light_tex_id = 0
[node name="StaticBody" type="StaticBody" parent="TestCube"]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
input/ray_pickable = true
input/capture_on_drag = false
shape_count = 1
shapes/0/shape = SubResource( 1 )
shapes/0/transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
shapes/0/trigger = false
collision/layers = 1
collision/mask = 1
friction = 1.0
bounce = 0.0
constant_linear_velocity = Vector3( 0, 0, 0 )
constant_angular_velocity = Vector3( 0, 0, 0 )
[node name="CollisionShape" type="CollisionShape" parent="TestCube/StaticBody"]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
shape = SubResource( 1 )
trigger = false
_update_shape_index = 0
[node name="Spatial" parent="." instance=ExtResource( 1 )]
[node name="OmniLight" type="OmniLight" parent="."]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
transform/local = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 35.4294, 0 )
layers = 1
params/enabled = true
params/editor_only = false
params/bake_mode = 0
params/energy = 1.0
colors/diffuse = Color( 1, 1, 1, 1 )
colors/specular = Color( 1, 1, 1, 1 )
shadow/shadow = true
shadow/darkening = 0.0
shadow/z_offset = 0.001
shadow/z_slope_scale = 0.0
shadow/esm_multiplier = 60.0
shadow/blur_passes = 1.0
projector = null
operator = 0
params/radius = 155.782
params/attenuation = 1.0

BIN
rock01.msh Normal file

Binary file not shown.

61
tank-base.gd Normal file
View File

@ -0,0 +1,61 @@
extends VehicleBody
# Member variables
const STEER_SPEED = .25
const STEER_LIMIT = .3
var steer_angle = 0
var steer_target = 0
var view_sensitivity = 0.3;
export var engine_force = 20
func _fixed_process(delta):
if (Input.is_action_pressed("ui_left")):
steer_target = -STEER_LIMIT
elif (Input.is_action_pressed("ui_right")):
steer_target = STEER_LIMIT
else:
steer_target = 0
if (Input.is_action_pressed("ui_up")):
set_engine_force(engine_force)
else:
set_engine_force(0)
if (Input.is_action_pressed("ui_down")):
#set_brake(1)
set_engine_force(-engine_force)
if (Input.is_action_pressed("driver_break")):
set_brake(1.0)
else:
set_brake(0.0)
if (steer_target < steer_angle):
steer_angle -= STEER_SPEED*delta
if (steer_target > steer_angle):
steer_angle = steer_target
elif (steer_target > steer_angle):
steer_angle += STEER_SPEED*delta
if (steer_target < steer_angle):
steer_angle = steer_target
set_steering(steer_angle)
func _ready():
set_fixed_process(true)
func _input(ie):
if ie.type == InputEvent.MOUSE_MOTION:
var yaw = rad2deg(get_node(".").get_rotation().y);
var pitch = rad2deg(get_node("Camera").get_rotation().x);
yaw = fmod(yaw - ie.relative_x * view_sensitivity, 360);
pitch = max(min(pitch - ie.relative_y * view_sensitivity, 90), -90);
get_node(".").set_rotation(Vector3(0, deg2rad(yaw), 0));
get_node("Camera").set_rotation(Vector3(deg2rad(pitch), 0, 0));

226
tank-base.tscn Normal file
View File

@ -0,0 +1,226 @@
[gd_scene load_steps=5 format=1]
[ext_resource path="res://tank-base.gd" type="Script" id=1]
[ext_resource path="res://tbody.msh" type="Mesh" id=2]
[ext_resource path="res://twheel.msh" type="Mesh" id=3]
[sub_resource type="BoxShape" id=1]
extents = Vector3( 1.06913, 0.569071, 2.77569 )
[node name="Spatial" type="Spatial"]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
[node name="VehicleBody" type="VehicleBody" parent="."]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
input/ray_pickable = true
input/capture_on_drag = false
shape_count = 1
shapes/0/shape = SubResource( 1 )
shapes/0/transform = Transform( 0.926353, 0, 0, 0, 0.926353, 0, 0, 0, 0.926353, 0, 0, 0 )
shapes/0/trigger = false
collision/layers = 1
collision/mask = 1
motion/engine_force = 0.0
motion/brake = 0.0
motion/steering = 0.0
body/mass = 40.0
body/friction = 1.0
script/script = ExtResource( 1 )
engine_force = 40
[node name="MeshInstance" type="MeshInstance" parent="VehicleBody"]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
layers = 1
geometry/visible = true
geometry/material_override = null
geometry/cast_shadow = 1
geometry/receive_shadows = true
geometry/range_begin = 0.0
geometry/range_end = 0.0
geometry/extra_cull_margin = 0.0
geometry/billboard = false
geometry/billboard_y = false
geometry/depth_scale = false
geometry/visible_in_all_rooms = false
geometry/use_baked_light = false
geometry/baked_light_tex_id = 0
mesh/mesh = ExtResource( 2 )
mesh/skeleton = NodePath("..")
material/0 = null
[node name="VehicleWheel" type="VehicleWheel" parent="VehicleBody"]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
transform/local = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.882344, -0.794859, -1.6514 )
type/traction = true
type/steering = false
wheel/radius = 0.5
wheel/rest_length = 0.15
wheel/friction_slip = 10.5
suspension/travel = 5.0
suspension/stiffness = 8.0
suspension/max_force = 6000.0
damping/compression = 0.83
damping/relaxation = 0.88
[node name="MeshInstance" type="MeshInstance" parent="VehicleBody/VehicleWheel"]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
layers = 1
geometry/visible = true
geometry/material_override = null
geometry/cast_shadow = 1
geometry/receive_shadows = true
geometry/range_begin = 0.0
geometry/range_end = 0.0
geometry/extra_cull_margin = 0.0
geometry/billboard = false
geometry/billboard_y = false
geometry/depth_scale = false
geometry/visible_in_all_rooms = false
geometry/use_baked_light = false
geometry/baked_light_tex_id = 0
mesh/mesh = ExtResource( 3 )
mesh/skeleton = NodePath("..")
material/0 = null
[node name="VehicleWheel1" type="VehicleWheel" parent="VehicleBody"]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
transform/local = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.927136, -0.794859, -1.6514 )
type/traction = true
type/steering = false
wheel/radius = 0.5
wheel/rest_length = 0.15
wheel/friction_slip = 10.5
suspension/travel = 5.0
suspension/stiffness = 8.0
suspension/max_force = 6000.0
damping/compression = 0.83
damping/relaxation = 0.88
[node name="MeshInstance" type="MeshInstance" parent="VehicleBody/VehicleWheel1"]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
transform/local = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00275898, -2.38419e-07, -0.00476646 )
layers = 1
geometry/visible = true
geometry/material_override = null
geometry/cast_shadow = 1
geometry/receive_shadows = true
geometry/range_begin = 0.0
geometry/range_end = 0.0
geometry/extra_cull_margin = 0.0
geometry/billboard = false
geometry/billboard_y = false
geometry/depth_scale = false
geometry/visible_in_all_rooms = false
geometry/use_baked_light = false
geometry/baked_light_tex_id = 0
mesh/mesh = ExtResource( 3 )
mesh/skeleton = NodePath("..")
material/0 = null
[node name="VehicleWheel2" type="VehicleWheel" parent="VehicleBody"]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
transform/local = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.927136, -0.794859, 1.00165 )
type/traction = true
type/steering = true
wheel/radius = 0.5
wheel/rest_length = 0.15
wheel/friction_slip = 10.5
suspension/travel = 5.0
suspension/stiffness = 10.0
suspension/max_force = 6000.0
damping/compression = 0.83
damping/relaxation = 0.88
[node name="MeshInstance" type="MeshInstance" parent="VehicleBody/VehicleWheel2"]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
layers = 1
geometry/visible = true
geometry/material_override = null
geometry/cast_shadow = 1
geometry/receive_shadows = true
geometry/range_begin = 0.0
geometry/range_end = 0.0
geometry/extra_cull_margin = 0.0
geometry/billboard = false
geometry/billboard_y = false
geometry/depth_scale = false
geometry/visible_in_all_rooms = false
geometry/use_baked_light = false
geometry/baked_light_tex_id = 0
mesh/mesh = ExtResource( 3 )
mesh/skeleton = NodePath("..")
material/0 = null
[node name="VehicleWheel3" type="VehicleWheel" parent="VehicleBody"]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
transform/local = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.880901, -0.794859, 1.00165 )
type/traction = true
type/steering = true
wheel/radius = 0.5
wheel/rest_length = 0.15
wheel/friction_slip = 10.5
suspension/travel = 5.0
suspension/stiffness = 10.0
suspension/max_force = 6000.0
damping/compression = 0.83
damping/relaxation = 0.88
[node name="MeshInstance" type="MeshInstance" parent="VehicleBody/VehicleWheel3"]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
layers = 1
geometry/visible = true
geometry/material_override = null
geometry/cast_shadow = 1
geometry/receive_shadows = true
geometry/range_begin = 0.0
geometry/range_end = 0.0
geometry/extra_cull_margin = 0.0
geometry/billboard = false
geometry/billboard_y = false
geometry/depth_scale = false
geometry/visible_in_all_rooms = false
geometry/use_baked_light = false
geometry/baked_light_tex_id = 0
mesh/mesh = ExtResource( 3 )
mesh/skeleton = NodePath("..")
material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="VehicleBody"]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
transform/local = Transform( 0.926353, 0, 0, 0, 0.926353, 0, 0, 0, 0.926353, 0, 0, 0 )
shape = SubResource( 1 )
trigger = false
_update_shape_index = 0
[node name="Camera" type="InterpolatedCamera" parent="VehicleBody"]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
transform/local = Transform( -0.919673, 0.0404591, -0.390595, -0.0062019, 0.993057, 0.117466, 0.392635, 0.110452, -0.913037, -3.38148, 1.22883, -6.13712 )
projection = 0
fov = 60.0
near = 0.1
far = 100.0
keep_aspect = 1
current = false
visible_layers = 1048575
environment = null
h_offset = 0.0
v_offset = 0.0
target = NodePath("")
speed = 1.0
enabled = false

BIN
tbody.msh Normal file

Binary file not shown.

64
testbounce.tscn Normal file
View File

@ -0,0 +1,64 @@
[gd_scene load_steps=2 format=1]
[ext_resource path="res://rock01.msh" type="Mesh" id=1]
[node name="MeshInstance" type="MeshInstance"]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
transform/local = Transform( 0.986554, 0.163435, 0, -0.163435, 0.986554, 0, 0, 0, 1, 0, 0, 0 )
layers = 1
geometry/visible = true
geometry/material_override = null
geometry/cast_shadow = 1
geometry/receive_shadows = true
geometry/range_begin = 0.0
geometry/range_end = 0.0
geometry/extra_cull_margin = 0.0
geometry/billboard = false
geometry/billboard_y = false
geometry/depth_scale = false
geometry/visible_in_all_rooms = false
geometry/use_baked_light = false
geometry/baked_light_tex_id = 0
mesh/mesh = ExtResource( 1 )
mesh/skeleton = NodePath("..")
material/0 = null
[node name="OmniLight" type="OmniLight" parent="."]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
transform/local = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -13.0938, 7.65127, 0 )
layers = 1
params/enabled = true
params/editor_only = false
params/bake_mode = 0
params/energy = 1.0
colors/diffuse = Color( 1, 1, 1, 1 )
colors/specular = Color( 1, 1, 1, 1 )
shadow/shadow = false
shadow/darkening = 0.0
shadow/z_offset = 0.001
shadow/z_slope_scale = 0.0
shadow/esm_multiplier = 60.0
shadow/blur_passes = 1.0
projector = null
operator = 0
params/radius = 2.0
params/attenuation = 1.0
[node name="Camera" type="Camera" parent="."]
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
transform/local = Transform( 0.11797, 0, -0.993017, 1.86265e-09, 1, 1.49012e-08, 0.993017, 0, 0.11797, -8.8291, 7.63259, 1.75589 )
projection = 0
fov = 60.0
near = 0.1
far = 100.0
keep_aspect = 1
current = false
visible_layers = 1048575
environment = null
h_offset = 0.0
v_offset = 0.0

BIN
twheel.msh Normal file

Binary file not shown.