ttypt/lam-cam.h(3)liblaminaVersion 1.0.0

NAME

ttypt/lam-cam.h - 3D Camera, matrix math, and perspective projection for liblamina.

SYNOPSIS

#include <stdint.h>
#include <stdbool.h>

Functions

void lam_mat4_identity (float m[16])

Initialize matrix to 4x4 identity.

void lam_mat4_mul (float out[16], const float a[16], const float b[16])

Multiply two 4x4 matrices: out = a * b.

void lam_mat4_translate (float m[16], float x, float y, float z)

Apply translation to matrix m.

void lam_mat4_scale (float m[16], float sx, float sy, float sz)

Apply scaling to matrix m.

void lam_mat4_rotate_x (float m[16], float rad)

Rotate matrix m around X axis by angle in radians.

void lam_mat4_rotate_y (float m[16], float rad)

Rotate matrix m around Y axis by angle in radians.

void lam_mat4_rotate_z (float m[16], float rad)

Rotate matrix m around Z axis by angle in radians.

void lam_mat4_perspective (float m[16], float fov_rad, float aspect, float near_z, float far_z)

Construct standard perspective projection matrix.

void lam_mat4_ortho (float m[16], float l, float r, float b, float t, float n, float f)

Construct standard orthographic projection matrix.

void lam_mat4_look_at (float m[16], const float eye[3], const float target[3], const float up[3])

Construct view matrix looking from eye towards target with given up vector.

bool lam_mat4_invert (float out[16], const float in[16])

Invert a 4x4 matrix. Returns true on success, false if singular.

void lam_cam_set_3d (float target_x, float target_y, float distance, float pitch_deg, float yaw_deg, float fov_deg)

Configure and activate the 3D camera.

void lam_cam_set_2d (void)

Restore classic 2D orthographic rendering mode.

int lam_cam_is_3d (void)

Check if 3D camera mode is currently active.

const lam_cam_t * lam_cam_get (void)

Get pointer to active camera state.

void lam_cam_get_vp (float out[16])

Copy the current View-Projection matrix into out.

void lam_cam_get_right (float r[3])

Get the camera right vector in world coordinates.

int lam_unproject_ground (int32_t screen_x, int32_t screen_y, float *out_x, float *out_y)

Cast a ray from screen coordinates and find intersection with ground plane Z=0.

Detailed Description

3D Camera, matrix math, and perspective projection for liblamina.

Provides a lightweight 3D pipeline for 2.5D tilted-camera and full 3D views, including 4x4 matrix operations, camera setup, ray-plane unprojecting, ground tiles, and billboard sprites.

Function Documentation

void lam_cam_set_3d (float target_x, float target_y, float distance, float pitch_deg, float yaw_deg, float fov_deg)

Configure and activate the 3D camera.

Parameters

target_x,target_y Target world coordinates on the ground plane
distance Camera distance / zoom
pitch_deg Camera tilt angle in degrees (e.g. 45..60)
yaw_deg Camera yaw rotation angle in degrees
fov_deg Field of view in degrees (e.g. 45.0)

int lam_unproject_ground (int32_t screen_x, int32_t screen_y, float * out_x, float * out_y)

Cast a ray from screen coordinates and find intersection with ground plane Z=0.

Parameters

screen_x,screen_y Screen pixel coordinates
out_x,out_y Output world coordinates on the ground plane

Returns

1 on intersection, 0 if parallel or pointing away

Author

Generated automatically by Doxygen for liblamina from the source code.