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 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; }