Rotating sprites.

Jan 11, 2014 at 9:03 PM
Edited Jan 11, 2014 at 9: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.
Coordinator
Jan 12, 2014 at 11:59 AM
Hi,

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.

Nico
Jan 13, 2014 at 12:18 AM
Edited Jan 13, 2014 at 12:19 AM
Thanks for answering!

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

Example:
sprite.Draw(blackArrow, new Vector2(0,0), 90, new Vector2(14, 14), CoordinateType.Absolute);
The third parameter is rotation in degrees.
Coordinator
Jan 13, 2014 at 1:47 PM
Edited Jan 14, 2014 at 9: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:
sprite.Draw(
    blackArrow, 
    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 °*/, 
    CoordinateType.Absolute);
I'd be happy if you would like to test the functionality in your application.

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

Gonna try that out, I'll give you some feedback.
Jan 13, 2014 at 11:34 PM
Edited Jan 14, 2014 at 12:16 AM
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!
Coordinator
Jan 14, 2014 at 9: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)   ...);
or
sprite.Draw(    ...    new Degrees(45)   ...);
Marked as answer by MrManiak on 1/17/2014 at 3:37 PM
Coordinator
Jan 14, 2014 at 3:48 PM
... which is now implemented exactly as described.
Marked as answer by MrManiak on 1/17/2014 at 3:38 PM