1
0
Fork 0
2018-soft-3d-renderer/include/camera.h

46 lines
774 B
C

#ifndef CAMERA_H
#include "point.h"
#include "util.h"
#include <cmath>
// STRUCTURE
struct Camera
{
inline Camera(void)
{
position.x = 0.0f;
position.y = 0.0f;
position.z = 0.0f;
rotation[0] = 0.0f;
rotation[1] = 0.0f;
rotation[2] = 0.0f;
nearClip = 5.0f;
farClip = 600.0f;
}
inline void SetFOV(float fov, int winWidth, int winHeight)
{
xZoom = 1.0f / tanf(DEG_TO_RAD(fov/2.0f));
yZoom = (xZoom * winWidth) / winHeight;
xScale = (0.5f * winWidth) - 0.5f;
yScale = (0.5f * winHeight) - 0.5f;
}
Point position;
float rotation[3];
float nearClip, farClip;
float xZoom, yZoom;
float xScale, yScale;
};
#define CAMERA_H
#endif