Hello everyone.

We have decided to phase out the Mixed Reality Forums over the next few months in favor of other ways to connect with us.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

The plan between now and the beginning of May is to clean up old, unanswered questions that are no longer relevant. The forums will remain open and usable.

On May 1st we will be locking the forums to new posts and replies. They will remain available for another three months for the purposes of searching them, and then they will be closed altogether on August 1st.

So, where does that leave our awesome community to ask questions? Well, there are a few places we want to engage with you. For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality. If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers. And always feel free to hit us up on Twitter @MxdRealityDev.

How To enhance Spatial Mapping Quality

Hi,

im new to hololens but i made a small app in which i would like to place some controls and elements to a real Object, lets say a telephone. The best thing would be to recognize the phone and attach my stage to the Object. right now im doing that manually but my holograms are not as fixed as i would like. Somehow Holograms in projects like Fragments or RoboGame seem to be glued to walls, they dont move but when i start my app it just dowsnt feel like that. how can i enhance that quality? Prescan? Or would it be a better Idea to skip enhancing and go to recognizing objects and attach everything to it?

Answers

  • Making sure your "space" is well scanned helps - and that HoloLens associates itself with the correct space. If you travel around a lot with the same HoloLens and carry a mobile hotspot with you that you connect to, the device can get "confused" at times that it is not finding the correct "space" right away. It typically self-corrects over time.
    You could take more ownership of the state of the spatial mapping in your program code and be more explicit about it, and do a pre-scan indeed.
    But what are the exact symptoms you are seeing?

  • Are you placing the objects using world anchors?

  • Hi, thank you for your fast response and sorry for my late answer, too many projects, not enought time. im not using world ancors. i used the code from the tutorials, which was enough right now.

        using UnityEngine;
    
        public class TapToPlaceParent : MonoBehaviour
        {
            bool placing = false;
    
            // Called by GazeGestureManager when the user performs a Select gesture
            void OnSelect()
            {
                // On each Select gesture, toggle whether the user is in placing mode.
                placing = !placing;
    
                // If the user is in placing mode, display the spatial mapping mesh.
                if (placing)
                {
                    SpatialMapping.Instance.DrawVisualMeshes = true;
                }
                // If the user is not in placing mode, hide the spatial mapping mesh.
                else
                {
                    SpatialMapping.Instance.DrawVisualMeshes = false;
                }
            }
    
            // Update is called once per frame
            void Update()
            {
                // If the user is in placing mode,
                // update the placement to match the user's gaze.
    
                if (placing)
                {
                    // Do a raycast into the world that will only hit the Spatial Mapping mesh.
                    var headPosition = Camera.main.transform.position;
                    var gazeDirection = Camera.main.transform.forward;
    
                    RaycastHit hitInfo;
                    if (Physics.Raycast(headPosition, gazeDirection, out hitInfo,
                        30.0f, SpatialMapping.PhysicsRaycastMask))
                    {
                        // Move this object's parent object to
                        // where the raycast hit the Spatial Mapping mesh.
                        this.transform.parent.position = hitInfo.point;
    
                        // Rotate this object's parent object to face the user.
                        Quaternion toQuat = Camera.main.transform.localRotation;
                        toQuat.x = 0;
                        toQuat.z = 0;
                        this.transform.parent.rotation = toQuat;
                    }
                }
            }
        }
    
Sign In or Register to comment.