static FRect MakeVertRect(Point drawsize, Vector2 location, Vector2 offset, Vector2 scale, Vector2 axis, SpriteEffects flip) { FRect r = new FRect(); Vector2 vloc = GetDrawLocation(drawsize, location, axis, scale, flip) + offset; r.X = vloc.X; r.Y = vloc.Y; r.Width = drawsize.X * scale.X; r.Height = drawsize.Y * scale.Y; return(r); }
static void SetPosition(Vertex[] buffer, Int32 offset, FRect r, Single rotation, Vector2 axis) { Vector2 v1 = RotatePoint(new Vector2(r.Left, r.Top), rotation, axis); Vector2 v2 = RotatePoint(new Vector2(r.Right, r.Bottom), rotation, axis); buffer[offset + 0].Position = new Vector2(v1.X, v1.Y); buffer[offset + 1].Position = new Vector2(v2.X, v1.Y); buffer[offset + 2].Position = new Vector2(v2.X, v2.Y); buffer[offset + 3].Position = new Vector2(v1.X, v1.Y); buffer[offset + 4].Position = new Vector2(v2.X, v2.Y); buffer[offset + 5].Position = new Vector2(v1.X, v2.Y); }
private static void SetPosition(Vertex[] buffer, int offset, FRect r, float rotation, Vector2 axis) { var v1 = RotatePoint(new Vector2(r.Left, r.Top), rotation, axis); var v2 = RotatePoint(new Vector2(r.Right, r.Bottom), rotation, axis); buffer[offset + 0].Position = new Vector4(v1.X, v1.Y, 0, 1); buffer[offset + 1].Position = new Vector4(v2.X, v1.Y, 0, 1); buffer[offset + 2].Position = new Vector4(v2.X, v2.Y, 0, 1); buffer[offset + 3].Position = new Vector4(v1.X, v1.Y, 0, 1); buffer[offset + 4].Position = new Vector4(v2.X, v2.Y, 0, 1); buffer[offset + 5].Position = new Vector4(v1.X, v2.Y, 0, 1); }
void OutlinedRectangleDraw(DrawState drawstate) { if (drawstate == null) { throw new ArgumentNullException("drawstate"); } if (drawstate.Mode != DrawMode.OutlinedRectangle) { throw new ArgumentException("Incorrect drawstate"); } m_effect.CurrentTechnique = (UseOldShader == true) ? m_effect.Techniques["DrawOLD"] : m_effect.Techniques["Draw"]; SetShaderParameters(drawstate.ShaderParameters, drawstate.Pixels, drawstate.Palette); Int32 count = 0; foreach (DrawData data in drawstate) { if (data.DrawRect != null) { Point drawsize = new Point(data.DrawRect.Value.Width, data.DrawRect.Value.Height); FRect frect = Renderer.MakeVertRect(drawsize, data.Location, CameraShift, drawstate.Scale, drawstate.Axis - drawstate.Offset, drawstate.Flip); m_drawbuffer[(count * 8) + 0].Position = new Vector2(frect.Left, frect.Top); m_drawbuffer[(count * 8) + 1].Position = new Vector2(frect.Left, frect.Bottom); m_drawbuffer[(count * 8) + 2].Position = new Vector2(frect.Right, frect.Top); m_drawbuffer[(count * 8) + 3].Position = new Vector2(frect.Right, frect.Bottom); m_drawbuffer[(count * 8) + 4].Position = new Vector2(frect.Left, frect.Top); m_drawbuffer[(count * 8) + 5].Position = new Vector2(frect.Right, frect.Top); m_drawbuffer[(count * 8) + 6].Position = new Vector2(frect.Left, frect.Bottom); m_drawbuffer[(count * 8) + 7].Position = new Vector2(frect.Right, frect.Bottom); for (Int32 i = 0; i != 8; ++i) { m_drawbuffer[(count * 8) + i].Tint = data.Tint; } ++count; } } if (count > 0) { FinishDrawing(PrimitiveType.LineList, count * 4); } }
Int32 DefaultDrawSetup(DrawState drawstate, Point pixelsize) { if (drawstate == null) { throw new ArgumentNullException("drawstate"); } Int32 count = 0; Vector2 camerashift = CameraShift; foreach (DrawData data in drawstate) { Point drawsize = new Point(); if (data.DrawRect != null) { drawsize = new Point(data.DrawRect.Value.Width, data.DrawRect.Value.Height); Renderer.SetTextureCoords(m_drawbuffer, count * 6, pixelsize, data.DrawRect.Value, drawstate.Flip); } else { drawsize = pixelsize; Renderer.SetTextureCoords(m_drawbuffer, count * 6, drawstate.Flip); } FRect frect = Renderer.MakeVertRect(drawsize, data.Location, camerashift, drawstate.Scale, drawstate.Axis - drawstate.Offset, drawstate.Flip); Vector2 rotationaxis = data.Location + camerashift + drawstate.Offset; Renderer.SetPosition(m_drawbuffer, count * 6, frect, MathHelper.ToRadians(drawstate.Rotation), rotationaxis); Renderer.SetColor(m_drawbuffer, count * 6, Misc.BlendColors(Tint, data.Tint)); ++count; } return(count); }
static FRect MakeVertRect(Point drawsize, Vector2 location, Vector2 offset, Vector2 scale, Vector2 axis, SpriteEffects flip) { FRect r = new FRect(); Vector2 vloc = GetDrawLocation(drawsize, location, axis, scale, flip) + offset; r.X = vloc.X; r.Y = vloc.Y; r.Width = drawsize.X * scale.X; r.Height = drawsize.Y * scale.Y; return r; }