当前位置: 首页>>代码示例>>C#>>正文


C# Plane.RayHitPlane方法代码示例

本文整理汇总了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);
        }
开发者ID:jeske,项目名称:agg-sharp,代码行数:26,代码来源:TraceAPITests.cs

示例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;
		}
开发者ID:broettge,项目名称:MatterControl,代码行数:33,代码来源:PlatingHelper.cs


注:本文中的Plane.RayHitPlane方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。