diff --git a/README.md b/README.md index fe6ee78..482515a 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,39 @@ And change the map itself : # raycasting --- +Raycasting is a technic that creates the illusion of 3D with very low computational power. + +This technic has the hability to not show hidden area by design, which is a great simplification for rendering. + +How it works : + +1. first you determine the position and orientation of the viewer in a plan, + +![](assets/raycast_step1.png) + +2. then you cast a ray until it reaches a wall + +![](assets/raycast_step2.png) + +3. you can now trace the vertical line on the 3D view + +![](assets/raycast_step3.png) + +4. the height of the wall is inversely proportional to the length of the ray : the closer the wall, the heigher it is + +![](assets/raycast_step4.png) + +5. finally, if the rays scan the whole picture, you see the perspective appears + +![](assets/raycast_steps.gif) + +6. but you can also see that walls are rounded, like a fish eye effect. It's because rays change length while scanning the wall, so we must apply a correction to the angle + +![](assets/raycast_steps_round.gif) + +example of raycasting in action while construction of the project : + +![example of raycasting during the construction of the project](assets/cube3d_raycasting.gif) diff --git a/assets/cube3d_raycasting.gif b/assets/cube3d_raycasting.gif new file mode 100644 index 0000000..387ee90 Binary files /dev/null and b/assets/cube3d_raycasting.gif differ diff --git a/assets/cube3d_raycasting_construction_gif.xcf b/assets/cube3d_raycasting_construction_gif.xcf new file mode 100644 index 0000000..7c342a4 Binary files /dev/null and b/assets/cube3d_raycasting_construction_gif.xcf differ diff --git a/assets/cube3d_raycasting_explanation.gif b/assets/cube3d_raycasting_explanation.gif new file mode 100644 index 0000000..041f512 Binary files /dev/null and b/assets/cube3d_raycasting_explanation.gif differ diff --git a/assets/cube3d_raycasting_explanation.xcf b/assets/cube3d_raycasting_explanation.xcf new file mode 100644 index 0000000..16cbfee Binary files /dev/null and b/assets/cube3d_raycasting_explanation.xcf differ diff --git a/assets/cube3d_raycasting_steps_construction.xcf b/assets/cube3d_raycasting_steps_construction.xcf new file mode 100644 index 0000000..e5f1b5e Binary files /dev/null and b/assets/cube3d_raycasting_steps_construction.xcf differ diff --git a/assets/cube3d_raycasting_steps_gif.xcf b/assets/cube3d_raycasting_steps_gif.xcf new file mode 100644 index 0000000..b43d9c8 Binary files /dev/null and b/assets/cube3d_raycasting_steps_gif.xcf differ diff --git a/assets/cube3d_raycasting_steps_gif_round.xcf b/assets/cube3d_raycasting_steps_gif_round.xcf new file mode 100644 index 0000000..5cc5710 Binary files /dev/null and b/assets/cube3d_raycasting_steps_gif_round.xcf differ diff --git a/assets/raycast_step1.png b/assets/raycast_step1.png new file mode 100644 index 0000000..2280480 Binary files /dev/null and b/assets/raycast_step1.png differ diff --git a/assets/raycast_step2.png b/assets/raycast_step2.png new file mode 100644 index 0000000..82b139c Binary files /dev/null and b/assets/raycast_step2.png differ diff --git a/assets/raycast_step3.png b/assets/raycast_step3.png new file mode 100644 index 0000000..515fa44 Binary files /dev/null and b/assets/raycast_step3.png differ diff --git a/assets/raycast_step4.png b/assets/raycast_step4.png new file mode 100644 index 0000000..5b0af00 Binary files /dev/null and b/assets/raycast_step4.png differ diff --git a/assets/raycast_steps.gif b/assets/raycast_steps.gif new file mode 100644 index 0000000..db583c6 Binary files /dev/null and b/assets/raycast_steps.gif differ diff --git a/assets/raycast_steps_round.gif b/assets/raycast_steps_round.gif new file mode 100644 index 0000000..3a0032c Binary files /dev/null and b/assets/raycast_steps_round.gif differ diff --git a/headers/cube3d_macro.h b/headers/cube3d_macro.h index a25bcca..1bf3e87 100644 --- a/headers/cube3d_macro.h +++ b/headers/cube3d_macro.h @@ -34,7 +34,7 @@ /* size of a cell on the map */ # define CELL 100 // minimum time in milliseconds between two keypress -# define DEBOUNCE_TIME 500 +# define DEBOUNCE_TIME 10 /*