コード例 #1
0
ファイル: AlignedBox.cs プロジェクト: forestrf/Henge3D
        /// <summary>
        /// Transforms a bounding box into world-space or local-space using the specified transform. The box may grow
        /// significantly depending on the size and new/old basis axes.
        /// </summary>
        /// <param name="box">The bounding box to transform.</param>
        /// <param name="transform">The transformation to apply.</param>
        /// <param name="output">Returns the transformed bounding box.</param>
        public static void Transform(ref AlignedBox box, ref Transform transform, out AlignedBox output)
        {
            Vector3 dim = box.Maximum - box.Minimum;
            Vector3 p1, p2, p3, p4, p5, p6, p7, p8;

            p1    = p2 = p3 = p4 = p5 = p6 = p7 = p8 = box.Minimum;
            p2.X += dim.X;
            p3.X += dim.X; p3.Y += dim.Y;
            p4.Y += dim.Y;
            p5.Z += dim.Z;
            p6.X += dim.X; p6.Z += dim.Z;
            p7.X += dim.X; p7.Y += dim.Y; p7.Z += dim.Z;
            p8.Y += dim.Y; p8.Z += dim.Z;
            Vector3.Transform(ref p1, ref transform.Combined, out p1);
            Vector3.Transform(ref p2, ref transform.Combined, out p2);
            Vector3.Transform(ref p3, ref transform.Combined, out p3);
            Vector3.Transform(ref p4, ref transform.Combined, out p4);
            Vector3.Transform(ref p5, ref transform.Combined, out p5);
            Vector3.Transform(ref p6, ref transform.Combined, out p6);
            Vector3.Transform(ref p7, ref transform.Combined, out p7);
            Vector3.Transform(ref p8, ref transform.Combined, out p8);
            output = AlignedBox.Null;
            output.Add(ref p1);
            output.Add(ref p2);
            output.Add(ref p3);
            output.Add(ref p4);
            output.Add(ref p5);
            output.Add(ref p6);
            output.Add(ref p7);
            output.Add(ref p8);
        }
コード例 #2
0
ファイル: MeshPart.cs プロジェクト: jdddog/jengasimulatorp4p
		/// <summary>
		/// Apply a transform to the collision skin part to bring it into world space.
		/// </summary>
		/// <param name="transform">The world-space transform to apply.</param>
		public override void ApplyTransform(ref Transform transform)
		{
			Transform = transform;
			transform.Invert(out TransformInverse);

			if (transform.Combined != Matrix.Identity)
			{
				_boundingBox = AlignedBox.Null;
				for (int i = 0; i < _body.Body.Length; i++)
				{
					Vector3 p;
					Vector3.Transform(ref _body.Body[i], ref transform.Combined, out p);
					_boundingBox.Add(ref p);
				}
			}
			else
				_boundingBox = _body.Nodes[0].BoundingBox;
		}
コード例 #3
0
        /// <summary>
        /// Apply a transform to the collision skin part to bring it into world space.
        /// </summary>
        /// <param name="transform">The world-space transform to apply.</param>
        public override void ApplyTransform(ref Transform transform)
        {
            Transform = transform;
            transform.Invert(out TransformInverse);

            if (transform.Combined != Matrix.Identity)
            {
                _boundingBox = AlignedBox.Null;
                for (int i = 0; i < _body.Body.Length; i++)
                {
                    Vector3 p;
                    Vector3.Transform(ref _body.Body[i], ref transform.Combined, out p);
                    _boundingBox.Add(ref p);
                }
            }
            else
            {
                _boundingBox = _body.Nodes[0].BoundingBox;
            }
        }
コード例 #4
0
		/// <summary>
		/// Transforms a bounding box into world-space or local-space using the specified transform. The box may grow
		/// significantly depending on the size and new/old basis axes.
		/// </summary>
		/// <param name="box">The bounding box to transform.</param>
		/// <param name="transform">The transformation to apply.</param>
		/// <param name="output">Returns the transformed bounding box.</param>
		public static void Transform(ref AlignedBox box, ref Transform transform, out AlignedBox output)
		{
			Vector3 dim = box.Maximum - box.Minimum;
			Vector3 p1, p2, p3, p4, p5, p6, p7, p8;
			p1 = p2 = p3 = p4 = p5 = p6 = p7 = p8 = box.Minimum;
			p2.X += dim.X;
			p3.X += dim.X; p3.Y += dim.Y;
			p4.Y += dim.Y;
			p5.Z += dim.Z;
			p6.X += dim.X; p6.Z += dim.Z;
			p7.X += dim.X; p7.Y += dim.Y; p7.Z += dim.Z;
			p8.Y += dim.Y; p8.Z += dim.Z;
			Vector3.Transform(ref p1, ref transform.Combined, out p1);
			Vector3.Transform(ref p2, ref transform.Combined, out p2);
			Vector3.Transform(ref p3, ref transform.Combined, out p3);
			Vector3.Transform(ref p4, ref transform.Combined, out p4);
			Vector3.Transform(ref p5, ref transform.Combined, out p5);
			Vector3.Transform(ref p6, ref transform.Combined, out p6);
			Vector3.Transform(ref p7, ref transform.Combined, out p7);
			Vector3.Transform(ref p8, ref transform.Combined, out p8);
			output = AlignedBox.Null;
			output.Add(ref p1);
			output.Add(ref p2);
			output.Add(ref p3);
			output.Add(ref p4);
			output.Add(ref p5);
			output.Add(ref p6);
			output.Add(ref p7);
			output.Add(ref p8);
		}
コード例 #5
0
		/// <summary>
		/// Constructs a new bounding box that encapsulates a series of points.
		/// </summary>
		/// <param name="p1">The first point.</param>
		/// <param name="p2">The second point.</param>
		/// <param name="p3">The third point.</param>
		/// <param name="aabb">Returns the bounding box containing all points.</param>
		public static void Fit(ref Vector3 p1, ref Vector3 p2, ref Vector3 p3, out AlignedBox aabb)
		{
			aabb = new AlignedBox(p1, p1);
			aabb.Add(ref p2);
			aabb.Add(ref p3);
		}
コード例 #6
0
ファイル: AlignedBox.cs プロジェクト: forestrf/Henge3D
 /// <summary>
 /// Constructs a new bounding box that encapsulates a series of points.
 /// </summary>
 /// <param name="p1">The first point.</param>
 /// <param name="p2">The second point.</param>
 /// <param name="p3">The third point.</param>
 /// <param name="aabb">Returns the bounding box containing all points.</param>
 public static void Fit(ref Vector3 p1, ref Vector3 p2, ref Vector3 p3, out AlignedBox aabb)
 {
     aabb = new AlignedBox(p1, p1);
     aabb.Add(ref p2);
     aabb.Add(ref p3);
 }