I try to project a 3D vector (a direction, not a position) in screen space, but it does not return satisfying results:
FVector LineDirectionOnScreen =
EdMode->ViewMatrices.GetViewProjMatrix().TransformVector(LineDirection);
FVector2D LineDirectionOnScreen2D(
LineDirectionOnScreen.X * 0.5f * (float)EdMode->ViewRect.Width(),
LineDirectionOnScreen.Y * 0.5f * (float)EdMode->ViewRect.Height());
When LineDirection
is (0,0,1) it always returns a something like (0,Y) (Y can be anything), no matter how the camera is rotated.
What is wrong with my code?