Intersect point from Ray

Hi, guys! Help me to understand work with Rays, pls. I’m need to get intersection point at procedural plane from my ray (from mouse position for example). How to get vector3 information of it?

I do so:

Vector3 nearScreenPoint = new Vector3(input.mouseState.X, input.mouseState.Y, 0);
Vector3 farScreenPoint = new Vector3(input.mouseState.X, input.mouseState.Y, 1);
Vector3 near3DWorldPoint = device.Viewport.Unproject(nearScreenPoint, Projection, View, Matrix.Identity);
Vector3 far3DWorldPoint = device.Viewport.Unproject(farScreenPoint, Projection, View, Matrix.Identity);
Vector3 pointerRayDirection = far3DWorldPoint - near3DWorldPoint;
Ray pointerRay = new Ray(near3DWorldPoint, pointerRayDirection);
float? res = pointerRay.Intersects(new Plane(0, -1, 0, offsetH));
if (res.HasValue)
    Vector3 Target = position + (res.Value * pointerRay.Direction);
1 Like

Thanks for reply! I think i just figured out this point :relieved: