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.
SpatialSurfaceInfo::TryGetBounds seems to return wrong bounds
Again, I'm not using Unity here, so please restrict answers to the actual Platform SDK.
I'm trying to get a world-space oriented bounding box of the spatial surfaces but the results are tilted on their side and in the wrong position.... and seemingly the wrong scale. At first I figured it was okay because these are oriented boxes, but ALL of them are tilted the same amount and I was expecting them to at least be flat w.r.t. the floor.
Edit: It gets even weirder, all the extent scale values are coming back identical regardless of the surface. Is this a bug in the SDK?
Code:
SpatialCoordinateSystem ^currentCoordinateSystem = referenceFrame->CoordinateSystem; //stationary, same as rest of app auto bounds = newSurface->TryGetBounds(currentCoordinateSystem); //........ if(auto updatedBounds = bounds) { float3 pos = float3(updatedBounds->Value.Center.x, updatedBounds->Value.Center.y, updatedBounds->Value.Center.z); float3 scale = float3(updatedBounds->Value.Extents.x, updatedBounds->Value.Extents.y, updatedBounds->Value.Extents.z); QUAT q = { updatedBounds->Value.Orientation.x, updatedBounds->Value.Orientation.y, updatedBounds->Value.Orientation.z, updatedBounds->Value.Orientation.w }; //my QUAT is in format X, Y, Z, W cube->second->setPos(pos); cube->second->setScale(scale); cube->second->setRotationQuat(q); }
Any idea what I could be doing wrong here?
Best Answer
-
OptionsAdam ✭
I can confirm now that the function works.
I tested it by adding bounding box rendering to the SpatialMeshRenderer demo.
I constructed a unit cube matrix centered at 0,0,0. The world matrix to properly render it is:
Platform::IBox<SpatialBoundingOrientedBox>^ bounds = m_surfaceMesh->SurfaceInfo->TryGetBounds( desiredCoordinateSystem ); if ( bounds == nullptr ) { // Some error result here } XMMATRIX rotation = XMMatrixTranspose(XMLoadFloat4x4(&make_float4x4_from_quaternion(bounds->Value.Orientation))); XMMATRIX scale = XMLoadFloat4x4(&make_float4x4_scale(2 * bounds->Value.Extents)); XMMATRIX translation = XMMatrixTranspose(XMLoadFloat4x4(&make_float4x4_translation(bounds->Value.Center))); XMMATRIX res = rotation * scale; res = translation * res;
5
Answers
Without this working, I'm going to be forced to compute the bounds manually myself in a concurrent task..
I must say, its extremely frustrating that this API isn't working. I'm losing hours of valuable dev time on manually trying to get a working bounding box with all the transforms. Where can I file a bug report for this??
Hello,
I'm currently working with TryGetBounds and it's not working the way I expect either.
What I'm wondering, is what the order of operations their expecting and what you (and I) are applying.
The documentation says that the bounds returned are in the requested coordinate system, does this mean that the box is at Center, with Extents rotated by Rotation? Or is the box at Center with Extents, rotated by Rotation? Currently, our code assumes the former.
I will continue experimenting, but I agree it is incredibly frustrating to be plodding along in the dark.
@Patrick Any possible feedback for this code?
I can confirm now that the function works.
I tested it by adding bounding box rendering to the SpatialMeshRenderer demo.
I constructed a unit cube matrix centered at 0,0,0. The world matrix to properly render it is: