Beispiel #1
0
        public void updateBoundingBox()
        {
            if (mChainElementList.Count < 2)
            {
                return;
            }

            float   width       = ((myBillBoardChainElement)mChainElementList[0]).width;
            Vector3 widthVector = new Vector3(width, width, width);
            Vector3 position    = ((myBillBoardChainElement)mChainElementList[0]).position;
            Vector3 minimum     = position - widthVector;
            Vector3 maximum     = position + widthVector;

            for (int i = 1; i < mChainElementList.Count; i++)
            {
                // Update the bounds of the bounding box
                width       = ((myBillBoardChainElement)mChainElementList[i]).width;
                widthVector = new Vector3(width, width, width);
                position    = ((myBillBoardChainElement)mChainElementList[i]).position;
                minimum.Floor((position - widthVector));
                maximum.Ceil((position + widthVector));
            }

            // Set the current bounding box
            //this.setBoundingBox( new AxisAlignedBox( minimum, maximum ) );
            AxisAlignedBox box = this.CallBase_getBoundingBox();

            box.SetMinimum(minimum.x, minimum.y, minimum.z);
            box.SetMaximum(maximum.x, maximum.y, maximum.z);

            // Set the current radius
            mRadius = (float)Math.Sqrt(Math.Max((double)minimum.LengthSquared, (double)maximum.LengthSquared));
        }
Beispiel #2
0
        /// Builds an AABB from a list of points
        public static AxisAlignedBox AABBfromPoints(List <Vector3> points)
        {
            AxisAlignedBox aabb = new AxisAlignedBox();

            if (points.Count == 0)
            {
                return(aabb);
            }
            aabb.SetMinimum(points[0]);
            aabb.SetMaximum(points[0]);
            //for (List< Vector3>.Enumerator it = points.GetEnumerator(); it.MoveNext(); ++it.)
            foreach (var it in points)
            {
                aabb.SetMinimum(min(aabb.Minimum, it));
                aabb.SetMaximum(max(aabb.Maximum, it));
            }

            return(aabb);
        }
Beispiel #3
0
        /// Builds an AABB from a list of points
        public static AxisAlignedBox AABBfromPoints(List<Vector3> points) {
            AxisAlignedBox aabb = new AxisAlignedBox();
            if (points.Count == 0)
                return aabb;
            aabb.SetMinimum(points[0]);
            aabb.SetMaximum(points[0]);
            //for (List< Vector3>.Enumerator it = points.GetEnumerator(); it.MoveNext(); ++it.)
            foreach (var it in points) {
                aabb.SetMinimum(min(aabb.Minimum, it));
                aabb.SetMaximum(max(aabb.Maximum, it));
            }

            return aabb;
        }