rgx.legacy
rgx.legacy copied to clipboard
Sprite rotation
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.
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?
For reference: https://github.com/cloudhead/rgx/pull/10
@cloudhead You can assign me to this, gonna need it anyway.
@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 😉
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!
Amazing! Looking forward to seeing these changes.
Ok, in this case I will post a pull request as soon as the single sprite rotation transform example code works out as expected!
@cloudhead, posted a draft pull request. This is my first pull request on GitHub, so sorry if something is done incorrectly! Waiting for feedback!