C#XNA鼠标的位置投射到3D平面鼠标、平面、位置、XNA

2023-09-08 10:38:15 作者:菇凉、你只需哭不允许输

我工作的一个3D XNA项目,我一直在思考这个问题像2周。 于是我就决定要问你。

I'm working on a 3D XNA project, and I've been thinking about this problem for like 2 weeks. So I just decided to ask you.

基本上我有一个平面上,我想突出鼠标的位置,以那架飞机,但如何? 我试了很多办法做到这一点,计算的角度... 但我要指出,该距离必须作用于X位置,也许一些数学需要的是什么我以前从来没有听说过。

Basically I have a flat plane and i want to project the mouse position to that plane, but how? I tried many ways to do it, calculated angles... But i figured out, that the distance must effect on the X position, maybe some math is needed what I've never heard before.

感谢您的时间。

推荐答案

在这里,您可以观看完整的源$ C ​​$ C样品做你想要什么......

Here you can watch a full source code sample doing what you want....

http://www.youtube.com/watch?v=axHp1f3RlHM

据计算在康拉德做......但光线交叉与一个平面物体做...没有优化,更容易理解如何做同样的方式曙光。

It calculates a ray in the same way that konrad do... but the ray intersection is done with a plane object... without optimizations and easier to understand how is done.