@ -5,6 +5,9 @@ extends Mod_Base
@ export var address : = " "
@ export var address : = " "
@ export var port : = 52410
@ export var port : = 52410
## Hardcoded list of bone names that will get syncronized.
var tracked_bones : Array [ String ]
var main_controller : ModelController
var main_controller : ModelController
# Temporary positioning system.
# Temporary positioning system.
@ -18,6 +21,23 @@ var accumulative_offset := Vector3( 0.35, 0.0, 0.0)
var functions_blendshapes : Script = load ( " res://Mods/MediaPipe/MediaPipeController_BlendShapes.gd " )
var functions_blendshapes : Script = load ( " res://Mods/MediaPipe/MediaPipeController_BlendShapes.gd " )
func _ready ( ) - > void :
func _ready ( ) - > void :
# 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 " , " Chest " , " UpperChest " , " Neck " , " Head " ]
for side in [ " Left " , " Right " ] :
# Legs
for bone in [ " UpperLeg " , " LowerLeg " , " Foot " ] :
tracked_bones . append ( " %s %s " % [ side , bone ] )
# Arms
for bone in [ " Shoulder " , " UpperArm " , " LowerArm " , " Hand " ] :
tracked_bones . append ( " %s %s " % [ side , bone ] )
# Fingers
for phalange in [ " Metacarpal " , " Proximal " , " Distal " ] :
tracked_bones . append ( " %s Thumb %s " % [ side , phalange ] )
for finger in [ " Index " , " Middle " , " Ring " , " Little " ] :
for phalange in [ " Proximal " , " Intermediate " , " Distal " ] :
tracked_bones . append ( " %s %s %s " % [ side , finger , phalange ] )
# FIXME: Hardcoded way to get the main model controller.
# FIXME: Hardcoded way to get the main model controller.
main_controller = $ " /root/SnekStudio_Main/ModelController "
main_controller = $ " /root/SnekStudio_Main/ModelController "
main_controller . child_entered_tree . connect ( model_changed )
main_controller . child_entered_tree . connect ( model_changed )
@ -101,7 +121,7 @@ func peer_connected(id: int) -> void:
new_controller . name = str ( id )
new_controller . name = str ( id )
add_child ( new_controller )
add_child ( new_controller )
player_order . push_back ( id )
player_order . append ( id )
update_model_transforms ( )
update_model_transforms ( )
var filename = main_controller . _last_loaded_vrm . get_file ( )
var filename = main_controller . _last_loaded_vrm . get_file ( )
@ -203,7 +223,7 @@ func model_changed(child: Node) -> void:
# FIXME: This sends way more information than necessary, but works as a proof-of-concept!
# FIXME: This sends way more information than necessary, but works as a proof-of-concept!
@ rpc ( " any_peer " , " unreliable_ordered " )
@ rpc ( " any_peer " , " unreliable_ordered " )
func update (
func sync_model_animation (
model_transform : Transform3D ,
model_transform : Transform3D ,
shape_dict : Dictionary , # Dictionary[String, float]
shape_dict : Dictionary , # Dictionary[String, float]
bone_poses : Dictionary , # Dictionary[String, Transform3D]
bone_poses : Dictionary , # Dictionary[String, Transform3D]
@ -234,8 +254,9 @@ func _process(_delta: float) -> void:
var shape_dict = media_pipe_ctrl . blend_shape_last_values
var shape_dict = media_pipe_ctrl . blend_shape_last_values
var bone_poses = { }
var bone_poses = { }
for idx in skeleton . get_bone_count ( ) :
for bone_name in tracked_bones :
var bone_name = skeleton . get_bone_name ( idx )
var bone_idx = skeleton . find_bone ( bone_name )
var bone_pose = skeleton . get_bone_pose ( idx )
if bone_idx == - 1 : continue
var bone_pose = skeleton . get_bone_pose ( bone_idx )
bone_poses [ bone_name ] = bone_pose
bone_poses [ bone_name ] = bone_pose
update . rpc ( model . transform , shape_dict , bone_poses )
sync_model_animation . rpc ( model . transform , shape_dict , bone_poses )