diff options
Diffstat (limited to 'platformer/src/camera.h')
| -rw-r--r-- | platformer/src/camera.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/platformer/src/camera.h b/platformer/src/camera.h new file mode 100644 index 0000000..ead4bc9 --- /dev/null +++ b/platformer/src/camera.h @@ -0,0 +1,52 @@ +/* + * ============================================================ + * FILE: camera.h + * + * PURPOSE: Public interface for the third-person orbit camera: it sits + * on a sphere around the player and the right stick moves it + * around that sphere. + * + * FITS IN: main.c calls camera_update() each tick AFTER player_update(). + * player_update() receives camera_yaw() so "stick up" means "away + * from the camera". render.c reads camera_view()/camera_projection(). + * + * INTERFACE: Use these exact names: + * + * typedef struct Camera { + * Vec3 target; the smoothed point we look at (near the player) + * float yaw; orbit angle around the target, radians + * float pitch; angle above horizontal, radians + * float distance; meters from target + * Vec3 position; derived eye position (recomputed in camera_update) + * } Camera; + * + * void camera_init(Camera *c, Vec3 follow_point); + * void camera_update(Camera *c, const Input *in, Vec3 follow_point, float dt); + * follow_point = the player's feet position; the camera adds + * CAMERA_TARGET_HEIGHT itself. + * float camera_yaw(const Camera *c); + * Mat4 camera_view(const Camera *c); + * Mat4 camera_projection(const Camera *c, float aspect); + * + * YAW CONVENTION (player.c relies on this, so keep it exact): + * position = target + distance * ( sin(yaw)*cos(pitch), + * sin(pitch), + * cos(yaw)*cos(pitch) ) + * So on the ground plane, the camera's + * forward (toward target) = (-sin(yaw), 0, -cos(yaw)) + * right = ( cos(yaw), 0, -sin(yaw)) + * + * Include "math3d.h" and "controls.h". + * + * CONVENTIONS: Include guard: CAMERA_H. + * + * NOT IN SCOPE: Collision with geometry, automatic "behind the player" + * recentering, cutscene/fixed cameras, zoom levels. + * + * DONE WHEN: player.c and render.c can be written against this header alone. + * ============================================================ + */ +#ifndef CAMERA_H +#define CAMERA_H + +#endif /* CAMERA_H */ |
