Ejemplo n.º 1
0
        /// <summary>
        ///		Allows for merging two boxes together (combining).
        /// </summary>
        /// <param name="box">Source box.</param>
        public void Merge(AxisAlignedBox box)
        {
            if (box.IsNull)
            {
                // nothing to merge with in this case, just return
                return;
            }
            else if (box.IsInfinite)
            {
                this.IsInfinite = true;
            }
            else if (this.IsNull)
            {
                SetExtents(box.Minimum, box.Maximum);
            }
            else if (!this.IsInfinite)
            {
                minVector.Floor(box.Minimum);
                maxVector.Ceil(box.Maximum);

                UpdateCorners();
            }
        }
Ejemplo n.º 2
0
 public AxisAlignedBox(AxisAlignedBox box)
 {
     SetExtents(box.Minimum, box.Maximum);
     isNull     = box.IsNull;
     isInfinite = box.IsInfinite;
 }
Ejemplo n.º 3
0
        /// <summary>
        ///		Calculate the area of intersection of this box and another
        /// </summary>
        public AxisAlignedBox Intersection(AxisAlignedBox b2)
        {
            if (!Intersects(b2))
            {
                return(new AxisAlignedBox());
            }

            Vector3 intMin = Vector3.Zero;
            Vector3 intMax = Vector3.Zero;

            Vector3 b2max = b2.maxVector;
            Vector3 b2min = b2.minVector;

            if (b2max.x > maxVector.x && maxVector.x > b2min.x)
            {
                intMax.x = maxVector.x;
            }
            else
            {
                intMax.x = b2max.x;
            }
            if (b2max.y > maxVector.y && maxVector.y > b2min.y)
            {
                intMax.y = maxVector.y;
            }
            else
            {
                intMax.y = b2max.y;
            }
            if (b2max.z > maxVector.z && maxVector.z > b2min.z)
            {
                intMax.z = maxVector.z;
            }
            else
            {
                intMax.z = b2max.z;
            }

            if (b2min.x < minVector.x && minVector.x < b2max.x)
            {
                intMin.x = minVector.x;
            }
            else
            {
                intMin.x = b2min.x;
            }
            if (b2min.y < minVector.y && minVector.y < b2max.y)
            {
                intMin.y = minVector.y;
            }
            else
            {
                intMin.y = b2min.y;
            }
            if (b2min.z < minVector.z && minVector.z < b2max.z)
            {
                intMin.z = minVector.z;
            }
            else
            {
                intMin.z = b2min.z;
            }

            return(new AxisAlignedBox(intMin, intMax));
        }