/// <summary> /// Gets the 3D data from map centered in pos. /// </summary> /// <param name="pos">The center of square</param> /// <param name="size">The size of the square</param> /// <returns></returns> public Frame getPosition(Vector2 pos, uint size = 10) { Contract.Requires(map.ValidPosition(new Vector3(pos, 2))); //ToDo: work the case when some blocks don't exist because they are outside the map. In that case the frontier blocks should be repeated. List <VertexPositionNormalTexture> VertexPosList = new List <VertexPositionNormalTexture>(); List <int> IndexBufferList = new List <int>(); for (uint i = (uint)pos.X - size; i < pos.X + size; i++) { for (uint j = (uint)(pos.Y) - size; j < pos.Y + size; j++) { for (uint k = 0; k < map.Height; k++) { Block block = map.GetBlock(new Vector3(i, j, k)); int idx = 0; foreach (VertexPositionNormalTexture vx in block.Coors) { VertexPosList.Add(vx); idx++; } int c = VertexPosList.Count - idx; foreach (int ib in block.IndexBufferCollection) { IndexBufferList.Add(c + ib); } } } } List <VertexPositionNormalTexture> objectsVertexPosList = new List <VertexPositionNormalTexture>(); List <int> objectsIndexBufferList = new List <int>(); foreach (Pedestrian ped in pedList) { Frame md = ped.Draw(); int idx = 0; foreach (VertexPositionNormalTexture vx in md.ObjectVertexList) { objectsVertexPosList.Add(vx); idx++; } int c = objectsVertexPosList.Count - idx; foreach (int ib in md.ObjectIndexList) { objectsIndexBufferList.Add(c + ib); } } return(new Frame(VertexPosList, IndexBufferList, objectsVertexPosList, objectsIndexBufferList, pos)); }
/// <summary> /// Gets the 3D data from map centered in pos. /// </summary> /// <param name="pos">The center of square</param> /// <param name="size">The size of the square</param> /// <returns></returns> public Frame getPosition(Vector2 pos, uint size = 10) { Contract.Requires(map.ValidPosition(new Vector3(pos, 2))); //ToDo: work the case when some blocks don't exist because they are outside the map. In that case the frontier blocks should be repeated. List <VertexPositionNormalTexture> VertexPosList = new List <VertexPositionNormalTexture>(); List <int> IndexBufferList = new List <int>(); for (uint i = (uint)pos.X - size; i < pos.X + size; i++) { for (uint j = (uint)(pos.Y) - size; j < pos.Y + size; j++) { for (uint k = 0; k < map.Height; k++) { Block block = map.GetBlock(new Vector3(i, j, k)); int idx = 0; foreach (VertexPositionNormalTexture vx in block.Coors) { VertexPosList.Add(vx); idx++; } int c = VertexPosList.Count - idx; foreach (int ib in block.IndexBufferCollection) { IndexBufferList.Add(c + ib); } } } } List <VertexPositionNormalTexture> objectsVertexPosList = new List <VertexPositionNormalTexture>(); List <int> objectsIndexBufferList = new List <int>(); foreach (Pedestrian ped in pedList) { Frame md = ped.Draw(); int idx = 0; foreach (VertexPositionNormalTexture vx in md.ObjectVertexList) { objectsVertexPosList.Add(vx); idx++; } int c = objectsVertexPosList.Count - idx; foreach (int ib in md.ObjectIndexList) { objectsIndexBufferList.Add(c + ib); } } Frame frame = new Frame(VertexPosList, IndexBufferList, objectsVertexPosList, objectsIndexBufferList, pos); if (debugDraw) { drawer = new DebugDrawer(); foreach (RigidBody body in _physics.RigidBodiesList) { body.DebugDraw(drawer); body.AllowDeactivation = false; body.EnableDebugDraw = true; } frame.TriangleDebug = drawer.DrawInfo.TriangleDebug; frame.LineDebug = drawer.DrawInfo.LineDebug; } return(frame); }