Skip to content

Commit

Permalink
Changes to work with SkeletonModifier3D and the XRTacker changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Malcolmnixon committed Apr 22, 2024
1 parent bff01aa commit 495fed0
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 28 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ Official releases are tagged and can be found [here](https://github.com/Malcolmn
The following branches are in active development:
| Branch | Description | Godot version |
|-----------|-------------------------------|------------------|
| master | Current development branch | Godot 4.3-dev4+ |
| master | Current development branch | Godot 4.3-dev6+ |

<sub>NOTE: This requires the [XR Trackers](https://github.com/godotengine/godot/pull/90645) PR which is in the Godot master branch, but no release has been made.</sub>

## Overview

Expand Down Expand Up @@ -51,6 +53,10 @@ The character model must be in Godot Humanoid format. This can be achieved in th

### Body Driving

The body is positioned using an [XRNode3D](https://docs.godotengine.org/en/latest/classes/class_xrnode3d.html) node configured to track the character body:

![XRNode3D](/docs/xrnode3d.png)

The body is driven using an [XRBodyModifier3D](https://docs.godotengine.org/en/latest/classes/class_xrbodymodifier3d.html) node configured to drive the skeleton of the character:

![XRBodyModifier3D](/docs/xrbodymodifier3d.png)
Expand Down
3 changes: 3 additions & 0 deletions VERSIONS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 1.2.0
- Updated for changes to XR Tracker names and hierarchy

# 1.1.0
- Improved root motion
- Added scaling controls
Expand Down
2 changes: 1 addition & 1 deletion addons/godot_axis_studio_tracker/axis_studio_plugin.gd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func _enter_tree() -> void:
# Get the body tracker name
var body_tracker_name : String = ProjectSettings.get_setting(
"axis_studio_tracker/tracking/body_tracker_name",
"/axis_studio/body")
"/axis_studio/body_tracker")

# Get the position mode
var position_mode = ProjectSettings.get_setting(
Expand Down
4 changes: 3 additions & 1 deletion addons/godot_axis_studio_tracker/axis_studio_source.gd
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ func _init(
_abs_rotations.fill(Quaternion.IDENTITY)

# Register the body tracker
XRServer.add_body_tracker(body_tracker_name, _body_tracker)
_body_tracker.name = body_tracker_name
XRServer.add_tracker(_body_tracker)

# Save the position mode
_position_mode = position_mode
Expand Down Expand Up @@ -145,6 +146,7 @@ func _on_axis_studio_packet(data : AxisStudioBody.JointData) -> void:
var root := Transform3D(root_x, root_y, root_z, root_o).orthonormalized()
_body_tracker.set_joint_transform(XRBodyTracker.JOINT_ROOT, root)
_body_tracker.set_joint_flags(XRBodyTracker.JOINT_ROOT, JOINT_TRACKING)
_body_tracker.set_pose("default", root, Vector3.ZERO, Vector3.ZERO, XRPose.XR_TRACKING_CONFIDENCE_HIGH)

# Indicate we are tracking the body
_body_tracker.body_flags = BODY_TRACKING
Expand Down
2 changes: 1 addition & 1 deletion addons/godot_axis_studio_tracker/axis_studio_tracker.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extends Node


## Body tracker name
@export var body_tracker_name : String = "/axis_studio/body"
@export var body_tracker_name : String = "/axis_studio/body_tracker"

## Position mode
@export_enum("Free", "Calibrate", "Locked") var position_mode : int = 0
Expand Down
2 changes: 1 addition & 1 deletion addons/godot_axis_studio_tracker/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
name="Godot Axis Studio Tracker"
description="Godot Axis Studio Tracker plugin"
author="Malcolm Nixon and Contributors"
version="1.0.0"
version="1.2.0"
script="plugin.gd"
2 changes: 1 addition & 1 deletion addons/godot_axis_studio_tracker/plugin.gd
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func _enter_tree():
TYPE_STRING,
PROPERTY_HINT_NONE,
"",
"/axis_studio/body")
"/axis_studio/body_tracker")

# Add position mode
_define_project_setting(
Expand Down
1 change: 1 addition & 0 deletions assets/test_chan/Test-Chan.fbx.import
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
_subresources={
"materials": {
Expand Down
1 change: 1 addition & 0 deletions assets/test_kun/Test-Kun.fbx.import
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
_subresources={
"materials": {
Expand Down
48 changes: 26 additions & 22 deletions demo.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=14 format=3 uid="uid://btisi43jtpet"]
[gd_scene load_steps=14 format=4 uid="uid://btisi43jtpet"]

[ext_resource type="PackedScene" uid="uid://bhc6nngwjdvum" path="res://assets/test_chan/Test-Chan.fbx" id="1_lkeve"]
[ext_resource type="Texture2D" uid="uid://drjoya1j38i21" path="res://assets/ambientcg.com/Carpet003_1K-JPG_Color.jpg" id="1_pfl7p"]
Expand Down Expand Up @@ -66,16 +66,13 @@ transform = Transform3D(0.939693, 0.0593911, -0.336824, 0, 0.984808, 0.173648, 0
[node name="Chan" type="Node3D" parent="."]
transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, -0.6, 0, 0)

[node name="XRBodyModifier3D" type="XRBodyModifier3D" parent="Chan"]
body_tracker = &"/axis_studio/body"
target = NodePath("Test-Chan/Armature/Skeleton3D")
show_when_tracked = false
[node name="ChanAvatar" type="XRNode3D" parent="Chan"]
tracker = &"/axis_studio/body_tracker"

[node name="Test-Chan" parent="Chan/XRBodyModifier3D" instance=ExtResource("1_lkeve")]
unique_name_in_owner = true
[node name="Test-Chan" parent="Chan/ChanAvatar" instance=ExtResource("1_lkeve")]
transform = Transform3D(1, 0, -1.74846e-07, 0, 1, 0, 1.74846e-07, 0, 1, 0, 0, 0)

[node name="Body" parent="Chan/XRBodyModifier3D/Test-Chan/Armature/Skeleton3D" index="0"]
[node name="Body" parent="Chan/ChanAvatar/Test-Chan/Armature/Skeleton3D" index="0"]
blend_shapes/Cheek_Puff_Left = 1.28996e-05
blend_shapes/Cheek_Puff_Right = 1.28996e-05
blend_shapes/Eye_Left_Left = 0.297788
Expand Down Expand Up @@ -118,28 +115,30 @@ blend_shapes/mouthPressRight = 0.0310566
blend_shapes/mouthStretchLeft = 0.0145674
blend_shapes/mouthStretchRight = 0.00253638

[node name="GroundRing" type="MeshInstance3D" parent="Chan/XRBodyModifier3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.05, 0)
[node name="XRBodyModifier3D" type="XRBodyModifier3D" parent="Chan/ChanAvatar/Test-Chan/Armature/Skeleton3D" index="3"]
transform = Transform3D(1, 0, 1.74846e-07, 0, 1, 0, -1.74846e-07, 0, 1, 0, 0, 0)
body_tracker = &"/axis_studio/body_tracker"
bone_update = 1

[node name="GroundRing" type="MeshInstance3D" parent="Chan/ChanAvatar"]
transform = Transform3D(1, 0, 7.10543e-15, 0, 1, 0, -7.10543e-15, 0, 1, 0, 0.05, 0)
mesh = SubResource("TorusMesh_c2425")
skeleton = NodePath("")

[node name="Forward" type="MeshInstance3D" parent="Chan/XRBodyModifier3D/GroundRing"]
[node name="Forward" type="MeshInstance3D" parent="Chan/ChanAvatar/GroundRing"]
transform = Transform3D(1, -8.74228e-08, -8.74228e-08, 8.74228e-08, -4.37114e-08, 1, -8.74228e-08, -1, -4.37114e-08, -5.96046e-08, 0, -0.6)
mesh = SubResource("SphereMesh_tw3o4")

[node name="Kun" type="Node3D" parent="."]
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0.6, 0, 0)

[node name="XRBodyModifier3D" type="XRBodyModifier3D" parent="Kun"]
body_tracker = &"/axis_studio/body"
target = NodePath("Test-Kun/Armature/Skeleton3D")
show_when_tracked = false
[node name="KunAvatar" type="XRNode3D" parent="Kun"]
tracker = &"/axis_studio/body_tracker"

[node name="Test-Kun" parent="Kun/XRBodyModifier3D" instance=ExtResource("2_67k0v")]
unique_name_in_owner = true
[node name="Test-Kun" parent="Kun/KunAvatar" instance=ExtResource("2_67k0v")]
transform = Transform3D(1, 0, -2.13163e-14, 0, 1, 0, 2.13163e-14, 0, 1, 0, 0, 0)

[node name="Body" parent="Kun/XRBodyModifier3D/Test-Kun/Armature/Skeleton3D" index="0"]
[node name="Body" parent="Kun/KunAvatar/Test-Kun/Armature/Skeleton3D" index="0"]
blend_shapes/Cheek_Puff_Left = 1.28996e-05
blend_shapes/Cheek_Puff_Right = 1.28996e-05
blend_shapes/Eye_Left_Left = 0.297788
Expand Down Expand Up @@ -182,12 +181,17 @@ blend_shapes/mouthPressRight = 0.0310566
blend_shapes/mouthStretchLeft = 0.0145674
blend_shapes/mouthStretchRight = 0.00253638

[node name="GroundRing" type="MeshInstance3D" parent="Kun/XRBodyModifier3D"]
[node name="XRBodyModifier3D" type="XRBodyModifier3D" parent="Kun/KunAvatar/Test-Kun/Armature/Skeleton3D" index="3"]
transform = Transform3D(1, 0, 2.13163e-14, 0, 1, 0, -2.13163e-14, 0, 1, 0, 0, 0)
body_tracker = &"/axis_studio/body_tracker"
bone_update = 1

[node name="GroundRing" type="MeshInstance3D" parent="Kun/KunAvatar"]
transform = Transform3D(1, 0, -1.74846e-07, 0, 1, 0, 1.74846e-07, 0, 1, 0, 0.05, 0)
mesh = SubResource("TorusMesh_c2425")
skeleton = NodePath("")

[node name="Forward" type="MeshInstance3D" parent="Kun/XRBodyModifier3D/GroundRing"]
[node name="Forward" type="MeshInstance3D" parent="Kun/KunAvatar/GroundRing"]
transform = Transform3D(1, -8.74228e-08, -8.74228e-08, 8.74228e-08, -4.37114e-08, 1, -8.74228e-08, -1, -4.37114e-08, -5.96046e-08, 0, -0.6)
mesh = SubResource("SphereMesh_tw3o4")

Expand Down Expand Up @@ -260,5 +264,5 @@ value = 1.0
[connection signal="value_changed" from="PanelContainer/MarginContainer/HBoxContainer/GridContainer/SkeletonSpinBox" to="." method="_on_skeleton_spin_box_value_changed"]
[connection signal="value_changed" from="PanelContainer/MarginContainer/HBoxContainer/GridContainer/WorldSpinBox" to="." method="_on_world_spin_box_value_changed"]

[editable path="Chan/XRBodyModifier3D/Test-Chan"]
[editable path="Kun/XRBodyModifier3D/Test-Kun"]
[editable path="Chan/ChanAvatar/Test-Chan"]
[editable path="Kun/KunAvatar/Test-Kun"]
Binary file modified docs/enable_plugin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/plugin_settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/xrbodymodifier3d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/xrnode3d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 495fed0

Please sign in to comment.