<<PREVIOUS | TABLE OF CONTENTS | CONTINUE >> HORIZONTAL MOTION The player should be able to move at least in three ways: forward, backward, and turning. The player’s position is defined by a coordinate and a viewing angle. To allow motion, two more attributes are needed. They are the player’s movement speed, and the player’s turning […]

<<PREVIOUS | TABLE OF CONTENTS | CONTINUE >> VARIABLE HEIGHT WALLS So far, all the walls in our world have the same height. With some innovations, we can actually use walls of different height. This makes the world more interesting as illustrated in the next figure. Figure 28: Variable height walls The easiest way to conceptualize […]

<<PREVIOUS | TABLE OF CONTENTS | CONTINUE >> DRAWING CEILINGS To draw the ceiling, the floor-casting process can be reversed. Instead of tracing rays from the bottom of a wall slice in downward direction, trace the ray from the top of the wall in the upward direction. This is actually pretty straightforward once the theory behind […]

<<PREVIOUS | TABLE OF CONTENTS | CONTINUE >> FLOOR CASTING (Continued) The math behind floor-casting is explained in the Figure 25 below. Figure 25: The math behind floor-casting. To reiterate, take a look at the illustration while reading these steps: * Start from the bottom of the wall slice. Take the pixel position (you have this […]

<<PREVIOUS | TABLE OF CONTENTS | CONTINUE >> DRAWING FLOORS To draw floors, we can perform floor-casting (floor-casting refers to a techique of rendering floors). Note however, that it would be wasteful to perform floor-casting without texture mapping or shading. In other words, if the floor is not to be textured or shaded (shading will be […]

<<PREVIOUS | TABLE OF CONTENTS | CONTINUE >> TEXTURE MAPPED WALLS To make the walls more attractive, the walls can be painted with texture (bitmap) using a technique known as texture mapping. (Texture mapping in general refers to a technique of painting a bitmap/texture onto a surface.) For the cube world, we use bitmaps that have […]

<<PREVIOUS | TABLE OF CONTENTS | CONTINUE >> RAY-CASTING STEP 5: DRAWING WALLS In the previous steps, 320 rays are casts, when each ray hits a wall, the distance to that wall is computed. Knowing the distance, the wall slice can then be projected onto the projection plane. To do this, the height of the projected […]

<<PREVIOUS | TABLE OF CONTENTS | CONTINUE >> RAY-CASTING STEP 4: FINDING DISTANCE TO WALLS There are several ways to find the distance from the viewpoint (player) to the wall slice. They are illustrated below.   Figure 17: Finding distance to a wall slice.   The sine or cosine functions are cheaper to implement because they […]

<<PREVIOUS | TABLE OF CONTENTS | CONTINUE >> To find walls, we need to check any grid intersection points that are encountered by the ray; and see if there is a wall on the grid or not. The best way is to check for horizontal and vertical intersections separately. When there is a wall on either […]

<<PREVIOUS | TABLE OF CONTENTS | CONTINUE >> RAY-CASTING STEP 3: FINDING WALLS Notice from the previous image (Figure 11), that the wall can be viewed as collection of 320 vertical lines (or 320 wall slices). Figure 12 This is precisely a form of geometrical constraints that will be suitable for ray-casting. Instead of tracing a […]