You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1021 B
69 lines
1021 B
|
|
#pragma once |
|
|
|
#include <glm/glm.hpp> |
|
|
|
#include "types.h" |
|
|
|
using glm::ivec2; |
|
using glm::vec2; |
|
using glm::vec3; |
|
using glm::mat4; |
|
|
|
|
|
struct Camera |
|
{ |
|
float hAngle; |
|
float vAngle; |
|
|
|
vec3 position; |
|
vec3 forward; |
|
vec3 up; |
|
vec3 left; |
|
vec3 target; |
|
vec3 world_up; |
|
|
|
mat4 model; |
|
mat4 view; |
|
mat4 projection; |
|
mat4 MVP; |
|
}; |
|
|
|
|
|
// FIXME: we should keep to our convention of passing pointers to structs in |
|
// these interface functions |
|
vec2 |
|
cameraUnproject(Camera& cam, int x, int y, int vp_width, int vp_height); |
|
|
|
vec3 |
|
cameraCreateRay(Camera& cam, ivec2 vp_coords, ivec2 vp_dims); |
|
|
|
bool |
|
cameraIntersectPlane(Camera& cam, |
|
vec3 ray, |
|
vec3 plane_origin, |
|
vec3 plane_normal, |
|
vec3& intersection); |
|
|
|
void |
|
cameraInitPerspective(Camera* cam, |
|
vec3 position, |
|
vec3 target, |
|
vec3 world_up, |
|
float aspect_ratio = 16.f / 9.f); |
|
|
|
void |
|
cameraMove(Camera& cam, |
|
bool up, |
|
bool left, |
|
bool down, |
|
bool right, |
|
bool forward, |
|
bool backward); |
|
|
|
void |
|
cameraRotate(Camera& cam, i32 xrel, i32 yrel); |
|
|
|
void |
|
cameraRoll(Camera& cam, bool CW, bool CCW); |
|
|
|
|