2

基本的に、大砲からのレーザービームが地形に当たるかどうかを確認したいと思います。Ray の概念を理解していないか、何かが間違っています。このコード行を見てみましょう

Intersector.intersectRayTriangle(intersectorRay, new Vector3(0.5f,1,0), new Vector3(0.5f,-1,0), new Vector3(1,0,0), hitPoint);

intersectorRay は原点 0,0,0 と方向 1,0,0 を持っているので、ポイント 0,0 から「まっすぐ右」を指していると仮定します。三角形の頂点の座標を考えると、三角形と交差するはずですよね? コードは false を返します。

一方、この行は true を返します。

Intersector.intersectRayTriangle(intersectorRay, new Vector3(0.5f,1,0), new Vector3(0.5f,-1,0), new Vector3(-1,0,0), hitPoint);

他の例でのテストでは、Ray の原点が三角形の内側にある場合にのみ true を返すことが証明されました (この場合、何かにヒットすることは明らかです...)。

私は何を間違っていますか?9 月 6 日以降、libgdx の最新のナイトリー バージョンを使用しています。

4

1 に答える 1

1

I am going to go out on a limb here and say that the reason it returns false in your first example is because the ray does not pass through the face of the triangle, due to it being on the same xy plane that the ray is shooting across.

If, instead, your triangle were on a zy plane (or any other plane that was not exactly the plane the ray was shooting across) I suspect you would get the result you expect.

于 2012-09-16T21:42:43.223 に答える