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.

Pixel to Application-specified Coordante System for Unity

Hi There,
I found an example at https://docs.microsoft.com/en-us/windows/mixed-reality/locatable-camera where you convert 2D Pixel coordinates into 3D positions. How would you do this in unity (see code below)? Thank you very much in advance?

float2 ImagePosZeroToOne = float2( PixelPos.x / ImageWidth, 1.0 - (PixelPos.y / ImageHeight ) );
float2 ImagePosProjected = ( ( ImagePosZeroToOne * 2.0 ) - float2(1,1) ); // -1 to 1 space
float3 CameraSpacePos = UnProjectVector( Projection, float3( ImagePosProjected, 1) );
float3 WorldSpaceRayPoint1 = mul( CameraToWorld, float4(0,0,0,1) ); // camera location in world space
float3 WorldSpaceRayPoint2 = mul( CameraToWorld, CameraSpacePos ); // ray point in world space

public static Vector3 UnProjectVector(Matrix4x4 proj, Vector3 to)
{
Vector3 from = new Vector3(0, 0, 0);
var axsX = proj.GetRow(0);
var axsY = proj.GetRow(1);
var axsZ = proj.GetRow(2);
from.z = to.z / axsZ.z;
from.y = (to.y - (from.z * axsY.z)) / axsY.y;
from.x = (to.x - (from.z * axsX.z)) / axsX.x;
return from;
}

Sign In or Register to comment.