diff --git a/default_env.tres b/default_env.tres index bed4799..20207a4 100644 --- a/default_env.tres +++ b/default_env.tres @@ -5,4 +5,3 @@ [resource] background_mode = 2 background_sky = SubResource( 1 ) - diff --git a/materials/tilables/base_plastic_hard_shiny.material b/materials/tilables/base_plastic_hard_shiny.material index 9baeac5..f6389f3 100644 Binary files a/materials/tilables/base_plastic_hard_shiny.material and b/materials/tilables/base_plastic_hard_shiny.material differ diff --git a/materials/tilables/base_plastic_soft.material b/materials/tilables/base_plastic_soft.material index fca6c45..b3486b4 100644 Binary files a/materials/tilables/base_plastic_soft.material and b/materials/tilables/base_plastic_soft.material differ diff --git a/materials/tilables/base_steel_glossy.material b/materials/tilables/base_steel_glossy.material index c159c2d..6035a2c 100644 Binary files a/materials/tilables/base_steel_glossy.material and b/materials/tilables/base_steel_glossy.material differ diff --git a/meshes/props/pendo_teddy/pendo_teddy.glb b/meshes/props/pendo_teddy/pendo_teddy.glb index 0560a50..0243a48 100644 Binary files a/meshes/props/pendo_teddy/pendo_teddy.glb and b/meshes/props/pendo_teddy/pendo_teddy.glb differ diff --git a/meshes/props/pendo_teddy/pendo_teddy.material b/meshes/props/pendo_teddy/pendo_teddy.material index bb23da7..e9140a8 100644 Binary files a/meshes/props/pendo_teddy/pendo_teddy.material and b/meshes/props/pendo_teddy/pendo_teddy.material differ diff --git a/previewer/previewer.gd b/previewer/previewer.gd index 286e2d5..fb1fe20 100644 --- a/previewer/previewer.gd +++ b/previewer/previewer.gd @@ -1,30 +1,78 @@ extends Spatial +var _mouse_look = false +var _mouse_position = Vector2( 0.0, 0.0 ) +var _yaw = 0.0 +var _pitch = 0.0 +var _total_yaw = 0.0 +var _total_pitch = 0.0 +var _current_camera_speed = 1.0 + +export(int) var yaw_limit = 360 +export(int) var pitch_limit = 360 +export(float) var camera_sensitivity = 0.5 +export(float) var camera_smoothness = 0.5 +export(float) var camera_speed = 1.0 +export(float) var camera_accel = 10.0 + +func _ready(): + self._current_camera_speed = self.camera_speed + func _process( delta ): - - if Input.is_action_pressed("move_forward"): - $dummy/camera_stand.translate( Vector3( 0.0, 0.0,-10.0*delta ) ) - if Input.is_action_pressed("move_backward"): - $dummy/camera_stand.translate( Vector3( 0.0, 0.0, 10.0*delta ) ) + + if Input.is_action_pressed("move_up"): + $dummy/camera_stand.translate( Vector3( 0.0, self._current_camera_speed*delta, 0.0 ) ) + elif Input.is_action_pressed("move_down"): + $dummy/camera_stand.translate( Vector3( 0.0,-self._current_camera_speed*delta, 0.0 ) ) + elif Input.is_action_pressed("move_forward"): + $dummy/camera_stand.translate( Vector3( 0.0, 0.0,-self._current_camera_speed*delta ) ) + elif Input.is_action_pressed("move_backward"): + $dummy/camera_stand.translate( Vector3( 0.0, 0.0, self._current_camera_speed*delta ) ) if Input.is_action_pressed("move_left"): - $dummy/camera_stand.translate( Vector3(-10.0*delta, 0.0, 0.0 ) ) - if Input.is_action_pressed("move_right"): - $dummy/camera_stand.translate( Vector3( 10.0*delta, 0.0, 0.0 ) ) + $dummy/camera_stand.translate( Vector3(-self._current_camera_speed*delta, 0.0, 0.0 ) ) + elif Input.is_action_pressed("move_right"): + $dummy/camera_stand.translate( Vector3( self._current_camera_speed*delta, 0.0, 0.0 ) ) + + + if _mouse_look: + _update_mouselook() + +func _update_mouselook(): + _mouse_position *= self.camera_sensitivity + _yaw = _yaw * self.camera_smoothness + _mouse_position.x * (1.0 - self.camera_smoothness) + _pitch = _pitch * self.camera_smoothness + _mouse_position.y * (1.0 - self.camera_smoothness) + _mouse_position = Vector2(0, 0) + + if yaw_limit < 360: + _yaw = clamp(_yaw, -yaw_limit - _total_yaw, yaw_limit - _total_yaw) + if pitch_limit < 360: + _pitch = clamp(_pitch, -pitch_limit - _total_pitch, pitch_limit - _total_pitch) + + _total_yaw += _yaw + _total_pitch += _pitch + + $dummy/camera_stand.rotate_y(deg2rad(-_yaw)) + $dummy/camera_stand.rotate_object_local(Vector3(1,0,0), deg2rad(-_pitch)) func _input(event): if event.is_action_pressed( "move_look" ): Input.set_mouse_mode( Input.MOUSE_MODE_CAPTURED ) + self._mouse_look = true elif event.is_action_released( "move_look" ): Input.set_mouse_mode( Input.MOUSE_MODE_VISIBLE ) + self._mouse_look = false if event is InputEventMouseMotion: - if Input.is_action_pressed( "move_look" ): - $dummy/camera_stand/camera.rotate_x( -event.relative.y * 0.01 ) - $dummy/camera_stand.rotate_y( -event.relative.x * 0.01 ) - + if _mouse_look: + _mouse_position = event.relative + if event.is_action_pressed( "move_zoom_in" ): $dummy/camera_stand/camera.set_fov( $dummy/camera_stand/camera.get_fov()-1.0 ) elif event.is_action_pressed( "move_zoom_out" ): $dummy/camera_stand/camera.set_fov( $dummy/camera_stand/camera.get_fov()+1.0 ) - \ No newline at end of file + + if event.is_action_pressed( "move_speed" ): + self._current_camera_speed = self.camera_speed + self.camera_accel + elif event.is_action_released( "move_speed" ): + self._current_camera_speed = self.camera_speed \ No newline at end of file diff --git a/previewer/previewer.tscn b/previewer/previewer.tscn index f533a37..ed59d41 100644 --- a/previewer/previewer.tscn +++ b/previewer/previewer.tscn @@ -71,4 +71,3 @@ shadow_enabled = true [node name="gi_probe" type="GIProbe" parent="light_system"] extents = Vector3( 63.192, 10, 76.3229 ) data = SubResource( 5 ) - diff --git a/project.godot b/project.godot index 8bc0940..163b15d 100644 --- a/project.godot +++ b/project.godot @@ -56,6 +56,21 @@ move_zoom_out={ "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) ] } +move_up={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":true,"meta":false,"command":true,"pressed":false,"scancode":16777232,"unicode":0,"echo":false,"script":null) + ] +} +move_down={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":true,"meta":false,"command":true,"pressed":false,"scancode":16777234,"unicode":0,"echo":false,"script":null) + ] +} +move_speed={ +"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":16777237,"unicode":0,"echo":false,"script":null) + ] +} [node]