Edit: the images below aren't supposed to have whitespace. I am just trying to show you that i am trying to create a rectangle from a 1x64 image, positioned as shown in the second picture
I know how to rotate an image like that in XNA
But how is it possible to draw a sprite in this angle this way ?
I can't seem to be able to find an answer on that and i'm sort on ideas
Answer
What you want is a skew matrix. XNA has no built-in mechanism for creating one. Fortunately we can write our own:
Matrix CreateSkewX(float angle)
{
Matrix skew = Matrix.Identity;
skew.M12 = (float)Math.Tan((double)angle);
return skew;
}
Matrix CreateSkewY(float angle)
{
Matrix skew = Matrix.Identity;
skew.M21 = (float)Math.Tan((double)angle);
return skew;
}
(Note: These are untested, and I might have X and Y reversed.)
Check out this answer for more details.
No comments:
Post a Comment