#ifndef __RENDERH__ # define __RENDERH__ #include "settings.h" #include "util.h" #include struct camera { //======= Fixed settings =======// /* Vertical FOV, in degrees. */ num fov; void set_fov(num fov); /* Distance to the screen (world units). */ num screen_distance() const { return this->_sd; } /* Distance to the near plane, for clipping. TODO: Figure out a better choice of a near plane. */ num near_plane() const { return this->screen_distance() * num(0.75); } //======= World data =======// /* Position in space; always looking towards +z. */ vec3 pos; /* Current platform (used to assign colors). */ int platform; /* Vector canceling the player's angular rotation around z. */ vec2 angle_vector; //======= Screen settings =======// /* Screen size. */ vec2 screen_size; private: num _sd; }; struct player; /* Move the camera to track behind a player. */ void camera_track(struct camera *, struct player const *); /* Project a world point to the screen as viewed through a camera. The returned vector has its x/y members set to screen coordinates stored as num; the z member is kept unchanged. */ vec3 camera_project_point(struct camera *, vec3 point); /* Optimized camera_project_point() that projects an entire prect in-place. */ void camera_project_prect(struct camera *, struct prect *rect); /* Compute the platform's color based on the camera's angle. */ int camera_platform_color(struct camera *camera, int platform_id); /* Queue an Azur command to render the triangle defined by p1/p2/p3. Only the x/y coordinates are used, z is ignored. */ void render_triangle(vec3 *p1, vec3 *p2, vec3 *p3, int color); /* Queue Azur commands to render a list of dots. Only x/y coordinates are used, z is ignored. */ void render_dots(std::initializer_list const &&points); #endif /* __RENDERH__ */