The Mixed Reality Forums here are no longer being used or maintained.
There are a few other places we would like to direct you to for support, both from Microsoft and from the community.
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.
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, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.
And always feel free to hit us up on Twitter @MxdRealityDev.
Tap to place (but not on a mesh)
Hi,
I want to be able to move a hologram similar to the Holograms App on the Hololens. For example, when you select a hologram, you can place it anywhere in your room, it does not have to touch a mesh. This way, I can have a hologram float in the air.
I've been able to use the TapToPlace script to select my hologram and use gaze to move the hologram to where it hits a mesh. This makes sense to me. However, to have a hologram float in the air means my gaze will not be intersecting a point for placement.
Any suggestions on how to get started?
Best Answers
-
OptionsDavidKlineMS mod
@bulgogi,
Essentially, you want to be doing the same thing thing that TapToPlace does, except that you stop moving the hologram with your gaze without checking for a surface mesh intersection.If you set the GazeManager's MaxDistance property a distance closer than the 15m default, you can simply use it's Position property to place your hologram.
If want to also see surfaces further than a given distance (ex: 3m) you can grab the following line of code and use it in your script.
Vector3 position = Camera.main.transform.position + (Camera.main.transform.forward * distance);
Thanks!
David7 -
OptionsDavidKlineMS mod
@bulgogi,
Take a look at Placeable.cs in the Holograms 230 course. It handles keeping an object parallel to the wall.The method to look at is called OrientObject.
private void OrientObject(bool alignToVerticalSurface, Vector3 surfaceNormal) { Quaternion rotation = Camera.main.transform.localRotation; // If the user's gaze does not intersect with the Spatial Mapping mesh, // orient the object towards the user. if (alignToVerticalSurface && (PlacementSurface == PlacementSurfaces.Vertical)) { // We are placing on a vertical surface. // If the normal of the Spatial Mapping mesh indicates that the // surface is vertical, orient parallel to the surface. if (Mathf.Abs(surfaceNormal.y) <= (1 - upNormalThreshold)) { rotation = Quaternion.LookRotation(-surfaceNormal, Vector3.up); } } else { rotation.x = 0f; rotation.z = 0f; } gameObject.transform.rotation = rotation; }
Thanks!
David5 -
OptionsPatrick mod
Hey Bulgogi,
One thing to try is rather than boundsAsset.tranform.parent, try boundsAsset.transform.SetParent(gameobject.transform, false);the false will tell unity not to attempt to preserve the scale and position of the object while reparenting. Otherwise, if your parent as a really small scale the boundsAsset local scale will become really huge to compensate.
===
This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.(Daddy, what does 'now formatting drive C:' mean?)
6
Answers
@bulgogi,
Essentially, you want to be doing the same thing thing that TapToPlace does, except that you stop moving the hologram with your gaze without checking for a surface mesh intersection.
If you set the GazeManager's MaxDistance property a distance closer than the 15m default, you can simply use it's Position property to place your hologram.
If want to also see surfaces further than a given distance (ex: 3m) you can grab the following line of code and use it in your script.
Vector3 position = Camera.main.transform.position + (Camera.main.transform.forward * distance);
Thanks!
David
David,
Thank you for the quick reply. That makes a lot of sense actually. I'll give it a try and report my findings later. Many thanks!
@bulgogi,
You are very welcome.
Thanks!
David
It worked nicely. Now my app will float 2 meters away from the camera if it doesn't hit a mesh. If it hits a mesh, it will sit on the mesh facing the camera. How do I make the hologram hug the surface of the wall (parallel to the wall)?
Currently, depending on where I'm standing, the hologram sticks out of the wall at an angle because it's trying to face the camera. Thanks!
@bulgogi,
Take a look at Placeable.cs in the Holograms 230 course. It handles keeping an object parallel to the wall.
The method to look at is called OrientObject.
Thanks!
David
Thank you David, this worked.
However, the cube that is being created in Placeable to indicate the bounds of my Game Object is way too big causing it not to be placed on walls that should have enough space. I traced it to the following code in Awake():
I wanted to add the following to determine the size of the cube:
but it didn't work.
Thoughts?
Hey Bulgogi,
One thing to try is rather than boundsAsset.tranform.parent, try boundsAsset.transform.SetParent(gameobject.transform, false);
the false will tell unity not to attempt to preserve the scale and position of the object while reparenting. Otherwise, if your parent as a really small scale the boundsAsset local scale will become really huge to compensate.
===
This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.
(Daddy, what does 'now formatting drive C:' mean?)
Thank you David and Patrick!