示例#1
0
        /// <summary>
        /// Gets the bounding box of an element in the data.
        /// </summary>
        /// <param name="triangleIndex">Index of the triangle in the data.</param>
        /// <param name="boundingBox">Bounding box of the triangle.</param>
        public void GetBoundingBox(int triangleIndex, out BoundingBox boundingBox)
        {
            Vector3f v1, v2, v3;

            GetTriangle(triangleIndex, out v1, out v2, out v3);
            Vector3f.ComponentMin(ref v1, ref v2, out boundingBox.Min);
            Vector3f.ComponentMin(ref boundingBox.Min, ref v3, out boundingBox.Min);
            Vector3f.ComponentMax(ref v1, ref v2, out boundingBox.Max);
            Vector3f.ComponentMax(ref boundingBox.Max, ref v3, out boundingBox.Max);
        }
示例#2
0
        /// <summary>
        /// Initializes the detector entity and any other necessary logic.
        /// </summary>
        protected internal override void Initialize()
        {
            //Setup the dimensions of the detector.
            Vector3f startpoint = wheel.suspension.localAttachmentPoint;
            Vector3f endpoint = startpoint + wheel.suspension.localDirection * wheel.suspension.restLength;
            Vector3f min, max;

            Vector3f.ComponentMin(ref startpoint, ref endpoint, out min);
            Vector3f.ComponentMax(ref startpoint, ref endpoint, out max);

            detector.Width  = max.X - min.X;
            detector.Height = max.Y - min.Y;
            detector.Length = max.Z - min.Z;
        }
示例#3
0
        /// <summary>
        /// Gets the bounding box of the shape given a transform.
        /// </summary>
        /// <param name="shapeTransform">Transform to use.</param>
        /// <param name="boundingBox">Bounding box of the transformed shape.</param>
        public override void GetBoundingBox(ref RigidTransform shapeTransform, out BoundingBox boundingBox)
        {
            Vector3f a, b, c;

            Matrix3f o;

            Matrix3f.FromQuaternion(ref shapeTransform.Orientation, out o);
            Vector3f.Transform(ref vA, ref o, out a);
            Vector3f.Transform(ref vB, ref o, out b);
            Vector3f.Transform(ref vC, ref o, out c);

            Vector3f.ComponentMin(ref a, ref b, out boundingBox.Min);
            Vector3f.ComponentMin(ref c, ref boundingBox.Min, out boundingBox.Min);

            Vector3f.ComponentMax(ref a, ref b, out boundingBox.Max);
            Vector3f.ComponentMax(ref c, ref boundingBox.Max, out boundingBox.Max);

            boundingBox.Min.X += shapeTransform.Position.X - collisionMargin;
            boundingBox.Min.Y += shapeTransform.Position.Y - collisionMargin;
            boundingBox.Min.Z += shapeTransform.Position.Z - collisionMargin;
            boundingBox.Max.X += shapeTransform.Position.X + collisionMargin;
            boundingBox.Max.Y += shapeTransform.Position.Y + collisionMargin;
            boundingBox.Max.Z += shapeTransform.Position.Z + collisionMargin;
        }