Skip to main content

Module geom

Module geom 

Source
Expand description

Geometry shared by the viewer and the thumbnail renderer: welding duplicate vertices, face and smooth normals, feature edges, the measurements Eagle’s viewer lists, and the lighting both draw with.

Structs§

Stats
What Eagle’s model viewer lists under Details.

Constants§

AMBIENT
Ambient and directional light strengths (0x88 / 255).
DIFFUSE
SHININESS
SPECULAR
The highlight’s strength and sharpness.

Functions§

add_light
shade’s result with the surface’s own light added, in display values as in Eagle’s viewer.
back_to_front
The order to draw see-through parts in: the indices of centers, farthest from the camera vp (projection times view) first.
bumped
The normal n tilted by a height field that changes by dh (per unit of u, per unit of v) in picture coordinates, on a surface as in normal_mapped: Mikkelsen’s surface gradient, heights in the model’s units.
center
The middle of the box around the vertices of mesh that triangles use.
face_normal
The unit normal of the triangle (a, b, c), counter-clockwise front; zero for a degenerate triangle.
feature_edges
The edges to draw for Eagle’s “Show Edges”: the segments where the faces on either side meet at more than threshold_deg degrees, plus the open edges with a face on one side only. Edges inside a flat area (the diagonals of a triangulated quad) are left out.
is_closed
Whether every edge of the mesh is shared by exactly two triangles that run along it in opposite directions: a closed, consistently wound surface, the only kind with a volume.
normal_mapped
The normal n turned by a tangent-space normal map’s stored values texel (0..1, green up in the picture), on a surface where going along q0 moves the picture coordinates (u right, v down) by st0 and going along q1 by st1. No tangents are stored: the frame comes from those differences, as in Schüler’s “Normal Mapping Without Precomputed Tangents”. n comes back alone where the coordinates don’t change. The shader in the app computes the same from screen derivatives.
shade
The lighting of Eagle’s viewer: a grey ambient light and a grey directional light shining from the camera, each at 0x88 (0.533), with a faint highlight. Both sides of a face are lit. n is the unit normal, to_eye the unit direction from the surface to the camera, base the surface colour; the result is a display colour in 0..1. The WGSL shader in the app computes the same thing.
smooth_normals
One normal per vertex for smooth shading: the file’s own normals when it has them, otherwise the area-weighted average of the faces meeting at the vertex’s place (welded, so a corner repeated per triangle still shades smoothly).
stats
weld
For each vertex of positions, the index of the first vertex at exactly the same place. Formats such as STL repeat a corner for every triangle that uses it; welding lets them share normals and edges.