Ray-casting technology training. Part 2

Greetings, reader. This is the second part of the "Ray-Casting Tutorial For Game Development And Other Purposes" translation series. The second part is preceded by the first, which can also be viewed .

Let's start! Let's continue!

Ray-casting limitations

Ray casting technology is fast because it uses some geometric constraints. In most cases, the walls are always perpendicular to the floor (note that this does not apply to the corners between the walls themselves).

From this we get another limitation: the viewpoint cannot rotate along the Z-axis (which we all know as the axis of the applicate - approx. Per.). Why? Imagine the opposite: rotation is allowed. In this case, the walls can tilt, and, accordingly, the advantage of drawing vertical cuts of these same walls is lost. Rotation limitation is one of the reasons why ray casting cannot be considered full 3D.

The ray-casting technology allows the player to move forward / backward and turn right / left, but not rotate around the Z axis (this type of rotation is called roll (if the Y axis is vertical, then rotation along it is pitch, and along the X axis is yaw, - approx. . per.)).

Step 1: creating the environment

In order to render the ray casting work, we will create a maze scene based on the following geometric constraints:

  •   

64x64x64 ( , , 2. , ). , , , ,  .

, ( - ), - . .

. , .  -  .

2.

,    , . :

  • , (FOV - Field Of View),

, . FOV, , . FOV 90° . , . 60°, ( - FOV). , 32 . , , . ( -, : 2.4  / 1.7 = 1.41 - . .).

,  -  , . , , FOV - . .

, X-, Y- . 3 POV (point of view) .

, - (1, 2), 45 , FOV , . ( 64x64 ).

POV, . - FOV - . - . .

, , . 320 200 - , ..  VG .

POV , , .

FOV .

:

, ( ): 320200 (160, 100). " ". - . .

( , , , , ).

FOV 60. 320 , 60° 320 , , 1 60 / 320 . - . .

FOV . , 320 / 2 = 160 : 90°, 60° / 2 = 30° 90° - 30° = 60° .    (277), . - . .

:

  • () = 320200

  • (160, 100)

  • = 277

  • = 60 / 320

(We will sometimes refer to the angle between successive rays as the angle between adjacent columns. Later this angle will be used to iterate within the loop from one column to the next. The distance to the projection plane will be needed for scaling.)

End of the second part




All Articles