|
|
|
@ -27,6 +27,9 @@ var accumulative_offset := Vector3( 0.35, 0.0, 0.0) |
|
|
|
|
# I don't believe this should be a source of issues. |
|
|
|
|
|
|
|
|
|
func _ready() -> void: |
|
|
|
|
# FIXME: Hardcoded way to get the main model controller. |
|
|
|
|
main_controller = $"/root/SnekStudio_Main/ModelController" |
|
|
|
|
|
|
|
|
|
# FIXME: This is just thrown together. Dunno if this is an accurate list. |
|
|
|
|
# TODO: Allow specifying additional bones, with the help of a hierachical list of existing bones in the model. |
|
|
|
|
tracked_bones = [ "Hips", "Spine", "Chest", "UpperChest", "Neck", "Head" ] |
|
|
|
@ -46,11 +49,6 @@ func _ready() -> void: |
|
|
|
|
for phalange in [ "Proximal", "Intermediate", "Distal" ]: |
|
|
|
|
tracked_bones.append("%s%s%s" % [ side, finger, phalange ]) |
|
|
|
|
|
|
|
|
|
# FIXME: Hardcoded way to get the main model controller. |
|
|
|
|
main_controller = $"/root/SnekStudio_Main/ModelController" |
|
|
|
|
main_controller.child_entered_tree.connect(on_model_changed) |
|
|
|
|
on_model_changed(main_controller.get_node_or_null("Model")) |
|
|
|
|
|
|
|
|
|
setup_setting_widget("cache" , "Cache/LineEdit", true ) |
|
|
|
|
setup_setting_widget("nickname", "Name/LineEdit" , false) |
|
|
|
|
setup_setting_widget("address" , "Host/Address" , true ) |
|
|
|
@ -222,13 +220,12 @@ func clear_player_models() -> void: |
|
|
|
|
func _process(_delta: float) -> void: |
|
|
|
|
SyncController.send_model_animation(self) |
|
|
|
|
|
|
|
|
|
# Will be called once when the module is initialized, and also when a child is |
|
|
|
|
# added to the main ModelController, which happens when the model is changed. |
|
|
|
|
func on_model_changed(model: Node) -> void: |
|
|
|
|
if (model == null) or (model.name != "Model"): return |
|
|
|
|
|
|
|
|
|
var skeleton: Skeleton3D = main_controller._get_model_skeleton() |
|
|
|
|
if not skeleton: return # Do nothing, I guess? Unsure if potential bug. |
|
|
|
|
# Called when module is initialized or load_vrm is called. |
|
|
|
|
func scene_init() -> void: |
|
|
|
|
var model := get_model() |
|
|
|
|
var skeleton := get_skeleton() |
|
|
|
|
# Do nothing, I guess? Unsure if source of potential bugs. |
|
|
|
|
if (not model) or (not skeleton): return |
|
|
|
|
|
|
|
|
|
# This "version" is used to ensure that sync updates |
|
|
|
|
# are not applied to the incorrect lookup tables. |
|
|
|
@ -250,11 +247,9 @@ func on_model_changed(model: Node) -> void: |
|
|
|
|
blendshape_lookup.append(anim.track_get_path(track_index)) |
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
# Wait for one frame, then "_last_loaded_vrm" is updated. |
|
|
|
|
await get_tree().process_frame |
|
|
|
|
var filename = main_controller._last_loaded_vrm.get_file() |
|
|
|
|
|
|
|
|
|
change_model.rpc(version, bone_lookup, blendshape_lookup, filename) |
|
|
|
|
if multiplayer.get_peers().size() > 1: |
|
|
|
|
var filename = main_controller._last_loaded_vrm.get_file() |
|
|
|
|
change_model.rpc(version, bone_lookup, blendshape_lookup, filename) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Gets the SyncController for the player with the specified peer id. |
|
|
|
|