Hello everyone.

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.
Options

Distances between Camera and visual vertexes of the Spatial Mesh

Hi guys,

I guys, I need the distance for every vertex of the spatial mesh in field of view, between the vertex and the main camera. Any ideas?

Answers

  • Options
    AmerAmerAmerAmer ✭✭✭
    edited January 2017

    if you are using unity, then you should be able to do a Raycast from camera to the spatial mesh. It will have distance as a property. The cursor from the holotoolkit does this already when placing the cursor on the spatial mesh using its normal as a direction.

    Physics.Raycast(Camera.main.transform.position + camera.main.transform.forward, SpatialMesh.transform.position, , <"Whatever layer the mesh sits on">)
    the raycasthit object will have the actual vector and the distance of that vector (thus the distance you need).

    If you are developing in c++, you can do that in the shader and do distance computation once the vertex has the world_matrix applied to it. But you have to pass your camera position and forward vector to the input layout. Otherwise you have to parse out the buffer and do some basic vector math from your camera position to the vertex in world space. But to identify which vertex we're talking about, you'll have to calculate your own Raycast and use the resulting vector to get its length. Its a lot easier done in shader. I'm assuming you're doing like a heat map or setting a vertex color based on distance? Its pretty expensive trying to raycast specific vertex, consider a collider of sorts?

    http://www.redsprocketstudio.com/
    Developer | Check out my new project blog

  • Options

    Thanks for your answer. The problem is, as you mention, raycasts are far to expensive even if they would accomplish the task quite good. I also tried spherecast, but since I only have one collider for a big part of the spatial mesh I only get one result.

    The Heatmap is exactly what I want to achieve. Since I have no experience with shaders, how would I do the world matrix application and distance computation?

Sign In or Register to comment.