1 Lou's Pseudo 3d Web Page
Willian Brackman edited this page 2025-08-03 03:05:41 +08:00


Be aware that you will have totally different FOV values for horizontal (x) and vertical (y) for a regular or widescreen monitor that's in horizontal orientation. What we want to do to repair our perspective drawback is to precompute a listing of distances for every line of the display screen. In short, the issue is how to explain build a home-based business flat aircraft in 3d. To know how this works, first think of the 2d equivalent: a line! To explain a horizontal line in 2d, you'll say that for every (x, y) coordinate the y is identical. If we extend this into 3d, it turns into a airplane: for every x and z distance, the y is similar! In the case of a flat horizontal surface, it would not matter how removed from the digicam it's, the y is all the time the identical. Likewise, it does not matter how much to the left or proper the purpose is, the y will nonetheless be the same.


Again to figuring out the gap of each line of the screen: let's name this a Z Map. Calculating the Z Map is only a matter of rearranging the 3d projection formulation to discover a Z worth for every display Y! This is identical for each line because, as described within the introductory paragraph, we're fascinated with a flat road for the time-being. Along with looking way more correct and avoiding the "oatmeal effect", it has the benefit that it is easy to compute what the maximum draw distance is. The street is mapped onto the screen by studying via this buffer: For each distance, you will need to work out what part of the highway texture belongs there by noting what number of models every stripe or pixel of the texture take up. Although we now know the gap of each row of the screen, it may even be useful to cache either the width of the street or scale issue for every line.


The scaling factor would simply be the inverse of the gap, adjusted in order that the value is 1 on the road which the player's automotive graphic spends essentially the most time. This could then be used to scale sprites that are on a given line, or to find what the width of the street is. To curve a highway, you simply want to alter the place of the middle-line in a curve shape. There are a pair ways to do this. A method is to do it the way in which the Z positions had been executed in "The only Street": with three variables. That is, starting at the bottom of the screen, the quantity that the center of the road shifts left or proper per line steadily increases. Like with the texture reads, we are able to refer to these variables as the middle line (curve) place, the curve velocity, and the curve acceleration. There are some problems with this technique although.


One is that S-curves will not be very convinient. One other limitation that going into a flip appears the identical as coming out of a turn: The road bends, and merely unbends. To improve the state of affairs, we'll introduce the idea of highway segments. A street segment is a partition which is invisible to the player. Think of it as an invisible horizontal divide which units the curve of the road above that line. At any given time, one of those section dividers is at the underside of the display and one other is travelling down at a gradual rate in direction of the underside of the screen. Let's name the one at the bottom the bottom section, as a result of it units the initial curve of the road. When we begin drawing the street, the very first thing we do is look at the bottom point and set the parameters for drawing accordingly. As a turn approaches, the section line for that might start in the space and come in the direction of the player kind of like every other street object, except it needs to drift down the screen at a gradual price.