Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to handle SkeletonModifier3D / XRTracker changes #1

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions 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,7 +53,11 @@ The character model must be in Godot Humanoid format. This can be achieved in th

### Body Driving

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:
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 posed using an [XRBodyModifier3D](https://docs.godotengine.org/en/latest/classes/class_xrbodymodifier3d.html) skeleton modifier:

![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,2 +1,5 @@
# 1.1.0
- Updated for changes to XR Tracker names and hierarchy

# 1.0.0
- Initial Revision
2 changes: 1 addition & 1 deletion addons/godot_mvn_tracker/mvn_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(
"mvn_tracker/tracking/body_tracker_name",
"/mvn/body")
"/mvn/body_tracker")

# Get the position mode
var position_mode = ProjectSettings.get_setting(
Expand Down
9 changes: 8 additions & 1 deletion addons/godot_mvn_tracker/mvn_source.gd
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ func _init(
udp_listener_port : int) -> void:

# 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 @@ -122,6 +123,12 @@ func _on_mvn_packet(data : MvnBody.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_mvn_tracker/mvn_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 = "/mvn/body"
@export var body_tracker_name : String = "/mvn/body_tracker"

## Position mode
@export_enum("Free", "Calibrate", "Locked") var position_mode : int = 0
Expand Down
2 changes: 1 addition & 1 deletion addons/godot_mvn_tracker/mvn_tracker.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=2 format=3 uid="uid://i7q25eljiwhw"]
[gd_scene load_steps=2 format=4 uid="uid://i7q25eljiwhw"]

[ext_resource type="Script" path="res://addons/godot_mvn_tracker/mvn_tracker.gd" id="1_k6gtg"]

Expand Down
2 changes: 1 addition & 1 deletion addons/godot_mvn_tracker/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
name="Godot MVN Tracker"
description="Godot MVN Tracker plugin"
author="Malcolm Nixon and Contributors"
version="1.0.0"
version="1.1.0"
script="plugin.gd"
2 changes: 1 addition & 1 deletion addons/godot_mvn_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,
"",
"/mvn/body")
"/mvn/body_tracker")

# Add position mode
_define_project_setting(
Expand Down
4 changes: 2 additions & 2 deletions demo.gd
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ func _input(event : InputEvent) -> void:


func _on_skeleton_spin_box_value_changed(value: float) -> void:
%"Test-Chan/Armature/Skeleton3D".motion_scale = value
%"Test-Kun/Armature/Skeleton3D".motion_scale = value
$"Chan/ChanAvatar/Test-Chan/Armature/Skeleton3D".motion_scale = value
$"Kun/KunAvatar/Test-Kun/Armature/Skeleton3D".motion_scale = value


func _on_world_spin_box_value_changed(value: float) -> void:
Expand Down
42 changes: 21 additions & 21 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://dkkew3u3hi7md"]
[gd_scene load_steps=14 format=4 uid="uid://dkkew3u3hi7md"]

[ext_resource type="Script" path="res://demo.gd" id="1_dt0nj"]
[ext_resource type="PackedScene" uid="uid://bhc6nngwjdvum" path="res://assets/test_chan/Test-Chan.fbx" id="1_lkeve"]
Expand Down Expand Up @@ -65,15 +65,12 @@ 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 = &"/mvn/body"
target = NodePath("Test-Chan/Armature/Skeleton3D")
show_when_tracked = false
[node name="ChanAvatar" type="XRNode3D" parent="Chan"]
tracker = &"/mvn/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")]

[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 @@ -116,27 +113,27 @@ blend_shapes/mouthPressRight = 0.0310566
blend_shapes/mouthStretchLeft = 0.0145674
blend_shapes/mouthStretchRight = 0.00253638

[node name="GroundRing" type="MeshInstance3D" parent="Chan/XRBodyModifier3D"]
[node name="XRBodyModifier3D" type="XRBodyModifier3D" parent="Chan/ChanAvatar/Test-Chan/Armature/Skeleton3D" index="2"]
body_tracker = &"/mvn/body_tracker"

[node name="GroundRing" type="MeshInstance3D" parent="Chan/ChanAvatar"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.05, 0)
mesh = SubResource("TorusMesh_rbtmk")
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_j1uet")

[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 = &"/mvn/body"
target = NodePath("Test-Kun/Armature/Skeleton3D")
show_when_tracked = false
[node name="KunAvatar" type="XRNode3D" parent="Kun"]
tracker = &"/mvn/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")]

[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 @@ -179,12 +176,15 @@ 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="2"]
body_tracker = &"/mvn/body_tracker"

[node name="GroundRing" type="MeshInstance3D" parent="Kun/KunAvatar"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.05, 0)
mesh = SubResource("TorusMesh_rbtmk")
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_j1uet")

Expand Down Expand Up @@ -256,5 +256,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.
Loading