World: Implement raycaster
Implement the basic raycaster, checking every block intersection and the block linked to that position. Split the screen uniformally along the width. Add data needed for camera maths in the Player class Specify constraints on the raycast parameters. Render the screen using the raycasts. Call the renderer in the main loop.
This commit is contained in:
parent
34625a841d
commit
b359ff171f
4 changed files with 126 additions and 28 deletions
6
Player.h
6
Player.h
|
@ -5,6 +5,9 @@
|
|||
#ifndef RAYCASTING_PLAYER_H
|
||||
#define RAYCASTING_PLAYER_H
|
||||
|
||||
#include <cmath>
|
||||
|
||||
static constexpr float deg_to_rad = 3.14159265/180;
|
||||
|
||||
class Player {
|
||||
public:
|
||||
|
@ -14,7 +17,10 @@ public:
|
|||
float y;
|
||||
float orientation;
|
||||
|
||||
/* View properties. */
|
||||
float fov = 70;
|
||||
float sensorSize = 0.035; /* 35mm, about equivalent to human eye ? */
|
||||
float focalLength = sensorSize / (2*tanf((fov*deg_to_rad)/2));
|
||||
|
||||
void move(float dx, float dy);
|
||||
void rotate(float alpha);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue