![]() If you have a sharp eye, you will notice I made an error in answering question 1. So, the author calculates the ratio of scaling and applies half of the cropping to the top, leaving the remainder to happen at the bottom. This would make it look like our camera was translating instead of staying centered. ![]() If that's all he did, then the aspect transform would crop pixels on the bottom of the picture but not at the top. In the authors code, he has already changed the scale of the camera's height. Since this is a game camera and the picture is generated at runtime, adding pixels is not difficult, we just need to know how many to add. stretching is not a very nice solution because it creates distortion, so we prefer to crop or add pixels. Scaling can happen in two ways: either we stretch/squish a picture, or we crop/add pixels to your picture. They are scaling from the current window aspect. However, the author of this code isn't scaling from a square picture. Scale = targetAspect / squareAspect // this is a technically meaningless operation SO, a 4:3 fit into 16:9 will consume ALL the height, and a fraction of the width. If we wanted to fit 4:3 into 16:9, and we know that 16:9 has more relative width to work with, what should we do? This means that we're going to have black bars on the right and left, because 16:9 is wider than 4:3. Which means that it's width is larger relative to its height, than 4:3's width is to its height. So if we were going from say 16:9 to 4:3, we'd end up with a ratio of 1.33333333333, this means that 16:9 is inverse steaper than 4:3. If realAspect : targetAspect 1 would appear shallower. ![]() And if the value 1, that means that the slope of real is greater than the target. If a ratio is 1, that means we're wider than we are tall. The numerator changes faster than the denominator. If a ratio is > 1, then the numerator is larger than the denominator. 1) lets look at this as fractions in general. ![]()
0 Comments
Leave a Reply. |