swallow
Pure generators for the meshes the `fauna` slice puts in the air. Nothing here touches the scene; each function returns a flat geometry table ready to hand to `asset.create("mesh", name, geo)`.
demo.fauna.swallow — the barn swallow's geometry
Pure generators for the meshes the fauna slice puts in the air. Nothing here
touches the scene; each function returns a flat geometry table ready to hand to
asset.create("mesh", name, geo).
local Swallow = require("demo.fauna.swallow")
asset.create("mesh", "swallow_body", Swallow.body())
asset.create("mesh", "swallow_wing_r", Swallow.wing(1))
asset.create("mesh", "swallow_wing_l", Swallow.wing(-1))
body() | head, keel, rump, two eyes, and the ten rectrices that make the fork |
wing(side) | one wing, its origin AT THE SHOULDER — +1 right, -1 left |
wingRotation(side, flapDeg, sweepDeg) | the local rotation for a wing: flap lifts the tip about the bird's forward axis, sweep rakes it back along the body, which is how a perched swallow folds it away |
SHOULDER | where to parent a wing on the body |
PLUMAGE | the five colours, for anything that wants to match them |
Life size: 18.5 cm from beak to streamer tip, 33 cm across the wings.
Plumage lives in the vertex stream
There is one material for the whole bird and it is white. Every scrap of colour —
the glossy steel blue-black back, the rufous chin and forehead, the buff
underparts, the near-black beak and eye — is written per vertex by
bodyColour(z, k) and by the span ramps in wing. That is what lets fourteen
swallows render through one material, and it is why a bird crossing a shaft of
window light picks that light up on its belly while its back stays dark.
Winding is derived, not reasoned about
Every vertex is written with the direction its surface faces. orient() then
reverses any triangle whose face normal opposes what its own vertices say, and
smoothNormals() runs after that. So a primitive built the wrong way round
corrects itself, and the engine's own check — "winds N of its M triangles away
from the normals its own vertices carry" — stays silent. Adding a new part means
stating its outward direction, not working out an index order.
Scoped to this part · feeds back into the world's score.