Esempio n. 1
0
        public UWB_BoundingBox GetBounds(ref UWB_DrawHelper helper, bool bDraw)
        {
            UWB_BoundingBox box = new UWB_BoundingBox();

            box.makeInvalid();
            if (mPrimitive != null)
            {
                box.add(mPrimitive.getBoundingVolume(eLevelofDetail.lodLow));
            }

            helper.pushModelTransform();
            {
                mXFormInfo.setupModelStack(helper);
                //Draw the box for debugging
                if (bDraw)
                {
                    box.Draw(ref helper);
                }
                Vector3 minPt = box.getMin();
                Vector3 maxPt = box.getMax();
                Vector3 pt1   = new Vector3(minPt.X, minPt.Y, minPt.Z);
                Vector3 pt2   = new Vector3(maxPt.X, minPt.Y, minPt.Z);
                Vector3 pt3   = new Vector3(maxPt.X, maxPt.Y, minPt.Z);
                Vector3 pt4   = new Vector3(minPt.X, maxPt.Y, minPt.Z);
                Vector3 pt5   = new Vector3(minPt.X, minPt.Y, maxPt.Z);
                Vector3 pt6   = new Vector3(maxPt.X, minPt.Y, maxPt.Z);
                Vector3 pt7   = new Vector3(maxPt.X, maxPt.Y, maxPt.Z);
                Vector3 pt8   = new Vector3(minPt.X, maxPt.Y, maxPt.Z);
                helper.transformPoint(ref pt1);
                helper.transformPoint(ref pt2);
                helper.transformPoint(ref pt3);
                helper.transformPoint(ref pt4);
                helper.transformPoint(ref pt5);
                helper.transformPoint(ref pt6);
                helper.transformPoint(ref pt7);
                helper.transformPoint(ref pt8);

                box.makeInvalid();
                box.add(new UWB_BoundingBox(pt1, pt2));
                box.add(new UWB_BoundingBox(pt3, pt4));
                box.add(new UWB_BoundingBox(pt5, pt6));
                box.add(new UWB_BoundingBox(pt7, pt8));

                int count = mChildNodes.count();
                for (int i = 0; i < count; i++)
                {
                    box.add(mChildNodes.getItem(i).GetBounds(ref helper, bDraw));
                }
            }
            helper.popModelTransform();

            return(box);
        }
        public UWB_BoundingBox GetBounds(ref UWB_DrawHelper helper, bool bDraw)
        {
            UWB_BoundingBox box = new UWB_BoundingBox();
            box.makeInvalid();
            if (mPrimitive != null)
                box.add(mPrimitive.getBoundingVolume(eLevelofDetail.lodLow));

            helper.pushModelTransform();
            {
                mXFormInfo.setupModelStack(helper);
                //Draw the box for debugging
                if (bDraw)
                    box.Draw(ref helper);
                Vector3 minPt = box.getMin();
                Vector3 maxPt = box.getMax();
                Vector3 pt1 = new Vector3(minPt.X, minPt.Y, minPt.Z);
                Vector3 pt2 = new Vector3(maxPt.X, minPt.Y, minPt.Z);
                Vector3 pt3 = new Vector3(maxPt.X, maxPt.Y, minPt.Z);
                Vector3 pt4 = new Vector3(minPt.X, maxPt.Y, minPt.Z);
                Vector3 pt5 = new Vector3(minPt.X, minPt.Y, maxPt.Z);
                Vector3 pt6 = new Vector3(maxPt.X, minPt.Y, maxPt.Z);
                Vector3 pt7 = new Vector3(maxPt.X, maxPt.Y, maxPt.Z);
                Vector3 pt8 = new Vector3(minPt.X, maxPt.Y, maxPt.Z);
                helper.transformPoint(ref pt1);
                helper.transformPoint(ref pt2);
                helper.transformPoint(ref pt3);
                helper.transformPoint(ref pt4);
                helper.transformPoint(ref pt5);
                helper.transformPoint(ref pt6);
                helper.transformPoint(ref pt7);
                helper.transformPoint(ref pt8);

                box.makeInvalid();
                box.add(new UWB_BoundingBox(pt1, pt2));
                box.add(new UWB_BoundingBox(pt3, pt4));
                box.add(new UWB_BoundingBox(pt5, pt6));
                box.add(new UWB_BoundingBox(pt7, pt8));

                int count = mChildNodes.count();
                for (int i = 0; i < count; i++)
                    box.add(mChildNodes.getItem(i).GetBounds(ref helper, bDraw));
            }
            helper.popModelTransform();

            return box;
        }
Esempio n. 3
0
        public override UWB_BoundingVolume getBoundingVolume(eLevelofDetail lod)
        {
            int count = mList.count();

            if (count == 0)
            {
                return(null);
            }
            mBounds.makeInvalid();

            // NOTE: This is pretty inefficient. We could speed this up by maintaining
            // some sort of "changed" flag and only updating the bounds when this flag changes
            for (int i = 0; i < count; i++)
            {
                UWB_Primitive child = mList.getItem(i);
                mBounds.add(child.getBoundingVolume(lod));
            }

            return(mBounds);
        }