public GameViewPort(WorldRenderer wr, Map map) { worldRenderer = wr; //ScreenClip = Rectangle.FromLTRB(0, 0, WarGame.Renderer., Game.GraphicsDevice.DisplayMode.Height); var grid = WarGame.ModData.Manifest.Get <MapGrid>(); if (wr.World.Type == WorldT.Editor) { } else { var tl = wr.ScreenPxPosition(map.ProjectedTopLeft); var br = wr.ScreenPxPosition(map.ProjectedBottomRight); mapBounds = Rectangle.FromLTRB(tl.X, tl.Y, br.X, br.Y); CenterLocation = (tl + br) / 2; } Zoom = WarGame.Settings.Graphics.PixelDouble ? 2 : 1; tileSize = grid.TileSize; }
public Rectangle ScreenBounds(WorldRenderer wr, WPos pos, WVec offset, float scale) { var xy = wr.ScreenPxPosition(pos) + wr.ScreenPxOffset(offset); var cb = CurrentSequence.Bounds; return(Rectangle.FromLTRB(xy.X + (int)(cb.Left * scale), xy.Y + (int)(cb.Top * scale), xy.X + (int)(cb.Right * scale), xy.Y + (int)(cb.Bottom * scale))); }
public Rectangle ScreenBounds(WPos pos, WorldRenderer wr, float scale) { var r = Model.AggregateBounds; var offset = OffsetFunc != null?OffsetFunc() : WVec.Zero; var xy = wr.ScreenPxPosition(pos) + wr.ScreenPxOffset(offset); return(Rectangle.FromLTRB( xy.X + (int)(r.Left * scale), xy.Y + (int)(r.Top * scale), xy.X + (int)(r.Right * scale), xy.Y + (int)(r.Bottom * scale) )); }
/// <summary> /// Rectangle(int viewport coords) that contains things to be drawn /// </summary> /// <param name="insideBounds"></param> /// <returns></returns> public Rectangle GetScissorBounds(bool insideBounds) { //Visible rectangle in world coordinates (expanded to the corner of the cells) var bounds = insideBounds ? VisibleCellsInsideBounds : AllVisibleCells; var map = worldRenderer.World.Map; //mpos -> cpos -> wpos var ctl = map.CenterOfCell(((MPos)bounds.TopLeft).ToCPos(map)) - new WVec(512, 512, 0); var cbr = map.CenterOfCell(((MPos)bounds.BottomRight).ToCPos(map)) + new WVec(512, 512, 0); //Convert to screen coordinates var tl = WorldToViewPx(worldRenderer.ScreenPxPosition(ctl - new WVec(0, 0, ctl.Z))).Clamp(ScreenClip); var br = WorldToViewPx(worldRenderer.ScreenPxPosition(cbr - new WVec(0, 0, cbr.Z))).Clamp(ScreenClip); return(Rectangle.FromLTRB(tl.X - tileSize.Width, tl.Y - tileSize.Height, br.X + tileSize.Width, br.Y + tileSize.Height)); }
Vector3 ScreenPosition(WorldRenderer wr) { var xy = wr.ScreenPxPosition(pos) + wr.ScreenPxOffset(offset) - (0.5f * scale * sprite.Size.XY).ToInt2(); return(new Vector3(xy, sprite.Offset.Z + wr.ScreenZPosition(pos, 0) - 0.5f * scale * sprite.Size.Z)); }