How to Match a reference point in 2 different AR scenes by position and rotation?
Here are some details about my project: I have 2 scenes: "new scan" and "load scan". In the "new scan" scene I instantiate a 3d cube and make all the other points relative to it. This is my reference point. Then I instantiate some more points and finally save all the data to the device (my phone). Next, in "load scan" I load the scene again and instantiate the cube in the exact same world position. For now, I managed to set the right position for each point but the axis is rotated because I start the scene from a different real-world location and different phone rotation. Based on the cubes which are instantiated in the same place, I need to match the rotation and the position of the scene so the points will appear in the same relative position as the first cube.
Note: one can assume that the cube will instantiate with the user standing in the same direction as the desired position. But Do NOT assume that the user starts the "load scan" scene in the same direction as the "new scan" scene (which effect the whole scene rotation).
Here is a visualization of the problem: Image of New Scan:
Image of Load Scan:
Thanks
CodePudding user response:
If you want to make sure that the cube will appear in the same position/rotation in every AR session you have several options:
- Use an Image marker
- Use ARWorldMap (iOS exclusive)
- Use a Cloud Tracking solution (google cloud anchors / Azure spatial anchors)
Of course you can also try to make the user place the cube correctly themselves, or redesign your app to work without these restrictions.
CodePudding user response:
If I'm understanding the question correctly, a simple solution would be to make the points children of the cube instead of instantiating them at the top level. That would automatically make them relative to the cube.