How to geometrically align a 3D model to real furniture?
For my video-see-through AR application I want a model to automatically be placed on the biggest found table surface. I achieved the first step: The model is correctly positioned at the table center. However, the orientationis not correct. I want the model to "lie down" on the table, means laying on the back, facing up, while the longest side of the model is orientated just as the longest side of the table - see the following pictures: After a very long time trying, I could not figure out how to align the model correctly. If you have any idea/hint/ or clue I could try, please let me know. Used Asset for testing: Low Poly Human I added an Empty (called ModelPlacer) where I added the script (see below) and pulled this asset in the modelInstance field. Used Meta XR Building Blocks: Camera Rig Passthrough MR Utility Kit Scene Debugger Effect Mesh Hand Tracking Controller Tracking Technical Specifications: Unity 2022.3.50f1 VR-Glasses: Meta Quest 3 Meta MR Utility Kit Code: using Meta.XR.MRUtilityKit; using System.Collections; using System.Collections.Generic; using UnityEngine; public class ModelPlacer : MonoBehaviour { public GameObject modelPrefab; private GameObject modelInstance; void Start() { MRUK.Instance?.RegisterSceneLoadedCallback(OnSceneLoaded); } private void OnSceneLoaded() { SpawnModel(); AlignModelWithSurface(); } public void SpawnModel() { Vector3 spawnPosition = new Vector3(0.0f, 1.0f, -1.0f); modelInstance = Instantiate(modelPrefab, spawnPosition, Quaternion.identity); } public void AlignModelWithSurface() { var largestSurface = MRUK.Instance?.GetCurrentRoom()?.FindLargestSurface(MRUKAnchor.SceneLabels.TABLE); if (modelInstance != null) { if (largestSurface != null) { modelInstance.transform.SetParent(largestSurface.transform); Renderer modelRenderer = modelInstance.GetComponent<Renderer>(); modelInstance.transform.rotation = Quaternion.Euler(-90, 0, 0); Vector3 modelCenter = modelRenderer.bounds.center; Vector3 surfaceCenter = largestSurface.transform.position; Vector3 positionOffset = surfaceCenter - modelCenter; Vector3 adjustedPosition = modelInstance.transform.position + positionOffset; modelInstance.transform.position = adjustedPosition; } else { Debug.LogWarning("No surface found."); } } else { Debug.LogWarning("modelInstance is null."); } } }891Views0likes3CommentsProblem saving spatial anchor
Hi everyone, I'm trying to save a spatial anchor, but the method "var result = await anchor.SaveAnchorAsync();" is causing this error: 2024/10/18 10:41:34.675 9468 9487 Error OVRPlugin [SaveSpaces] m_XR_META_spatial_entity_persistence extension is not supported. (arvr\projects\integrations\OVRPlugin\Src\Util\CompositorOpenXR.cpp:18491) Also, the SaveResult is FailureUnsupported. I really don't understand what the problem could be. Can someone help me?436Views0likes1CommentLoading unbound anchors returns [0 or anchors_count_till_last_session] (NOT null)
I saved the anchors' uuid in the playerprefs after creating them - it's getting created successfully. Then, I tried to load the anchors in the same session without quitting the app (my use case is to visually clear the anchors after saving and loading them on the user's command) - the resultant anchors-array from LoadingUnboundAnchors is NOT null but it contains only anchors from last session. Once I quit and reopen the app, the anchors are loading successfully. I want to load them before quitting the app as well (I mean in the same session). Any ideas on why this is not happening?? Or any suggestions on how to implement this? OVRSpatialAnchor.LoadUnboundAnchorsAsync(loadOptions).ContinueWith(anchors => { if(anchors == null) { Debug.Log("Anchor Sample: Load anchors failed with null result."); } Debug.Log($"Anchor Sample: anchors available {anchors.Length}"); //length is zero if loaded in the same session or it is equal to the number of anchors created till the last session });308Views0likes0CommentsIssue with Sharing Spatial Anchors in Meta XR SDK v. 66
Hello, I am encountering an issue with spatial anchors in my application using Meta XR SDK v. 66 on Quest 3. My application allows one user to create a spatial anchor and share it with other users in the session. However, the users who receive the shared spatial anchor are unable to share the same anchor using ShareAsync, despite successfully loading (LoadUnboundSharedAnchorsAsync) and saving (SaveAnchorsAsync) the anchor beforehand. Previously, with Meta XR SDK v. 60, I could do this without any issues by saving the anchor to the cloud before sharing using the now obsolete method: OVRSpatialAnchor.SaveOptions saveOptions; saveOptions.Storage = OVRSpace.StorageLocation.Cloud; _spatialAnchor.Save(saveOptions, (spatialAnchor, isSuccessful) => { ... }); Since updating to Meta XR SDK v. 66 and the latest Quest 3 software, and switching to the new async SSA methods, only the user who originally created the anchor can share it. For other users, the OVRSpatialAnchor.ShareAsync method fails with error code -1006. Here is a summary of the steps I am following: User A creates a spatial anchor and saves it using OVRSpatialAnchor.SaveAnchorsAsync. User A shares the anchor using OVRSpatialAnchor.ShareAsync. User B receives and successfully loads the shared anchor using OVRSpatialAnchor.LoadUnboundSharedAnchorsAsync. User B successfully saves the anchor using OVRSpatialAnchor.SaveAnchorsAsync. User B attempts to share the anchor but OVRSpatialAnchor.ShareAsync fails with error code -1006. I have verified that I am correctly adding the OVRSpaceUsers when sharing the anchors. The app has also been correctly configured on Oculus Developer Dashboard, and Share Point Cloud Data is enabled on all devices. Any guidance or solutions to resolve this issue would be greatly appreciated. Thank you!1.7KViews2likes3CommentsShare Spatial Anchor on custom app
I'm working on a VR experience that requires all the users be on the same physical room. I've managed to get working an OVRSpatialAnchor and save it locally for later sessions. I can calibrate the VR room to match the real life room using that anchor, save the anchor and load it for repositioning the content aligned to the real world. I'm using Photon as network solution and I can have all the users on the same room. Al works fine there. The problem is: I would like do the room calibration using only one headset and then share that anchor to other users in order to avoid calibrate the room again and again for the same session. Other users could get that anchor and automatic get the content aligned, ready to play. I've created the app on the Oculus developer dashboard, and I've requested permissions to handle user ID and User Profile on that app, it's approved. So, the next steps are confused to me, should I add every headset user to the users list on the app in order to share the anchor? If not, whats the next step? Also I can't figure the code for share , broadcast and Load that anchor on the other users headset. "The Big Picture" (https://developer.oculus.com/documentation/unity/unity-shared-spatial-anchors/?intern_source=devblog&intern_content=build-local-multiplayer-experiences-shared-spatial-anchors#the-big-picture) steps are barely specific about that.Please, any help will be very appreciated. Thanks.1.1KViews0likes0CommentsCannot create OVRSpaceUser for sharing Spatial Anchor
As per the Shared Spatial Anchors Sample (https://github.com/oculus-samples/Unity-SharedSpatialAnchors) I need to create a list of OVRSpaceUsers which to share the OVRSpatialAnchor with. But when I create an OVRSpaceUser using the Oculus ID from the logged in user, the OVRSpaceUser turns out invalid and the id defaults to 0. What am I doing wrong?580Views1like0CommentsSpatial Anchors bug: LoadUnboundAnchors returns null UUIDList
Hi, I am struggling trying to work with Spatial Anchors and what looks like a bug. I am creating a few gameobjects in the virtual room, adding Space Anchors to them, saving the room anchors to local storage and reloading them. I save the uuid list so I can reload the objects even if I close the app and run it again. It works fine but, in some "random" situations, the LoadUnboundAnchors returns a null UUIDList as if it were no Unbound anchors to be loaded. When this happens I can try and try to load them but always get the same result. But... if I create a new anchor in the session and save it, then I can reload all of them.🙄 Once they are loaded I can remove all objects and anchors and reload again and works fine. So, it looks that I cannot load correctly the saved anchors unless I have previously saved one in the same session. I know that they are correctly saved because after creating a new anchor in the empty room I reload them succesfully. Anyone else have this problem? I am using Quest 2, Unity 2022.3.11, Meta XR Core 59. The loading sequence is something like this: OVRSpatialAnchor.LoadOptions options = new OVRSpatialAnchor.LoadOptions { Timeout = 0, StorageLocation = OVRSpace.StorageLocation.Local, Uuids = GetSavedAnchorsUuids() }; OVRSpatialAnchor.LoadUnboundAnchors(options, _anchorSavedUUIDList => { if (_anchorSavedUUIDList == null) { //Debug.Log("Anchor list is null!"); return; } .... }1.3KViews0likes1CommentProblems with Spatial Anchors
Hello, I've been having some issues for quite a while with spatial anchors. I tried to dabble with them some months ago with little success and now I'm trying again. I've had very inconsistent result with the samples where sometimes they work and other times I can't even place the anchor. In my code all I want to do for now is call this function to place the anchor: public void PlaceLeftAnchor(Vector3 position, Quaternion rotation) { SpatialAnchor anchor = Instantiate(m_AnchorPrefab.GetComponent<SpatialAnchor>(), position, rotation); anchor.SaveAnchorLocally(); } and here is the SpatialAnchor code based on the oculus samples: using System.Collections; using UnityEngine; [RequireComponent(typeof(OVRSpatialAnchor))] public class SpatialAnchor : MonoBehaviour { [SerializeField] private OVRSpatialAnchor m_SpatialAnchor = null; public string Uuid { get => m_Uuid; } private string m_Uuid = ""; private IEnumerator Start() { while (m_SpatialAnchor && !m_SpatialAnchor.Created) { yield return null; } Debug.LogError($"Achor created. Enabled?: {m_SpatialAnchor.enabled}"); } public void SaveAnchorLocally() { Logger.Instance.LogError($"Saving anchor start. Status of anchor component: {m_SpatialAnchor == null} / {m_SpatialAnchor.enabled}"); m_SpatialAnchor.Save((anchor, success) => { // --> Never reaches this part <-- }); Logger.Instance.LogError($"End of Save Anchor"); } } I don't manage to receive a callback within the m_SpatialAnchor.Save function and that seems to be the case due to the spatial anchor self-destructing itself. I get this error: As a side note, I noticed that the anchors weren't working in the samples, until I added this line (<uses-permission android:name="com.oculus.permission.USE_ANCHOR_API" />) to the manifest. Now I was able to place and save the samples, but that wasn't enough to fix my own implementation. Perhaps I am missing more permissions? If would greatly appreciate anyone who could provide insights or their own working example of a spatial anchor implementation.2.2KViews0likes1CommentMixed reality only work in the first scene
When a mixed reality scene element OVRSceneAnchor is destroyed, it get ignored during the whole game session. Opening Mixed reality a second time in another Unity scene is impossible, or very laborious. This is because of recent changes in the Unity Integration SDK in OVRSceneAnchor.cs. Problem is reproducible on v48 & v49. Not on v43. I removed the line : DestroyedSceneAnchors.Add(this.Uuid); in OVRSceneAnchor.cs line 209 for a workaround. But maybe there is something I'm missing ?1.1KViews1like1Comment