Rotating sprites.

Jan 11, 2014 at 8:03 PM
Edited Jan 11, 2014 at 8:13 PM
I'm new to the Direct3D rendering scene and I'm looking for a way I could use to rotate my sprites/textures during runtime? I've heard of aplying Matrix to sprites, but I'd like to continue using this library.

Thanks for the lib, though. Keep up with the good work!

EDIT: Just remembered about this: "More advanced tasks like rotating or skewing textures and aligning text to arbitrary curves are not supported up to now." Welp. I'm fucked.
Jan 12, 2014 at 10:59 AM

could you please tell me more about what you need? Implementing rotation of sprites is not that difficult. Rotating text is a bit harder, though.

Jan 12, 2014 at 11:18 PM
Edited Jan 12, 2014 at 11:19 PM
Thanks for answering!

I basically just need simple sprite rotation. No need for text rotating.

sprite.Draw(blackArrow, new Vector2(0,0), 90, new Vector2(14, 14), CoordinateType.Absolute);
The third parameter is rotation in degrees.
Jan 13, 2014 at 12:47 PM
Edited Jan 14, 2014 at 8:00 AM
Version 1.2.0 now introduces sprite rotation. Besides the rotation angle, you need to define the pivot point about which to rotate:
    new Vector2(20, 20)/*pivot point is placed here*/, 
    new Vector2(14, 14) /*sprite size*/, 
    new Vector2(7, 7) /*pivot point within the texture*/, 
    Math.PI/4 /*45 °*/, 
I'd be happy if you would like to test the functionality in your application.

Jan 13, 2014 at 10:11 PM
Thank you so, so much! I love you!

Gonna try that out, I'll give you some feedback.
Jan 13, 2014 at 10:34 PM
Edited Jan 13, 2014 at 11:16 PM
Works fantastic, but for some reason, I had to use this math for the angles:
Math.PI * desiredAngles/180 * -1
-1 is for the clockwise turn. 90 degrees is actually Math.PI/2, because Math.PI/4 is 45 degrees. That may look not very userfriendly to someone who isn't comfortable with maths.

I'm very grateful for your help, though.

Stay awsome!
Jan 14, 2014 at 8:09 AM
Thank you for your feedback.

Regarding the maths: Usually positive angles mean counter-clockwise rotations. This is the case in almost all libraries. I also mentioned it in the documentation.

Most things in computer graphics are expressed with radians. Degrees are really just a convenience for the "normal user". But you're right. I think, I'll implement some conversion functionality, so you can use it like:
sprite.Draw(    ...    new Radians(Math.PI/4)   ...);
sprite.Draw(    ...    new Degrees(45)   ...);
Marked as answer by MrManiak on 1/17/2014 at 3:37 PM
Jan 14, 2014 at 2:48 PM
... which is now implemented exactly as described.
Marked as answer by MrManiak on 1/17/2014 at 3:38 PM