[Prev] [Home] [Next]


Ray casting is fast because it utilizes some geometric constraints. In most cases, walls are always at 90 degrees angle with the floor. (Note that we are not talking about the angle between walls and another walls, but the angle between walls and floor.)

Thus, a limitation that almost exists on a ray-casting game is that the viewpoint cannot be rotated along the Z axis (Figure 5). If this is allowed, then walls could be slanted and the benefit of drawing in vertical slices will be lost. This inability to rotate along the Z axis is one of the reason of why ray-casting environment is not regarded as a true three dimensional environment.

Figure 5: On a ray-casting environment, the player can move forward, backward, and turn left or right; but cannot rotate/swing around the Z-axis (this kind of Z-axis rotation is called a tilt).


To illustrate the process of ray-casting, we will create a maze world that has the following geometric constraints:
    1. Walls are always at 90° angle with the floor.
    2. Walls are made of cubes that have the same size.
    3. Floor is always flat.
For our purpose, each cube will have the size of 64x64x64 units. (The choice of 64 is arbitrary, but it will be useful to pick a number that is a multiple of 2; because we can perform some arithmetic shift operations on such number (shift operations are faster than multiplication or division). The larger the size of the cube, the blockier the world will look like, but smaller cube will make the rendering slower.)

Such a world is illustrated in Figure 6.

Figure 6

Before continuing, we will define our coordinate system so that there is no confusion. The coordinate system that we use is illustrated in Figure 7.
Figure 7

Note: Any kind of cartesian coordinate system would work just as well. However, you do have to be consistent (don't use the top-down coordinate system for one thing but then use the buttom-up coordinate for others). You'd be likely to confuse yourself if you do this - I did.

[Prev] [Home] [Next]