Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sprite rotation #16

Open
skyne98 opened this issue Jan 27, 2020 · 8 comments
Open

Sprite rotation #16

skyne98 opened this issue Jan 27, 2020 · 8 comments

Comments

@skyne98
Copy link

skyne98 commented Jan 27, 2020

Are there any plans to introduce an ability to rotate sprites added to the sprite batch?

In theory, it should be pretty easily done by introducing something like RotationRect as an extension of Rect, which will contain additional info about the angle and origin of rotation. Later this RotationRect may be used by calling batch.add_rotated.
As an alternative, it might be a good solution to go "XNA" way by adding both angle and origin to the direct batch.add call.

@cloudhead
Copy link
Owner

We did exactly this (the XNA way) for the shape2d pipeline, so should be pretty easy to port over to sprite2d. It is planned, but I don't know when it'll land. Would you want to take a stab at it?

@cloudhead
Copy link
Owner

For reference: https://github.com/cloudhead/rgx/pull/10

@xla
Copy link
Contributor

xla commented Jan 28, 2020

@cloudhead You can assign me to this, gonna need it anyway.

@skyne98
Copy link
Author

skyne98 commented Jan 29, 2020

@xla, in case something goes wrong, I am ready to try to do it as well. Will be keeping my eye on the progress here 😉

@skyne98
Copy link
Author

skyne98 commented Mar 16, 2020

I have some changes I can post as an early draft for the pull request. The new code supports full matrix transformations for sprites (rotation and scaling with origin). However, there are a couple of downsides, at the moment:

  • New coded crudely uses ultraviolet as a math library (as it seems to be the fastest and I use it for the personal projects)
  • Some more testing needs to be done in regards to correctness of the results, as well as performance

I think those issues can be resolved pretty quickly with some cooperation, providing RGX with some kind of proper sprite transform support. Looking forward to it!

@cloudhead
Copy link
Owner

cloudhead commented Mar 16, 2020

Amazing! Looking forward to seeing these changes.

@skyne98
Copy link
Author

skyne98 commented Mar 17, 2020

Ok, in this case I will post a pull request as soon as the single sprite rotation transform example code works out as expected!

@skyne98
Copy link
Author

skyne98 commented Mar 23, 2020

@cloudhead, posted a draft pull request. This is my first pull request on GitHub, so sorry if something is done incorrectly! Waiting for feedback!

@xla xla removed their assignment Sep 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants