AcTools.Render.Base.Cameras.BaseCamera.GetPickingRay C# (CSharp) Method

GetPickingRay() public method

public GetPickingRay ( System.Vector2 sp, System.Vector2 screenDims ) : Ray
sp System.Vector2
screenDims System.Vector2
return Ray
        public Ray GetPickingRay(Vector2 sp, Vector2 screenDims) {
            // convert screen pixel to view space
            var vx = (2.0f * sp.X / screenDims.X - 1.0f) / Proj.M11;
            var vy = (-2.0f * sp.Y / screenDims.Y + 1.0f) / Proj.M22;

            var ray = new Ray(new Vector3(), new Vector3(vx, vy, 1.0f));
            ray = new Ray(Vector3.TransformCoordinate(ray.Position, ViewInvert), Vector3.TransformNormal(ray.Direction, ViewInvert));
            ray.Direction.Normalize();
            return ray;
        }