-
Notifications
You must be signed in to change notification settings - Fork 27
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
Add support for developer-created spatial anchors via XR_FB_spatial_entity #121
Conversation
d88a214
to
d57232c
Compare
Rebased after recent merges! |
266c6ed
to
f9bbbec
Compare
common/src/main/cpp/include/extensions/openxr_fb_spatial_entity_extension_wrapper.h
Outdated
Show resolved
Hide resolved
common/src/main/cpp/classes/openxr_fb_spatial_anchor_manager.cpp
Outdated
Show resolved
Hide resolved
ca93e51
to
ea04f10
Compare
0b0eb76
to
1503d73
Compare
This is updated per @m4gr3d's requested changes, and rebased on all the recent merges |
nullptr, // next | ||
reinterpret_cast<XrSpace>(get_openxr_api()->get_play_space()), // space | ||
pose, // poseInSpace | ||
get_openxr_api()->get_next_frame_time(), // time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use get_predicted_display_time
following the merging of godotengine/godot#89734
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! However, we'd need to update the extension_api.json
we're using, and there's 4 other unrelated places where we're calling get_next_frame_time()
. That feels like something for a dedicated PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good! I've added #140 to track.
common/src/main/cpp/classes/openxr_fb_spatial_anchor_manager.cpp
Outdated
Show resolved
Hide resolved
1503d73
to
95f1ced
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
This is a follow-up to PR #107 which added support for scene anchors (aka the data from Meta's scene understanding).
This PR adds the ability for the developer to create and manage their own spatial anchors.
Here's a screenshot from the demo:
When you switch into passthrough mode, you can press the trigger on a surface from scene understanding (aka a scene anchor) and place a spatial anchor, which is represented by a colored cone (the color is selected randomly). If you point at an existing spatial anchor, pressing the trigger will remove it. If you close and open the app again, the spatial anchors will be restored with the same colors they had previously.
This is done via a new node called
OpenXRFbSpatialAnchorManager
which works a lot like theOpenXRFbSceneManager
which was added in PR #107Here's how it works:
create_anchor(transform: Transform3D, custom_data: Dictionary)
on the node. It won't be created immediately - it's an asynchronous operation. But when it is, theopenxr_fb_spatial_anchor_tracked
signal will be emitted, which will give the developer anXRAnchor3D
and theOpenXRFbSpatialEntity
object (with thecustom_data
stashed in it). Thecustom_data
can be used to store application-specific data about what the anchor actually is, ie what object the player is actually placing in the world (on the OpenXR side it only has a UUID and a location).XRAnchor3D
. So, rather than connecting to theopenxr_fb_spatial_anchor_tracked
signal and instantiating the scene manually, the developer can optionally set thescene
property, which will be automatically instantiated, and have a method called on it with theOpenXRFbSpatialEntity
. (This is very similar to howOpenXRFbSceneManager
works!) Here they can grab thecustom_data
and use it to initialize the scene - the demo uses this to setup the anchor with the correct color.By using thepersist_in_local_file
andlocal_file_path
, theOpenXRFbSpatialAnchorManager
node will save the anchors to a JSON file (along with theircustom_data
), and then automatically load them from the file when the application starts up again. While it's possible to query OpenXR for all pre-existing anchors, all you get is the UUIDs and positions, you don't get any information about what the anchor is meant to be in the application. That's why we need to also store these in a JSON file along with thecustom_data
, which is where the developer would put that information.openxr_fb_spatial_anchor_tracked
signal is also emitted for anchors that are loaded (not just created), which allows the developer to handle new and existing anchors at the same time.If the developer doesn't want any of the automatic file saving/loading or other automatic features, they can disable those via properties on the node, which gives them the freedom to do something more custom if they want.UPDATE: The saving/loading from file functionality was removed from the node, and moved into the demo project. Developers will need to implement their own loading/saving, but once they hand the data off to the node, it should take care of everything else.
Here's the properties in the editor: