59 std::snprintf(
buf,
sizeof(
buf),
"%.1fM",
n / 1000000.0);
64 std::snprintf(
buf,
sizeof(
buf),
"%uk",
static_cast<unsigned>(
n / 1000));
67 return std::to_string(
n);
71 if (
bytes >= 1024 * 1024) {
73 std::snprintf(
buf,
sizeof(
buf),
"%.1fMB",
bytes / (1024.0 * 1024.0));
78 std::snprintf(
buf,
sizeof(
buf),
"%ukB",
static_cast<unsigned>(
bytes / 1024));
81 return std::to_string(
bytes) +
"B";
87 os <<
"rgba(" <<
c.r <<
", " <<
c.g <<
", " <<
c.b <<
", " <<
c.a <<
")";
92 os <<
"(" <<
v.x <<
", " <<
v.y <<
", " <<
v.z <<
")";
97 os <<
"Tri(" <<
t.v0 <<
", " <<
t.v1 <<
", " <<
t.v2 <<
")";
114 os <<
"Light(pos=" <<
l.position <<
", color=" <<
l.color
115 <<
", I=" <<
l.intensity
116 <<
", " << (
l.is_directional ?
"dir" :
"point") <<
")";
121 os <<
"ClipPlane(n=" <<
cp.normal <<
", off=" <<
cp.offset
127 float dist = glm::length(
cam.eye -
cam.center);
128 os <<
"Camera(eye=" <<
cam.eye <<
", ctr=" <<
cam.center
131 <<
", fov=" << std::fixed << std::setprecision(1) <<
cam.fov_degrees <<
"°"
132 <<
", dist=" << std::fixed << std::setprecision(1) <<
dist <<
")";
138 <<
", tris=" <<
fmt_count(
m.triangles.size());
139 if (
m.has_colors())
os <<
", cols";
140 if (
m.has_normals())
os <<
", norms";
141 else os <<
", ~norms";
142 if (
m.has_uvs())
os <<
", uvs";
143 if (
m.has_texture())
os <<
", tex";
144 if (
m.has_transparency)
os <<
", transp";
145 if (!
m.vertices.empty()) {
148 os <<
", bb=[" <<
bmin <<
", " <<
bmax <<
"]";
155 os <<
"Scene(meshes=" <<
s.meshes.size();
156 if (!
s.meshes.empty()) {
159 os <<
", bb=[" <<
bmin <<
", " <<
bmax <<
"]";
167 os <<
"Image(" <<
img.width <<
"x" <<
img.height
173 os <<
"RenderOpts(" <<
opts.width <<
"x" <<
opts.height
175 if (
opts.backface_culling)
os <<
", cull";
176 else os <<
", ~cull";
177 os <<
", bg=" <<
opts.background_color
178 <<
", lights=" <<
opts.lights.size()
179 <<
", amb=" <<
opts.ambient
180 <<
", aa=" <<
opts.aa_samples;
181 if (
opts.wireframe)
os <<
", wire";
183 <<
":" <<
opts.fog_start <<
"-" <<
opts.fog_end <<
")";
184 if (
opts.ssao_enabled)
os <<
", ssao(r=" <<
opts.ssao_radius
185 <<
", I=" <<
opts.ssao_intensity <<
")";
186 if (
opts.threads > 0)
os <<
", threads=" <<
opts.threads;
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.
const char * str_plane_space(PlaneSpace s)
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)
PlaneSpace
Coordinate space in which a ClipPlane is defined.
@ EYE
Eye (view/camera) space: the plane is anchored to the camera and therefore travels and rotates with i...
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_fog_space(FogSpace s)
FogSpace
Coordinate space (and hence the unit) of the fog distances RenderOptions::fog_start and RenderOptions...
@ NDC
Normalized device depth: the raw values of the depth buffer, in [-1, 1], where -1 is the near plane,...
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.
A clipping plane that can hide parts of the scene.
An RGBA color with floating-point components.
A light source for the Blinn-Phong shading model.
A 3D triangle mesh using an indexed face set representation.
All settings that control rendering output.
A collection of Mesh objects to be rendered together.
A triangle defined by three vertex indices.
int x
Left edge of the bitmap, in image pixels.
Fundamental types used throughout the scimesh rendering engine.