Ray Casting Tutorial – Part 17
May 17, 1996
Share this:Share on FacebookTweet about this on TwitterShare on TumblrPin on PinterestShare on Google+


B. Flying and crouching.
Recall that the player’s height is set to be 32 units. This means that the player’s eyes (imagine the player’s eyes are exactly on top of the player’s head) are looking straight at the walls at point 32. Since 32 is one half of the walls’ height, having the player’s height at 32 makes the player’s eyes halfway between the floor and the ceiling (see next figure).

What if we change this value? Surprisingly (or maybe not), the walls will shift either upward or downward depending on whether the player’s height is increased or decreased.

Thus, to make the player as if he/she is flying (or leaping), we can simplyincrease the player’s height. Similarly, to make the player as if she/he iscrouching, we can decrease the player’s height. The height should not be allowed to be less than 0 or greater than walls’ height, because doing that will make the player go over the ceiling or sink into the floor.

The next figure shows why this method works.


If you’re confused, again we use the mirror method to clarify how this works. Imagine that that you are standing straight, holding a mirror on a small room. Stand facing away from the wall. Position the mirror so that it’s in front of the eye (i.e.: you do not have to turn your head to see the mirror). Now, imagine what happen if you squat and see what is in the mirror. In the mirror, you should see different part of the wall and more floor area… like 2nd image on this page …. hope you got the idea.

The mirror is the projection plane, and the eye position is the player’s height.

There’s one counter intuitive aspect of this vertical-motion method, which is this:

the projection plane must always be perpendicular with the player’s eyes. (That is: the projection plane must always be parallel to the walls – they cannot be skewed in any way.) The best way to conceptualize this is to imagine a person “aiming” through a camera lens. The person always aims in forward direction at 90 degrees angle; even when he/she is crouching or standing on top of a table.

The reason for this is that when using this method, we can not skew the projection plane like in the next figure; because if we rotate the projection plane to follow the “normal” eye direction, then the walls will be slanted (no longer parallel with the projection plane); and the rendering process must then take this into account. That means, more complex calculation will be required, and the rendering process will become terribly slow.

This is how a more realistic looking down is supposed to happen:
when you look down, you move not only your eye, but also your head, so that the perspective is different (compare with the previous 6 pictures). The technique descibed on this page uses tricks earlier to “simulate” this.


Share this:Share on FacebookTweet about this on TwitterShare on TumblrPin on PinterestShare on Google+