public void DrawImageColored(SmartTexture texture, Color4 color, Vector2[] verts, Vector2[] tverts) { device.VertexFormat = VertexFormat.Position | VertexFormat.Diffuse | VertexFormat.Specular | VertexFormat.Texture1; SetupTexture(texture); Vector2 toUV = new Vector2( (texture == null) ? 1 : 1.0f / (float)texture.Width, (texture == null) ? 1 : 1.0f / (float)texture.Height); int diffuseColor = color.ToArgb(); int specular = currentOverlayColor.ToArgb(); TexturedVertex[] verts2 = new TexturedVertex[] { new TexturedVertex(new Vector3(verts[0], 0), diffuseColor, specular, Vector2.Modulate(tverts[0], toUV)), new TexturedVertex(new Vector3(verts[1], 0), diffuseColor, specular, Vector2.Modulate(tverts[1], toUV)), new TexturedVertex(new Vector3(verts[2], 0), diffuseColor, specular, Vector2.Modulate(tverts[2], toUV)), new TexturedVertex(new Vector3(verts[3], 0), diffuseColor, specular, Vector2.Modulate(tverts[3], toUV)), }; device.DrawUserPrimitives <TexturedVertex>(PrimitiveType.TriangleFan, 2, verts2); }
public void DrawImageColored(SmartTexture texture, Color4 color, RectangleF screenRect) { float twidth = (texture == null) ? 0 : texture.Width; float theight = (texture == null) ? 0 : texture.Height; RectangleF textureRect = new RectangleF(0, 0, twidth, theight); DrawImageColored(texture, color, screenRect, textureRect); }
private void SetupTexture(SmartTexture smartTexture) { Texture texture = null; if (smartTexture != null) { texture = smartTexture.Texture; } SetupTexture(texture, false); }
public void DrawImageColored(SmartTexture texture, Color4 color, Vector2[] verts) { float twidth = (texture == null) ? 0 : texture.Width; float theight = (texture == null) ? 0 : texture.Height; Vector2[] tverts = new Vector2[] { new Vector2(0, 0), new Vector2(0, theight), new Vector2(twidth, theight), new Vector2(twidth, 0) }; DrawImageColored(texture, color, verts, tverts); }
public void DrawImageColored(SmartTexture texture, Color4 color, float x, float y) { float twidth = (texture == null) ? 0 : texture.Width; float theight = (texture == null) ? 0 : texture.Height; Vector2[] verts = new Vector2[] { new Vector2(x, y), new Vector2(x, y + theight), new Vector2(x + twidth, y + theight), new Vector2(x + twidth, y) }; DrawImageColored(texture, color, verts); }
public void DrawImageColored(SmartTexture texture, Color4 color, RectangleF screenRect, RectangleF textureRect) { Vector2[] verts = new Vector2[] { new Vector2(screenRect.Left, screenRect.Top), new Vector2(screenRect.Left, screenRect.Bottom), new Vector2(screenRect.Right, screenRect.Bottom), new Vector2(screenRect.Right, screenRect.Top) }; Vector2[] tverts = new Vector2[] { new Vector2(textureRect.Left, textureRect.Top), new Vector2(textureRect.Left, textureRect.Bottom), new Vector2(textureRect.Right, textureRect.Bottom), new Vector2(textureRect.Right, textureRect.Top) }; DrawImageColored(texture, color, verts, tverts); }
public void DrawImageColoredTransformed(SmartTexture texture, Color color, RectangleF dstRect, RectangleF texRect, PointF scaleCenter, float scale, PointF rotateCenter, float rotateAngle) { Vector2[] verts = new Vector2[4]; Vector2[] tverts = new Vector2[4]; verts[0].X = dstRect.X; verts[0].Y = dstRect.Y; verts[1].X = dstRect.X; verts[1].Y = dstRect.Y + dstRect.Height; verts[2].X = dstRect.X + dstRect.Width; verts[2].Y = dstRect.Y + dstRect.Height; verts[3].X = dstRect.X + dstRect.Width; verts[3].Y = dstRect.Y; Matrix mtx = Matrix.Transformation2D( new Vector2(scaleCenter.X, scaleCenter.Y), 0.0f, new Vector2(scale, scale), new Vector2(rotateCenter.X, rotateCenter.Y), (float)(rotateAngle * Math.PI / 180.0f), new Vector2(0, 0)); for (int i = 0; i < 4; ++i) { Vector2 v = Vector2.TransformCoordinate(new Vector2(verts[i].X, verts[i].Y), mtx); verts[i].X = v.X; verts[i].Y = v.Y; } tverts[0].X = texRect.X; tverts[0].Y = texRect.Y; tverts[1].X = texRect.X; tverts[1].Y = texRect.Y + texRect.Height; tverts[2].X = texRect.X + texRect.Width; tverts[2].Y = texRect.Y + texRect.Height; tverts[3].X = texRect.X + texRect.Width; tverts[3].Y = texRect.Y; DrawImageColored(texture, color, verts, tverts); }
public void DrawImage(SmartTexture texture, RectangleF screenRect, RectangleF textureRect) { DrawImageColored(texture, new Color4(Color.White), screenRect, textureRect); }
public void DrawImage(SmartTexture texture, float x, float y) { DrawImageColored(texture, new Color4(Color.White), x, y); }