Ray intersection with 3D quads in XNA?

后端 未结 3 1350
野趣味
野趣味 2021-01-20 09:19

So I have successfully made a ray the represents the mouse unprojected into the world, and now I need to check if that ray can intersect with a quad object, here is the code

3条回答
  •  梦谈多话
    2021-01-20 10:04

    Since you are using cubes, you can use the Ray.Intersects(Plane) method. You just need a few more planes.

    Once you determine the first intersection point, then you can construct more planes for each perpendicular face of your cube. Then you can use the Plane.Distance(Vector3) (I'm pretty sure this or something like it exists) to make sure your point is between each pair of perpendicular planes. If it is not between them, then you can ignore the intersection.

提交回复
热议问题