According to this article about making a simple raycasting engine (like the one that was used in Wolfenstein3d), the distance between the player and the projection plane will be constant.

For example, suppose we are using a projection plane of dimension 320 X 200, and player's field of view (fov) is 60 degrees. Then the distance from the player to the projection plane is going to be

160 / tan(30 degrees) = 277 units

I can understand the trigonometry, but I can't understand why would the distance remain constant througout the game? Why wouldn't the distance change when the player moves closer or farther away from the projection plane?


It would change if the player moved closer or farther away from the projection plane (I can image you could still do that for some special effects though). However, he does not.
You can think of it this way: your eye is the player(camera) and your computer screen a window(projection plane) into the games world - naturally this distance is constant. When you walk in-game, you do not move the player but actually move the world in opposite direction.

  • \$\begingroup\$ Is the world moving instead of player? I read the article, I think the player is actually moving while the world is static. \$\endgroup\$
    – arandomguy
    Aug 2 '16 at 2:01
  • \$\begingroup\$ Also the player is the player inside the 3d world who is moving. It doesn't say anything about the eye. \$\endgroup\$
    – arandomguy
    Aug 2 '16 at 2:02
  • \$\begingroup\$ Relative to the screen (projection plane) it's the world that is moving, the screen doesn't move, the screen's pixels stay in the same place (pixel (1,1) is always pixel (1,1)). The model-view matrix is the opposite of the camera movement so it's the world that is moved to the screen. It sounds crazy but that's how the math works. The projection plane "follows" the player like a pair of glasses on his face so the distance doesn't change. \$\endgroup\$ Aug 2 '16 at 4:36
  • \$\begingroup\$ @StephaneHockenhull I can understand that you're talking about openGl stuffs, but in that tutorial openGl isn't used. No matrices are used in the tutorial. It just uses high school trigonometry. \$\endgroup\$
    – arandomguy
    Aug 2 '16 at 8:07
  • \$\begingroup\$ @Raj yes, it is trigonometry, but it does the same. Since they locked one dimension they can get away by doing all the work matrices do "by hand" using trigonometry. You can see it at p7, they are getting local camera coordinates. \$\endgroup\$
    – wondra
    Aug 2 '16 at 9:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.