Why my annotation placed in the space by Hololens is Partial
Overview
Hi,all.I have got the cameraToWorldMatrix,pixelToCameraMatrix and cameraViewTransform successfully.But the location of the annotations is partial,is my code wrong?how can I change the code?
Expected Behavior
The annotation should be placed in the right place in space
Actual Behavior
The location of the annotations is partial
Steps to reproduce
And these are my code in unity:
Vector3 result;
result = UnProjectVector(pointPos, pixelToCameraMatrix);//pointPos is the coordinate of the point drawed on the photo captured by Hololens on pc screen and be sent back to hololens
result = cameraViewTransform.inverse.MultiplyPoint3x4(result);
result = cameraToWorldMatrix.inverse.MultiplyPoint3x4(result);
result = ConvertRightLeft(result);
static Vector3 UnProjectVector(Vector3 from, Matrix4x4 cameraProjection)
{
var to = new Vector3(0, 0, 0);
var axsX = new Vector3(cameraProjection.m00, cameraProjection.m01, cameraProjection.m02);
var axsY = new Vector3(cameraProjection.m10, cameraProjection.m11, cameraProjection.m12);
var axsZ = new Vector3(cameraProjection.m20, cameraProjection.m21, cameraProjection.m22);
to.z = from.z / axsZ.z;
to.y = (from.y - (to.z * axsY.z)) / axsY.y;
to.x = (from.x - (to.z * axsX.z)) / axsX.x;
return to;
}
private Vector3 ConvertRightLeft(Vector3 from)
{
var to = new Vector3(0, 0, 0);
to.x = from.x;
to.y = from.y;
to.z = -from.z;
return to;
}
Unity Editor Version
Unity 2017.4.8f1
Hi @hanzz0502,
please provide more information on what you are trying to achieve? Without any more information the above code does not make any sense to me. I can only guess what you are doing.
How is this related to the HoloToolkit?
I have solved the problem.The reason why the annotation is partial is that the matrixs haven't been transport before they are used to thransform the coordinate.Thanks anyway.