Beispiel #1
0
		/// <summary>
		/// Copy constructor.
		/// </summary>
		/// <param name="from">Another HitTestData object to copy from.</param>
		public HitTestPointData(HitTestPointData from)
		{
			this._hitTransformation = from._hitTransformation;
			this._worldTransformation = from._worldTransformation;
		}
Beispiel #2
0
		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="transformation">The original hit ray matrix. Usually obtained using the mouse coordinates and the camera settings.</param>
		public HitTestPointData(Matrix4x4 transformation)
		{
			_hitTransformation = transformation;
			_worldTransformation = Matrix4x3.Identity;
		}
Beispiel #3
0
		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="hitTransformation">The original hit ray matrix. Usually obtained using the mouse coordinates and the camera settings.</param>
		/// <param name="worldTransformation">The original world transformation.</param>
		private HitTestPointData(Matrix4x4 hitTransformation, Matrix4x3 worldTransformation)
		{
			_hitTransformation = hitTransformation;
			_worldTransformation = worldTransformation;
		}
Beispiel #4
0
		/// <summary>
		/// Determines whether the specified 3D-rectangle r is hit by a ray given by the provided transformation matrix that would transform
		/// the hit ray in a ray at x=0, y=0, and z=-Infinity .. +Infinity.
		/// </summary>
		/// <param name="r">The rectangle r.</param>
		/// <param name="rayTransformation">The hit ray transformation.</param>
		/// <param name="z">If there was a hit, this is the z coordinate of the hit (otherwise, NaN is returned).</param>
		/// <returns>True if the rectangle is hit by a ray given by the provided hit ray matrix.</returns>
		public static bool IsRectangleHitByRay(RectangleD3D r, Matrix4x4 rayTransformation, out double z)
		{
			PointD3D[] vertices = new PointD3D[8];

			int i = 0;
			foreach (var v in r.Vertices)
				vertices[i++] = rayTransformation.Transform(v);

			foreach (var ti in r.TriangleIndices)
			{
				if (HitTestWithAlreadyTransformedPoints(vertices[ti.Item1], vertices[ti.Item2], vertices[ti.Item3], out z) && z >= 0)
					return true;
			}

			z = double.NaN;
			return false;
		}