From 1af5322cb825c798f076ca12c43f346316536e52 Mon Sep 17 00:00:00 2001 From: Malcolm Nixon Date: Sun, 3 Mar 2024 00:02:49 -0500 Subject: [PATCH] Apply root position from current hips. --- .../axis_studio_tracker.gd | 14 +++++++------- demo.tscn | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/addons/godot_axis_studio_tracker/axis_studio_tracker.gd b/addons/godot_axis_studio_tracker/axis_studio_tracker.gd index f93f252..eb3de41 100644 --- a/addons/godot_axis_studio_tracker/axis_studio_tracker.gd +++ b/addons/godot_axis_studio_tracker/axis_studio_tracker.gd @@ -122,13 +122,6 @@ func _on_axis_studio_packet(data : AxisStudioBody.JointData) -> void: _abs_positions[joint] = pos _abs_rotations[joint] = rot - # Calculate and set the root joint under the hips - var root := _body_tracker.get_joint_transform(XRBodyTracker.JOINT_HIPS) - root.basis = Basis.IDENTITY - root.origin = root.origin.slide(Vector3.UP) - _body_tracker.set_joint_transform(XRBodyTracker.JOINT_ROOT, root) - _body_tracker.set_joint_flags(XRBodyTracker.JOINT_ROOT, JOINT_TRACKING) - # Apply to the XRBodyTracker for joint in AxisStudioBody.JOINT_MAPPING: var body : XRBodyTracker.Joint = joint["body"] @@ -145,6 +138,13 @@ func _on_axis_studio_packet(data : AxisStudioBody.JointData) -> void: # Set the joint flags _body_tracker.set_joint_flags(body, JOINT_TRACKING) + # Calculate and set the root joint under the hips + var root := _body_tracker.get_joint_transform(XRBodyTracker.JOINT_HIPS) + root.basis = Basis.IDENTITY + root.origin = root.origin.slide(Vector3.UP) + _body_tracker.set_joint_transform(XRBodyTracker.JOINT_ROOT, root) + _body_tracker.set_joint_flags(XRBodyTracker.JOINT_ROOT, JOINT_TRACKING) + # Indicate we are tracking the body _body_tracker.body_flags = BODY_TRACKING _body_tracker.has_tracking_data = true diff --git a/demo.tscn b/demo.tscn index 858db30..768674e 100644 --- a/demo.tscn +++ b/demo.tscn @@ -118,6 +118,7 @@ transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0.6, 0 [node name="XRBodyModifier3D" type="XRBodyModifier3D" parent="Kun"] body_tracker = &"/axis_studio/body" target = NodePath("Test-Kun/Armature/Skeleton3D") +bone_update = 1 show_when_tracked = false [node name="Test-Kun" parent="Kun/XRBodyModifier3D" instance=ExtResource("2_67k0v")]