Skip to content

Commit

Permalink
Apply root position from current hips.
Browse files Browse the repository at this point in the history
  • Loading branch information
Malcolmnixon committed Mar 3, 2024
1 parent d89f6f4 commit 1af5322
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
14 changes: 7 additions & 7 deletions addons/godot_axis_studio_tracker/axis_studio_tracker.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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
1 change: 1 addition & 0 deletions demo.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down

0 comments on commit 1af5322

Please sign in to comment.