vehiclesKit modelgen: builds every vehicle model (kind x look) as vertex-
coloured triangle soup on torqueCars' meshkit, in the chassis frame (metres,
x right, y up, y = 0 the ground at rest or the waterline for boats, z = 0
mid-length, front = -Z). Pure Luau and deterministic: no engine calls.
local Gen = require("vehiclesKit.modelgen")
local g = Gen.body("bus", "real") -- finalized geometry (unit box) + center/size/tris
local parts = Gen.parts("helicopter", "toy") -- { { name, spin, geom (unit box around pivot), center = pivot, size } }
local l = Gen.layout("bus") -- seats / eye / hood / hull / wheels (same for every look)
Colours follow torqueCars: { r, g, b, partCode } where the alpha is the
`carBody` shader's part code (1 paint, .85 glass, .7 metal, .55 gloss,
.4 trim/rubber, .25 lamp, .1 tail lamp), so `torqueCars.bodies` paints
repaint only the painted panels.
builder(lookName: string) → any
b = { m, look, d (detail), lookName, trim, dark, metal, accent, seat }
| arg | type | description |
|---|
| lookName | string | |
box(b: any, o: any) → void
| arg | type | description |
|---|
| b | any | |
| o | any | |
tube(b: any, p0: vector, p1: vector, r: number, col: any, o: any?) → void
| arg | type | description |
|---|
| b | any | |
| p0 | vector | |
| p1 | vector | |
| r | number | |
| col | any | |
| o | any? | |
path(b: any, pts: { vector }, r: number, col: any, o: any?) → void
| arg | type | description |
|---|
| b | any | |
| pts | { vector } | |
| r | number | |
| col | any | |
| o | any? | |
ell(b: any, c: vector, rad: vector, col: any, o: any?) → void
| arg | type | description |
|---|
| b | any | |
| c | vector | |
| rad | vector | |
| col | any | |
| o | any? | |
rotX(deg: number) → void
Rotation frames.
| arg | type | description |
|---|
| deg | number | |
rotY(deg: number) → void
| arg | type | description |
|---|
| deg | number | |
rotZ(deg: number) → void
| arg | type | description |
|---|
| deg | number | |
rev(b: any, c: vector, dir: vector, prof: { { number } }, o: any?) → void
Revolve a profile { {a, r}, ... } around the axis through c along dir.
Walk the profile back-to-front along the outside (a increasing on the
barrel) and the faces point outward. o: seg, col (colour or fn(k)), phase, inside.
| arg | type | description |
|---|
| b | any | |
| c | vector | |
| dir | vector | |
| prof | { { number } } | |
| o | any? | |
P(a: number, r: number, i: number) → vector
| arg | type | description |
|---|
| a | number | |
| r | number | |
| i | number | |
solid(b: any, c: vector, dir: vector, prof: { { number } }, o: any?) → void
A closed solid of revolution: radii along the axis, capped (r = 0 ends).
| arg | type | description |
|---|
| b | any | |
| c | vector | |
| dir | vector | |
| prof | { { number } } | |
| o | any? | |
torus(b: any, c: vector, dir: vector, R: number, r: number, col: any, o: any?) → void
A torus ring around the axis through c along dir: radius R, tube r.
| arg | type | description |
|---|
| b | any | |
| c | vector | |
| dir | vector | |
| R | number | |
| r | number | |
| col | any | |
| o | any? | |
ring(b: any, c: vector, nrm: vector, R: number, r: number, col: any, segs: number?) → void
A ring of tubes (steering wheel rim) around c in the plane with normal nrm.
| arg | type | description |
|---|
| b | any | |
| c | vector | |
| nrm | vector | |
| R | number | |
| r | number | |
| col | any | |
| segs | number? | |
spow(x: number, e: number) → number
Signed power.
| arg | type | description |
|---|
| x | number | |
| e | number | |
range(a: number, bb: number, step: number, musts: { number }?) → void
Sorted samples from a to b at about `step`, hitting every value in musts.
| arg | type | description |
|---|
| a | number | |
| bb | number | |
| step | number | |
| musts | { number }? | |
secXY(s: any, th: number, grow: number) → void
A surface swept along z through superellipse sections. sec(z) returns
{ cx, cy, w, top, bot, nT, nB }: centre, half width, height above and depth
below the centre line, and the exponents of the upper and lower halves
(2 = ellipse, 4+ = boxy, ~1 = diamond / V). The angle th runs 0 at +x,
+pi/2 at the top, -pi/2 at the bottom. o: z0, z1, sec, zsp (m), zMust,
seg, th0/th1 (an open arc when given), thMust, grow (m outward), inward,
col = fn(q) -> colour | HOLE, with q = { z, th, p, n, t, side }, capF/capR.
| arg | type | description |
|---|
| s | any | |
| th | number | |
| grow | number | |
thAt(s: any, y: number) → number
Angle on the right side (x > 0) where a section reaches height y.
| arg | type | description |
|---|
| s | any | |
| y | number | |
puffed(b: any, s: any) → any
| arg | type | description |
|---|
| b | any | |
| s | any | |
relax(n: number) → number
| arg | type | description |
|---|
| n | number | |
loft(b: any, o: any) → void
| arg | type | description |
|---|
| b | any | |
| o | any | |
S(z: number) → any
| arg | type | description |
|---|
| z | number | |
cap(i: number, dirz0: number, ccol: any) → void
| arg | type | description |
|---|
| i | number | |
| dirz0 | number | |
| ccol | any | |
extrude(b: any, poly: { { number } }, o: any) → void
A convex 2D polygon { {u, v}, ... } extruded along W from w0 to w1 in the
frame (U, V, W) at origin o. bev bevels both ends (m); scale1 shrinks the
far end (sloped sides); col is a colour or fn(q) with q.part = "side" |
"cap0" | "cap1" | "bevel" and q.n.
| arg | type | description |
|---|
| b | any | |
| poly | { { number } } | |
| o | any | |
ringAt(w: number, inset: number, sc: number) → void
| arg | type | description |
|---|
| w | number | |
| inset | number | |
| sc | number | |
slabX(b: any, poly: { { number } }, x0: number, x1: number, col: any, o: any?) → void
Side-profile extrusion across x: poly in (z, y), from x0 to x1.
| arg | type | description |
|---|
| b | any | |
| poly | { { number } } | |
| x0 | number | |
| x1 | number | |
| col | any | |
| o | any? | |
slabY(b: any, poly: { { number } }, y0: number, y1: number, col: any, o: any?) → void
Plan extrusion up y: poly in (x, z), from y0 to y1 (scale1 tapers the top).
| arg | type | description |
|---|
| b | any | |
| poly | { { number } } | |
| y0 | number | |
| y1 | number | |
| col | any | |
| o | any? | |
belt(b: any, loop: { { number } }, x0: number, x1: number, thick: number, col: any, colIn: any) → void
A closed belt (tank track) around a convex loop of (z, y) points, across
x0..x1, `thick` deep, inner face toward the loop centre.
| arg | type | description |
|---|
| b | any | |
| loop | { { number } } | |
| x0 | number | |
| x1 | number | |
| thick | number | |
| col | any | |
| colIn | any | |
P(q: { number }, x: number) → vector return V3
| arg | type | description |
|---|
| q | { number } | |
| x | number | |
plate(b: any, a: vector, bb: vector, c: vector, d: vector, t: number, col: any) → void
A flat panel (two-sided thin plate) through four corners, thickness t along nrm.
| arg | type | description |
|---|
| b | any | |
| a | vector | |
| bb | vector | |
| c | vector | |
| d | vector | |
| t | number | |
| col | any | |
wing(b: any, root: vector, tip: vector, back: vector, up: vector, chordR: number, chordT: number, tR: number, tT: number, col: any, o: any?) → void
A wing / blade: a thin aerofoil-ish slab spanning from root to tip.
root, tip: leading-edge points; chordR/chordT along `back`; thickness tR/tT
along `up`. Sections are a lens (leading edge rounder than the trailing).
| arg | type | description |
|---|
| b | any | |
| root | vector | |
| tip | vector | |
| back | vector | |
| up | vector | |
| chordR | number | |
| chordT | number | |
| tR | number | |
| tT | number | |
| col | any | |
| o | any? | |
section(p: vector, ch: number, th: number) → void
| arg | type | description |
|---|
| p | vector | |
| ch | number | |
| th | number | |
seat(b: any, hip: vector, o: any?) → void
A seat for a seated rider whose hip is at `hip`, facing `face` (-1 = front
at -Z, +1 = facing +Z). o: w (half width), back (backrest height), col, frame.
| arg | type | description |
|---|
| b | any | |
| hip | vector | |
| o | any? | |
compact(m: any) → void
Remove HOLE triangles from the soup.
finish(b: any, pivot: vector?) → any
Finalize: the body fits its bounds; a part (pivot given) is stored in a unit
box centred on its pivot (built around the origin), size = 2 x its reach.
| arg | type | description |
|---|
| b | any | |
| pivot | vector? | |
layout(kind: string) → any
The layout of a kind: seats (first = driver), eye, hood, hull box, wheels, extras.
| arg | type | description |
|---|
| kind | string | |
kart(b: any, L: any) → void
| arg | type | description |
|---|
| b | any | |
| L | any | |
sec(z: number) → void
| arg | type | description |
|---|
| z | number | |
sec(z: number) → void
| arg | type | description |
|---|
| z | number | |
bus(b: any, L: any) → void
One rounded box (gridBox) with real window openings so the seats inside
show, glass on the windscreen, doors and rear window.
| arg | type | description |
|---|
| b | any | |
| L | any | |
panes(list: any, z0: number, z1: number, n: number) → void
| arg | type | description |
|---|
| list | any | |
| z0 | number | |
| z1 | number | |
| n | number | |
A(x: number) → void
| arg | type | description |
|---|
| x | number | |
B(y: number) → void
| arg | type | description |
|---|
| y | number | |
Cz(z: number) → void
| arg | type | description |
|---|
| z | number | |
inList(z: number, list: any, m: number?) → boolean
| arg | type | description |
|---|
| z | number | |
| list | any | |
| m | number? | |
map(a: number, bb: number, c: number) → void
| arg | type | description |
|---|
| a | number | |
| bb | number | |
| c | number | |
sweep(b: any, pts: { vector }, closed: boolean, rad: any, col: any, sides: number?) → void
A tube swept around a closed or open loop of points (skirts, rails).
rad: number or fn(i) ; col: colour or fn(i, p).
| arg | type | description |
|---|
| b | any | |
| pts | { vector } | |
| closed | boolean | |
| rad | any | |
| col | any | |
| sides | number? | |
resample(loop: { { number } }, step: number) → void
Resample a closed loop of {z, y} points at about `step`.
| arg | type | description |
|---|
| loop | { { number } } | |
| step | number | |
roadWheel(b: any, c: vector, r: number, w: number, tyre: any, hub: any) → void
Solid revolved cylinder-ish wheel along x at c: radius r, width w.
| arg | type | description |
|---|
| b | any | |
| c | vector | |
| r | number | |
| w | number | |
| tyre | any | |
| hub | any | |
blade(b: any, r0: number, r1: number, rdir: vector, tdir: vector, up: vector, chord0: number, chord1: number, th: number, pitch: number, col: any, o: any?) → void
A rotor / fan blade: radial direction rdir, rotation direction tdir, axis up.
| arg | type | description |
|---|
| b | any | |
| r0 | number | |
| r1 | number | |
| rdir | vector | |
| tdir | vector | |
| up | vector | |
| chord0 | number | |
| chord1 | number | |
| th | number | |
| pitch | number | |
| col | any | |
| o | any? | |
tank(b: any, L: any) → void
| arg | type | description |
|---|
| b | any | |
| L | any | |
build(b: any, L: any) → void
| arg | type | description |
|---|
| b | any | |
| L | any | |
hovercraft(b: any, L: any) → void
| arg | type | description |
|---|
| b | any | |
| L | any | |
on(cx: number, cz: number, ang: number) → vector
| arg | type | description |
|---|
| cx | number | |
| cz | number | |
| ang | number | |
sec(z: number) → void
| arg | type | description |
|---|
| z | number | |
sec(z: number) → void
| arg | type | description |
|---|
| z | number | |
sec(z: number) → void
| arg | type | description |
|---|
| z | number | |
build(b: any, L: any) → void
| arg | type | description |
|---|
| b | any | |
| L | any | |
boatSection(z: number, o: any) → any
| arg | type | description |
|---|
| z | number | |
| o | any | |
speedboat(b: any, L: any) → void
| arg | type | description |
|---|
| b | any | |
| L | any | |
sheer(t: number) → void
| arg | type | description |
|---|
| t | number | |
keel(t: number) → void
| arg | type | description |
|---|
| t | number | |
sec(z: number) → any return boatSection
| arg | type | description |
|---|
| z | number | |
sec(z: number) → void
| arg | type | description |
|---|
| z | number | |
hw(z: number) → number
| arg | type | description |
|---|
| z | number | |
taper(a: number, bb: number, c: number) → void
| arg | type | description |
|---|
| a | number | |
| bb | number | |
| c | number | |
rowboat(b: any, L: any) → void
| arg | type | description |
|---|
| b | any | |
| L | any | |
sheer(t: number) → void
| arg | type | description |
|---|
| t | number | |
keel(t: number) → void
| arg | type | description |
|---|
| t | number | |
sec(z: number) → any return boatSection
| arg | type | description |
|---|
| z | number | |
oar(b: any, side: number) → void
| arg | type | description |
|---|
| b | any | |
| side | number | |
plane(b: any, L: any) → void
| arg | type | description |
|---|
| b | any | |
| L | any | |
sec(z: number) → any
| arg | type | description |
|---|
| z | number | |
helicopter(b: any, L: any) → void
| arg | type | description |
|---|
| b | any | |
| L | any | |
sec(z: number) → any
| arg | type | description |
|---|
| z | number | |
sec(z: number) → void
| arg | type | description |
|---|
| z | number | |
sec(z: number) → void
| arg | type | description |
|---|
| z | number | |
spaceship(b: any, L: any) → void
| arg | type | description |
|---|
| b | any | |
| L | any | |
sec(z: number) → any
| arg | type | description |
|---|
| z | number | |
taper(a: number, bb: number, c: number) → void
| arg | type | description |
|---|
| a | number | |
| bb | number | |
| c | number | |
body(kind: string, lookName: string) → any
Build a body: finalized geometry (unit box) with center/size (chassis frame, m) and tris.
| arg | type | description |
|---|
| kind | string | |
| lookName | string | |
parts(kind: string, lookName: string) → void
The moving parts of a kind: { { name, spin, geom, center = pivot, size } } (geometry in a unit box around the pivot).
| arg | type | description |
|---|
| kind | string | |
| lookName | string | |
partNames(kind: string) → void
The part names a kind has.
| arg | type | description |
|---|
| kind | string | |
hasBody(kind: string) → boolean
| arg | type | description |
|---|
| kind | string | |