Ejemplo n.º 1
0
        /// <summary>
        /// Gets the axis aligned bounding box of the orientated shape.
        /// </summary>
        /// <param name="orientation">The orientation of the shape.</param>
        /// <param name="box">The axis aligned bounding box of the shape.</param>
        public override void GetBoundingBox(ref TSMatrix orientation, out TSBBox box)
        {
            TSMatrix abs; TSMath.Absolute(ref orientation, out abs);
            TSVector temp;

            TSVector.Transform(ref halfSize, ref abs, out temp);

            box.max = temp;
            TSVector.Negate(ref temp, out box.min);
        }
Ejemplo n.º 2
0
        public void Transform(ref TSMatrix orientation)
        {
            TSVector halfExtents = FP.Half * (max - min);
            TSVector center      = FP.Half * (max + min);

            TSVector.Transform(ref center, ref orientation, out center);

            TSMatrix abs; TSMath.Absolute(ref orientation, out abs);

            TSVector.Transform(ref halfExtents, ref abs, out halfExtents);

            max = center + halfExtents;
            min = center - halfExtents;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the axis aligned bounding box of the orientated shape. (Inlcuding all
        /// 'sub' shapes)
        /// </summary>
        /// <param name="orientation">The orientation of the shape.</param>
        /// <param name="box">The axis aligned bounding box of the shape.</param>
        public override void GetBoundingBox(ref TSMatrix orientation, out TSBBox box)
        {
            box.min = mInternalBBox.min;
            box.max = mInternalBBox.max;

            TSVector localHalfExtents = FP.Half * (box.max - box.min);
            TSVector localCenter      = FP.Half * (box.max + box.min);

            TSVector center;

            TSVector.Transform(ref localCenter, ref orientation, out center);

            TSMatrix abs; TSMath.Absolute(ref orientation, out abs);
            TSVector temp;

            TSVector.Transform(ref localHalfExtents, ref abs, out temp);

            box.max = center + temp;
            box.min = center - temp;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Transforms the bounding box into the space given by orientation and position.
        /// </summary>
        /// <param name="position"></param>
        /// <param name="orientation"></param>
        /// <param name="result"></param>
        internal void InverseTransform(ref TSVector position, ref TSMatrix orientation)
        {
            TSVector.Subtract(ref max, ref position, out max);
            TSVector.Subtract(ref min, ref position, out min);

            TSVector center;

            TSVector.Add(ref max, ref min, out center);
            center.x *= FP.Half; center.y *= FP.Half; center.z *= FP.Half;

            TSVector halfExtents;

            TSVector.Subtract(ref max, ref min, out halfExtents);
            halfExtents.x *= FP.Half; halfExtents.y *= FP.Half; halfExtents.z *= FP.Half;

            TSVector.TransposedTransform(ref center, ref orientation, out center);

            TSMatrix abs; TSMath.Absolute(ref orientation, out abs);

            TSVector.TransposedTransform(ref halfExtents, ref abs, out halfExtents);

            TSVector.Add(ref center, ref halfExtents, out max);
            TSVector.Subtract(ref center, ref halfExtents, out min);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Transforms the bounding box into the space given by orientation and position.
        /// </summary>
        /// <param name="position"></param>
        /// <param name="orientation"></param>
        /// <param name="result"></param>
        internal void InverseTransform(TSVector position, TSMatrix orientation)
        {
            TSVector.Subtract(max, position, out max);
            TSVector.Subtract(min, position, out min);

            TSVector center;

            TSVector.Add(max, min, out center);
            center.x *= FP.Half; center.y *= FP.Half; center.z *= FP.Half;

            TSVector halfExtents;

            TSVector.Subtract(max, min, out halfExtents);
            halfExtents.x *= FP.Half; halfExtents.y *= FP.Half; halfExtents.z *= FP.Half;

            TSVector.TransposedTransform(center, orientation, out center);

            TSMatrix abs; TSMath.Absolute(orientation, out abs);

            TSVector.TransposedTransform(halfExtents, abs, out halfExtents);

            TSVector.Add(center, halfExtents, out max);
            TSVector.Subtract(center, halfExtents, out min);
        }