Open brettmjohnson opened 3 years ago
Good suggestion!
I started working on this but it complicates things such as screen to world calculations. I'll hopefully be able to solve the problems though.
The latest version of Orthographic has a viewport configuration that can be used to achieve this. I will use this new functionality to implement crop support.
Hi, any news on the crop function for the orthographic camera?
any news on the crop function for the orthographic camera?
No, I'm afraid I never had the time to look into it.
No, I'm afraid I never had the time to look into it.
Ok, thanks anyway. I incorporated part of the script from your example cited above (crop_viewport) in the ortographic.render_script, now I have pillarbox or letterbox when the window dimension change so I can keep my aspect ratio view, works for FIXED_AUTO and FIXED_ZOOM options. I'm new to Defold and to Lua, so maybe my implementation it's not elegant or efficient in every situation, for example the BOUNDS option doesn't work anymore. Before I used GUI nodes to cover extra graphics I didn't want to show, it worked but also BOUNDS didn't work as intended. But I thinks that the render script solution is more universal, If you ever update the Ortographic Camera I can rollback to the original ortographic.render_script. For now it's ok, I can move on, I want to prototype some simple game, maybe apply to some future gamejam!
Ah! Was hoping to get this to work already. I've played with modifying the default render script but the screen conversion makes things complicated, especially when having to deal with GUI as well. I feel like this is a friction point especially for less experienced and new users and a comprehensive solution would help.
It would be super helpful to have an option to crop to the set aspect ratio, like in the example code you wrote here: https://github.com/britzl/publicexamples/tree/master/examples/crop_viewport