ajout de la possibilite de tourner et zoomer le modele lors de la selection/creation de personnage.

This commit is contained in:
osquallo 2018-08-23 17:50:34 +02:00
parent 98d9df20d4
commit 29de0913d6
2 changed files with 209 additions and 11 deletions

View file

@ -7,9 +7,14 @@ var preview_slot = 0
var character_preview = null var character_preview = null
var character_mesh = null var character_mesh = null
var character_face_camera = null
var character_box = null var character_box = null
var name_input = null var name_input = null
var turn_direction = null
var zoom_direction = null
func update_character_slots(): func update_character_slots():
var config_file = ConfigFile.new() var config_file = ConfigFile.new()
@ -73,6 +78,7 @@ func _ready():
self.character_preview = $viewport/character self.character_preview = $viewport/character
self.character_mesh = $viewport/character.get_node("MeshInstance") self.character_mesh = $viewport/character.get_node("MeshInstance")
self.character_face_camera = $viewport/character/Camera_rotation_helper/face_camera
self.character_box = $margin_container/character_box self.character_box = $margin_container/character_box
self.name_input = self.character_box.get_node( "character_creation_box/margin_container/v_box_container/name_box/line_edit" ) self.name_input = self.character_box.get_node( "character_creation_box/margin_container/v_box_container/name_box/line_edit" )
self.character_preview.update() self.character_preview.update()
@ -179,3 +185,41 @@ func _on_character_creation_box_sex_bar_changed( value ):
func _on_character_creation_box_size_bar_changed( value ): func _on_character_creation_box_size_bar_changed( value ):
self.character_preview.size = value self.character_preview.size = value
self.character_preview.update() self.character_preview.update()
func _process( delta ):
if turn_direction == "left":
self.character_mesh.rotation.y -= delta
elif turn_direction == "right":
self.character_mesh.rotation.y += delta
#
# if zoom_direction == "front":
# self.character_mesh.translation.z += delta
# elif zoom_direction == "back":
# self.character_mesh.translation.z -= delta
if zoom_direction == "front":
self.character_face_camera.size += delta
elif zoom_direction == "back":
self.character_face_camera.size -= delta
func _on_turn_left_button_down():
turn_direction = "left"
func _on_turn_left_button_up():
turn_direction = null
func _on_turn_right_button_down():
turn_direction = "right"
func _on_turn_right_button_up():
turn_direction = null
func _on_zoom_out_button_down():
zoom_direction = "front"
func _on_zoom_out_button_up():
zoom_direction = null
func _on_zoom_in_button_down():
zoom_direction = "back"
func _on_zoom_in_button_up():
zoom_direction = null

View file

