I have a unity scene that does spatial mapping on a space, then in a new scene the mesh is loaded. The ZED_Rig_Stereo is carried over into the new scene in order to make the call to zedManager.LoadMesh(). However, the mesh is almost never in the same place in the scene when it is loaded. It seems to be based off of the orientation of the physical camera. I would like to know how to have the mesh be located in the same place each time the new scene is loaded.
After doing some looking around I found that ZedManager.LoadMesh() makes a call to SpatialMapping.LoadMesh() which has this line holder.transform.rotation = Quaternion.identity;. I believe this means that the scan will inherit the rotation of its parent which is the ZED_Rig_Stereo. This makes sense why the scan is orientated in the scene differently each time a new scan is created. However, after removing this line the problem still persists. I am confused as to why. Are there any other places where the orientation of the mesh is set by the ZED cameras orientation?
I’m having trouble visualizing the problem, would you be able to send a video recording either here or to support@stereolabs.com? (referencing this post)
Are you trying to have the mesh in the same position relative to the camera (real world) or the unity scene when switching scenes?
If you’re trying to keep the mesh static relative to Unity, you could maybe save the transform of you zed_rig in scene A, and apply it to the one in scene B while also disabling the positional tracking in scene B. You should be able to call load mesh without the tracking enabled I think. (make sure area memory is off).
@JPlou No worries! Thank you for the response! I am trying to keep the mesh static relative to Unity. I have attached a sketch/diagram of what I am trying to accomplish as I can’t screen record. The arrows on the diagram just show the direction each object should be facing. The scan1/scan2 are when entering play mode and scanning the same location/environment. Let me know if anything is unclear. I will try out your suggestions and follow up with the results!
This has proven trickier than expected.
I’m looking into this, I hope to be able to share some results with you tomorrow, the way the mesh is spawned is a bit complicated even with access to the underlying code, since at its root, it’s not really a Unity structure.
I’ll get back to you (or the team will).
Can you try to remove the “-” on the x axis here and here and try again ?
I’m not sure why we put them at the first place. I’ll need to look into it a bit longer but It seems to solve the issue. On my side, the loaded mesh was flipped, that’s why it was rotating like that.