private static bool DetectCollision(ref BoundingBox agentBB,
                                            Obstacle obst)
        {
            var objTrans = obst.Entity.Transform;

            objTrans.UpdateWorldMatrix();

            var objWorldPos = objTrans.WorldMatrix.TranslationVector;

            foreach (var boundingBox in obst.BoundingBoxes)
            {
                var minVec = objWorldPos + boundingBox.Minimum;
                var maxVec = objWorldPos + boundingBox.Maximum;
                var testBB = new BoundingBox(minVec, maxVec);

                if (Collision.BoxContainsBox(ref testBB, ref agentBB) != ContainmentType.Disjoint)
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
        /* This implentation is wrong
         * /// <summary>
         * /// Determines whether the current objects contains a triangle.
         * /// </summary>
         * /// <param name="vertex1">The first vertex of the triangle to test.</param>
         * /// <param name="vertex2">The second vertex of the triagnle to test.</param>
         * /// <param name="vertex3">The third vertex of the triangle to test.</param>
         * /// <returns>The type of containment the two objects have.</returns>
         * public ContainmentType Contains(ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3)
         * {
         *      return Collision.BoxContainsTriangle(ref this, ref vertex1, ref vertex2, ref vertex3);
         * }
         */

        /// <summary>
        /// Determines whether the current objects contains a <see cref="BoundingBox"/>.
        /// </summary>
        /// <param name="box">The box to test.</param>
        /// <returns>The type of containment the two objects have.</returns>
        public ContainmentType Contains(ref BoundingBox box)
        {
            return(Collision.BoxContainsBox(ref this, ref box));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Determines whether a BoundingBox contains a BoundingBox.
 /// </summary>
 /// <param name="box1">The first box to test</param>
 /// <param name="box2">The second box to test</param>
 /// <returns>The type of containment the two objects have</returns>
 public static ContainmentType BoxContainsBox(ref BoundingBox box1, ref BoundingBox box2)
 {
     return(Collision.BoxContainsBox(ref box1, ref box2));
 }