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

Using the camera with rotation? #124

Open
smokefilledrooms opened this issue Mar 15, 2018 · 4 comments
Open

Using the camera with rotation? #124

smokefilledrooms opened this issue Mar 15, 2018 · 4 comments

Comments

@smokefilledrooms
Copy link

smokefilledrooms commented Mar 15, 2018

Hi there,

So, I've been trying to use the camera (in 2d) rotated and I cannot for the life of me get the panning and zooming to work correctly while rotated. The camera zooms in toward somewhere in the lower left instead of the center of the screen. The camera doesn't pan parallel and perpendicular to its edges when using simple operations like cam.x++ and cam.y++, I used some basic trig to compensate for the latter, which worked, but only at one zoom level (8x out, specifically).

I'd chalk this up to my dubious math and programming skills, but the camera test program doesn't seem to compensate at all for the rotation which makes me think something else may be going on here? I'm not sure how to build the tests to make sure (on linux), though. I managed to generate a bunch of cmake files/directories and a feature_tests.bin but nothing that seems to run or can be make install'd

I'd greatly appreciate any pointers or instructions how to build the tests, thanks.

ETA: I figured out a work around for my use case, tips would still be appreciated though.

@dhiahassen
Copy link

Yeah we were talking about this issue in the past , still not solved #26 , see at the buttom of the page other issue related

@dhiahassen
Copy link

@fedkanaut my workarround was to apply trasformation matrices manually , what was yours ?

@smokefilledrooms
Copy link
Author

I couldn’t get that to play nice for whatever reason (probably me). I didn’t actually really need runtime camera rotation so I just baked it into the polygons I was working with and called it a day (my use case is weird).

albertvaka added a commit to albertvaka/sdl-gpu that referenced this issue Oct 4, 2020
Ensure rotation and scale happen after translation, and from the center of the camera.

Fixes grimfang4#133 and grimfang4#124
@albertvaka
Copy link
Contributor

I know this issue is a bit old, but if you still have the original code I would appreciate if you could try this patch and confirm it works for your use case: #206

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