Hello together,
I am working on an AR App for navigation inside a building. The goal is that the user selects the room or place they are looking for and the app shows a line leading to that location inside the building (public building with 3 floors). I know there are things like Vuforia Area Targets which would make this very easy, but that is no option due to expensive 3D scanners and licensing prices. Therefore my goal is to achieve this completely with ARFoundation and without third party tools.
First I want to explain my approach.
Based on floor plans I created a simple real size 3D model of the building with cubes and planes and I use NavMesh for the Navigation part in connection with a line renderer to display the route (starting point is the current camera and end point is an empty game object placed at the desired destination). This part is working fine. When testing in the editor without AR everything works as expected.
For positioning the (then invisible) 3D model at the right position in the real world building I am using the following approach:
Inside the real building I place several Image Targets. Each target is “connected” to a Gameobject inside the virtual building at the exact same position as in real life (with connected I mean that when a target is tracked I use the reference image name and look for that name inside a list of game objects I placed inside the building the get the correct position corresponding to the real life image target).
So whenever tracking is drifting too much (I don’t know a better term for this) or the tracking is lost completely users have an Image Target near them to relocate their position.
Since the building is a static object due to the NavMesh I am using ARSessionOrigin.MakeContentAppearAt method for positioning whenever an Image Target is tracked.
This is where my issues occur right now.
For example: when the image target with the reference image “position1” is tracked I get the transform.position of the object “position1” inside the 3d model. This is working fine. Lets say position1.transform.position is at (5, 0, 2). I use MakeContentAppearAt(buildingOrigin, -position1.transform.position, Quaternion.Euler(0, arCamera.transform.eulerAngles.y, 0)
First, I am using the negative Vector3 of position1 since the origin of my building is supposed to appear at (-5, 0, -2) if my thought is correct here.
Second, I use the ARCamera y-Rotation so that the buildings rotation is matching the cameras rotation and everything lines up perfectly (don’t know if this is correct or even necesarry).
But there seem to be some issues with that. The positioning and also the rotation appear way off. It almost seems random to me.
I certainly have some misconceptions there but I cannot see where. This is what I was able to achieve by my own by looking at the documentations and any help or solution to the problem would really be appreciated.
And if my whole approach is not working like that or there is a different, better approach I would also gladly use that. (Maybe persistent cloud anchors are a better solution. I once used them to place content under one anchor, but I don’t know how I could make use of them in a similar way to Vuforia Area Targets or something like that).
Thanks and greetings