Beispiel #1
0
 public Vector3[] Corners()
 {
     if (corners.IsNotNull())
     {
         return(corners);
     }
     corners = new[] {
         boxf.Corner(0).ToVector3(),
         boxf.Corner(1).ToVector3(),
         boxf.Corner(2).ToVector3(),
         boxf.Corner(3).ToVector3(),
         boxf.Corner(4).ToVector3(),
         boxf.Corner(5).ToVector3(),
         boxf.Corner(6).ToVector3(),
         boxf.Corner(7).ToVector3()
     };
     return(corners);
 }
Beispiel #2
0
        /// <summary>
        /// Compute AABB of scene in given space. Note that this will *not* be the same box
        /// in world space as in scene space.
        /// This computation ignores SOs with zero volume.
        /// </summary>
        public AxisAlignedBox3f GetBoundingBox(CoordSpace eSpace, bool bIncludeBoundsObjects)
        {
            if (eSpace == CoordSpace.ObjectCoords)
            {
                eSpace = CoordSpace.SceneCoords;
            }

            AxisAlignedBox3f b = AxisAlignedBox3f.Empty;

            foreach (SceneObject so in SceneObjects)
            {
                Box3f sobox = so.GetBoundingBox(eSpace);
                if (sobox.Volume > 0)
                {
                    foreach (Vector3d v in sobox.VerticesItr())
                    {
                        b.Contain(v);
                    }
                }
            }
            if (bIncludeBoundsObjects)
            {
                AxisAlignedBox3f sceneBounds =
                    UnityUtil.GetGeometryBoundingBox(BoundsObjects, true);
                if (sceneBounds.Volume > 0)
                {
                    if (eSpace == CoordSpace.WorldCoords)
                    {
                        for (int k = 0; k < 8; ++k)
                        {
                            b.Contain(ToWorldP(sceneBounds.Corner(k)));
                        }
                    }
                    else
                    {
                        b.Contain(sceneBounds);
                    }
                }
            }
            if (b.Volume == 0)
            {
                b = new AxisAlignedBox3f(1.0f);
            }
            return(b);
        }