本文整理汇总了C#中Plane.RayHitPlane方法的典型用法代码示例。如果您正苦于以下问题:C# Plane.RayHitPlane方法的具体用法?C# Plane.RayHitPlane怎么用?C# Plane.RayHitPlane使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plane
的用法示例。
在下文中一共展示了Plane.RayHitPlane方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PlaneGetDistanceToIntersection
internal void PlaneGetDistanceToIntersection()
{
Plane testPlane = new Plane(Vector3.UnitZ, 10);
bool hitFrontOfPlane;
double distanceToHit;
Ray lookingAtFrontOfPlane = new Ray(new Vector3(0, 0, 11), new Vector3(0, 0, -1));
Assert.IsTrue(testPlane.RayHitPlane(lookingAtFrontOfPlane, out distanceToHit, out hitFrontOfPlane));
Assert.IsTrue(distanceToHit == 1);
Assert.IsTrue(hitFrontOfPlane);
Ray notLookingAtFrontOfPlane = new Ray(new Vector3(0, 0, 11), new Vector3(0, 0, 1));
Assert.IsTrue(!testPlane.RayHitPlane(notLookingAtFrontOfPlane, out distanceToHit, out hitFrontOfPlane));
Assert.IsTrue(distanceToHit == double.PositiveInfinity);
Assert.IsTrue(!hitFrontOfPlane);
Ray lookingAtBackOfPlane = new Ray(new Vector3(0, 0, 9), new Vector3(0, 0, 1));
Assert.IsTrue(testPlane.RayHitPlane(lookingAtBackOfPlane, out distanceToHit, out hitFrontOfPlane));
Assert.IsTrue(distanceToHit == 1);
Assert.IsTrue(!hitFrontOfPlane);
Ray notLookingAtBackOfPlane = new Ray(new Vector3(0, 0, 9), new Vector3(0, 0, -1));
Assert.IsTrue(!testPlane.RayHitPlane(notLookingAtBackOfPlane, out distanceToHit, out hitFrontOfPlane));
Assert.IsTrue(distanceToHit == double.PositiveInfinity);
Assert.IsTrue(hitFrontOfPlane);
}
示例2: GetClosestIntersection
public IntersectInfo GetClosestIntersection(Ray ray)
{
// find the point on the plane
Vector3[] positions = new Vector3[3];
int index = 0;
foreach (FaceEdge faceEdge in face.FaceEdges())
{
positions[index++] = faceEdge.firstVertex.Position;
if(index==3)
{
break;
}
}
Plane plane = new Plane(positions[0], positions[1], positions[2]);
double distanceToHit;
bool hitFrontOfPlane;
if (plane.RayHitPlane(ray, out distanceToHit, out hitFrontOfPlane))
{
Vector3 polyPlaneIntersection = ray.origin + ray.directionNormal * distanceToHit;
if (face.PointInPoly(polyPlaneIntersection))
{
IntersectInfo info = new IntersectInfo();
info.closestHitObject = this;
info.distanceToHit = distanceToHit;
info.hitPosition = polyPlaneIntersection;
info.normalAtHit = face.normal;
info.hitType = IntersectionType.FrontFace;
return info;
}
}
return null;
}