implement vertical mesh sprite flipping

mesh_sprite_draw
cosmonaut 2020-12-09 22:31:09 -08:00
parent 2f589e584d
commit 7f0bf47f07
1 changed files with 13 additions and 4 deletions

View File

@ -97,27 +97,36 @@ namespace Kav
var xLeft = 0; var xLeft = 0;
var xRight = 1; var xRight = 1;
var yTop = 0;
var yBottom = 1;
if (flipOptions == FlipOptions.Horizontal || flipOptions == FlipOptions.Both) if (flipOptions == FlipOptions.Horizontal || flipOptions == FlipOptions.Both)
{ {
xLeft = 1; xLeft = 1;
xRight = 0; xRight = 0;
} }
if (flipOptions == FlipOptions.Vertical || flipOptions == FlipOptions.Both)
{
yTop = 1;
yBottom = 0;
}
result[0].Position = new Vector3(-texture.Width / 2, texture.Height / 2, 0) / PixelScale; result[0].Position = new Vector3(-texture.Width / 2, texture.Height / 2, 0) / PixelScale;
result[0].Normal = new Vector3(0, 0, 1); result[0].Normal = new Vector3(0, 0, 1);
result[0].TextureCoordinate = new Vector2(xLeft, 0); result[0].TextureCoordinate = new Vector2(xLeft, yTop);
result[1].Position = new Vector3(texture.Width / 2, texture.Height / 2, 0) / PixelScale; result[1].Position = new Vector3(texture.Width / 2, texture.Height / 2, 0) / PixelScale;
result[1].Normal = new Vector3(0, 0, 1); result[1].Normal = new Vector3(0, 0, 1);
result[1].TextureCoordinate = new Vector2(xRight, 0); result[1].TextureCoordinate = new Vector2(xRight, yTop);
result[2].Position = new Vector3(-texture.Width / 2, -texture.Height / 2, 0) / PixelScale; result[2].Position = new Vector3(-texture.Width / 2, -texture.Height / 2, 0) / PixelScale;
result[2].Normal = new Vector3(0, 0, 1); result[2].Normal = new Vector3(0, 0, 1);
result[2].TextureCoordinate = new Vector2(xLeft, 1); result[2].TextureCoordinate = new Vector2(xLeft, yBottom);
result[3].Position = new Vector3(texture.Width / 2, -texture.Height / 2, 0) / PixelScale; result[3].Position = new Vector3(texture.Width / 2, -texture.Height / 2, 0) / PixelScale;
result[3].Normal = new Vector3(0, 0, 1); result[3].Normal = new Vector3(0, 0, 1);
result[3].TextureCoordinate = new Vector2(xRight, 1); result[3].TextureCoordinate = new Vector2(xRight, yBottom);
return result; return result;
} }