Exemple #1
0
 //initializng
 /// <summary>
 /// Constructor
 /// </summary>
 public Camera(StreamReader file)
 {
     Load(file);
     SetNewAngle((int)currentAngle);
     CreateProjectionMatrix();
     frustum = new BoundingFrustum();
 }
Exemple #2
0
 /// <summary>
 /// Check if the bounding frustum and point intersect
 /// </summary>
 /// <param name="a">Bounding frustum</param>
 /// <param name="sphere">Point as Vector3</param>
 /// <returns>True or false/bounding volume an the point intersects or not/returns>
 public static bool Intersects(BoundingFrustum a, Vector3 point)
 {
     Vector4 vec = new Vector4(point, 1f);
     for (int i = 0; i < 6; i++)
         if (Plane.Dot(a.planes[i], vec) < 0)
             return false;
     return true;
 }
Exemple #3
0
 //intersections
 /// <summary>
 /// Check if the bounding frustum and the bounding sphere intersect
 /// </summary>
 /// <param name="a">Bounding frustum</param>
 /// <param name="sphere">Bounding sphere</param>
 /// <returns>True or false/bounding volumes intersects or not</returns>
 public static bool Intersects(BoundingFrustum a, BoundingSphere sphere)
 {
     Vector4 vec = new Vector4(sphere.Center, 1f);
     for (int i = 0; i < 6; i++)
         if (Plane.Dot(a.planes[i], vec) + sphere.Radius < 0)
             return false;
     return true;
 }
Exemple #4
0
        /// <summary>
        /// Check if the bounding frustum and the bounding sphere intersect
        /// </summary>
        /// <param name="a">Bounding frustum</param>
        /// <param name="sphere">Bounding box</param>
        /// <returns>True or false/bounding volumes intersects or not</returns>
        public static bool Intersects(BoundingFrustum a, BoundingBox box)
        {
            for (int i = 0; i < 6; i++)
            {
                //calculating the positive vertex
                //(the vertex from the box that is further along the normal's direction)
                Vector4 p = new Vector4(box.Minimum,1f);
                if (a.planes[i].Normal.X >= 0)
                    p.X = box.Maximum.X;
                if (a.planes[i].Normal.Y >= 0)
                    p.Y = box.Maximum.Y;
                if (a.planes[i].Normal.Z >= 0)
                    p.Z = box.Maximum.Z;

                if (Plane.Dot(a.planes[i], p)<0) //if this vertex is not on a good side of the plane return false
                    return false;
            }
            return true;
        }