mirror of
https://port.numenaute.org/aleajactaest/khanat-client.git
synced 2024-11-22 07:06:14 +00:00
ADD ajout de mouvement de camera.
This commit is contained in:
parent
128fba0f65
commit
60f5c2b9e6
4 changed files with 79 additions and 6 deletions
|
@ -102,6 +102,26 @@ debug_window={
|
|||
"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":73,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
free_look={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":2,"pressed":false,"doubleclick":false,"script":null)
|
||||
]
|
||||
}
|
||||
zoom_in={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":4,"pressed":false,"doubleclick":false,"script":null)
|
||||
]
|
||||
}
|
||||
zoom_out={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":5,"pressed":false,"doubleclick":false,"script":null)
|
||||
]
|
||||
}
|
||||
reset_camera={
|
||||
"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":67,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[khanat]
|
||||
|
||||
|
|
|
@ -3,6 +3,13 @@ extends Spatial
|
|||
var player_speed = 1.0
|
||||
var player_rotation_speed = 0.1
|
||||
|
||||
var mouse_old_position = null
|
||||
var mouse_delta = Vector2( 0.0, 0.0 )
|
||||
|
||||
var camera_zoom_speed = 0.5
|
||||
var camera_zoom = 0.0
|
||||
|
||||
|
||||
var heightmap = null
|
||||
|
||||
|
||||
|
@ -26,6 +33,39 @@ func _input( event ):
|
|||
$creatures/player.turn( rotation )
|
||||
$creatures/player.move( movment )
|
||||
|
||||
if event.is_action( "zoom_in" ):
|
||||
self.camera_zoom -= self.camera_zoom_speed
|
||||
elif event.is_action( "zoom_out" ):
|
||||
self.camera_zoom += self.camera_zoom_speed
|
||||
|
||||
if event.is_action_pressed( "free_look" ):
|
||||
self.mouse_old_position = event.position
|
||||
elif event.is_action_released( "free_look" ):
|
||||
self.mouse_old_position = null
|
||||
|
||||
if event.is_action( "reset_camera" ):
|
||||
$creatures/player.reset_camera()
|
||||
|
||||
if event is InputEventMouseMotion:
|
||||
if not mouse_old_position == null:
|
||||
self.mouse_delta = self.mouse_old_position - event.position
|
||||
self.mouse_old_position = event.position
|
||||
|
||||
func _process( delta ):
|
||||
|
||||
# $camera_base.translate( camera_translation )
|
||||
# camera_translation = Vector3()
|
||||
# $camera_base.rotate( Vector3( 0.0, 1.0, 0.0 ), deg2rad( camera_rotation ) )
|
||||
$creatures/player.rotate_camera_arm( Vector3( 0.0, 1.0, 0.0 ), deg2rad( self.mouse_delta.x ) )
|
||||
|
||||
|
||||
$creatures/player.move_camera( Vector3( 0.0, 0.0, camera_zoom ) )
|
||||
$creatures/player.rotate_camera( Vector3( 1.0, 0.0, 0.0 ), deg2rad(-self.mouse_delta.y ) )
|
||||
|
||||
# camera_rotation = 0.0
|
||||
self.camera_zoom = 0.0
|
||||
self.mouse_delta = Vector2( 0.0, 0.0 )
|
||||
|
||||
|
||||
func load_player( filename ):
|
||||
$creatures/player.load_creature( filename )
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=20 format=2]
|
||||
[gd_scene load_steps=19 format=2]
|
||||
|
||||
[ext_resource path="res://scenes/player/player.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://scenes/game/game.gd" type="Script" id=3]
|
||||
|
@ -7,7 +7,6 @@
|
|||
[ext_resource path="res://assets/mist/mist.shader" type="Shader" id=7]
|
||||
[ext_resource path="res://assets/interfaces/debug_window/debug_window.tscn" type="PackedScene" id=8]
|
||||
[ext_resource path="res://assets/interfaces/themes/khanat_theme.theme" type="Theme" id=9]
|
||||
[ext_resource path="res://assets/interfaces/buttons/close_icon.png" type="Texture" id=10]
|
||||
[ext_resource path="res://scenes/interfaces/game_menu/game_ui.tscn" type="PackedScene" id=11]
|
||||
[ext_resource path="res://scenes/decors/terrains/test/test_level.tscn" type="PackedScene" id=12]
|
||||
|
||||
|
@ -24,8 +23,8 @@ noise = SubResource( 1 )
|
|||
[sub_resource type="ShaderMaterial" id=3]
|
||||
resource_local_to_scene = true
|
||||
shader = ExtResource( 5 )
|
||||
shader_param/iTime = 666.195
|
||||
shader_param/iFrame = 15250
|
||||
shader_param/iTime = 233.623
|
||||
shader_param/iFrame = 16024
|
||||
shader_param/COVERAGE = 0.5
|
||||
shader_param/THICKNESS = 25.0
|
||||
shader_param/ABSORPTION = 1.031
|
||||
|
@ -96,7 +95,6 @@ sun_position = Vector3( -1.15706e-06, 100, 8.66537e-06 )
|
|||
|
||||
[node name="sun" type="DirectionalLight" parent="sky"]
|
||||
transform = Transform( 0.991203, 0.132352, -1.15706e-08, 0, 8.74228e-08, 1, 0.132352, -0.991203, 8.66537e-08, -1.15706e-06, 100, 8.66537e-06 )
|
||||
light_energy = 1.0
|
||||
shadow_enabled = true
|
||||
|
||||
[node name="world_environment" type="WorldEnvironment" parent="."]
|
||||
|
@ -126,7 +124,6 @@ margin_right = -51.1268
|
|||
margin_bottom = -411.645
|
||||
focus_mode = 1
|
||||
theme = ExtResource( 9 )
|
||||
custom_icons/close = ExtResource( 10 )
|
||||
[connection signal="douleur_minus_pressed" from="debug_window" to="." method="_on_debug_window_douleur_minus_pressed"]
|
||||
[connection signal="douleur_plus_pressed" from="debug_window" to="." method="_on_debug_window_douleur_plus_pressed"]
|
||||
[connection signal="mist_level_changed" from="debug_window" to="." method="_on_debug_window_mist_level_changed"]
|
||||
|
|
|
@ -24,3 +24,19 @@ func load_creature( filename ):
|
|||
$model/ra/model/body.get_surface_material( 0 ).set_shader_param( "albedo", str2var( json[ "color" ] ) )
|
||||
print( str2var( json[ "color" ] ) )
|
||||
file.close()
|
||||
|
||||
|
||||
func rotate_camera_arm( p_axis, p_angle_degree ):
|
||||
$model/ra/spring_arm.rotate( p_axis, p_angle_degree )
|
||||
|
||||
func rotate_camera( p_axis, p_angle_degree ):
|
||||
$model/ra/spring_arm/camera.rotate( p_axis, p_angle_degree )
|
||||
|
||||
func move_camera( p_translation ):
|
||||
$model/ra/spring_arm/camera.translate( p_translation )
|
||||
|
||||
func reset_camera():
|
||||
$model/ra/spring_arm.translation = Vector3( 0, 1.731, -1.74 )
|
||||
$model/ra/spring_arm.rotation_degrees = Vector3( 0.0, 0.0, 0.0 )
|
||||
$model/ra/spring_arm/camera.translation = Vector3( 0.0, 0.0, 0.0 )
|
||||
$model/ra/spring_arm/camera.rotation_degrees = Vector3( -14, -178.1, 0.328 )
|
||||
|
|
Loading…
Reference in a new issue