51 std::snprintf(buf,
sizeof(buf),
"%.1fM", n / 1000000.0);
56 std::snprintf(buf,
sizeof(buf),
"%uk",
static_cast<unsigned>(n / 1000));
59 return std::to_string(n);
63 if (bytes >= 1024 * 1024) {
65 std::snprintf(buf,
sizeof(buf),
"%.1fMB", bytes / (1024.0 * 1024.0));
70 std::snprintf(buf,
sizeof(buf),
"%ukB",
static_cast<unsigned>(bytes / 1024));
73 return std::to_string(bytes) +
"B";
79 os <<
"rgba(" << c.
r <<
", " << c.
g <<
", " << c.
b <<
", " << c.
a <<
")";
84 os <<
"(" << v.x <<
", " << v.y <<
", " << v.z <<
")";
89 os <<
"Tri(" << t.
v0 <<
", " << t.
v1 <<
", " << t.
v2 <<
")";
113 os <<
"ClipPlane(n=" << cp.
normal <<
", off=" << cp.
offset <<
")";
118 float dist = glm::length(cam.
eye - cam.
center);
119 os <<
"Camera(eye=" << cam.
eye <<
", ctr=" << cam.
center
122 <<
", fov=" << std::fixed << std::setprecision(1) << cam.
fov_degrees <<
"°"
123 <<
", dist=" << std::fixed << std::setprecision(1) << dist <<
")";
132 else os <<
", ~norms";
133 if (m.
has_uvs()) os <<
", uvs";
139 os <<
", bb=[" << bmin <<
", " << bmax <<
"]";
146 os <<
"Scene(meshes=" << s.
meshes.size();
150 os <<
", bb=[" << bmin <<
", " << bmax <<
"]";
157 size_t bytes = img.
pixels.size();
164 os <<
"RenderOpts(" << opts.
width <<
"x" << opts.
height
167 else os <<
", ~cull";
169 <<
", lights=" << opts.
lights.size()
Camera definition and helper functions for view setup.
The Image — an RGBA pixel buffer with compositing and I/O operations.
The Mesh — the central data structure for 3D geometry in scimesh.
CropContentDirection
Direction(s) for the crop_to_content() operation.
@ BOTTOM
Crop bottom edge only.
@ RIGHT
Crop right edge only.
@ VERTICAL
Crop both top and bottom edges.
@ ALL
Crop all four edges.
@ LEFT
Crop left edge only.
@ HORIZONTAL
Crop both left and right edges.
MergeDirection
Direction for the merge() operation.
@ BOTTOM
Attach other below.
@ RIGHT
Attach other to the right side.
@ LEFT
Attach other to the left side.
glm::vec3 Vec3
3-component floating-point vector (xyz).
std::string fmt_size_bytes(size_t bytes)
const char * str_shading(ShadingMode s)
std::ostream & operator<<(std::ostream &os, const Color &c)
ShadingMode
How surface normals are interpolated across triangles.
@ FLAT
Flat shading: each triangle uses a single normal, giving a faceted, low-poly look.
std::string fmt_count(size_t n)
ProjectionType
The type of 3D→2D projection used by the camera.
@ ORTHOGRAPHIC
Orthographic projection: parallel lines stay parallel.
const char * str_projection(ProjectionType p)
const char * str_merge(MergeDirection d)
const char * str_crop(CropContentDirection d)
RenderOptions — all settings that control how meshes are drawn.
The Scene — a collection of meshes rendered together.
A virtual camera that defines the viewpoint for rendering.
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).
A clipping plane that can hide parts of the scene.
Vec3 normal
The plane normal vector (should be unit-length).
float offset
Offset along the normal.
An RGBA color with floating-point components.
float g
Green channel, [0, 1].
float r
Red channel, [0, 1].
float b
Blue channel, [0, 1].
float a
Alpha (opacity) channel, [0, 1]. 1.0 = fully opaque.
int height
Image height in pixels.
int width
Image width in pixels.
std::vector< uint8_t > pixels
Raw pixel data: RGBA bytes, row-major, bottom-left origin.
A light source for the Blinn-Phong shading model.
bool is_directional
Whether this is a directional light (default: true).
Color color
Color of the light (default: white).
Vec3 position
Position of the light.
float intensity
Brightness multiplier (default: 1.0).
A 3D triangle mesh using an indexed face set representation.
bool has_uvs() const
Does the mesh have texture coordinates?
bool has_transparency
Whether the mesh contains any transparent fragments.
bool has_colors() const
Does the mesh have per-vertex colors?
bool has_normals() const
Does the mesh have per-vertex normals?
void compute_bounding_box(Vec3 &min_bound, Vec3 &max_bound) const
Compute the axis-aligned bounding box (AABB) of the mesh.
std::vector< Vec3 > vertices
3D vertex positions.
bool has_texture() const
Does the mesh have a texture image?
std::vector< Triangle > triangles
Triangle index triplets.
All settings that control rendering output.
std::vector< Light > lights
List of light sources.
bool fog_enabled
Enable depth fog (default: false).
Color background_color
Background color (default: opaque white).
float ambient
Ambient light level (default: 0.3).
int height
Image height in pixels (default: 600).
int width
Image width in pixels (default: 800).
float ssao_intensity
SSAO darkening intensity (default: 0.8).
bool backface_culling
Enable backface culling (default: true).
bool ssao_enabled
Enable SSAO (default: false).
int threads
Number of render threads (default: 0 = auto-detect).
int aa_samples
Anti-aliasing sample count (default: 1 = no AA).
bool wireframe
Draw triangle edges as lines (default: false).
float ssao_radius
SSAO sample radius in pixels (default: 16).
ShadingMode shading
Shading mode (default: SMOOTH).
A collection of Mesh objects to be rendered together.
std::vector< Mesh > meshes
The meshes in this scene, drawn in order.
void compute_bounding_box(Vec3 &min_bound, Vec3 &max_bound) const
Compute the combined axis-aligned bounding box of all meshes, after applying each mesh's placement tr...
A triangle defined by three vertex indices.
uint32_t v2
Index of the third vertex in Mesh::vertices.
uint32_t v1
Index of the second vertex in Mesh::vertices.
uint32_t v0
Index of the first vertex in Mesh::vertices.
Fundamental types used throughout the scimesh rendering engine.