184 float near_plane,
float far_plane);
220 for (
int i = 0;
i < 8;
i++) {
263 for (
int i = 0;
i < 8;
i++) {
298 float fov_degrees,
float margin = 1.1f,
327 const Vec3 &up,
float fov_degrees,
float margin = 1.1f,
351 const Vec3 &up,
float fov_degrees,
float margin = 1.1f,
glm::vec2 Vec2
2-component floating-point vector (xy).
Camera camera_look_at(const Vec3 ¢er, float radius, const Vec3 &direction, const Vec3 &up, float fov_degrees, float margin, ProjectionType projection)
Create a camera that looks at a point from a given distance and direction.
glm::mat4 Mat4
4×4 floating-point matrix.
glm::vec3 Vec3
3-component floating-point vector (xyz).
Camera camera_fit_scene(const Scene &scene, const Vec3 &direction, const Vec3 &up, float fov_degrees, float margin, ProjectionType projection)
Create a camera that automatically frames an entire Scene.
Camera camera_fit_mesh(const Mesh &mesh, const Vec3 &direction, const Vec3 &up, float fov_degrees, float margin, ProjectionType projection)
Create a camera that automatically frames a single Mesh.
ProjectionType
The type of 3D→2D projection used by the camera.
@ ORTHOGRAPHIC
Orthographic projection: parallel lines stay parallel.
@ PERSPECTIVE
Perspective projection: objects farther away appear smaller.
float perp_extent_radius(const Vec3 &bmin, const Vec3 &bmax, const Vec3 ¢er, const Vec3 &dir, float fov_radians, float *out_dist=nullptr)
Compute the "perpendicular extent radius" of an axis-aligned bounding box relative to a view directio...
float max_ortho_extent(const Vec3 &bmin, const Vec3 &bmax, const Vec3 ¢er, const Vec3 &dir)
Compute the maximum perpendicular extent of an AABB from a view ray (for orthographic projection fram...
Camera camera_orbit(const Camera &camera, const Vec3 &axis, float angle_degrees)
Orbit the camera around its look-at point.
ProjectedPoint world_to_screen(const Camera &camera, const Vec3 &world, int width, int height, ProjectionType projection, float near_plane, float far_plane)
Project a world-space point to the pixel coordinates of a rendered image.
The Scene — a collection of meshes rendered together.
A virtual camera that defines the viewpoint for rendering.
Mat4 get_view_matrix() const
Compute the view matrix (world → camera space).
ProjectionType projection
Which projection type to use.
Vec3 center
The point the camera looks at.
Vec3 up
The camera's "up" direction.
Vec3 eye
Camera position in world space.
float fov_degrees
Vertical field of view in degrees (perspective only).
Mat4 get_projection_matrix(float aspect_ratio, float near_plane, float far_plane) const
Compute the projection matrix (camera → clip space).
A world-space point projected into the rendered image.
bool in_front
Whether the point is in front of the camera.
float depth
Depth in normalized device coordinates, in [-1, 1]; smaller values are closer to the camera.
Vec2 pixel
Pixel coordinates, origin at the top left, y growing down.
int x
Left edge of the bitmap, in image pixels.
Fundamental types used throughout the scimesh rendering engine.