Пример #1
0
        public BBox TransformBBox(BBox b)
        {
            var ret = BBox.FromPoint(TransformPoint(new Point(b.Min.X, b.Min.Y, b.Min.Z)));

            ret = BBox.Union(ret, TransformPoint(new Point(b.Max.X, b.Min.Y, b.Min.Z)));
            ret = BBox.Union(ret, TransformPoint(new Point(b.Min.X, b.Max.Y, b.Min.Z)));
            ret = BBox.Union(ret, TransformPoint(new Point(b.Min.X, b.Min.Y, b.Max.Z)));
            ret = BBox.Union(ret, TransformPoint(new Point(b.Min.X, b.Max.Y, b.Max.Z)));
            ret = BBox.Union(ret, TransformPoint(new Point(b.Max.X, b.Max.Y, b.Min.Z)));
            ret = BBox.Union(ret, TransformPoint(new Point(b.Max.X, b.Min.Y, b.Max.Z)));
            ret = BBox.Union(ret, TransformPoint(new Point(b.Max.X, b.Max.Y, b.Max.Z)));
            return(ret);
        }
Пример #2
0
        public BBox MotionBounds(BBox b, bool useInverse)
        {
            if (!_actuallyAnimated)
            {
                return(Transform.Invert(_startTransform).TransformBBox(b));
            }
            BBox      ret    = BBox.Empty;
            const int nSteps = 128;

            for (int i = 0; i < nSteps; ++i)
            {
                Transform t;
                float     time = MathUtility.Lerp(i / (float)(nSteps - 1), _startTime, _endTime);
                Interpolate(time, out t);
                if (useInverse)
                {
                    t = Transform.Invert(t);
                }
                ret = BBox.Union(ret, t.TransformBBox(b));
            }
            return(ret);
        }