@ -9,7 +9,7 @@
[sub_resource type="ViewportTexture" id=1] [sub_resource type="ViewportTexture" id=1]
resource_local_to_scene = true resource_local_to_scene = true
flags = 12 flags = 0
viewport_path = NodePath("viewport") viewport_path = NodePath("viewport")
[node name="character_selection_menu" type="Control" index="0"] [node name="character_selection_menu" type="Control" index="0"]
@ -32,7 +32,7 @@ arvr = false
size = Vector2( 512, 512 ) size = Vector2( 512, 512 )
own_world = false own_world = false
world = null world = null
transparent_bg = false transparent_bg = true
msaa = 2 msaa = 2
hdr = true hdr = true
disable_3d = false disable_3d = false
@ -84,7 +84,10 @@ mouse_filter = 0
mouse_default_cursor_shape = 0 mouse_default_cursor_shape = 0
size_flags_horizontal = 1 size_flags_horizontal = 1
size_flags_vertical = 1 size_flags_vertical = 1
custom_constants/margin_right = 8
custom_constants/margin_top = 8
custom_constants/margin_left = 8 custom_constants/margin_left = 8
custom_constants/margin_bottom = 8
_sections_unfolded = [ "Size Flags", "custom_constants" ] _sections_unfolded = [ "Size Flags", "custom_constants" ]
[node name="character_box" type="HBoxContainer" parent="margin_container" index="0"] [node name="character_box" type="HBoxContainer" parent="margin_container" index="0"]
@ -94,8 +97,9 @@ anchor_top = 0.0
anchor_right = 0.0 anchor_right = 0.0
anchor_bottom = 0.0 anchor_bottom = 0.0
margin_left = 8.0 margin_left = 8.0
margin_right = 1024.0 margin_top = 8.0
margin_bottom = 600.0 margin_right = 1016.0
margin_bottom = 592.0
rect_pivot_offset = Vector2( 0, 0 ) rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false rect_clip_content = false
mouse_filter = 1 mouse_filter = 1
@ -107,8 +111,8 @@ _sections_unfolded = [ "Size Flags", "custom_constants" ]
[node name="character_slots" parent="margin_container/character_box" index="0" instance=ExtResource( 4 )] [node name="character_slots" parent="margin_container/character_box" index="0" instance=ExtResource( 4 )]
margin_top = 290.0 margin_top = 282.0
margin_bottom = 310.0 margin_bottom = 302.0
size_flags_vertical = 6 size_flags_vertical = 6
custom_constants/separation = 8 custom_constants/separation = 8
_sections_unfolded = [ "Size Flags", "custom_constants" ] _sections_unfolded = [ "Size Flags", "custom_constants" ]
@ -121,16 +125,34 @@ margin_top = 191.0
margin_right = 600.0 margin_right = 600.0
margin_bottom = 409.0 margin_bottom = 409.0
[node name="nine_patch_rect" type="NinePatchRect" parent="margin_container/character_box" index="2"] [node name="v_box_container" type="VBoxContainer" parent="margin_container/character_box" index="2"]
anchor_left = 0.0 anchor_left = 0.0
anchor_top = 0.0 anchor_top = 0.0
anchor_right = 0.0 anchor_right = 0.0
anchor_bottom = 0.0 anchor_bottom = 0.0
margin_left = 281.0 margin_left = 58.0
margin_top = 44.0 margin_right = 1008.0
margin_right = 793.0 margin_bottom = 584.0
margin_bottom = 556.0 rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 3
size_flags_vertical = 3
alignment = 0
_sections_unfolded = [ "Size Flags" ]
[node name="nine_patch_rect" type="NinePatchRect" parent="margin_container/character_box/v_box_container" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 219.0
margin_top = 24.0
margin_right = 731.0
margin_bottom = 536.0
rect_min_size = Vector2( 512, 512 ) rect_min_size = Vector2( 512, 512 )
rect_pivot_offset = Vector2( 0, 0 ) rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false rect_clip_content = false
@ -141,6 +163,122 @@ size_flags_vertical = 6
texture = SubResource( 1 ) texture = SubResource( 1 )
_sections_unfolded = [ "Axis Stretch", "Grow Direction", "Margin", "Rect", "Size Flags" ] _sections_unfolded = [ "Axis Stretch", "Grow Direction", "Margin", "Rect", "Size Flags" ]
[node name="h_box_container" type="HBoxContainer" parent="margin_container/character_box/v_box_container" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 425.0
margin_top = 564.0
margin_right = 524.0
margin_bottom = 584.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 6
size_flags_vertical = 1
alignment = 0
_sections_unfolded = [ "Size Flags" ]
[node name="turn_left" type="Button" parent="margin_container/character_box/v_box_container/h_box_container" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 25.0
margin_bottom = 20.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = false
action_mode = 0
enabled_focus_mode = 2
shortcut = null
group = null
text = "<-"
flat = false
align = 1
[node name="zoom_out" type="Button" parent="margin_container/character_box/v_box_container/h_box_container" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 29.0
margin_right = 46.0
margin_bottom = 20.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
group = null
text = "-"
flat = false
align = 1
[node name="zoom_in" type="Button" parent="margin_container/character_box/v_box_container/h_box_container" index="2"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 50.0
margin_right = 70.0
margin_bottom = 20.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
group = null
text = "+"
flat = false
align = 1
[node name="turn_right" type="Button" parent="margin_container/character_box/v_box_container/h_box_container" index="3"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 74.0
margin_right = 99.0
margin_bottom = 20.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = false
action_mode = 0
enabled_focus_mode = 2
shortcut = null
group = null
text = "->"
flat = false
align = 1
[connection signal="return_button_pressed" from="margin_container/character_box/character_slots" to="." method="_on_character_slots_return_button_pressed"] [connection signal="return_button_pressed" from="margin_container/character_box/character_slots" to="." method="_on_character_slots_return_button_pressed"]
[connection signal="creation_button_pressed" from="margin_container/character_box/character_creation_box" to="." method="_on_character_creation_box_creation_button_pressed"] [connection signal="creation_button_pressed" from="margin_container/character_box/character_creation_box" to="." method="_on_character_creation_box_creation_button_pressed"]
@ -151,4 +289,20 @@ _sections_unfolded = [ "Axis Stretch", "Grow Direction", "Margin", "Rect", "Size
[connection signal="size_bar_changed" from="margin_container/character_box/character_creation_box" to="." method="_on_character_creation_box_size_bar_changed"] [connection signal="size_bar_changed" from="margin_container/character_box/character_creation_box" to="." method="_on_character_creation_box_size_bar_changed"]
[connection signal="button_down" from="margin_container/character_box/v_box_container/h_box_container/turn_left" to="." method="_on_turn_left_button_down"]
[connection signal="button_up" from="margin_container/character_box/v_box_container/h_box_container/turn_left" to="." method="_on_turn_left_button_up"]
[connection signal="button_down" from="margin_container/character_box/v_box_container/h_box_container/zoom_out" to="." method="_on_zoom_out_button_down"]
[connection signal="button_up" from="margin_container/character_box/v_box_container/h_box_container/zoom_out" to="." method="_on_zoom_out_button_up"]
[connection signal="button_down" from="margin_container/character_box/v_box_container/h_box_container/zoom_in" to="." method="_on_zoom_in_button_down"]
[connection signal="button_up" from="margin_container/character_box/v_box_container/h_box_container/zoom_in" to="." method="_on_zoom_in_button_up"]
[connection signal="button_down" from="margin_container/character_box/v_box_container/h_box_container/turn_right" to="." method="_on_turn_right_button_down"]
[connection signal="button_up" from="margin_container/character_box/v_box_container/h_box_container/turn_right" to="." method="_on_turn_right_button_up"]