public ContainmentType Contains(BoundingFrustum frustum) { Vector3[] corners = frustum.GetCorners(); int index1; ContainmentType result; for (index1 = 0; index1 < corners.Length; ++index1) { this.Contains(ref corners[index1], out result); if (result == ContainmentType.Disjoint) { break; } } if (index1 == corners.Length) { return(ContainmentType.Contains); } if (index1 != 0) { return(ContainmentType.Intersects); } for (int index2 = index1 + 1; index2 < corners.Length; ++index2) { this.Contains(ref corners[index2], out result); if (result != ContainmentType.Contains) { return(ContainmentType.Intersects); } } return(ContainmentType.Contains); }
public ContainmentType Contains(BoundingFrustum frustum) { //check if all corner is in sphere bool inside = true; Vector3[] corners = frustum.GetCorners(); foreach (Vector3 corner in corners) { if (this.Contains(corner) == ContainmentType.Disjoint) { inside = false; break; } } if (inside) { return(ContainmentType.Contains); } //check if the distance from sphere center to frustrum face < radius double dmin = 0; //TODO : calcul dmin if (dmin <= Radius * Radius) { return(ContainmentType.Intersects); } //else disjoint return(ContainmentType.Disjoint); }
public override void StartFrame(ref Microsoft.Xna.Framework.Matrix view, ref Microsoft.Xna.Framework.Matrix projection, Microsoft.Xna.Framework.BoundingFrustum frustrum) { rend = 0; MaterialSortedObjects.Clear(); Vector3[] corners = new Vector3[8]; frustrum.GetCorners(corners); List <I2DPhysicObject> objs = world.PhysicWorld.TestAABB(new Vector2(corners[0].X, corners[0].Y), new Vector2(corners[2].X, corners[2].Y)); foreach (var item in objs) { I2DObject obj = item.Owner; if (!MaterialSortedObjects.ContainsKey(obj.Material.GetType())) { MaterialSortedObjects[obj.Material.GetType()] = new List <I2DObject>(); } MaterialSortedObjects[obj.Material.GetType()].Add(obj); rend++; } foreach (var obj in ghosts) { if (!MaterialSortedObjects.ContainsKey(obj.Material.GetType())) { MaterialSortedObjects[obj.Material.GetType()] = new List <I2DObject>(); } MaterialSortedObjects[obj.Material.GetType()].Add(obj); } rend += ghosts.Count; }
public ContainmentType Contains(BoundingFrustum frustum) { /* TODO: bad done here need a fix. * Because the question is not if frustum contains box but the reverse and * this is not the same. */ int i; ContainmentType contained; Vector3[] corners = frustum.GetCorners(); // First we check if frustum is in box. for (i = 0; i < corners.Length; i += 1) { this.Contains(ref corners[i], out contained); if (contained == ContainmentType.Disjoint) { break; } } // This means we checked all the corners and they were all contain or instersect if (i == corners.Length) { return(ContainmentType.Contains); } // If i is not equal to zero, we can fastpath and say that this box intersects if (i != 0) { return(ContainmentType.Intersects); } /* If we get here, it means the first (and only) point we checked was * actually contained in the frustum. So we assume that all other points * will also be contained. If one of the points is disjoint, we can * exit immediately saying that the result is Intersects */ i += 1; for (; i < corners.Length; i += 1) { this.Contains(ref corners[i], out contained); if (contained != ContainmentType.Contains) { return(ContainmentType.Intersects); } } /* If we get here, then we know all the points were actually contained, * therefore result is Contains. */ return(ContainmentType.Contains); }
public ContainmentType Contains(BoundingFrustum frustum) { bool flag = true; foreach (Vector3 point in frustum.GetCorners()) { if (this.Contains(point) == ContainmentType.Disjoint) { flag = false; break; } } if (flag) { return(ContainmentType.Contains); } return(0.0 <= (double)this.Radius * (double)this.Radius ? ContainmentType.Intersects : ContainmentType.Disjoint); }
public override void DoPreFrameWork(Microsoft.Xna.Framework.BoundingFrustum frustum) { Vector3[] corners = frustum.GetCorners(); float xx = corners[6].X - corners[2].X; float yy = corners[2].Y - corners[6].Y; float dx = (corners[2].Y * xx) / yy; int minx = (int)(corners[0].X - dx); int maxx = (int)(corners[2].X + dx); minx = (int)MathHelper.Clamp(minx / 32, 0, blocks.Length - 1); maxx = (int)MathHelper.Clamp(maxx / 32, 0, blocks.Length - 1); leftFrameBlock = minx; rightFrameBlock = maxx; }
public static BoundingSphere CreateFromFrustum(BoundingFrustum frustum) { return(BoundingSphere.CreateFromPoints(frustum.GetCorners())); }
public static BoundingSphere CreateFromFrustum(BoundingFrustum frustum) { return(BoundingSphere.CreateFromPoints((IEnumerable <Vector3>)frustum.GetCorners())); }