terrain

Real-time terrain generation using marching cubes
git clone git://git.christianermann.dev/terrain
Log | Files | Refs | README | LICENSE

camera.h (711B)


      1 #ifndef CAMERA_H
      2 #define CAMERA_H
      3 
      4 #include "input.h"
      5 #include "vec.h"
      6 #include "transform.h"
      7 #include "types.h"
      8 
      9 typedef struct {
     10     Vec3 n;
     11     Vec3 p;
     12 } Plane;
     13 
     14 typedef struct {
     15     Transform *transform;
     16 
     17     f32 fovy;
     18     f32 aspect;
     19     f32 near;
     20     f32 far;
     21 
     22     Mat4 matrix;
     23 
     24     f32 near_h;
     25     f32 near_w;
     26     f32 far_h;
     27     f32 far_w;
     28     Plane frustum[6];
     29 
     30 } Camera;
     31 
     32 Camera *Camera_make(Transform *t);
     33 void Camera_free(Camera *camera);
     34 
     35 void Camera_defaultSettings(Camera* camera);
     36 
     37 // Update the (projection * view) matrix of the camera.
     38 void Camera_updateMatrix(Camera* camera);
     39 
     40 void Camera_updateFrustum(Camera *camera);
     41 b8 Camera_sphereInFrustum(const Camera *camera, Vec3 p, f32 r);
     42 
     43 #endif