Torque Valley: Driving, Drift and Crash Sandbox
README.md
bodygen
The procedural car body generator behind torqueCars: BodyGen.body(kind, look) builds one car kind (hatchback, coupe, muscle, rally, drift, pickup, van, suv, buggy, kart, boxtruck, electric) in one look (lowpoly faceted, toy rounded, real detailed) as a single vertex-coloured mesh. It returns the geometry normalised to the unit box plus its center, size, tris and lamp positions (lamps.head, lamps.tail) in the chassis frame, in metres. It is deterministic, so a re-run gives the same mesh.
How it builds: each closed body is a rounded cube grid bent along the kind's side profile (bottom, deck/hood/belt line, roof line, width, nose and tail rake). Wheel arches are cut radially around the real wheel positions from the catalog, with flares, an inset wheel-well wall and edge vertices snapped onto the arch circle. A pickup bed or buggy cockpit is a cavity pressed into the top. Part colours come from rules on each quad: glass from the greenhouse rows and window ranges, lamps, grille, bumpers, cladding, door shut lines, handles and stripes. Mirrors, wings, scoops, rally lamps, mudflaps, roof rails, exhausts, the box-truck box and chassis, the buggy cage and the kart (with driver) are added as boxes, tubes and ellipsoids from torqueCars.meshkit. Kind specs live in BodyGen.kinds; looks (sampling density, rounding, detail level) in BodyGen.LOOKS. Called by torqueCars.bodybake.