$darkmode
First-person camera module with realistic physics and head-bobbing. More...
#include <cglm/cglm.h>Go to the source code of this file.
Data Structures | |
| struct | Camera |
| Represents a 3D camera with orientation, movement, and physical properties. More... | |
Macros | |
| #define | DEFAULT_CAMERA_SPEED 15.0F |
| #define | DEFAULT_CAMERA_SENSITIVITY 0.15F |
| #define | DEFAULT_CAMERA_ZOOM 60.0F |
| #define | DEFAULT_ZOOM_SPEED 1.0F |
| #define | DEFAULT_SCROLL_SENSITIVITY 50.0F |
| #define | DEFAULT_MAX_PITCH 89.0F |
| #define | DEFAULT_MIN_PITCH -89.0F |
| #define | DEFAULT_MAX_ALPHA 1.0F |
| #define | DEFAULT_ACCELERATION 10.0F |
| #define | DEFAULT_FRICTION 0.85F |
| #define | DEFAULT_ROTATION_SMOOTHING 0.18F |
| #define | DEFAULT_BOBBING_FREQUENCY 2.2F |
| #define | DEFAULT_BOBBING_AMPLITUDE 0.0004F |
| #define | DEFAULT_MIN_VELOCITY_FOR_BOBBING 0.5F |
| #define | DEFAULT_BOBBING_RESET_SPEED 0.95F |
| #define | DEFAULT_MIN_VELOCITY 0.01F |
| #define | DEFAULT_TARGET_FPS 60 |
| #define | DEFAULT_FIXED_TIMESTEP (1.0F / DEFAULT_TARGET_FPS) |
| #define | DEFAULT_MOUSE_SMOOTHING_FACTOR 0.1F |
Functions | |
| void | camera_init (Camera *cam, float distance, float yaw, float pitch) |
| Initializes the camera with default values. More... | |
| void | camera_update_vectors (Camera *cam) |
| Recalculates front, right, and up vectors from yaw and pitch. More... | |
| void | camera_process_mouse (Camera *cam, float xoffset, float yoffset) |
| Processes mouse movement to update target orientation. More... | |
| void | camera_get_view_matrix (Camera *cam, mat4 view) |
| Generates the 4x4 view matrix for this camera. More... | |
| void | camera_process_scroll (Camera *cam, float yoffset) |
| Processes mouse scroll events to apply physical impulse. More... | |
| void | camera_fixed_update (Camera *cam) |
| Performs one fixed-step physics update. More... | |
First-person camera module with realistic physics and head-bobbing.
| #define DEFAULT_ACCELERATION 10.0F |
Physical push strength.
| #define DEFAULT_BOBBING_AMPLITUDE 0.0004F |
Height of head-bob.
| #define DEFAULT_BOBBING_FREQUENCY 2.2F |
Waves per meter.
| #define DEFAULT_BOBBING_RESET_SPEED 0.95F |
Decay of bobbing offset.
| #define DEFAULT_CAMERA_SENSITIVITY 0.15F |
Mouse scaling.
| #define DEFAULT_CAMERA_SPEED 15.0F |
Units per second.
| #define DEFAULT_CAMERA_ZOOM 60.0F |
Default FOV.
| #define DEFAULT_FIXED_TIMESTEP (1.0F / DEFAULT_TARGET_FPS) |
Simulation step.
| #define DEFAULT_FRICTION 0.85F |
Velocity decay per frame.
| #define DEFAULT_MAX_ALPHA 1.0F |
Unused.
| #define DEFAULT_MAX_PITCH 89.0F |
Upward look limit.
| #define DEFAULT_MIN_PITCH -89.0F |
Downward look limit.
| #define DEFAULT_MIN_VELOCITY 0.01F |
Cutoff for full stop.
| #define DEFAULT_MIN_VELOCITY_FOR_BOBBING 0.5F |
threshold to trigger bobbing.
| #define DEFAULT_MOUSE_SMOOTHING_FACTOR 0.1F |
Input lag simulation.
| #define DEFAULT_ROTATION_SMOOTHING 0.18F |
Orientation lerp factor.
| #define DEFAULT_SCROLL_SENSITIVITY 50.0F |
Scroll impulsiveness.
| #define DEFAULT_TARGET_FPS 60 |
Reference for fixed updates.
| #define DEFAULT_ZOOM_SPEED 1.0F |
FOV adjustment rate.
| void camera_fixed_update | ( | Camera * | cam | ) |
Performs one fixed-step physics update.
Handles momentum, friction, and head-bobbing calculations.
| cam | Pointer to the camera instance. |
| void camera_get_view_matrix | ( | Camera * | cam, |
| mat4 | view | ||
| ) |
Generates the 4x4 view matrix for this camera.
| cam | Pointer to the camera instance. | |
| [out] | view | Matrix to populate. |
| void camera_init | ( | Camera * | cam, |
| float | distance, | ||
| float | yaw, | ||
| float | pitch | ||
| ) |
Initializes the camera with default values.
| cam | Pointer to the camera instance. |
| distance | Initial forward offset (legacy). |
| yaw | Initial horizontal rotation. |
| pitch | Initial vertical rotation. |
| void camera_process_mouse | ( | Camera * | cam, |
| float | xoffset, | ||
| float | yoffset | ||
| ) |
Processes mouse movement to update target orientation.
| cam | Pointer to the camera instance. |
| xoffset | Relative horizontal mouse movement. |
| yoffset | Relative vertical mouse movement. |
| void camera_process_scroll | ( | Camera * | cam, |
| float | yoffset | ||
| ) |
Processes mouse scroll events to apply physical impulse.
| cam | Pointer to the camera instance. |
| yoffset | Scroll amount along the y-axis. |
| void camera_update_vectors | ( | Camera * | cam | ) |
Recalculates front, right, and up vectors from yaw and pitch.
| cam | Pointer to the camera instance. |