0

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?

anonymous
  • 514
  • 1
  • 8
  • 21

1 Answers1

1

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.

wondra
  • 4,920
  • 1
  • 22
  • 36
  • Is the world moving instead of player? I read the article, I think the player is actually moving while the world is static. – anonymous Aug 02 '16 at 02:01
  • Also the player is the player inside the 3d world who is moving. It doesn't say anything about the eye. – anonymous Aug 02 '16 at 02:02
  • 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. – Stephane Hockenhull Aug 02 '16 at 04:36
  • @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. – anonymous Aug 02 '16 at 08:07
  • @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. – wondra Aug 02 '16 at 09:40
  • @Raj, in a ray casting engine it's a 2D projection matrix into a 1D view line, rather than 3D projection into a 2D view plane but it's the same thing otherwise. Because the Y coordinate is always zero all those extra operations get eliminated into basic high school trigonometry. A line is a plane with a height of zero (or width of zero). – Stephane Hockenhull Aug 03 '16 at 00:53