1843 lines
163 KiB
Markdown
1843 lines
163 KiB
Markdown
# Kitbash parts: machinery from kits
|
|
|
|
`surfaces/blender/brokkr_kitbash` is a Blender add-on that places parametric machine parts from a **kit**, mates
|
|
them **socket** to socket, cuts them with booleans and freezes them, and makes the faceted armor **shell** they sit under. It is the machinery vocabulary of a ship's fixed chassis: the frame, tanks,
|
|
actuators, housings and plumbing an agent assembles offline under a hand-fit armor cage, baked once. It is a host
|
|
add-on in Brokkr's sense (`install.md`, "Host add-on actions"), a sibling of `brokkr_mesh_polish` and `brokkr_rig`:
|
|
it imports the polish package's operator base, `Refused` and `mesh_object`, and nothing from `brokkr_bridge`.
|
|
Enable `brokkr_mesh_polish` first; `brokkr_kitbash` refuses to register without it. `brokkr_actions.json` beside
|
|
its `__init__.py` lists the sixteen operators agents may run. Every action writes a JSON report to
|
|
`brokkr_mesh_polish_result`, returned in the receipt's `hostResult`.
|
|
|
|
Who owns what:
|
|
|
|
- `brokkr_kitbash/core.py` (numpy and the standard library, no Blender) owns the kit format: what a kit document
|
|
may say (`check_kit`), what a part's params may be (`resolve_params`), and the geometry and socket frames a part
|
|
and its params produce (`build`). There is no other validator of the format.
|
|
- `brokkr_kitbash/kits/<name>.v0.json` own kit content. A kit is chosen by name (`a-z`, `0-9`, `_`, at most 32);
|
|
the name is the only thing an intent contributes to the path.
|
|
- In the scene, an object's `kit_kit`, `kit_part` and `kit_params` ID properties own what that part is. Its mesh is
|
|
derived from them: `set_params` rebuilds it, and an edit made to the mesh by hand is lost at the next
|
|
`set_params`. Socket frames are derived at every report and stored nowhere.
|
|
- Two things would give a part a second owner, and are refused. `set_params` refuses an object whose mesh
|
|
datablock another object uses (a linked duplicate): rebuilding it would change the other while its params stay.
|
|
`set_params` and `report` refuse a part whose world transform scales, mirrors or shears, its parents'
|
|
included: a part's size is its params, and a socket's frame is a rotation and an origin. Set scale to 1 and
|
|
resize with `set_params`.
|
|
- A connection between two parts belongs to the child: its parent pointer and its `kit_socket`,
|
|
`kit_parent_socket` and `kit_roll` properties, and its joint record (`kit_slide`, `kit_min`, `kit_max`,
|
|
`kit_mechanism`, `kit_compliance`). Where the child stands is derived from them ("Assembling parts"). The
|
|
joint's kind belongs to the kit's socket type and its axis to the parent socket's frame: neither is stored on
|
|
the connection.
|
|
- A closure, the joint that closes a loop, belongs to the closing part: its `kit_close_socket`, `kit_close_to`
|
|
and `kit_close_to_socket` properties. Only `close` writes them and only `detach` clears them. A closure places
|
|
nothing: whether it holds is derived at each report.
|
|
- A boolean belongs to its Boolean modifier on the part that is cut.
|
|
- Whether a cut object is live or frozen belongs to its `kit_frozen` property, which holds the live mesh while
|
|
the object carries its evaluated one. Only `freeze` sets it, and `thaw`, which deletes it, is its one undo.
|
|
Both go through one function, `hold`, which is also the only writer of `kit_kept` and of the fake user on a held
|
|
live mesh ("Freezing").
|
|
- Every `kit_*` custom property is the kit's: Brokkr's `setObjectCustomProperty` refuses a name that starts with
|
|
`kit_`, and `importGltf` drops such properties from the objects and meshes it imports and names the objects in
|
|
its receipt, so each has only the writers named here. A kit part exported with extras comes back as a plain mesh.
|
|
|
|
## A part, end to end
|
|
|
|
A kit document is `{schema: "brokkr.kit.v0", kit, doc, socketTypes, parts}`. One part of a kit, whole:
|
|
|
|
```json
|
|
{
|
|
"name": "standoff",
|
|
"doc": "A post on a square foot.",
|
|
"params": [
|
|
{"name": "height", "type": "number", "min": 0.05, "max": 0.5, "default": 0.2, "doc": "foot face to top face"},
|
|
{"name": "radius", "type": "number", "min": 0.01, "max": 0.05, "default": 0.02, "doc": "post radius"},
|
|
{"name": "bolts", "type": "integer", "min": 1, "max": 4, "default": 2, "doc": "bolts along x"}
|
|
],
|
|
"bevel": "0.1*radius",
|
|
"shapes": [
|
|
{"shape": "box", "size": ["6*radius", "3*radius", "radius"], "at": [0, 0, "0.5*radius"]},
|
|
{"shape": "tube", "r0": "radius", "r1": "0.8*radius", "length": "height-0.5*radius", "segments": 24, "smooth": true,
|
|
"at": [0, 0, "0.5*radius"]},
|
|
{"shape": "repeat", "count": "bolts", "step": ["4*radius/max(bolts-1,1)", 0, 0], "of":
|
|
{"shape": "tube", "r0": "0.3*radius", "r1": "0.3*radius", "length": "0.4*radius", "segments": 6,
|
|
"at": ["-2*radius", 0, "0.9*radius"]}}
|
|
],
|
|
"sockets": [
|
|
{"name": "foot", "type": "mount", "size": "3*radius", "at": [0, 0, 0], "z": "-z", "y": "+y"},
|
|
{"name": "top", "type": "mount", "size": "1.6*radius", "at": [0, 0, "height"], "z": "+z", "y": "+y"}
|
|
]
|
|
}
|
|
```
|
|
|
|
Lengths are metres in the part's own frame. Unknown keys are refused at every level, and so is a repeated part,
|
|
param or socket name, a default outside `[min, max]`, and an integer param with a fractional bound or default.
|
|
|
|
**Params** are `number` or `integer` with inclusive bounds. A param name is lower case (`a-z`, then `a-z`, `0-9`,
|
|
`_`) and is not `min` or `max`.
|
|
|
|
**Shapes.** Each is one or more closed shells wound outward. `at` (metres) and `rot` (XYZ Euler degrees: about x,
|
|
then y, then z, about the shape's own origin) place it, rotation first; both default to zero.
|
|
|
|
| shape | fields | what it is |
|
|
| --- | --- | --- |
|
|
| `tube` | `r0`, `r1`, `length`, `segments`, `inner0`?, `inner1`?, `smooth`? | A frustum on +z from radius `r0` at z=0 to `r1` at z=`length`, with n-gon caps. Inner radii above 0 make it hollow (an inner wall and two flat end rings); they are both above 0 or both 0, and below the outer radius. `segments` is 3 to 128. `smooth` shades the walls smooth; caps stay flat. |
|
|
| `box` | `size` | A box centred on its origin; every size above 0. |
|
|
| `lathe` | `profile`, `segments`, `loop`?, `smooth`? | A profile of `[r, z]` points revolved about +z into one shell, a ring of `segments` (3 to 128) vertices per point. An open profile's end on the axis (`r` exactly 0) is a pole; an end off the axis gets a flat n-gon cap. With `loop` true the last point joins the first and there are no caps (a ring: 3 points or more). `smooth` shades the walls smooth; a band between two points of one `z` (an annulus) and the caps stay flat. A point written `[r, z, "sharp"]` is a crease. |
|
|
| `extrude` | `section`, `w`, `h`, `t`, `path`, `up`, `loop`? | A section (`I`, `C`, `T`, `L`, `box`, `wedge` or `gusset`: a name, never an expression) of width `w`, height `h` and wall `t`, swept along `path`, 2 to 64 `[x, y, z]` points, into one shell with a flat cap at each end. `up` is the direction the section's height stands along: one `[x, y, z]` vector for the whole path, or an array of one per path point. With `loop` true the last point joins the first and there are no caps (3 points or more). Every face is flat. |
|
|
| `repeat` | `count`, `of`, and `step` or `around` with `center`? | `count` copies (1 to 256) of one tube, box, lathe or extrude: at `k * step`, k from 0, or turned `k * 360 / count` degrees, right-handed, about the axis `around` (one of `+x -x +y -y +z -z`) through `center` (default the origin). Exactly one of `step` and `around`. A repeat cannot hold a repeat. |
|
|
|
|
A lathe's profile is listed out along the bottom and up the outside, as this flanged stub is: a cap of radius 0.1
|
|
at z=0, the flange's rim, its top face, the pipe, and a cap of radius 0.05 at z=0.3.
|
|
|
|
```json
|
|
{"shape": "lathe", "segments": 24, "smooth": true,
|
|
"profile": [[0.1, 0], [0.1, 0.02], [0.05, 0.02], [0.05, 0.3]]}
|
|
```
|
|
|
|
The rule behind "up the outside": the profile, closed down the axis from its last `z` to its first (a loop closes
|
|
itself), has positive area in (r, z). A profile listed the other way is refused, and so are a negative `r`, an
|
|
`r` of 0 anywhere but an open profile's two ends, and a point that repeats the one before it. A flat profile
|
|
(every point at one `z`) encloses nothing and is refused whatever its digits: the area must be above 5.1e-10 of
|
|
the square of the profile's largest coordinate, which float rounding does not reach and no real profile comes
|
|
near. A profile may turn back down inside itself (a bell's inner wall); one that crosses itself is not caught by
|
|
`core`, and builds a shell that is not a solid. For a shipped kit `test_no_lathe_profile_crosses_itself` catches
|
|
it, at every corner of the part's params. A turned part with many steps is one lathe, and so one shell, where a
|
|
stack of tubes is one shell each: a Boolean on it costs less ("Assembling parts").
|
|
|
|
Smooth shading rounds every bend of a smooth lathe, and the Bevel only cuts edges sharper than 30 degrees. Where
|
|
a turned part should show a hard line at a shallower bend (a cone leaving a neck), mark the point:
|
|
|
|
```json
|
|
["big_r", "flange_t+0.15*(length-2*flange_t)", "sharp"]
|
|
```
|
|
|
|
The ring of edges at that point is then shaded as a crease (`Built.sharp`, written to the mesh's `sharp_edge`
|
|
attribute by `place_part` and `set_params`). The mark is per point and authored: no angle decides it. It is
|
|
refused at an open profile's two ends, which are a cap or a pole. No modifier or auto-smooth setting takes part.
|
|
|
|
Shells may overlap (a pad that runs into a tank), and a part is then not one solid: reports give the shell count.
|
|
|
|
An extrude stands its section on the path by one rule (`core.sweep`, which also makes a rib's longerons). At each
|
|
path point the section lies in the plane that bisects the turn there. Its y axis is `up` with the path's direction
|
|
taken out of it, and its x axis is that y cross the path's direction: along +z with `up` +y the section's x is +x
|
|
and its y is +y, as drawn; along +x with `up` +z its x is +y. A corner is mitred: the section is stretched in the
|
|
plane of the turn by 1 / cos(half the turn), so it keeps its size on both sides of the corner. `at` and `rot` then
|
|
place the whole shell as they place any shape.
|
|
|
|
| section | outline, counter-clockwise in (x, y), centred on its `w` by `h` box | `t` | `t` must be under |
|
|
| --- | --- | --- | --- |
|
|
| `I` | two flanges across x joined by a web along y | flange and web thickness | `w` and `h / 2` |
|
|
| `C` | the web on -x, two flanges opening toward +x | flange and web thickness | `w` and `h / 2` |
|
|
| `T` | the flange across x at +y, the stem down the middle | flange and stem thickness | `w` and `h` |
|
|
| `L` | one leg along x at -y, one along y at -x | leg thickness | `w` and `h` |
|
|
| `box` | the solid `w` by `h` rectangle | unused, but above 0 | |
|
|
| `wedge` | a right trapezoid: base `w` at -y, its back `h` tall at -x, its front `t` tall at +x | front height | `h` |
|
|
| `gusset` | a right triangle on legs `w` (along x at -y) and `h` (along y at -x), each acute tip cut square | length of the flat that cuts a tip | half the shorter leg |
|
|
|
|
Every size is above 0. A build is refused, naming the kit, part and shape, when the section has no room for its
|
|
wall, when `up` runs along the path at a point (or is zero), when two path points are closer than 1e-9, when the
|
|
path turns more than 150 degrees at a point (past it a mitre runs 3.9 times the section's width), and when the
|
|
section folds: the path turns tighter than the section reaches on the inside of the turn. One `up` must cross
|
|
every segment and every corner's bisector, so it can only stand a bent path's section across the plane of the
|
|
bend. To keep the section's height in that plane give one `up` per point, each in the plane and across the path
|
|
there (at a corner, across its bisector): the portal's four point toward the inside of the frame, which stands its
|
|
I section's web in the frame's plane. An array of ups that is not one per path point is refused.
|
|
`smooth` is not a field of an extrude: a section's faces are flat, and its corners take the part's `bevel`.
|
|
|
|
**`bevel`** is the width of a Bevel modifier `place_part` adds (2 segments, edges sharper than 30 degrees). Keep it
|
|
well under the part's thinnest feature at its smallest params.
|
|
|
|
**Sockets** are frames. `at` is the origin; `z` is the outward normal (a mating socket faces it), `y` is up (the
|
|
roll reference), and x is y cross z; each is one of `+x -x +y -y +z -z` in the part's frame, on different axes.
|
|
`size` is a diameter in metres. `type` names one of the kit's `socketTypes`, whose `match` says how sizes are to
|
|
be compared when sockets are mated: `equal` (within 1 percent) or `fits` (the child at most the parent), and
|
|
whose optional `dof` (`revolute` or `prismatic`; absent is rigid) says how a child seated on such a socket moves. A socket
|
|
sits on a flat face of the part whose normal is its `z`; `test_kitbash` checks this for every part of a shipped
|
|
kit at its default, smallest and largest params and at seeded draws between.
|
|
|
|
A pin joint is a socket whose `z` runs along the pin, with its origin on the pin's end face and its `y` along the
|
|
part. Two such sockets mate face to face on one pin axis, and the roll of the connection is then the hinge
|
|
angle: at 0 the two parts line up, side by side. A pin carries a socket on each of its end faces (`end_a` and
|
|
`end_a_back`), so a part can be pinned from either side, and by both at once.
|
|
|
|
## Assembling parts
|
|
|
|
**A connection** seats one socket of a child part on one socket of a parent part: the two origins together, the
|
|
two normals opposed, and the child turned `roll` degrees about the parent socket's normal (right-handed; at 0 the
|
|
two sockets' up axes line up). On a prismatic socket the child also stands `slide` metres along that normal. The
|
|
child owns it. It is the child's parent pointer, under an identity parent inverse, and three ID properties on the
|
|
child: `kit_socket` (its own socket), `kit_parent_socket` and `kit_roll`, with its joint record ("Joint records",
|
|
below). Nothing else stores it: no parent name, no world matrix, no empties. The child's `matrix_basis` is
|
|
derived,
|
|
|
|
```text
|
|
matrix_basis = S_parent @ T(0, 0, slide) @ Rz(roll) @ FLIP @ inverse(S_child) FLIP = half a turn about y
|
|
```
|
|
|
|
with `S` each socket's frame in its own part at that part's stored params (`core.mate`); a turn about z and a move
|
|
along it commute, so one connection carries both. `attach`, `set_params`, `roll`, `aim`, `reach`, `slide`,
|
|
`joint` and `follow` write it; nothing else should.
|
|
|
|
**Joint records.** A connection's degree of freedom is its parent socket's type's: a socket type states
|
|
`"dof": "revolute"` (the child turns about the socket's z: `pivot`), `"dof": "prismatic"` (it slides along it:
|
|
`slide`) or nothing, and is then rigid (`flange`, `mount`, `hose`). No part, socket or object name decides it. A
|
|
revolute joint's value is its `kit_roll`, in degrees; a prismatic joint's is its `kit_slide`, in metres, and its
|
|
roll is a build angle. Beside the value the child's connection carries a record:
|
|
|
|
| Property | States | Stated by |
|
|
| --- | --- | --- |
|
|
| `kit_slide` | metres along the parent socket's z; prismatic only, 0 where the two origins meet | `slide` |
|
|
| `kit_min`, `kit_max` | the limits of the value, both or neither: degrees on a revolute joint (a span of at most 360, each end within 360 of 0), metres on a prismatic one (each end within 10 m of 0) | `joint` |
|
|
| `kit_mechanism` | a label of 1 to 32 `a-z`, `0-9` and `_`: which mechanism the joint is (`knee`, `shock`) | `joint` |
|
|
| `kit_compliance` | `{"hertz", "damping_ratio"}` (hertz over 0 to 30, damping ratio 0 to 2): a slide in the load path that settles and rebounds under load. Prismatic only, and it needs limits, the travel it settles within | `joint` |
|
|
| `kit_follows`, `kit_follows_driver` | that the value is derived from another joint's: `{"kind": "ratio", "k", "offset"}` or `{"kind": "loop"}`, and an ID pointer to the driver, which follows a rename | `follow` |
|
|
|
|
Every one of them is written by one function, `write_connections`, which `attach`, `set_params`, `roll`, `aim`,
|
|
`reach`, `slide`, `joint` and `follow` all seat through; `detach` clears them with the connection. It takes
|
|
several connections and checks every one before it writes any, so a driver and its followers are written together
|
|
or not at all. So the limits have one check: a value with no representative inside them is refused before anything
|
|
is written, naming value and limits, and a roll a turn away from its limits is written as the roll inside them
|
|
(limits 150 to 210 and a roll of -170: 190). `aim` inside limits takes the free roll when the limits hold it and
|
|
otherwise the end that points the axis nearer; `reach` takes only a root inside them. A new connection states no
|
|
record. A value written by hand outside its limits reads `within: false` in every report; a pose that puts it
|
|
inside them is accepted and clears that, and `set_params` of the part or of its parent is refused until then, as
|
|
it is for a slide written by hand on a connection that is not prismatic. A record written by hand that its
|
|
connection may not carry (a compliance on a revolute joint) reads null in every report and goes at the next write.
|
|
|
|
**Followers.** A joint whose value is a function of another's is a follower, and `follow` states it. A follower has
|
|
exactly one driver and a driver is never a follower (aetheria-release:ruling:one-joint-one-driver); `roll`, `aim`,
|
|
`reach` and `slide` on a follower are refused naming its driver, and `joint` on one states limits and a mechanism
|
|
and keeps the derived value. Posing a driver derives every follower in the same action and writes them with it: a
|
|
follower outside its own limits, or a loop that cannot close, refuses the pose with nothing changed.
|
|
|
|
| Kind | The follower's value | For |
|
|
| --- | --- | --- |
|
|
| `ratio` | `k` x the driver's value + `offset`, either joint revolute or prismatic (a slide following a roll has `k` in metres per degree). The driver states limits, so its value is one number and not one of many a turn apart | a kneecap on the bisector (`k` 0.5), lames at `k/n` of the knee, a pinion at minus ring over pinion, a crosshead |
|
|
| `loop` | solved: the part that states a closure and its parent both follow, and their two values are the ones at which the closure holds | a rocker and coupler closing on a crank; a ram's barrel and rod closing on the part it pushes; a torque link's two arms |
|
|
|
|
A loop has exactly two unknowns, the closing part's joint and its parent's, and it is planar: each revolute pin is
|
|
parallel to the pin it closes on and each slide runs across it. Exactly one of its two ends (the parent's parent,
|
|
and the part closed on) moves with the driver: it is the driver, follows it, or hangs from one that does. And the
|
|
driver is the only input the two ends depend on: every revolute or prismatic joint between an end and the part the
|
|
two ends share (or the root, when they share none) is the driver, follows it, or is held by limits of one value. A
|
|
joint there that follows another driver, or that follows nothing and has travel, is a second driver: a pose of it
|
|
would open the loop, and nothing here solves a loop for two drivers. The rule is read before each write, over
|
|
each loop the write touches, as the scene would stand after it (`one_driver`, asked by the one writer of
|
|
connections, by `set_params` before it rebuilds a mesh, by `detach` and by Brokkr's `setObjectParent`), so it holds
|
|
after the loop is stated as it does when `follow` states it. A write touches a loop when a part it writes is the
|
|
closing follower, the part closed on or the driver, or one of those hangs from it; no other write can change what
|
|
the loop's ends depend on, and no other loop is read. Each of these is refused with
|
|
nothing changed, naming the loop's driver and each other one: `attach` of an end's root on a pin or a slide,
|
|
`detach` of a part between an end and the part both ends hang from, `follow` with null on a follower between the
|
|
ends, `joint` widening or clearing limits that held a pin there, `setObjectParent` giving or clearing a parent
|
|
between the ends, and any write that touches the loop once such a joint was written by hand. To change a mechanism between a loop's ends, give the new joint its one driver or its one value first, or
|
|
clear the loop and state it again. A loop whose driver is detached is derived by nothing and is not read; the
|
|
attach that gives the driver a connection again reads it. A torque link is the case for limits of one value: a
|
|
real torque link exists to stop the rod rolling in its barrel, so its lug has no travel, and a strut pinned to
|
|
the rod's end and held by limits `[90, 90]` is that lug (a strut's two pins face one way, so the lower arm cannot
|
|
close on the rod's own pin). The lug is held before the arms follow the rod's slide. Nothing
|
|
stores a pin position or a linkage record: `core.close_loop` solves the pair from the kits' socket frames at the
|
|
parts' stored params each time, by Newton's method on the closing pin's error in the loop's plane with the analytic
|
|
Jacobian. That is the position analysis of the kinematics texts (Nikravesh, *Computer-Aided Analysis of Mechanical
|
|
Systems*, 1988, ch. 4; Uicker, Pennock and Shigley, *Theory of Machines and Mechanisms*); the ratio is Box2D's
|
|
`b2GearJoint` and Jolt's `GearConstraint` and `RackAndPinionConstraint`. A loop has two assembly branches and
|
|
Newton finds the one nearest its seed, so a driver steps to its new value 5 degrees or 0.02 m at a time, each solve
|
|
seeded by the one before, and only the last step is written: the linkage stays on the branch it was built on.
|
|
Loops are solved in an order where a loop's base and the part it closes on are already placed (a ram closing on a
|
|
four-bar's rocker waits for the four-bar); loops that wait on each other are refused. At a dead centre, where the
|
|
pair's two joints move the closing pin along one line, the pose is refused naming the driver's value and the
|
|
closing part: the bound is 0.093 on the smaller singular value of the Jacobian with each column scaled by its lever.
|
|
For two revolute joints the columns are unit vectors and the reading is the two joints within about 7.6 degrees of
|
|
in line (the four-bar of `tests/test_kitbash.py` reads 0.184 at its last accepted step and 0.047 at the first
|
|
refused one). A ram's dead centre is its rod's end on its barrel's pin, where the barrel's roll is undefined, and
|
|
its two columns are across each other everywhere else, so the barrel's column is scaled by its lever with the slide
|
|
at 0 and the reading is the ram's lever over its closed lever: a ram drawn in to 0.184 of its closed lever is
|
|
accepted and one at 0.047 refused. The sign of the Jacobian's determinant about the pin is the assembly branch (an
|
|
elbow bent one way or the other, a rod's end on one side of its barrel's pin or the other), and a Newton step that
|
|
lands on the other sign from its seed is refused as past the dead centre, so no pose answers the other branch.
|
|
A ram whose limits keep its slide clear of minus its closed length never comes near either: its slide leaves its
|
|
limits first. One whose limits reach that far is refused by the bound above before it leaves them.
|
|
|
|
What followers give up: a loop of three or more unknowns, or one out of a plane, is not solved (follow-up
|
|
`kit-follows-wider-loops`); a follower does not drive another; `set_params` never derives a follower again, so a
|
|
loop it opens reads `holds: false` until its driver is posed; and a loop
|
|
with a second driver (a limit widened by hand, a parent set in Blender's own interface, a saved file) refuses
|
|
every write that touches it (a write of a connection, a `set_params` or a `setObjectParent` of one of its parts
|
|
or of a part it hangs from, whether or not that write is the fault) until the joint is held again, follows the
|
|
driver, or the loop is cleared. A write that touches no such loop is made: a camera, an empty or a part of
|
|
another mechanism is posed and given a parent as before, and so is an object parented under a part of the loop. A connection's row in a report carries `follows: {driver, kind, k, offset, holds, reason}`:
|
|
`holds` is false, with a reason, when the value stands off the ratio, the loop has more than one driver, the loop's
|
|
closure does not hold, or the driver is gone or states no revolute or prismatic connection. A loop with a second
|
|
driver reads `holds: false` on both its followers whether or not its closure stands closed, and the reason names
|
|
the loop, its driver and each other one: the remedy is to hold that joint, have it follow the driver or clear the
|
|
loop, not to pose the driver. The joints report lists the same loops in `manyDrivers`. Both read the scene as it
|
|
stands by the reading the refusals use, so a second driver that no action wrote is told by the next report and
|
|
not first by a refused write. Detaching a driver leaves its followers'
|
|
statements; detaching a loop follower clears its partner's. No Blender driver or constraint is made: a follower's
|
|
pose is its stored value, as every connection's is.
|
|
|
|
Limits and springs follow Box2D v3's `b2PrismaticJointDef` and Jolt's `SliderConstraintSettings`: the slide's
|
|
limits and a spring as a frequency in hertz and a damping ratio sit on the joint itself. Frequency and damping
|
|
ratio describe how the strut feels whatever mass it carries; a stiffness in N/m would need the mass the kit does
|
|
not know. `kit_compliance` is a record for a runtime: nothing in Brokkr solves it.
|
|
|
|
Two things a rig needs are not stored, because each is already stated once. The axis is the parent socket's z in
|
|
the kit at the parent's stored params: a copy on the connection would go stale at the next `set_params`. The order
|
|
is the parent tree. `brokkr_kitbash.joints` derives both at each call and emits them, so a consumer derives
|
|
nothing:
|
|
|
|
```json
|
|
{"schema": "brokkr.joints", "version": 2, "root": "Tank", "frame": "the root object's: Blender axes (+Z up), metres",
|
|
"rigid": 2, "unlimited": ["Barrel"], "manyDrivers": [], "next": null, "joints": [
|
|
{"id": "Strut", "parent": null, "part": "strut", "socket": "Mount:pivot", "kind": "revolute",
|
|
"axis": [0.0, 1.0, 0.0], "origin": [0.436, 0.0, 0.85368], "value": -113.019997, "limits": [-116.02, -40.02],
|
|
"min": -3.000003, "max": 72.999997, "mechanism": "knee", "compliance": null, "held": false, "driven": null},
|
|
{"id": "Cap", "parent": "Strut", "part": "strut", "socket": "Strut:end_a_back", "kind": "revolute",
|
|
"axis": [0.0, -1.0, 0.0], "origin": [0.436, -0.09, 0.85368], "value": -56.509999, "limits": null,
|
|
"min": null, "max": null, "mechanism": null, "compliance": null, "held": false,
|
|
"driven": {"by": "Strut", "kind": "ratio", "k": 0.5, "offset": 0.0}},
|
|
{"id": "Rod", "parent": "Barrel", "part": "ram_rod", "socket": "Barrel:bore", "kind": "prismatic",
|
|
"axis": [0.97429, 0.0, 0.225296], "origin": [1.072572, 0.124, 1.312762], "value": 0.12, "limits": [0.0, 0.3],
|
|
"min": -0.12, "max": 0.18, "mechanism": "shock", "compliance": {"damping_ratio": 0.7, "hertz": 4.0},
|
|
"held": false, "driven": null}]}
|
|
```
|
|
|
|
A row per revolute or prismatic connection under the root, depth first with children by name, so a row's parent
|
|
comes before it; a root that itself states a revolute or prismatic connection has its own row first, with `parent`
|
|
null, so a report of a sub-tree carries the joint the sub-tree hangs by. `parent` is the nearest joint above, not
|
|
the object the part hangs from: rigid connections fold into it and are counted in `rigid`. `axis` and `origin` are the parent socket's z and origin in the root object's
|
|
frame. `min` and `max` are the limits less the value, the travel either way from the pose the report was taken at,
|
|
which is the shape of Aetheria's `ShipJoint` (`Min` and `Max` about rest). `held` is true when the limits are of
|
|
one value: the joint has no travel (a torque link's lug held at `[90, 90]`), its `min` and `max` are 0, and the
|
|
rig generator will make a fixed bone for it and not a degree of freedom (nothing reads joints rows yet:
|
|
`brokkr_rig` reads meshes); a held row is in neither `unlimited` nor `rigid`. `held` is computed from the limits
|
|
alone and is not the free `mechanism` label: a joint labelled `"held"` that has travel reads `held: false`. `driven` is null, or what the row follows
|
|
(`by` the driver's id, `kind`, `k`, `offset`): a driven row's value is derived, so the rig generator will make a
|
|
driven bone for it and not a degree of freedom. `unlimited` lists the ids of the rows this report carries that are not driven and
|
|
state no limits, so an exporter that needs limits on every degree of freedom refuses by reading one field of each
|
|
report. `manyDrivers` lists each loop with more than one driver that has a part in the tree under the root (its
|
|
closing part, that part's parent, the part closed on, the base, or one of its drivers), as
|
|
`{"loop": the closing part, "drivers": [the loop's driver, each other one]}` by the closing part's name: its
|
|
driven rows are not a function of one driver, so a rig generator refuses the tree while the list is not empty. It
|
|
is of the whole tree, as `rigid` is, and every page carries it. A tree whose rows a receipt cannot carry (about 60 rows, 33 with names of 62 characters) is read in pages:
|
|
`jointsOmitted` counts the rows left off, `next` is then the id of the last row carried, and a call with `after`
|
|
set to it carries the rows that follow, with their own `unlimited`. A row and its id in `unlimited` are kept or left
|
|
off together, so a report is never over a receipt and always carries a row.
|
|
|
|
`ShipJoint` is ruled to gain a kind per degree of freedom and an optional spring
|
|
(aetheria-release:ruling:shipjoint-gains-kind-and-spring), and the rows map to it one to one: `revolute` is its
|
|
`rotate` and `prismatic` its `slide`, with slide limits in metres, and `compliance` is its spring's hertz and
|
|
damping ratio. Brokkr keeps the kinematics names, which its kits' socket types state. What the report gives up: it
|
|
is the pose at the call, so rest is whatever the assembly stood at, and it carries no meshes or bone names, so a
|
|
consumer joins rows to the exported objects by `id`.
|
|
|
|
**What may mate** (`core.mate_refusal`): two sockets of one type whose sizes agree as the type's
|
|
`match` says: `equal` within 1 percent of the larger, `fits` with the child at most the parent. Socket types are a
|
|
vocabulary kits share: parts of two kits mate when both kits declare the socket's type with the same `match` and
|
|
the same `dof`
|
|
(`cutters` declares `mount` as `mechanical` does, so a vent seats on a recess floor), and are refused, naming both
|
|
kits and the type, when one does not declare it or declares it otherwise. KSP's attach nodes and LDraw's snap
|
|
types are connector vocabularies of this kind: global, matched by type and size. `attach` also
|
|
refuses, changing nothing:
|
|
|
|
- a child that has a parent (`detach` it; `setObjectParent` with an empty parent clears a parent it was not
|
|
attached to);
|
|
- a parent that is the child, or is below it (a loop);
|
|
- an occupied socket: one a child is already attached to, the one the part itself is attached by, or one a
|
|
closure holds, at either end;
|
|
- a part that is not a kit part, or is scaled in the world.
|
|
|
|
A part may carry a child on every socket but the one it hangs by. Connections are a tree: tank, then a tee on
|
|
its port, then a nozzle on each free flange of the tee. Nothing moves a part but `attach`, `set_params` and the
|
|
three that pose a hinge, through that tree.
|
|
|
|
**A closure** states the one thing a tree cannot: that a part's second socket also meets something. A brace
|
|
hangs from its own bracket by one pin (a connection); its other pin meets the leg's rod (a closure), and the
|
|
hull, leg and brace are then a loop. The closing part owns it, one at most, as three ID properties:
|
|
`kit_close_socket` (its own socket), `kit_close_to` (the other part, held as a pointer, so it follows a rename)
|
|
and `kit_close_to_socket`. The pointer keeps a deleted part in the file as an orphan, so a part counts as gone
|
|
when the pointer is empty or the object is in no collection. A spanning tree plus loop-closing
|
|
constraints is how closed chains are usually stated (Featherstone, Rigid Body Dynamics Algorithms, ch. 8;
|
|
MuJoCo's `connect` equality on its kinematic tree).
|
|
|
|
`close` writes those three properties and nothing else. It never moves a part: it is accepted only when the two
|
|
sockets already meet, origins together and normals opposed within 1e-5, at any roll (a closure is a pin). It
|
|
refuses, changing nothing: a part that is not a kit part, is scaled or is in no collection, a part closing on itself, two sockets
|
|
that may not mate (the part it names counts as the parent), an occupied socket at either end, a part that
|
|
already states a closure, and two sockets that do not meet, saying how far apart they stand.
|
|
|
|
Making them meet is the caller's work, and nothing in the add-on solves a loop. For two members pinned in one
|
|
plane it is a triangle. With `a` and `b` the two members' pin-to-pin lengths and `d` the distance between the
|
|
two fixed pins, the angle at the first fixed pin between the line to the second and the first member is
|
|
|
|
```text
|
|
acos((a*a + d*d - b*b) / (2*a*d))
|
|
```
|
|
|
|
which gives the point where the free pins meet. Each member's roll is then the angle, about its fixed pin's
|
|
`z`, from that socket's `y` to the direction of the meeting point. `report` gives every socket's world frame to
|
|
read these from.
|
|
|
|
**Posing a hinge.** The roll is a connection's one degree of freedom, and three actions change it where the part
|
|
hangs: its parent and both sockets stay, the part is seated again at the new roll, and what is attached to it
|
|
follows through parenting. None of them detaches anything. `roll` states the roll. `aim` and `reach` solve it:
|
|
with everything but the roll held, a point or an axis of the child moves on a circle as the roll turns, so along
|
|
a world direction `d` it reads
|
|
|
|
```text
|
|
d . p(roll) = A cos(roll) + B sin(roll) + C
|
|
```
|
|
|
|
with `A`, `B` and `C` from the parent's world frame, the two sockets and the point or axis in the child's own
|
|
frame (`core.roll_terms`). `aim` turns one of the child's own axes (`+x` to `-z`) as far toward `d` as the pin
|
|
lets it: `roll = atan2(B, A)`, and the dot it reaches is `C + hypot(A, B)`, reported as `aimed: {roll, dot}`; a
|
|
dot under 1 says the pin does not let the axis reach the direction. `reach` brings the origin of one of the
|
|
child's sockets to the plane `d . x = height`: `roll = atan2(B, A) ± acos((height - C) / hypot(A, B))`, of the two
|
|
the one nearer the roll the part has (a tie takes the smaller), reported as `reached: {roll, residual}`. Both are
|
|
exact: nothing is searched. The roll they write is in (-180, 180] and is stored as `kit_roll`; the direction or
|
|
plane it was solved for is stored nowhere, so a parent that moves afterwards carries the part with it and nothing
|
|
re-aims it.
|
|
|
|
They refuse, changing nothing: a part that states no connection (`attach` it first), one whose parent was
|
|
cleared, a connection `attach` would refuse now (sockets that no longer mate), a zero direction, an `aim` whose
|
|
axis or direction lies along the pin (no roll turns one toward the other), a `reach` with a socket that lies on
|
|
the pin or a direction along it (no roll moves it), and a `reach` to a height the socket's circle does not cross,
|
|
naming the range it does.
|
|
|
|
A scene's matrices and an action's fields are float32, and a direction read from a report has 6 decimals, so
|
|
neither test is exact. "Along the pin" is `hypot(A, B)` at most 1e-3 (`core.AIM_FLOOR`): a direction within about
|
|
0.06 degrees of the pin, which covers the pin's own direction read from a report and typed at 4 decimals. A
|
|
`reach` to a height up to 1e-5 m past the top or bottom of the circle (`core.REACH_EDGE`) is taken as the top or
|
|
bottom, so the range a refusal names can be typed back; `residual` then says how far short the socket stands.
|
|
|
|
A leg is posed with them from the hip down: `aim` the yoke's
|
|
front at where the leg should point, `reach` the last link's clevis to the ground plus the foot's drop, `aim`
|
|
the foot's sole at the ground. Each reports `closures` as `set_params` does, the part's own first: a roll moves
|
|
everything below the part, can open a closure anywhere there, and never seats one.
|
|
|
|
A part's report carries `closure`: `null`, or
|
|
|
|
```json
|
|
{"to": "Leg", "socket": "end_b", "toSocket": "rod_end", "residual": 3.9e-07, "holds": true, "reason": null}
|
|
```
|
|
|
|
`residual` is the larger of the largest difference between the two origins and the largest entry of the sum of
|
|
the two normals; `holds` is true when it is at most 1e-5 and nothing below applies. When it does not hold,
|
|
`reason` says why in a sentence: the other part is gone (`to` is then `null`); the other part cannot be read
|
|
against (not a kit part, scaled by hand, or without that socket; `residual` is then `null`);
|
|
another part's closure names the same socket, which a duplicated closing part leaves behind and which makes
|
|
both read not held until one is detached; or the two sockets stand apart. A closure is never seated. `set_params` on either end refuses a change
|
|
after which the two sockets may no longer mate (a pin of another size), naming the closure. A change that only
|
|
moves a socket (an actuator's `extension` under a closed brace) is accepted and opens the closure: the report
|
|
of `set_params` lists every closure in the scene as `closures: [{part, to, holds}]`, those its own part is an
|
|
end of first, then those that do not hold, then the rest, so the caller sees which
|
|
ones it opened and can solve the rolls again, turn the members with `roll` or `reach`, and find the closure holding.
|
|
`detach` clears the closing part's closure together with its connection.
|
|
|
|
**`set_params` keeps an assembly together.** Sockets move with params (an actuator's `rod_end` with `extension`, a
|
|
tank's `port_b` with `length`). After the rebuild `set_params` writes the derived `matrix_basis` of the part
|
|
itself, if it is attached, and of each part attached to it; what hangs further down follows through parenting.
|
|
Before it writes anything it checks every one of those connections against the part's new sockets, and a change
|
|
that breaks one (a `pipe_r` that no longer matches the flange it is bolted to) is refused, naming the
|
|
connection.
|
|
|
|
**Drift.** `setObjectTransform` and `setObjectParent` are Brokkr's own rows and can move or re-parent an attached
|
|
child; `setObjectParent` refuses only a parent that would give a stated loop a second driver, or the parent of a
|
|
part a loop that already has one hangs from ("Followers").
|
|
Reports show it: a part's `connection` is `null`, or
|
|
|
|
```json
|
|
{"parent": "Tee", "socket": "mount", "parentSocket": "c", "roll": 37.0, "residual": 2.1e-07, "holds": true}
|
|
```
|
|
|
|
`residual` is the largest entry of the difference between the socket's world frame and the frame its mate asks
|
|
for; `holds` is true when the parent is a kit part, both sockets exist, the roll is a number,
|
|
the parent inverse is the identity and the residual is at most 1e-5. The next `set_params` on the child or on
|
|
its parent (with any param, even at its current value) seats it again. A child whose parent was cleared or
|
|
replaced by something that is not a kit part reads `holds` false with a `null` residual, and `set_params`
|
|
refuses it: `detach` clears what is left.
|
|
A `kit_roll` that is not a finite number (only a hand can write one) reads `roll` `null` and `holds` false, and
|
|
`set_params` on the child or its parent refuses it and leaves it as written: `detach` the child and `attach` it
|
|
again. `detach` keeps the part where it stands in the world and leaves the parts attached to it attached.
|
|
|
|
**`boolean`** cuts a mesh, a kit part or any other, with another mesh object. A target carries at most one
|
|
Boolean modifier per operation, `Kit Difference`, `Kit Union` and `Kit Intersect`, evaluated in that order above
|
|
its `Kit Bevel` (so the cut's edges are bevelled with the rest), or at the end of the stack of a mesh that has no
|
|
Bevel. Each modifier cuts with a collection, and `boolean` adds the cutter to it: the modifier's collection is the
|
|
one statement of which cutters cut the target; its name (`<target> difference`) is a label, and it is linked to no
|
|
scene, so it does not show in the outliner's scene tree. A cutter is listed once: `boolean` refuses one that
|
|
already cuts the target under any operation. The target must not be scaled.
|
|
|
|
The solver is always Exact with self-intersection on: a kit part is several overlapping closed shells, and
|
|
without it the shells cancel where they overlap (the 1.8 m tank with a box cut through a cradle, the pad, a strap
|
|
and the barrel keeps 0.251 m3 with self-intersection and 0.006 m3 without). The cost grows with the shells that
|
|
overlap, so each turned body of the kit is one lathe. What carries from machine to machine is the ratio to the
|
|
same part built as a stack of tubes: 0.31 for the tank's turned body (6 shells against 20), 0.33 for the nozzle
|
|
(9 against 24) and 0.81 for a pipe fitting (14 against 19). As absolute times, a box cut from a part at its
|
|
defaults, placed through the add-on with its Bevel below the Boolean, evaluated in 0.50 to 0.55 s for the tank
|
|
(two sessions), 0.49 s for the nozzle and 0.31 s for a pipe fitting on Blender 5.3 on the workstation Starfire
|
|
(medians of four processes of five evaluations). The tank's four lugs, shells 7 to 10, add 1 percent to a cut
|
|
that misses them and 4 percent to one through them.
|
|
|
|
One Boolean over a collection is why cutters share a modifier. On a shell like a mech's pod (a loft of 6 rings of
|
|
8, Subsurf 3, Solidify 0.06: 5000 faces once cut) with 8 box and cylinder cutters placed by `cut`, one evaluation
|
|
took 1.89 s through the collection modifier, 12.6 s with a Boolean modifier for each cutter, and 1.81 s with the
|
|
eight cutters joined into one mesh (medians of five interleaved evaluations, Blender 5.3 on Starfire; an earlier
|
|
probe with raw cutters read 2.04, 14.7 and 1.94 s). All three give the same faces and volume. The cost is the
|
|
target's, hardly the cutters': one cutter on that shell already costs 1.4 s. The target pays it each time it is
|
|
evaluated, and Blender evaluates it after every action that changes it or a cutter, and after much that changes
|
|
neither ("Freezing", below): `freeze` an object when its cuts are settled. `boolean`
|
|
evaluates the target once and reports `evaluated: {faces, volume, nonManifoldEdges}`; `report` never evaluates a
|
|
modifier. The cutter is any other mesh object and is not changed: hide it with `setObjectVisibility`. A cutter
|
|
with no material leaves the target's material slots as they are; a cutter that has materials brings them, after
|
|
the target's own, on the faces it makes.
|
|
|
|
### Freezing
|
|
|
|
A live Boolean over a collection is paid for far more often than its target changes. In Blender 5.3 every such
|
|
Boolean in the scene is evaluated again, whatever it cuts, after any datablock is removed (an orphan mesh
|
|
included), after any object's `hide_viewport` changes, and after any evaluated mesh is copied out
|
|
(`new_from_object`). Adding objects, collections or modifiers does not do it. Nearly every action here does one of
|
|
the three (`cut_many` hides its target's Booleans to cast, `ribs` makes and removes working objects), so each
|
|
finished cut object is paid for again at each later action. Hiding the finished object does not help while its
|
|
cutters show, and the hide is itself one more trigger. On a replica of six cut plates (a subdivided, solidified
|
|
sphere under one Exact Boolean of four cutters each), each trigger on an unrelated datablock cost 19 to 23 s; with
|
|
the plates frozen, 0.004 to 0.014 s (three interleaved repetitions, Blender 5.3 on Starfire).
|
|
|
|
**`freeze`** takes any mesh object that has modifiers, a kit part, a shell or a plain mesh. Its mesh becomes its
|
|
evaluated mesh (named `<object> frozen`), its live mesh is held by an ID-pointer property, `kit_frozen`, and
|
|
given a fake user and `kit_kept`, a pointer to the frozen mesh, so it survives a purge of orphans and a save even
|
|
if `kit_frozen` is edited by hand. The kit settles this after every depsgraph update and before every save: a live
|
|
mesh that no `kit_frozen` points at loses its fake user and `kit_kept`, unless an object still carries the frozen
|
|
mesh its `kit_kept` names. So deleting a frozen object, by `deleteObject` or in Blender, releases its live mesh to
|
|
the next purge or save, and a `kit_kept` cleared by hand is written again. The fake user is the kit's: one already
|
|
set on a live mesh goes when the mesh is released. Every modifier stays in the stack with its collections, turned
|
|
off in viewports and renders. Nothing is removed: the cutter objects stay, a cutter placed by `cut` keeps its floor socket and what
|
|
is attached to it, and `booleans` still lists what cuts the object. The frozen mesh's material slots are the
|
|
object's own (an empty one it had included), followed by any a cutter brought; faces a cutter made from an empty
|
|
slot of its own take the first slot. A frozen kit part keeps `kit_kit`, `kit_part`, `kit_params` and its
|
|
connections: its sockets are still derived from the params, so `attach`, `detach`, `roll`, `aim`, `reach`, `joint`,
|
|
`slide`, `joints`, `follow` and `close` work on it and on what hangs from it. `freeze` reports the part (or `object`), `frozen`, `faces` (the live
|
|
mesh's count, as in every report), `evaluated: {faces, volume, nonManifoldEdges}` (the frozen mesh), `modifiers`
|
|
and `booleans`. `report` on a frozen part gives `faces`, still the live mesh's, and `evaluated: {faces}`, the
|
|
frozen mesh's.
|
|
|
|
**`thaw`** puts the live mesh back, deletes `kit_frozen`, turns every modifier on and removes the frozen mesh. It
|
|
evaluates nothing itself; Blender evaluates the object once afterwards, and the thawed object evaluates to the
|
|
faces and volume it had.
|
|
|
|
A frozen object's mesh is not its design, so every action that would write its live mesh or its stack refuses it
|
|
with "thaw it first": `set_params`, `boolean`, `cut`, `cut_many`, `ribs` from it, a `shell` or `hose` rebuild of
|
|
it, and `freeze`. Derive ribs before freezing a cage. `freeze` also refuses an object with no modifiers, one with a
|
|
modifier already off in viewports or renders (it names them: `thaw` turns every modifier on, and would not give
|
|
that stack back), and one Blender does not evaluate. `thaw` refuses an object that is not frozen, and one whose
|
|
`kit_frozen` no longer holds a mesh; if a hand edit overwrote or deleted it, the refusal names the kept live mesh
|
|
whose `kit_kept` points at the mesh the object carries, and setting `kit_frozen` back to that mesh by hand lets
|
|
`thaw` through.
|
|
|
|
A modifier of a frozen object turned on by hand is applied on top of the frozen mesh. `report` shows such a part
|
|
with `frozen` false and `dirty`, the names of the modifiers shown in viewports or renders; it stays refused by the
|
|
actions above, as "frozen and dirty", until it is thawed. `exportGltf` with `applyModifiers` exports a frozen
|
|
object's frozen mesh, since its modifiers are off, and refuses an export that includes a dirty one, by the same
|
|
rule: a modifier shown in viewports or renders. What nothing detects: a
|
|
material assigned to a frozen object, which lands on the frozen mesh and goes at `thaw`.
|
|
|
|
What it buys on an assembly: KESTREL, an experiment mech of 22 cut shells and blocks, evaluated 1035 Booleans
|
|
where its cuts need 139 when each finished component was only hidden, and 139 when each was frozen as it was
|
|
finished. The evaluation counts are the stable measure: they repeat exactly. Wall time follows the machine's
|
|
load: the whole build took about 2.7 to 5.7 times as long hidden as frozen across two series of three interleaved
|
|
pairs (Blender 5.3 on Starfire under other load; 133 to 149 s against 32 to 54 s in the later one). In
|
|
`tests/live/kitbash_assembly.py`, removing an orphan mesh beside three cut tanks costs about 1 s with them live
|
|
and about 0.002 s with them frozen.
|
|
|
|
## Making a shell
|
|
|
|
`shell` makes an armor plate the way one is modelled by hand: fit a sparse subdivision cage, crease the edges that
|
|
are facets' borders, give it a wall, then cut into it. The description is a JSON object, `sheet`, in one of two
|
|
forms, both compiled by `core.sheet` into the same cage: a **loft** (`rings`), below, or a **free cage** (`verts`
|
|
and `faces`, [A free cage](#a-free-cage)). A sheet states exactly one of `rings` and `verts`. The loft is rings of
|
|
points with equal counts, quads between neighbouring rings:
|
|
|
|
| key | default | what it says |
|
|
| --- | --- | --- |
|
|
| `rings` | required | 2 to 64 rings of 2 to 64 `[x, y, z]` points in the shell's own frame, equal counts |
|
|
| `closed` | `false` | each ring joins back to its first point (a sleeve); not with `mirror` |
|
|
| `mirror` | `false` | each ring is authored from its point 0 on x = 0 toward +x and mirrored across x: 2C - 1 points |
|
|
| `creases` | `[]` | runs: `{"ring": i, "from": a, "to": b, "weight": w}`, `{"column": j, "from": a, "to": b, "weight": w}`, `{"point": [i, j], "weight": w}` |
|
|
| `rim` | `1` | the weight of every boundary edge no run names |
|
|
| `flip` | `false` | reverse every face |
|
|
|
|
**Winding.** Quad (i, j) is `P[i][j], P[i][j+1], P[i+1][j+1], P[i+1][j]`: the surface faces out where, seen from
|
|
outside, a ring's points run left to right and the rings run upward. If the report's `facing` (the cage's mean
|
|
normal) points into the machine, set `flip` or author the rings the other way. Outward matters: the wall grows
|
|
inward from the designed surface (`offset` -1), `cut` rays must meet the outer face, and `ribs` stands on the
|
|
side the normals face away from.
|
|
|
|
**Creases.** A ring run creases ring `i`'s edges from point `from` to point `to`; a column run creases column
|
|
`j`'s edges from ring `from` to ring `to`; a point is one vertex. A weight of 1 is a hard facet edge, and lower
|
|
weights are semi-sharp: on the pauldron below, 1.0 holds 52 degrees across the shoulder line and 0.6 holds 35,
|
|
while every edge that carries no crease stays under 6. Runs are partial on purpose: a facet edge that dies out
|
|
halfway along a plate is a run that stops there. An edge has one weight; two runs that give it different ones are
|
|
refused, naming both. On a mirrored sheet a run names authored indices and lands on both halves, and a ring run
|
|
from point 0 joins across the middle. A vertex where exactly two creased edges meet is smoothed along them, so a
|
|
closed loop of runs (a raised face's border) rounds into a disc unless each of its corners is also a `point`;
|
|
where three or more meet, or a run ends on the rim, the corner holds by itself. `rim` 1 keeps the outline as drawn, corners included; with `rim` 0 the
|
|
outline rounds between the corners, which stay (the Subdivision preserves them).
|
|
|
|
```json
|
|
{"action": "brokkr_kitbash.shell", "object_name": "Pauldron", "thickness": 0.06, "bevel": 0.004,
|
|
"sheet": "{\"flip\": true, \"creases\": [{\"column\": 3, \"from\": 0, \"to\": 5, \"weight\": 1.0}], \"rings\": [[[0.47, -1.35, 1.02], [-0.17, -1.35, 1.28], [-0.77, -1.35, 1.15], [-1.15, -1.35, 0.85], [-1.32, -1.35, 0.26], [-1.4, -1.35, -0.3]], ...]}"}
|
|
```
|
|
|
|
Six rings of six points run aft to fore; each goes over the crown from inboard and down the outer face, and
|
|
column 3, the shoulder line, is creased, so the crown and the steep outer face are two facets of one plate. Ring 2
|
|
dips: the plate is concave there, which no convex hull can be.
|
|
|
|
The object carries the cage, `crease_edge` and `crease_vert`, and the modifiers `Kit Subsurf` (`levels`, creases
|
|
used) then `Kit Solidify` (`thickness`, `offset`, plain offset, rim filled), then any Booleans `cut` adds, then the `Kit
|
|
Bevel` when `bevel` is over 0. `kit_shell` on it is the request, and it owns the cage as `kit_params` owns a
|
|
part's mesh: an edit of the cage by hand is lost at the next `shell` call. `shell` reports `object`, `rebuilt`,
|
|
`rings`, `points`, `cageFaces`, `creases` (edges with a weight over 0), `folded` (see Thickness at a crease),
|
|
`corners`, `subdividedFaces`, `facing`, `thickness`, `offset`, `levels` and `children`. All but `folded` are facts
|
|
of the cage: without `count_folds`, `shell` reads no evaluated mesh.
|
|
|
|
**Rebuilding.** `shell` on a name that is already a shell rewrites its cage in place. The object, its mesh
|
|
datablock, its material slots, its cutters, its ribs and its Booleans stay, so a plate can be reshaped after it is
|
|
cut. Cutters stay at their frames in the shell's frame: where the surface moved away from a cutter the cut is
|
|
shallower or floats, so raise the cutter's `lift` or `depth` (`set_params`), or cut again. Ribs are a bake: after a
|
|
rebuild, delete them and run `ribs` again. A name that is some other object is refused, as are a scaled shell and
|
|
one that shares its mesh.
|
|
|
|
**Outlines.** A loft's outline is its first and last rings and its end columns. Notches and tabs in it are
|
|
through cuts at the rim: a `box` or `slot` cutter deeper than the wall, placed across the edge, takes a bite out of
|
|
the outline, and the plate left between two bites is a tab.
|
|
|
|
**With ribs.** `ribs` reads the plate's thickness from `Kit Solidify` and follows a crease, clipping a rib inside
|
|
it; a rib deeper than the room a tight crease leaves is refused with the size to lower.
|
|
|
|
**Thickness at a crease.** `shell` takes any `thickness` in its range and does not refuse one the cage cannot
|
|
hold: the limit is a fact of the subdivided mesh, not of the cage. `Kit Solidify` is a plain offset (Even Thickness
|
|
off): each vertex of the wall's far face stands `thickness` from its vertex of the designed surface, along that
|
|
vertex's normal. On a full crease that normal is the crease's bisector, so the wall there is `thickness` x cos(phi)
|
|
thick square to a facet, phi being half the angle between the two facets' normals: 0.71 of it at a right-angled
|
|
crease, and the rim strip at a creased corner is narrower by the same factor. A wall of 0.06 reads 0.0539 behind
|
|
the pauldron's shoulder crease above. The crease vertex slides `thickness` x sin(phi) across each facet; the
|
|
vertices beside it move straight in. Where that slide is longer than the first row of subdivided faces, the wall's
|
|
far face folds over itself beside the crease: at a wall depth over (W / 2^`levels`) / sin(phi), W the width across
|
|
the crease of the narrower of its two facets. The fold is on the crease's concave side: behind a ridge, so under a
|
|
wall grown inward, and in front of a valley, under a wall grown outward; the two read the same. Measured on two
|
|
flat facets, a crease of 1.0: the fold starts at 1.00 of that figure in 31 of 31 readings (W 1 and 0.4; phi 15 to
|
|
60; levels 1 to 3; a ridge, and a valley at levels 2), which is 0.25 for W 1, phi 30, levels 3, and 0.058 for W
|
|
0.4, phi 60, levels 3. Facets 1.0 and 0.3 wide at phi 45, levels 2, fold at 0.106, the narrow facet's figure, not
|
|
the wide one's 0.354. A crease of 0.5 folds at 0.72 to 1.14 of it, and an uncreased edge folds too, at 1.21 to 3.3
|
|
of it (three readings each). The fold is inside the wall and one subdivided row wide: the designed surface is
|
|
unchanged and the mesh has no open or non-manifold edge, but the solid passes through itself there, and a cut
|
|
through that place is untested.
|
|
|
|
Even Thickness would hold the wall at `thickness` square to both facets by moving the crease vertex `thickness` /
|
|
cos(phi) along the bisector. That slides it `thickness` x tan(phi) across each facet, so the wall folds sooner, at
|
|
(W / 2^`levels`) / tan(phi) (1.00 of it in the same 31 readings), and where creases meet at a pinned corner of a
|
|
narrow plate the factor runs away and the wall throws a needle. A plate of a crown ring, a flared skirt and a
|
|
domed centre, 0.13 m wide and 1.2 m long, with a wall of 0.04, stood 3.28 thicknesses beyond its cage's bounds
|
|
with Even Thickness and stands 0.95 with the plain offset (0.372 m against 0.076 m at a wall of 0.08). A hexagon of
|
|
the same make 1.2 m across folded 20 of its 168 inner faces at 0.015, 28 at 0.03 and 44 at 0.07; with the plain
|
|
offset it folds 0, 2 and 20. `tests/live/kitbash_cage.py` holds the two plates. Solidify's thickness clamp with
|
|
its angle clamp changed no fold count and no bound in either mode, and its complex mode threw a vertex 2.07 m
|
|
beyond a 1.0 m plate's cage at a wall of 0.08 (2026-12-03).
|
|
|
|
No figure read from the cage bounds this. Of three seeded lofts of planar trapezoid facets with partial crease
|
|
runs (`tests/fixtures/fold_lofts.json`), the evaluated wall first folds at 0.042 with the wall grown inward and
|
|
at 0.023 grown outward, and at `offset` 0 it folds at the least thickness `shell` takes (2026-12-03). The lofts
|
|
were drawn against Even Thickness, where the flat-facet figure of that mode, taken over every cage edge, was
|
|
neither a floor nor a ceiling: the wall first folded at 0.44 of it grown inward, at 0.03 of it at `offset` 0 and at
|
|
0.08 of it grown outward, and on the Seraph's plates a first face normal turned at 0.74 to 2.6 of it (2026-12-02).
|
|
So `shell` counts instead of estimating: with `count_folds` it evaluates the wall alone,
|
|
`Kit Subsurf` and `Kit Solidify` with every other modifier hidden for the reading and shown again, and reports
|
|
`folded`, the number of the wall's inner faces that fold. An inner face folds when the turn at any of its corners
|
|
runs with its outer twin's normal: the corner has passed over its neighbour. That is sooner than the face's own
|
|
normal turning: on the Seraph's cap, with Even Thickness, a corner turned at 0.033 and no face normal had at 0.0416. Without `count_folds`, `folded` is null
|
|
and nothing is evaluated. The count cost 3.9 ms on a new plate of 1600 subdivided faces (a call of 7.7 ms against
|
|
3.8 ms), and nothing measurable on a rebuild under six cutters (0.94 s against 0.92 s, the call's own Boolean),
|
|
medians of three interleaved calls in the live suite (Blender 5.3 on Starfire). On a shell whose `Kit Subsurf` or
|
|
`Kit Solidify` is hidden in viewports `count_folds` is refused before anything is written.
|
|
|
|
`folded` 0 is not yet a wall an Exact Boolean takes cleanly. Short of the fold the inner quads at a tight rim corner
|
|
are twisted, and the Boolean, which cuts quads into triangles, can read the wall as passing through itself and
|
|
leave edges with four faces. On the Seraph's cap, read with Even Thickness, that began at 0.91 of the thickness at which the first face
|
|
folds (0.0301 against 0.033), on the left cap and not on its mirror, the right; on its breast plate at 0.91 as
|
|
well (0.032 against 0.035). Read `nonManifoldEdges` after cutting (`boolean`, `freeze`, or a count on the evaluated
|
|
mesh), and keep `thickness` clear of the first folding one with a thinner wall, fewer `levels` or wider facets at
|
|
the corner.
|
|
|
|
Refused, each before anything is written and naming the field and index: a missing or unknown key; a non-finite
|
|
number; fewer than 2 or more than 64 rings or points; rings of unequal counts; a quad under 1e-8 m2 (a collapsed
|
|
corner); a mirrored ring that does not start on x = 0 or has a point behind it; `mirror` with `closed`; a run out
|
|
of range or with `from` not under `to`; a weight outside 0 to 1; more than 262144 subdivided faces (a quad gives
|
|
4 to the `levels`, a triangle three quarters of that).
|
|
|
|
On the pauldron (25 cage quads, 1600 subdivided faces, 3360 with the wall), `shell` took 3.5 ms a call with
|
|
Blender's own update after it, and one whole evaluation of the Subdivision and Solidify 1.7 ms. With six cutters
|
|
(four panel lines, two insets) and ribs under it, a rebuild took 0.92 s, which is its one Boolean evaluation.
|
|
Medians of 3, interleaved, Blender 5.3 on Starfire (`tests/live/kitbash_faceted.py`, `costs`).
|
|
|
|
### A free cage
|
|
|
|
A loft is a grid: every vertex off its boundary has four edges, so it cannot state a triangle, a pole, or a crease
|
|
that ends inside the surface. A hull modelled by hand uses all three. The bar is the fewest cage vertices that
|
|
hold the form, with creases doing the work: a dense cage that only looks smooth after subdivision is the failure.
|
|
The free form states the cage directly:
|
|
|
|
| key | default | what it says |
|
|
| --- | --- | --- |
|
|
| `verts` | required | 4 to 256 `[x, y, z]` in the shell's own frame |
|
|
| `faces` | required | each 3 or 4 vertex indices, counter-clockwise seen from outside |
|
|
| `creases` | `[]` | `[a, b, w]`: the edge between vertices a and b, weight 0 to 1 |
|
|
| `corners` | `[]` | `[vertex, w]`: a vertex held as a corner |
|
|
| `poles` | `[]` | the vertices of irregular valence, by index: a gate, below |
|
|
| `mirror` | `false` | the cage is authored on one side of x = 0 and reflected |
|
|
| `rim` | `1` | the weight of every boundary edge no crease names |
|
|
| `flip` | `false` | reverse every face |
|
|
|
|
```json
|
|
{"verts": [[0, 0, 0.5], [1, 0, 0], [0, 1, 0], [-1, 0, 0], [0, -1, 0], [1, 0, -1], [0, 1, -1]],
|
|
"faces": [[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 1], [2, 1, 5, 6]],
|
|
"creases": [[0, 1, 1.0], [0, 3, 1.0]], "poles": [1, 2], "rim": 0}
|
|
```
|
|
|
|
**Boundary.** A free cage's open boundary is smoothed through every vertex (Kit Subsurf at Boundary Smooth All),
|
|
as the hand-modelled cages are set: an uncreased outline is a soft curve and a plate's tip is round. A boundary
|
|
vertex is a corner only where `corners` pins it at weight 1 or its two edges are creased apart by the form. A loft
|
|
keeps its corners (Keep Corners), as it always has. With the outline uncreased the two settings differ by 7.7% of
|
|
extent on a 3 m plate, so the setting is the form's and not a taste.
|
|
|
|
**Mirror.** Every vertex off the seam stands on one side of x = 0 (either side, all the same). One within 0.005
|
|
of the cage's largest authored extent of the plane (5 mm on a 1 m hull) is on the seam, on whichever side it
|
|
strays: it is snapped to x = 0 and shared by both halves, so a cage reads the same at any scale. The others are
|
|
reflected (the k-th of them is vertex `len(verts) + k`), each face gets a reversed twin, and creases, corners and
|
|
poles land on both halves. A vertex further off the plane is not on the seam: the cage is open there, and a face
|
|
that then meets its reflection at one vertex alone is refused as pinched. A face lying on the plane, and an edge
|
|
on the plane that two authored faces share (a fin), are refused.
|
|
|
|
**The pole gate.** A vertex's valence is the number of cage edges at it, on the cage as built (after the
|
|
mirror). A pole is a vertex whose valence is not 4 off the boundary, or not 2 or 3 on it. `poles` must list
|
|
exactly the poles the faces make. An undeclared pole and a declared vertex that is none are both refused, naming
|
|
the vertex and its valence. The list changes nothing in the mesh: it is there so that no pole is an accident,
|
|
since a pole is where a subdivision surface pinches or flattens. Put one where a crease runs through it or a
|
|
triangle stands beside it, and where the form turns anyway.
|
|
|
|
**Triangles.** A triangle subdivides to three quads, so after one level the surface is all quads, and the wall,
|
|
`cut`, `ribs` and `count_folds` take it as any shell. Use one where a crease run ends: the two cage edges
|
|
either side of the crease close onto a point instead of carrying a loop across the rest of the form. Faces of
|
|
five or more sides are refused.
|
|
|
|
**Budget.** Two cages modelled by hand are the measure. A whole ship hull, 1 m long: 46 control vertices (29
|
|
authored under a mirror), 25 faces a side of which 6 are triangles, 9 creased edges a side, every one at weight
|
|
1, six poles, each on a crease or beside a triangle. A petal: 10 vertices, 4 quads and 6 triangles, 5 creased
|
|
ridges at weight 1, an uncreased outline. In both the creases are full weight and stand only where the form
|
|
truly breaks (turns of 40 to 170 degrees); the longest straight silhouette edges are single cage edges; the cage's
|
|
vertices stand outside the form, as subdivision shrinks toward the inside. An armour plate should cost about what
|
|
the petal does. Add a vertex only where the limit surface cannot otherwise reach the form, and say why.
|
|
|
|
**Refused**, before anything is written and naming the field and index: fewer than 4 or more than 256 vertices;
|
|
a vertex in no face; a face of other than 3 or 4 indices, with a repeated or out-of-range index, with another
|
|
face's vertices, or under 1e-8 m2; an edge in three faces; two faces crossing an edge the same way (wound
|
|
against each other); a pinched vertex, whose faces meet only at it and are not one fan, naming the fans; a crease
|
|
on no cage edge; two weights for one edge or point; a mirrored cage with vertices
|
|
on both sides; the pole gate. `closed` and the loft's crease runs belong to the loft and are refused here, as
|
|
`poles`, `corners` and `verts` are on a loft.
|
|
|
|
**The report** carries, for both forms, `cageVerts`, `cageFaces`, `triangles`, `creases`, `corners`, `poles`
|
|
(`{"3": 2, "5": 1}`: valence to how many vertices, on the cage as built) and `closed` (no boundary edge);
|
|
`rings` and `points` are null on a free cage.
|
|
|
|
**What it gives up.** A free cage is authored by index, by hand or by an agent: nothing derives it from a
|
|
silhouette, and a wrong index is caught only where it breaks a rule above, not where it merely makes a worse form.
|
|
There are no pentagons. A loft remains the shorter description of anything that is a grid.
|
|
|
|
**Reading and scoring a cage.** `tools/cage_export.py` writes an object of a `.blend` copy as a free cage document
|
|
(vertices as authored, creases from `crease_edge`, poles computed); it writes only that document and never saves
|
|
the `.blend`. `shell` builds that document as the object's own Subdivision draws it: an open plate with an
|
|
uncreased outline to 2e-5% of its extent, a mirrored hull to 0.28% (its seam snap). A Subdivision at Keep Corners
|
|
is refused, saying how to state the corners.
|
|
|
|
`tools/cage_score.py` builds two documents through `shell` and reports, with no pass bar and every figure a share
|
|
of the reference's largest extent: each one's counts; the distance between their level-3 surfaces, whose vertices
|
|
lie on the limit surface, each way and together (area-weighted mean, Hausdorff, median, 95th centile); silhouette
|
|
overlap along x, y and z; and `crease`, where each surface is sharp (level-3 edges turning 30 degrees or more,
|
|
read off the surface, not off the crease weights): `missPct`, how far the reference's sharp features lie from the
|
|
agent's, and `spurPct`, the reverse; 100 when one side has them and the other none. The headline is `cost`, after
|
|
the energy of Hoppe et al., *Piecewise Smooth Surface Reconstruction* (1994), fit plus complexity:
|
|
`fit = meanPct + hausdorffPct + (missPct + spurPct) / 2`, `complexity = 0.01 * cageVerts + 0.002 * creases` of the
|
|
agent's cage, a sharp edge a fifth of a vertex as in the paper. Lower is better; a cage against itself costs its
|
|
complexity. On the 46-vertex hull: itself 0.50, every vertex 0.5% off 1.26, one vertex moved 5% 1.56, nine more
|
|
edges creased 5.49, every edge creased 16.2, no crease 16.6. The median and the silhouettes cannot make that
|
|
order: a moved vertex leaves the median at 0 and every silhouette at 1, and the creaseless cage has the lower
|
|
median of the two. What the cost gives up: the three fit terms are summed at weight 1 and the vertex price is a
|
|
chosen 0.01, knobs and not measurements; the Hausdorff term is one point, so one stray vertex costs as much as
|
|
a broad error of the same size; and sharpness is a 30 degree threshold, so a crease softer than that is not a
|
|
feature to it.
|
|
|
|
## Cutting a shell
|
|
|
|
An armor plate is not a kit part: it is any mesh, usually one made by `shell`. `cut` cuts it, or a
|
|
kit part, where a ray meets it, and what it places is itself a kit part, of the kit `cutters`:
|
|
|
|
| part | params (besides `depth`, `lift`) | socket |
|
|
| --- | --- | --- |
|
|
| `box` | `width` (x), `height` (y), `count`, `pitch` | `floor` (mount, size the smaller side) |
|
|
| `cyl` | `r`, `count`, `pitch` | `floor` (mount, size `2*r`) |
|
|
| `slot` | `width` (x, end to end), `height` (across; less than `width`), `count`, `pitch` | `floor`, `floor_l`, `floor_r` (mount, size the smaller of `height` and `(width-height)/2`) |
|
|
| `slab` | `gap` (x), `length` (y) | none |
|
|
|
|
A cutter's frame has its origin where the ray met the surface, `z` along the surface normal (turned to face
|
|
against the ray), `y` along the projection of `up` (default the target's +z; refused when it runs along the
|
|
normal) and is then turned `roll` degrees about the normal, right-handed (`core.surface_frame`). Its geometry
|
|
spans `z` from `-depth` to `+lift`: `depth` below the hit point and `lift` above it, so that a curved surface is
|
|
cut cleanly across the whole cutter (raise `lift` for a wide cutter on a tight curve). A `depth` beyond the wall's
|
|
thickness opens a hole. `count` copies stand `pitch` apart along `y`, centred on the frame: a row of gills (roll
|
|
90 turns the row along `x`). A `slab` is a panel break: a thin slab standing on the normal, long along `y`.
|
|
|
|
`axis` (default all zero: the surface normal) states the cutter's `z` instead. A slab on a sloping roof leans
|
|
with the roof's normal; with an axis it stands where it is told, and the break's plane has the normal
|
|
`up` cross `axis`. An axis that points into the surface is refused.
|
|
|
|
The ray and `up` are given in the target's own frame, and the ray is cast at the target evaluated with its `Kit`
|
|
Booleans off: a second cut on the ray of a through bay lands on the surface as designed, not on the far wall
|
|
behind the bay. The target must not be scaled.
|
|
|
|
The cutter object is parented to the target under an identity parent inverse and joins the collection of the
|
|
target's `Kit Difference` modifier. It owns the cut: its `matrix_basis` is the recess frame and its params the
|
|
recess size, and nothing else stores either. `setObjectTransform` on the cutter moves the cut, `set_params`
|
|
resizes it, and deleting the cutter removes the cut. `cut` does not hide the cutter: `setObjectVisibility` does,
|
|
and a hidden cutter still cuts.
|
|
|
|
`box`, `cyl` and `slot` carry a socket, `floor`: on the bottom of the recess at `z = -depth`, at the frame's
|
|
centre, facing out of the recess. A `slot` carries two more on the same floor, `floor_l` and `floor_r`, at the
|
|
centres of its two round ends, `(width-height)/2` to each side: a visor with three eyes. The three are sized so
|
|
that neighbours never overlap and none passes the slot's ends. Machinery attaches there with the ordinary `attach` (a vent's `back`, a
|
|
sensor's `mount`), is a child of the cutter, and so follows the cut when the cutter moves and is seated again
|
|
when `set_params` changes its `depth`. With an even `count` and a `pitch` wider than the copies, the centre lies
|
|
between the two middle copies: use an odd count, or a cutter of its own, for a recess that carries a part. A
|
|
socket holds one part.
|
|
|
|
`cut` reports `{object, cutter, booleans}`, the cutter as `report` would give it, with its floors in the world.
|
|
Its own work is a few milliseconds and it evaluates no Boolean, but Blender evaluates a changed target after
|
|
every action, so each `cut` costs one Boolean evaluation of the target: on the shell above 1.4 to 1.9 s, one
|
|
cutter to eight. `cut_many` takes a JSON array of cutters (`name`, `part`, `origin`, `direction`, and optionally
|
|
`params`, `up`, `roll`, `axis`), checks them all and casts every ray before it writes anything, places all of
|
|
them or none, and costs one evaluation for the lot. On a pod with a Bevel under the Boolean (6500 faces once
|
|
cut), the same 13 cutters took 6.1 s placed by one `cut_many` and 51.3 s placed by 13 `cut` actions, about 8
|
|
times as long (medians of 3, Blender 5.3 on Starfire); hiding each cutter after its `cut` is a second evaluation
|
|
each and brought the 13 to 105 s. Any later action that changes the target or a cutter (hiding the cutters,
|
|
attaching a part to a floor) costs an evaluation again while the target is visible. `cut_many` reports
|
|
`{object, cutters, booleans}` with the cutters by name.
|
|
|
|
`booleans` in a report of `cut`, `cut_many` or `boolean` is trimmed to what a receipt carries: on a target with
|
|
more cutters than fit (about 150 of long names), the rows left off the end are counted in `booleansOmitted`. The
|
|
scene keeps every cutter; the target's `Kit` modifier collections list them.
|
|
|
|
`cut`, `cut_many`, `boolean` and `freeze` evaluate their object, and refuse one Blender does not evaluate in the
|
|
view layer: an object disabled in viewports that nothing evaluated depends on, or one whose collections no view
|
|
layer shows. A disabled object that an evaluated object needs (a parent of one, a cutter of one) is evaluated
|
|
all the same, and is cut.
|
|
|
|
## Ribs from a shell
|
|
|
|
`ribs` derives the frame under an armor cage from the cage, so the frame fits the armor by construction. It
|
|
takes planes in the cage's own frame and makes, as one mesh object under the cage:
|
|
|
|
- a rib along each plane's section of the cage's surface: `thickness` across the plane, set `standoff` behind
|
|
the plate's inner face and reaching `depth` further in along the plane. `standoff` is measured along the
|
|
plate's own normal, at any tilt of the plane and any curvature of the wall: the rib's outer edge is cut from
|
|
the inner face offset inward by `standoff` (every face moved along its own normal, creases mitred), then set
|
|
in by what half the rib's thickness needs on the side the plate leans over, and no part of the rib comes
|
|
nearer the inner face than `standoff`;
|
|
- lightening holes through each rib every `holes` of its length (radius 0.3 of `depth`; 0 for none);
|
|
- posts every `posts` that stand the plate off the rib: a rod from inside the plate into the rib, and a pad flat
|
|
on the plate's inner face (0 for none). A post starts midway between the plate's faces where it stands square
|
|
to them and deeper where it leans, so its end stays under the outer face; where the plate is thinner than the
|
|
lean of the post's end, no post stands;
|
|
- longerons through the ribs: each `{origin, axis, toward}` is the half-plane from the line through `origin`
|
|
along `axis`, on `toward`'s side. Where it crosses a plane's rib, at the rib's mid-depth, is a station; the
|
|
longeron runs through the stations in the planes' order and 0.12 of the end gaps past the end ribs, a section
|
|
`longeron` (a section of the extrude shape's table: `I`, `C`, `T`, `L`, `box`, `wedge` or `gusset`; `longeron_w`, `longeron_h`, `longeron_t`) with its up toward the plate.
|
|
|
|
A rib's outer edge is where its plane cuts the offset surface (`core.inset` makes it: each vertex of the inner
|
|
face stepped to where its faces, moved in by `standoff`, meet). Points `step` apart along the section each look
|
|
square in from the plate for it, and the edge's corners are put where the offset faces they landed on meet. Where
|
|
the offset surface has passed through itself (behind a crease, or inside a curve tighter than `standoff`) its
|
|
points measure nearer the plate than `standoff`: they are left out, and the edge closes across them at the corner
|
|
the faces either side make. Where nothing is left (a `standoff` greater than the wall's inner radius, a plane
|
|
that does not reach the offset surface) the call is refused. The rib is the band beside that edge
|
|
(`core.band`): the edge offset in its plane by `depth`, with mitred corners, and clipped as a polygon offset is,
|
|
so inside a turn tighter than the rib reaches the inner edge cuts the corner and the rib follows the crease.
|
|
The finished outer edge is then measured against the inner face, vertex by vertex, and moved in until none is
|
|
nearer than `standoff` (to 1e-7, what a float32 mesh holds). What the measure corrects is the half thickness,
|
|
which is laid off along the plane by the lean of the offset face: beside a tilted or curved wall that is right
|
|
to first order (it moved a rib 0.0006 on a prism cut at 64 degrees, and 0.005 on a sphere of radius 1 cut 60
|
|
degrees off its middle, where the offset surface leans 74 degrees). A rib that 8 moves do not stand off is
|
|
refused. The move is one distance for the whole rib, so elsewhere along it the rib stands further off than
|
|
`standoff` by up to that much.
|
|
Lightening holes stand on the band's centre line, clipped the same way, so a hole (0.3 of `depth`) keeps 0.2 of
|
|
`depth` of web on both sides; a post that would end outside the rib inside such a turn is left out. Posts and
|
|
longerons are a sweep of an outline along a path with mitred corners (`core.sweep`).
|
|
|
|
The cage is read twice. Evaluated with its Solidify, Bevel and Boolean modifiers off it is the surface as
|
|
designed: each plane cuts that surface into sections, and a section may be several chains (two legs in one cage).
|
|
Evaluated whole it is the plate as it is cut: at points `step` apart along a section, a ray from just outside the
|
|
plate's outer face asks whether the plate is there, looking 1.25 of the plate's thickness deep: a recess
|
|
shallower than the plate is plate, and the far wall of a narrow cage is not. Where it is not, the plate is open. An opening shorter than
|
|
`bridge` along the section is a panel break, and the rib runs behind it; at any other the rib stops `clearance`
|
|
short, and no post or hole stands there. A recess that does not go through is plate. `ribs` reads no cutter: cut
|
|
the cage first, in any way, and the ribs follow what the plate became.
|
|
|
|
The plate's two faces are read from the cage's one Solidify as Blender evaluates it (a cage with none has a
|
|
plate of no thickness; one with two is refused; a negative thickness is the same plate grown to the other side
|
|
of the surface). A simple Solidify writes the surface's vertices twice, in the surface's order, and the inner
|
|
face is the copy further against the normals: so the standoff is from the face the plate has, whatever the
|
|
thickness mode. Blender's default (even thickness off) moves each vertex the thickness along its own normal,
|
|
which makes a wall of 0.06 on a box 0.0424 thick beside each right angle; even thickness on a box whose sides
|
|
lean 45 and 20 degrees makes it 0.057 and 0.066. The report's `thickness` is the Solidify's own number, not a
|
|
measure. Where the Solidify does not write the two faces that way (complex mode, or a modifier after it that
|
|
remakes the vertices, such as a Subsurf after the Solidify) the plate is taken instead as the Solidify's
|
|
thickness behind every face of the designed surface, and the standoff is off by whatever the plate differs from
|
|
that: 0.0176 too far for a wall of 0.06 beside a right angle with even thickness off. Put the Solidify last
|
|
before Bevel and Booleans for the plate as it is. Inward is the side the cage's normals face away from, not a guess from
|
|
the section's shape: a cage whose normals change sides along a section is refused, and one whose normals all
|
|
face inward gets its frame outside. A rib is built at the section's own corners, so its faces lie along the
|
|
cage's facets, and it does not depend on which way round the section was followed.
|
|
|
|
Everything is checked before the ribs object is written, and a refusal names the plane or longeron: a plane that
|
|
misses the cage or lies along its surface; a section that leaves a rib no room, closing in on itself nearer than
|
|
the rib reaches everywhere (lower `standoff` or `depth`); a rib that cannot be stood `standoff` off the plate; a longeron that meets a plane's ribs twice, not at all, or in an opening;
|
|
holes that overlap or leave the rib; a cage that is scaled or that Blender does not evaluate; more than 64 planes or
|
|
16 longerons.
|
|
|
|
The ribs object is a bake of the cage at the call: a child of the cage under identity matrices, with no modifier
|
|
and no material. Its `kit_ribs` property is the request as JSON. After the cage or its cuts change, delete the
|
|
object and run `ribs` again. The holes are cut with one Manifold Boolean a plane, on that plane's ribs alone
|
|
(ribs of one plane never cross; ribs of two planes do), and each cut is checked: closed, and the volume gone is
|
|
the holes' own. Manifold is used here and nowhere else because these shells are built closed and apart; a target's
|
|
live Booleans stay Exact.
|
|
|
|
On a pod (2560 faces subdivided, a wall of 0.06, a port, a panel break and a recess; one whole evaluation
|
|
1.60 s), five ribs with 91 holes, 51 posts and four longerons took 2.26 s and the five ribs alone
|
|
2.02 s, medians of 5 calls in each of 3 processes interleaved with that evaluation (Blender 5.3 on Starfire). The hole cut is the Manifold
|
|
Boolean: 0.017 s a call for those holes against 0.44 s with Exact, 26 times.
|
|
|
|
Each call costs one whole evaluation of the cage, which scales with the cage's Exact Booleans: the action's own
|
|
work is the rest, 0.66 s and 0.42 s here: a second, light evaluation for the plate's two faces, three tree
|
|
queries for each point of a section, and the measure of each rib's edge against the plate, which builds a rib
|
|
again for each move (two to five on the pod). No cheaper route was found in Blender 5.3. The designed surface is read by hiding the cage's
|
|
Solidify, Bevel and Boolean modifiers for the call, which tags the cage, and Blender evaluates it whole again
|
|
afterwards. Reading the surface from a temporary copy without those modifiers costs 0.001 s to link and
|
|
evaluate, but deleting the copy costs the same whole evaluation (1.44 to 1.54 s on the pod against 1.45 to
|
|
1.52 s forced): Blender 5.3 evaluates the cage again after any datablock is deleted, a bare unlinked object
|
|
included, and the hole cut's temporary objects must be deleted too. So a hull with twenty cutters pays their
|
|
evaluation once for every `ribs` call; iterate planes on the cage before it is cut, or with its Booleans off.
|
|
|
|
## Hard plates
|
|
|
|
`brokkr_kitbash/plate.py` owns a hard armour plate's geometry: a convex faceted solid, every facet flat, with
|
|
raised detail panels, a bolt inside each panel corner, and the frames of what stands on it. It is numpy and the
|
|
standard library, as `core.py` and `route.py` are: `plate.check(document)` and `plate.build(table, side=1)`.
|
|
`brokkr_kitbash.plates` (The action, below) writes what `build` returns into the scene and decides none of it. A
|
|
plate the concept draws curved is a shell (Making a shell); the two do not call each other.
|
|
|
|
A plate table is a data document:
|
|
|
|
```json
|
|
{"schema": "brokkr.plates.v0", "plates": [
|
|
{"name": "Thigh.Shield", "mat": "khaki", "bevel": 0.022,
|
|
"slab": {"at": [0.02, 0.9, -0.5], "normal": [0.06, 1, 0.05], "up": [0, 0, 1], "right": [1, 0, 0],
|
|
"outline": [[-0.42, 0.98], [0.42, 0.98], [0.66, 0.5], [0.66, -0.52], [0.42, -1.0], [-0.42, -1.0], [-0.66, -0.52], [-0.66, 0.5]],
|
|
"thick": 0.26, "taper": 0.04},
|
|
"clad": {"mat": "olive_light", "min_area": 0.2, "lifts": [0.05, 0.05], "inset": 0.075, "gap": 0.045, "split": 99.0, "seed": 948708},
|
|
"fits": [{"kind": "mark", "id": "tri", "at": [0.0, -0.05], "height": 0.5}]}
|
|
]}
|
|
```
|
|
|
|
Coordinates are metres in the table's own frame. The module never sees a host or a world: whoever stands the
|
|
plates somewhere owns that matrix. The table alone decides the result. A table holds 1 to 256 rows.
|
|
|
|
### A row
|
|
|
|
| key | value |
|
|
| --- | --- |
|
|
| `name` | 1 to 48 of `a-z A-Z 0-9 _ .`, unique among the plates built |
|
|
| `mat` | a material name, 1 to 63 characters; the caller resolves it |
|
|
| `bevel` | 0 to 0.1 (default 0): the width of the chamfer the caller's Bevel gives every edge; carried, not built |
|
|
| `sides` | `"one"` (default) or `"both"`: built at `side` and at `-side`, named `<name>.R` at side +1 and `<name>.L` at -1 |
|
|
| `mirror` | `true`: the solid is the hull of its points and their x-mirrors, one solid across x = 0 |
|
|
| one solid form | `faces`, `slab`, `sections` or `points` (below) |
|
|
| `clad` | `null` or the detail plating (below) |
|
|
| `face` | `{at, normal, up, right}`: the face anchors stand on, for a row that is not a slab |
|
|
| `fits` | anchors and fittings (below) |
|
|
|
|
`mirror` and `sides` are independent. A two-sided row with one seed, or with no clad, is drawn once, at side +1,
|
|
and its `.L` is the mirror of its `.R`: the same facets in the same order, the same cuts and lifts, every face
|
|
wound the other way from the vertex it started at. Everywhere else, which is a one-sided row built at side -1 and
|
|
a two-sided row with a pair of seeds, side -1 negates x of every point before the hull is built, and facets, ties
|
|
and draws are those of the mirrored solid as built. That is not the mirror of side +1's panels even under the
|
|
same seed: a cut is measured along its edge in the facet's winding, which a mirror reverses, and a tie goes to the
|
|
greater x of the mirrored solid. The mech tracks' builders work this way (paladin's left thigh is its right
|
|
thigh's table at side -1 with the same seeds, and its split panels are cut at the other share), and the fixtures
|
|
hold `build` to them.
|
|
|
|
### Solid forms
|
|
|
|
Each form gives points; the plate is their convex hull.
|
|
|
|
- `faces`: 4 to 32 half-spaces, each `{at, normal}` (kept where `n . p <= n . at`) or
|
|
`{through: [a, b, c], out}` (the plane through three points, outward toward `out`). The corners are every three
|
|
faces' meeting point that lies inside all the others within 1e-6 m. Refused with fewer than four corners or a
|
|
corner 1000 m or more away.
|
|
- `slab`: `{at, normal, up, right, outline, thick, taper, back, gap}`. The outline is drawn on the plane through
|
|
`at` facing `normal`, in (a, b): b is `up` projected into the plane, a is b cross normal, turned toward `right`
|
|
where one is given. `outline` is 3 to 64 `[a, b]` points in either winding, or `{w, h, clip}`: a w by h
|
|
rectangle with its corners cut by `clip`. The outline is drawn in by `gap` (default 0) on every edge; the outer
|
|
face is that ring moved in by `taper` (default 0.04); the ring itself stands `taper` behind the face; the back
|
|
ring stands `thick` behind, scaled by `back` (default 1) about the ring's middle (the mean of its points).
|
|
- `slab` by corners: `{corners, names, inside, lift, thick, taper, back, gap, up}`. `corners` is 3 to 64 points;
|
|
the outer face is their least-squares plane, outward away from `inside`, standing `lift` (default 0.06) off
|
|
it; the outline is the corners in that plane's frame (`core.surface_frame` at centre + normal x lift). `names`
|
|
is optional, one distinct name per corner, so a plate blocked by `brokkr_reference.block_plate` can become a
|
|
row. Corners that stand off their plane by more than 0.05 of their extent (the greatest distance between two
|
|
of them) are refused: that is not a plate.
|
|
- `sections`: 2 to 16 `[z, w, y0, y1, c]`, each a rectangle w across x from y0 to y1 at height z with its corners
|
|
cut c: a housing down a limb.
|
|
- `points`: 4 to 64 `[x, y, z]`.
|
|
|
|
Where each came from on the three mech tracks: `faces` is bastion's carapace (`massing.corners`), `slab` paladin's
|
|
limb armour (`massing.slab_points`) with raptor's `gap`, the corners slab raptor's hull plates
|
|
(`raptor_body.wedge_plate`), `sections` paladin's and raptor's limb housings, `points` all three.
|
|
|
|
### The hull and its facets
|
|
|
|
The module builds the hull itself. A facet is every plane through three points that has all points on its inner
|
|
side, taken once for the set of points on it and ordered by angle about their middle. Then two rules, both at
|
|
0.5 degrees: adjacent facets whose normals are closer than that are one facet, and a vertex left with two edges
|
|
that turn less than that is dropped.
|
|
|
|
Facets are ordered by area, largest first; areas within 1e-9 m2 tie and go to the greater centre by x, then y,
|
|
then z (the centre is the mean of the facet's vertices). The order is computed on the solid as built in the table
|
|
frame, never from where the plate stands or from a mesh's order, and it decides which facet draws from the seed
|
|
first.
|
|
|
|
### Clad
|
|
|
|
`clad` raises a panel on each chosen facet:
|
|
|
|
| key | value |
|
|
| --- | --- |
|
|
| `mat` | the panels' material |
|
|
| `facets` | `"outer"` (a slab's default): facets whose normal on the face's normal is over 0.97. `"all"`. Or 1 to 8 selectors, any of which chooses: `{n, cos}` (normal on `n` over `cos`) or `{radial: axis, min_r, cos}` (the facet's centre stands over `min_r` from the axis through the origin, and its normal on the outward radial is over `cos`). A selector's direction is mirrored with the side. |
|
|
| `floor` | optional: facets whose normal's z is below it are left bare |
|
|
| `min_area` | facets under it are left bare |
|
|
| `lifts` | `[l0, l1]`: how proud panels stand |
|
|
| `inset` | how far a panel stands in from its facet's edges |
|
|
| `gap` | the seam between the two panels of a split facet |
|
|
| `split` | a facet over this area is cut in two |
|
|
| `seed` | an integer, or `[right, left]` on a row with `sides: "both"`. There is no default. One integer on a two-sided row makes a mirrored pair; a pair of seeds draws each side on its own solid, and an equal pair is refused: it would draw two different layouts, and one seed is how a row asks for the same on both sides. |
|
|
| `bolt_r` | a bolt's corner radius (default 0.028) |
|
|
| `bolt_mat` | the bolts' material, 1 to 63 characters (default `gunmetal`). Carried: `build` draws nothing from it; `brokkr_kitbash.plates` reads it |
|
|
| `bevel` | the width of the panels' Bevel, 0 to 0.05 (default 0.012). Carried, as the row's `bevel` is |
|
|
|
|
One `random.Random(seed)` draws, in facet order. A chosen facet over `split` is cut across its longest edge at a
|
|
share drawn from 0.36 to 0.64 of that edge, the two parts `gap` apart; edges within 1e-9 m of the longest tie and
|
|
go to the edge whose middle is greater by x, y, z. Then every chosen facet draws once: under 0.5 the parts take
|
|
`l0, l1`, otherwise `l1, l0`. A panel is its part moved in by `inset`, not made where that leaves nothing, under a
|
|
quarter of the part's area or under 0.02 m2; it is a prism from 0.02 below the facet to its lift above, its far
|
|
rim chamfered 0.02 (not chamfered where the chamfer would cost the rim a corner). A hexagonal bolt of radius
|
|
`bolt_r` stands inside each panel corner, on the panel's outline moved in 3.2 `bolt_r`: a panel with no room for
|
|
that ring has no bolts, and any two bolts whose centres would stand under 2 `bolt_r` apart are one bolt at their
|
|
middle, in the first one's place in the ring. Neighbours in ring order are read first, from the first corner, then
|
|
pairs one corner further apart round the ring, and after each joining the reading starts again; so no two bolt
|
|
heads of a panel overlap, neighbours or not.
|
|
|
|
One inset, `inset2d`, makes every such ring: a slab's `gap` and `taper`, a panel's outline, its rim and its bolt
|
|
ring. What it returns stands inside the outline. It moves each corner along its miter, where its two edges'
|
|
lines, moved in, cross. Where no edge runs out of length on the way, those corners are the ring, a sharp one held
|
|
to the distance / 0.3 from where it was (unless that would turn the ring the other way at some corner): the
|
|
corner move alone, to the byte. Otherwise the ring is followed in, as a straight skeleton's front is: the edge
|
|
that runs out first is dropped where it does and its two neighbours meet there, then the next, and the sharp
|
|
corners stand where the lines cross. Two edges left facing each other on one line (a tab's sides when its end has
|
|
run out) take the shorter away, both when they are equal, and two left on one line are one edge. Where nothing is
|
|
left the ring is empty. For a convex outline that is what its edges' half-planes, each moved in, leave of it.
|
|
|
|
A held corner steps. While no edge has run out, a corner sharper than 35 degrees (the sine of its half angle
|
|
under 0.3) stands distance / 0.3 along its miter; from the distance where the ring first loses an edge it stands
|
|
where its lines cross, distance / that sine along the same miter. The step is their difference and no more: on a
|
|
10.5 degree tip that loses its first edge at 0.109, from 0.36 to 1.19 m from the outline's corner. It is the
|
|
skeleton's own corner the step lands on, and it is inside the outline before and after; a facet near that
|
|
distance changes its panel by the step for a small change of `inset`.
|
|
|
|
An outline need not be convex: a slab's may be drawn so, and facets within 0.5 degrees of each other are one
|
|
facet whose outline can turn right. Its corners that turn right move in too, faster the sharper they are (the
|
|
distance / the sine of half the corner), and such a corner can reach an edge that is not its own: a neck between
|
|
two parallel edges closes at half its width. From there the ring would meet itself and be two rings or none, and
|
|
`inset2d` refuses it (`NotSimple`, a `PlateError`), naming the corner's two edges and the edge it reaches. For a
|
|
slab's `gap` or `taper` that is the row's refusal at `slab.outline` (or `slab.corners`), from `check` and from
|
|
`build` in the same words, since both make the slab's points the same way. A facet is no row's drawing: where
|
|
the inset of a facet or of a facet's part would meet itself, that part takes no panel; where the bolt ring of a
|
|
panel would, the panel takes no bolts; where the rim would, the rim is the outline. So `build` refuses nothing
|
|
that `check` passed.
|
|
|
|
### Anchors and fits
|
|
|
|
A fit stands on the row's face (a slab's outer face, or the `face` another row names), at `[a, b]` in the face's
|
|
(a, b). The face's top is the face, plus `lifts[0]` where a panel stands on it. Up to 64 a row; any other kind is
|
|
refused.
|
|
|
|
Two kinds are anchors, a frame and no geometry:
|
|
|
|
- `{kind: "mark", id, at, height}`: z is the face's normal and y the table's +z projected off it, so a numeral
|
|
stands upright whatever the plate's lean. On the face's top.
|
|
- `{kind: "hose_port", name, at, lift}`: z out of the face, y the face's up, `lift` (default 0) over the top.
|
|
|
|
`build` returns each as `{kind, name, matrix, mirrored}` (and `height` for a mark). At side -1 the position, normal
|
|
and up are mirrored and the frame is made right-handed again (x = y cross z); `mirrored` says so. What stands on
|
|
an anchor is its owner's business.
|
|
|
|
Three kinds are fittings, geometry `build` makes:
|
|
|
|
- `{kind: "part", part, at, roll, lift, params, mat}`: a part of the fittings kit (below) built by `core.build` at
|
|
`params` (`"k=v; ..."`, default the part's defaults) and placed by the fit's frame: z the face's normal, y the
|
|
face's up, turned `roll` degrees about the normal (default 0, -360 to 360), its origin `lift` (default 0, -1 to
|
|
1) over the face's top.
|
|
- `{kind: "bolts", inset, spacing, lift, params, mat}`: the kit's `bolt` along a slab's outline. The outline as
|
|
drawn (in by the slab's `gap`) is moved in by `inset` + the slab's `taper` (0 to 10), by `inset2d` as a
|
|
panel's bolt ring is, so the ring can have fewer edges than the outline; each edge of that ring takes `max(1, int(length / spacing))` bolts, bolt j at
|
|
`(j + 0.5) / count` along it. `params` are the bolt's. A rim bolt fastens the plate, not its cladding: the row
|
|
stands on the bare face, `lift` (default 0) over it, whatever panel the face carries. Where the inset leaves no
|
|
ring, or a ring that would meet itself (an outline that is not convex), the row stands no bolts: the ruling
|
|
plate-bolts-follow-edge-event. Refused on a row that is no slab.
|
|
- `{kind: "step", outline, at, lift, mat, bolt_mat}`: a raised panel on `outline` (3 to 64 `[a, b]` points, either
|
|
winding, about `at`) on the face's top: the clad's panel with inset 0, from 0.02 under the top to `lift` (0 to
|
|
1) over it, its far rim chamfered 0.02, a hexagonal bolt of radius 0.028 inside each corner in `bolt_mat`
|
|
(default `gunmetal`). Refused under 0.02 m2.
|
|
|
|
`mat` is the fitting's material, 1 to 63 characters. A part is one material: a fitting of two is two rows at one
|
|
place (a slot or a vents row and the `pit` under it; an `access_port` and its `port_bolts`).
|
|
|
|
At side -1 a fitting's place, normal and up are mirrored, its frame made right-handed and its roll negated, so a
|
|
part that is the same across its own x stands as the mirror of side +1's. On a two-sided row drawn once (one seed,
|
|
or no clad) the `.L` fittings are the `.R`'s mirrored across x = 0, as its panels are.
|
|
|
|
Refused, naming the path: a part the kit does not have (its parts are listed); params the part does not have or
|
|
outside its bounds, and what the part's shapes refuse at those params (`core`'s message); a `mat` over 63
|
|
characters.
|
|
|
|
### What build returns
|
|
|
|
One entry per plate built, in the table's order: `name`, `row` (its index), `mat`, `bevel`, `side`,
|
|
`solid: (V, faces)`, `facets` (each face's `normal`, `area`, `centre`), `panels: (V, faces)`, `bolts: (V, faces)`,
|
|
`fits: {mat: (V, faces)}` (the row's fittings, merged by material in row order), `anchors`, and
|
|
`report: {corners, facets, panels, bolts, fits}`, `fits` the count that stand (a bolts row counts each bolt). `V` is an (N, 3) float64 array; faces are lists of
|
|
vertex indices wound outward. `check` returns the table with every default written in. Both are pure functions.
|
|
|
|
Building the three mech fixtures takes 0.5 to 0.9 s each (23 to 50 plates, medians of 5 on Starfire, Python
|
|
3.13); the hull tries every plane through three points, so a slab with a 64-point outline takes 1.5 s alone.
|
|
|
|
### Refusals
|
|
|
|
Every refusal is a `PlateError` (a `ValueError`) that names the path, as `plates[3].slab.outline[2]` or
|
|
`plates[0].clad.seed`: a schema that is not `brokkr.plates.v0`; an unknown key anywhere; a row with no solid form
|
|
or two; a name built twice; a number that is not finite; an outline under 3 points or over 64, one that crosses
|
|
itself, repeats a point or has zero area; `thick`, `taper`, `back` or `gap` outside 0.001 to 2, 0 to 0.5, 0.1 to
|
|
1.5 and 0 to 0.5; a `taper` of half the outline's least width or more; a `gap` or `taper` at which an outline
|
|
that is not convex would meet itself; corners that are not a plate; faces that
|
|
bound nothing; points in one plane; a pair of seeds on a one-sided row, an equal pair, or no seed; an `up` along
|
|
the normal; a
|
|
fit on a row with no face; an unknown fit kind; two anchors of one name in a row; and what Anchors and fits lists
|
|
for a fitting.
|
|
|
|
### Against the mech tracks' builders
|
|
|
|
`tests/fixtures/plates_bastion.json`, `plates_paladin.json` and `plates_raptor.json` each hold a table converted
|
|
from a mech branch's own numbers and the solids, panels and bolt counts that branch's builder made in Blender
|
|
5.3; `tests/test_plate.py` holds `build` to them (solid vertices within 1e-6 m, panel vertices within 1e-5 m,
|
|
facet and bolt counts equal). The branches' builders work in float32 and leave two choices to Blender's mesh
|
|
order, so eleven of the 126 fixture plates are held to something else, each named in the test's `KNOWN`:
|
|
eight stand 1 to 2 micrometres (solid) or 29 micrometres (panels) from the float64 result and are held at 4 and
|
|
40; bastion's two quarter pods lack a corner their faces do bound (the branch's inside test lost it to float32),
|
|
so the branch's solid is smaller than the table's and its panels are another solid's; and one of bastion's two
|
|
belly-side plates splits its panel from the other of two equally long edges. Those three are held, solid, facets,
|
|
panels and bolts, to `repaired` in `plates_bastion.json`: the branch's own builder run in Blender 5.3 with the
|
|
inside test at 1e-5 m, and with its clad cutting from the other tied edge; `repaired.how` quotes both edits as
|
|
code.
|
|
|
|
The branches' inset has no edge event, so 31 of the 126 are held to another bolt count, each named in the test's
|
|
`EVENT`: eleven stand bare (raptor's thin trims and paladin's tail have no room for a bolt ring), and the
|
|
others lose one to four to a ring with no room, a dropped edge or heads that would overlap. Two of them, bastion's `Hull.Cheek.R`
|
|
and paladin's `Thigh.Outer`, have a panel whose outline dropped a corner, and that panel's vertices are held to
|
|
no truth. What holds every ring instead: every `inset2d` call the three fixtures make at both sides (812) stands
|
|
inside its outline. The 6 on a slab outline that is not convex are the corner move, every corner the distance
|
|
clear of every edge; 24 hold a sharp corner at the 0.3 limit with every edge running forwards; the other 782
|
|
equal, within 1e-12 m, the outline's half-planes moved in and clipped by the test's own clipper (37 of them an
|
|
edge or more short, 22 empty). 3,000 drawn convex rings are held the same way, and every bolt of 104 blade plates
|
|
(tips of 14 to 32 degrees) stands whole on its plate. No panel ring or bolt ring of any plate at either side turns
|
|
right or crosses, and no two bolt heads of a panel overlap; nor do any two on 3,591 blade plates (tips of 8 to 44
|
|
degrees), 50 of which kept such a pair while only neighbours were joined.
|
|
|
|
No fixture facet turns right, so 1,500 drawn sheets hold that case: 5 to 9 points up to 12 mm off one plane, whose
|
|
top facets the hull makes one. Each passes `check` and builds. Of their 519 rings that turn right, 84 lose an
|
|
edge, and each of those stands inside its outline without crossing, the distance clear of every edge, each of its
|
|
edges along one of the outline's in the outline's order; 2, both bolt rings, would meet themselves, and their
|
|
panels stand bare. A two-lobed facet with a neck holds the rest: no panel at an inset over half the neck, a bare
|
|
panel under it, and a prism whose rim would meet itself keeps its outline for a rim.
|
|
|
|
The same test builds the three fixtures to one sha256 of every coordinate rounded to 1e-9 m and every face,
|
|
pinned from Starfire (Windows 11, numpy 2.5.4) and Yggdrasil (Debian 13, numpy 2.2.4 on the system LAPACK). The
|
|
two hosts' coordinates differ by up to 2.7e-15 m, so the bytes of `build`'s arrays are equal between runs on one
|
|
host and not between hosts.
|
|
|
|
### The action
|
|
|
|
`brokkr_kitbash.plates` writes a table into the scene. It is the one writer of a hard plate's objects.
|
|
|
|
| field | value |
|
|
| --- | --- |
|
|
| `table` | the `brokkr.plates.v0` document as JSON, 1 to 32000 characters |
|
|
| `host` | the object every plate is parented to, 0 to 63 characters; empty: no parent |
|
|
| `frame` | the table's frame in the world, a JSON array of 4 rows of 4 numbers, at most 1000 characters; empty: the host's world matrix, or the world with no host |
|
|
| `side` | 1, or -1 for the table mirrored across its x = 0 |
|
|
| `prefix` | written before every plate's name: 0 to 32 of a-z A-Z 0-9 _ . |
|
|
|
|
Per built entry, N = `prefix` + its name:
|
|
|
|
- A mesh object N: `build`'s solid in the table frame (`mesh.from_pydata`, every face flat), material `mat`. Its
|
|
parent is `host` under an identity parent inverse and its `matrix_basis` is host world^-1 x `frame`; with no
|
|
host its world matrix is `frame`. A Kit Bevel of the row's `bevel`, angle 12 degrees. ID properties
|
|
`plate_kind` = `"hard"` and `kit_plate`: the checked row with `side` and `prefix`, as JSON. `kit_plate` is a
|
|
record: its presence admits a rebuild and nothing reads it to decide geometry.
|
|
- `N.fit.<clad mat>` holds the panels, `N.fit.<clad bolt_mat>` the bolts and `N.fit.<mat>` each fitting of that
|
|
`mat` (a step's corner bolts under its `bolt_mat`): a child mesh per material, the panels, then the bolts,
|
|
then the fittings in row order where they share one; identity basis, made only when its mesh is not empty. A
|
|
child that holds panels carries a Kit Bevel of `clad.bevel`, angle 20 degrees, one segment, and a fitting of
|
|
the panels' material is bevelled with them; any other child carries none. Every material a fit names must be
|
|
in the file.
|
|
- One empty per anchor, a child of N at the anchor's matrix: `N.mark.<id>` with `kit_anchor`
|
|
`{kind, id, height}`, `N.port.<name>` with `kit_anchor` `{kind, name}` (JSON). A port empty is an end
|
|
`brokkr_kitbash.hose` takes by name: the hose leaves along its z, out of the face.
|
|
|
|
An object named N that carries `kit_plate` is rebuilt in place: its mesh is cleared and rewritten, each
|
|
`N.fit.<mat>` child rewritten, made or removed as it is now empty or not, anchors kept by name and moved, and one
|
|
the row no longer names removed. N keeps its identity, its other children, its later material slots and its
|
|
modifiers. A frozen plate or one sharing its mesh is refused, as `shell` refuses. A plate is no kit part:
|
|
`joints` and `report` never list it, and a roll of its host carries it by Blender's parenting. The action
|
|
evaluates nothing.
|
|
|
|
It refuses before anything is written, object count and names unchanged: a table `check` or `build` refuses (the
|
|
path in the message); a material `bpy.data.materials` lacks, named with its path (`mat`, `clad.mat`,
|
|
`clad.bolt_mat`); a host not found, or scaled, mirrored or sheared; a `frame` that is not a JSON 4x4 of finite
|
|
numbers or not rigid; N, a child's or an anchor's name taken by an object that is not this plate's (N without
|
|
`kit_plate`, or an object that is not N's child); a name made twice in one call; a made name over 63 bytes; a
|
|
host that is one of the call's plates or stands under one; a report over 16000 characters.
|
|
|
|
The report: `{plates: [{name, rebuilt, corners, facets, panels, bolts, anchors}], host, side}`, `anchors` the
|
|
empties' names.
|
|
|
|
## Hoses between sockets
|
|
|
|
`brokkr_kitbash.hose` routes a bundle of hoses from one socket to another around everything in the scene:
|
|
|
|
```json
|
|
{"action": "brokkr_kitbash.hose", "object_name": "Feed", "start": "ThighRam:port_cap", "end": "ShinRam:port_cap",
|
|
"count": 3, "radius": 0.006, "clearance": 0.005,
|
|
"joint": "{\"socket\": \"Shin:end_a_back\", \"standoff\": 0.08}"}
|
|
```
|
|
|
|
**Ends.** `start` and `end` are `Object:socket` on a kit part, a `hose` socket (an actuator's `port_cap` and
|
|
`port_rod`) or a `flange`, no narrower than the bundle; or `Object` alone, an empty whose z the hose leaves along.
|
|
A fitting keeps a straight lead of 8 radii (a ferrule of 5, then 1.5 outside diameters before any bend), and the
|
|
bundle's clearance is not asked of that lead: it stands on its own port.
|
|
|
|
**The path.** `route.py` (numpy, no Blender) owns it. Waypoints are each fitting's lead end, each clamp and the
|
|
pin point. A leg between two waypoints is searched on a voxel grid of their box plus 0.25 m: a voxel is free when it
|
|
stands the bundle's half width, the clearance and half a voxel's diagonal from every other mesh, so every step
|
|
between neighbouring free voxels keeps the clearance; a 26-connected wavefront finds a shortest way and it is
|
|
pulled taut. The legs joined are one polyline, and each corner is rounded by the largest arc its measured room
|
|
allows: the arc stands within `radius * (1 - cos(turn / 2))` of its two tangent segments, so with that much room
|
|
beyond the clearance measured along them it keeps the clearance. Where two arcs would overlap on a segment each
|
|
keeps the tangent its bend takes at the floor and they share what the segment has left, in proportion to what each
|
|
asked beyond that; the corner at a pin holds the tangent its sharpest roll takes. The floor is `bend` outside diameters for the innermost hose (the centre line's is half the
|
|
bundle's spread more). The finished curve is measured once more against every mesh before anything is written.
|
|
|
|
**Measured, not sampled.** Every line the route trusts (a sight line of the pull, a tangent segment's room, the
|
|
finished curve, each side at each roll) is measured by `route.measure`: a reading answers for the piece of line
|
|
around it, less half the piece's length, because a distance to obstacles changes by no more than the distance
|
|
moved. A piece that this proves clear is done, one that reads under the need is refused, and any other is halved,
|
|
down to 1 mm. So a plate thinner than any spacing cannot stand unseen between two readings, and no measurement
|
|
depends on `step`: `step` sets only how fine the search for a way is. The price is half a millimetre: a line that
|
|
keeps the clearance by less than that cannot be proven and is refused as too near.
|
|
|
|
**Room for the bends.** A line pulled taut at the clearance alone grazes whatever it wraps, and the corner there
|
|
has no room for an arc; how much it happened to keep changed with `step`, so a bundle could route at 0.02 and at
|
|
0.03 and be refused at 0.0125. Each leg is therefore searched and pulled with room for its bends first: 0.29 of the
|
|
floor beyond the clearance, what the arc of a quarter turn at the floor takes (within twice that of a leg's end
|
|
the pull asks half the distance from the end instead, since an end stands where it is given). A leg with no way
|
|
that roomy (a clamp stands nearer its seat than that, and so does a gap the bundle only just passes) is searched
|
|
again without, and the hose is longer where the roomy way goes round.
|
|
|
|
**A seed, refined.** The polyline a search gives is a seed. Its vertices stand where the grid's lattice put them,
|
|
so whether two corners have the straight between them for both bends follows the lattice too: searched and pulled
|
|
with room alone, the first bundle on the knee routed at steps 0.125 and 0.13 and was refused at 0.1275, and the
|
|
second was refused at 26 of the 76 steps from 0.0125 to 0.2. Three things take the lattice out of the answer.
|
|
|
|
- A corner keeps its floor's tangent before a neighbour gets more (above), and the pin's corner holds what its
|
|
sharpest roll takes, exactly (`route.sharpest_turn`: the turn's cosine over a range of rolls is a + b cos + c sin).
|
|
- A seed that is refused is refined in continuous space (`route.relax`). About each segment too short for its
|
|
corners' tangents at the floor (`route.strain`), a vertex the search placed is dropped, moved along each axis and
|
|
along its own two segments, or joined by a new one beside a segment's middle; the try that lowers the shortfall
|
|
most is kept if `route.measure` proves its changed segments clear with the room a leg is pulled with. The moves
|
|
start a floor long and halve when nothing helps, down to 1 mm. Ports, lead ends, clamp straights and the pin
|
|
point do not move. The refinement prices straight only: room for an arc is still measured by the fillet after it.
|
|
- A route still refused is searched again on two more grid origins (half a step along each axis; then 0.31, 0.67
|
|
and 0.13 of a step), and then at half the step on all three, each seed refined the same way. `seed` in the
|
|
report is the step and origin that gave the route and whether it was refined.
|
|
|
|
The cost is in the refusals and in sameness: a route that cannot be made runs up to six seeds, three of them on 8
|
|
times the voxels, before it is refused, and the same request at another `step` may take another way round, though
|
|
never one that clears less than the clearance or bends under the floor.
|
|
|
|
A refusal after all that says what was tried, and that this shows no route was found, not that none exists: `the
|
|
search found no route: it tried steps 0.02 and 0.01, each on grid origins (0, 0, 0), (0.5, 0.5, 0.5), (0.31, 0.67,
|
|
0.13) of a step, and refined each seed in continuous space; this does not show that no route exists. The first
|
|
refusal: corner 2 at ...`. The first refusal is the requested step's own seed's, by corner, point or roll, with
|
|
what that polyline lacked: straight for a tangent, room for an arc (both distances named), or a segment two corners
|
|
cannot share. An end that stands nearer an obstacle than the bundle needs is refused at once: no grid lifts that.
|
|
|
|
`too stiff` is said only where it is proven (`route.leaves`). For its first pi floors of length a curve that bends
|
|
no tighter than the floor stays out of every ball of radius floor that touches its line where it starts, and ahead
|
|
of that point, and by then it stands 2 floors away (Schwarz's bound on a chord; Dubins 1957). So where a fitting's
|
|
lead ends, the hose must reach the sphere of 2 floors through points that keep the clearance and lie outside those
|
|
balls. They are read on voxels of a sixth of the floor with the bound every other measurement uses, and when they
|
|
do not join the lead's end to the sphere no route exists at that `bend`: `the bundle is too stiff to leave its
|
|
start: from the end of its lead at ... no curve that bends at the floor radius ... or wider keeps ... from what
|
|
stands within ... of it`. The proof is tried at both ports when no route was found. It does not look at clamps or
|
|
the pin, so a bundle too stiff for the room there gets the search's refusal. The remedies are a lower `bend`,
|
|
thinner or fewer hoses, waypoints further apart (a larger `standoff`), or a clamp that leads the hose wide.
|
|
|
|
**Slack.** `sag` (outside diameters, default 1) lowers the middle of each free span's longest segment along world
|
|
-z, by less where the span runs steeply, and never by more than half the room measured along it: both halves then
|
|
keep the clearance with as much room again for the arc at the middle. A route that the sag would break is made
|
|
taut instead; the report's `sag` lists the metres each leg hangs. 0 routes taut.
|
|
|
|
**Clamps.** `clamps` is a JSON array of up to 8 `{"socket": "Object:socket"}`, `mount` sockets in order along the
|
|
hose. The bundle runs straight along the socket's y through the point its half width, the clearance and one hose
|
|
radius above the face, for 2 outside diameters each side, and gets a pad on the face and a strap around it. The
|
|
bundle lies flat on the first clamp; its ups are rotation minimising (Wang et al. 2008), so it does not twist
|
|
between clamps, and a later clamp's strap follows the bundle as it arrives.
|
|
|
|
**A pin.** A hose may cross one pin: a revolute connection between its ends' parts, found from their parent
|
|
chains. `joint` names a socket on that pin's axis whose z runs along it (the free end face of the pin: a strut's
|
|
`end_a_back`) and a `standoff`. The roll range the hose is proven over is the pin's own: its connection's limits,
|
|
stated once with `brokkr_kitbash.joint` (`{"limits": [-120, 20]}`) and read by every hose across it. A pin with no
|
|
limits is refused, naming that action, and so is a prismatic connection between the ends: a hose across a slide
|
|
is not routed. The hose passes through the point `standoff` beyond that
|
|
socket, on the axis, as a robot's dress pack does: the straights on each side then move with their own part and
|
|
only the bend at that point changes with the roll. The whole range is measured without posing anything, not a
|
|
list of rolls in it. Each roll from `lo` to `hi` in steps of 5 degrees answers for the rolls nearer it than any
|
|
other: within such a bin of half width w a point that stands rho from the pin's axis moves at most `rho * w`
|
|
against the other side's parts, so its reading against them counts for that much less. The bend at the pin has one
|
|
radius through a bin, the largest that fits at the bin's sharpest turn, and its two tangent segments are measured
|
|
for the clearance and the arc's dip more. A bin that falls short is halved and measured again at each half's
|
|
middle, down to 0.3 degrees of half width, so a range that is clear costs 9 rolls for 40 degrees and one that
|
|
passes near a part costs more only there (`rolls` reports how many were measured). A range that fails is refused
|
|
by roll, side and point (`roll 50.78: the hose's child's side reads 0.0264 m from the parts about the pin at
|
|
[-0.2122, -0.2044, 0.7269], counting the 0.0005875 m it can move against the other side's through the 0.156 degrees
|
|
either side of it: under the 0.0266 m the bundle needs`); when the sagged route and the taut one both fail the
|
|
refusal names both. `worstClearance` is the least reading over the range, each less what its point can move within
|
|
its bin. `lengthChange` is the centre line's longest less its shortest over the rolls measured, as each rounds the
|
|
bend. Two pins between the ends are refused: end the hose on a part between them.
|
|
|
|
Another hose through the same pin bends with it and belongs to neither side. A route keeps clear of it where it
|
|
stands, and across the rolls each hose is measured against the parts of the two sides, not against where the other
|
|
hose stood: give two hoses through one pin different standoffs, and their clearance from each other holds at the
|
|
pose they were routed at. That is a ruled limit (`aetheria-release:ruling:hose-same-pin-pose-only-now`), and the
|
|
check it leaves out has an owner: follow-up `aetheria-release:follow_up:hose-motion-clearance-from-skinning` will pose
|
|
each other hose across the range with the skin blend the output mesh uses. Until it lands nothing measures two hoses
|
|
through one pin against each other in motion.
|
|
|
|
**What it writes.** One mesh object, a child of the start's object under identity matrices, with no modifier and
|
|
no material: each hose, two ferrule collars at each of its ends, and the clamps, all swept by `core.sweep`.
|
|
`kit_hose` on it is the request as JSON; the one thing read back from it is which two parts a hose joins, by a
|
|
later hose that crosses the same pin. Other hoses are obstacles like any mesh, so route the stiffest first. The hose is a bake of the scene at the call: after a part moves or rolls, run `hose`
|
|
again with the same `object_name` and it is rebuilt in place.
|
|
|
|
A hose that crosses a pin stays one object. In the exported mesh it is skinned geometry, meant to be weighted
|
|
between the bones on either side of the pin, blending near the pin point; the posed shape then comes from the
|
|
skin, and the rebuild is for stills and for checking the range. This package writes no weights or vertex groups:
|
|
skin weights are `brokkr_rig`'s.
|
|
|
|
**Refusals**, each before anything is written: a name taken by an object that is no hose; an end or clamp that
|
|
names no object, no such socket, or a socket of the wrong type; a bundle wider than a port, naming both sizes; a
|
|
part that is scaled or that Blender does not evaluate; a pin crossed with no `joint`, a `joint` with no pin, two
|
|
pins, a `joint` socket off the pin's axis, a pin with no limits or standing outside them, a slide between the
|
|
ends; a search box over 524288 voxels,
|
|
naming a step that fits; an end nearer an obstacle than the bundle needs; a bundle proven too stiff to leave a
|
|
port; and, once every seed has been tried, no route found, with the first seed's refusal: no way through, a corner
|
|
under the floor by what its polyline lacked, a curve not proven to keep the clearance at a named point, or a roll
|
|
that fails.
|
|
|
|
**Cost.** Probes in Blender 5.3 on Starfire, medians of 3 interleaved repetitions: a nearest-face query on a tree of
|
|
81,920 faces takes 100 to 123 us uncapped and 3.4 us capped at 0.06 m, so every query is capped; on a grid of
|
|
97,061 voxels with a wall and a hole a heap A* took 8.47 s (56,824 pops) and the wavefront 0.26 s (100 waves); on
|
|
a knee of five boxes (96,565 voxels at 0.02 m) the occupancy took 0.46 s uncapped, the search 0.19 s, the pull, the
|
|
fillet and the verification under 2 ms together, 27 rolls 0.056 s and the sweep of three hoses 4 ms. The live
|
|
knee of `tests/live/kitbash_hose.py` (two struts, two actuators and a plate; two legs of 79,488 and 53,406
|
|
voxels at roll 0, timed at roll 10; three hoses, 9 rolls) took 0.80 s a call, median of 3 each after one report
|
|
action, where it took 0.50 s when lines were sampled at half a voxel and each leg was searched once: the occupancy
|
|
is read to a larger cap and the room, the curve and the rolls are measured to 1 mm near what they pass. With
|
|
seeds refined and retried the same call took 0.64 s. Over the 76 steps from 0.0125 to 0.2 on that knee, one call
|
|
each with three other Blenders running, the first bundle took 0.53 s at the median and 2.34 s at most, and the
|
|
second 0.32 s and 2.56 s; of the second's 76 routes 8 came from a refined seed, 3 from another grid origin and 12
|
|
from half the step.
|
|
|
|
`tests/test_route.py` proves the path without Blender (the half-diagonal rule, a plate between two readings, a leg's
|
|
room where it wraps, the fillet's tangency, sharing, room and floor, a corner's floor before its neighbour's share, a
|
|
seed refined where the oracle allows, the proof of too stiff, the sharpest turn of a range of rolls, the sag's bound, the frames against the double
|
|
reflection method, the rolls and a plate between two of them, the bend at the pin's room), and
|
|
`tests/live/kitbash_hose.py` the action in Blender.
|
|
|
|
## Expressions
|
|
|
|
Every numeric field of a shape or socket, and `bevel`, is a number or a string over the part's params:
|
|
|
|
```text
|
|
+ - * / unary minus ( ) min(a, b) max(a, b) numbers param names
|
|
```
|
|
|
|
An expression is parsed once and walked against that list when the kit is checked; an attribute, subscript,
|
|
power, comparison, any other call, a keyword argument, a lambda or a string is refused there, naming the part and
|
|
field. Nothing in a kit is run as Python. Division by zero, a result that is not a finite number, and a `count`
|
|
or `segments` that is not whole are refused when the part is built, naming the expression; so is a shape whose
|
|
vertices overflow.
|
|
|
|
## Rams and linkages
|
|
|
|
`brokkr_kitbash/ram.py` owns the motion of a ram across one hinge. It is numpy and the standard library, imports
|
|
nothing from the package, and no action calls it yet: a rig or a runtime loads the file alone. Its input is a
|
|
mechanism record: the hinge (pivot, unit axis, `lo` and `hi` in degrees, positive right-handed about the axis like
|
|
a pin joint's roll), a kind, and pins, each in its own body's rest frame.
|
|
|
|
| kind | pins | the ram runs |
|
|
| --- | --- | --- |
|
|
| `direct` | `a` on the parent, `b` on the child | `a` to `b` |
|
|
| `four_bar` | `a`; `rocker` (R), the rocker's pivot on the parent; `p` on the rocker; `c` on the child; `d` = `p` | `a` to `p`: the excavator bucket linkage, a coupler from `p` to `c` turning the child |
|
|
| `bell_crank` | the same, `d` elsewhere on the rocker, at least 2 bore from `p` | `a` to `d` |
|
|
|
|
Everything is a function of the record and the hinge angle: `pose` gives each body's rotation, the ram's base and
|
|
eye, its pin-to-pin length L and dL/dtheta; `length` and `extension` (L less the closed length) are what a rig
|
|
drives a rod from. Nothing stores a rocker angle or an extension. The loop is solved in the plane across the axis:
|
|
`p` lies where the rocker's circle about R meets the coupler's about `c`, on the side of R -> `c` it has at rest,
|
|
so an angle gives the same pose whatever was asked before it. A pin's coordinate along the axis says only where
|
|
its member stands: the rocker bars at R's, the coupler at `c`'s, the ram at `a`'s plus each of `offsets` (twins).
|
|
Rates are closed form: for a linkage dphi/dtheta = (axis x (c - O)) . k / ((axis x (p - R)) . k), k along the
|
|
coupler, and dL/dtheta = (axis x (d - R)) . u x dphi/dtheta, u along the ram.
|
|
|
|
`fit` runs the gates over the range, in this order. A failed gate is a `RamError` naming the kind, the gate, the
|
|
angle and the pin, with the readings attached; a refusal of the record or of a call (an unknown kind, a range, a
|
|
grid over the limit, a version) names the pin or the field it refuses.
|
|
|
|
- **assembly**: the rocker and coupler close the loop at every step, and on the way from rest when the range does
|
|
not hold 0; within 1e-9 of a dead centre is refused, since the branch would change there. Names `c`.
|
|
- **stroke**: the barrel holds the travel, the overtravel at both ends and the gland. Names the angle of the
|
|
shortest length and the eye's pin.
|
|
- **toggle**, **arm**: dL/dtheta keeps one sign, and |dL/dtheta| (the effective arm: hinge torque per unit ram
|
|
force) stays at or above `min_arm`. Name the eye's pin.
|
|
- **load** (linkages): the coupler's pin load per unit ram force, |dL/dtheta| over the coupler's moment arm about
|
|
the hinge, stays at or under `max_load` (3). Names `c`.
|
|
- **clash**: clearance, when a distance oracle is given. Names the member, the part, and the member's nearer pin.
|
|
|
|
The barrel is derived, never stored: `barrel_length` is the length at the shorter end of the range less the
|
|
overtravel, the base clevis and the eye, and `fit` reads it from its own two end samples.
|
|
|
|
Transmission angles at `c` and `p` are reported and not gated. Over the R-3 knee's 125 degrees the best least
|
|
transmission angle of 200,000 sampled four-bars was 21.9 degrees, under the 30 to 40 a textbook asks; a gate there
|
|
would have refused every one of them. What a poor angle costs is pin load, and that is the gate.
|
|
|
|
### Clearance: parts, and zones about a member's pins
|
|
|
|
The record names the mechanism's `parts`, each a piece of one body (part -> parent, child, rocker or coupler: the
|
|
body whose rest frame it turns with), and `touch`: for each member (`barrel`, `rod`, `rocker`, `coupler`, and a
|
|
bell crank's `rocker arm`), zones `(part, pin, radius, depth)`. Every member meets every part. A zone changes what
|
|
the member's samples keep from one part, and only within `radius` of the axis of `pin`, measured across the hinge
|
|
axis; the pin is one the member rides (the ram `a` and its eye, the rocker its pivot and `p`, the coupler `p` and
|
|
`c`, the arm the pivot and `d`), and the part is one of a body that pin joins: `a` the parent; the rocker's pivot
|
|
the parent and the rocker; `p` the rocker and the coupler; `c` the coupler and the child; a direct ram's `b` the
|
|
child; `d` the rocker (`JOINS`). A zone naming a part of any other body is refused by the record, whatever its
|
|
radius and depth. Inside the zone a sample may come as near the part as `-depth`; beyond it the
|
|
pair is checked like any other. Nothing is exempt by a name, by a length cut from a member's end, or by the
|
|
member's own body: the barrel runs from its back end, the rod to the eye, a bar from pin to pin. Every body of the
|
|
kind owns at least one part, or the gate refuses the record.
|
|
|
|
A zone's radius is the eye's radius plus a margin: the pin's, collar's or cheek's radius plus what the member
|
|
keeps (radius, gap, half the spacing). Its depth says how the member stands to the part there. 0 is beside it: a
|
|
plate stacked on the pin, the bracket or horn the pin stands in. The member's axis then stays outside the part, so
|
|
a pin whose place along the axis is inside what it claims to stand beside is refused: the gate does not take the
|
|
record's x on trust. The pin's radius is for the pin through the member's eye, half the plate's thickness for the
|
|
member's own plate, which is zoned about both of the member's pins. Two plates stacked on a pin cross like
|
|
scissors; the zone that lets one link by the other's plate reaches as far as the two part, (half width + what a
|
|
link keeps) / sin of the least angle they cross at, and no further than the link is long. Two zones of one pair
|
|
that both reach a sample let it the deeper of the two.
|
|
|
|
A zone is bounded by its member. Its radius and its depth are finite and no more than the member's length from pin
|
|
to pin: a bar's length between its pins, and for the barrel and the rod the base's and the eye's distances from
|
|
the centre the eye turns about, added. A `Mechanism` refuses a zone past that from its pins alone. Its depth is
|
|
also no more than the member's eye on that pin (`Ram.eye`: `e_a` at the base, `e_b` at the rod's eye, `link_r` on
|
|
a bar), which `from_record` and the gate refuse, so a world's answer is held to it as well. The record holds no
|
|
plate widths, so the radius has no tighter bound than the length, and two zones of half a member's length about
|
|
its two pins cover it whole. What the record does hold is which body a part turns with: a member is let near only
|
|
what is pinned where it is pinned.
|
|
|
|
Between two samples of which either is in a zone the gate does not rely on the spacing. A distance changes by no
|
|
more than the way between two points, so along a segment it is at least (g(a) + g(b) - length) / 2. Where that
|
|
does not show the segment keeps `-depth`, the gate halves it and reads the midpoint, down to spacing / 64. A
|
|
segment still unproved there against a part the axis is held outside (depth 0) is refused: the part is within
|
|
spacing / 128 of the axis, crossed or touched, whatever its thickness. Against a part the axis may enter, the
|
|
samples' readings stand, so a burial is read to spacing / 128. This asks of the oracle that it never reads more
|
|
than the true distance.
|
|
|
|
What it gives up: inside a zone the gate holds only the member's axis `depth` from the part, not its surface a
|
|
gap from it, so a link may graze the plate it scissors with anywhere within the stated radius. Among the parts of
|
|
the bodies a pin joins the gate still cannot tell a member's own plate from another: a zone over the whole member
|
|
lets its axis `depth` into any of them. A part of a third body is never zoned, so a plate stacked on a pin from a
|
|
body the pin does not join is refused where it stands; it is stated as a part of a body the pin joins. A four-bar's
|
|
eye rides `d`, which joins the rocker alone, though it stands on `p`: the ram is let near the coupler's plates
|
|
there by no zone. The members are
|
|
round bars; a plate's flat sides are not modelled, which is why stacked plates need a zone at all. The proof
|
|
between samples costs oracle calls: a depth stated with no slack over the burial (a bar's own plates at `link_r`)
|
|
is halved to the floor along the whole zone. And it is along the axis at each checked angle; between two angles
|
|
nothing is proved.
|
|
|
|
The oracle is `distance(part, points) -> distances`, `points` in the rest frame of the part's body. Each member is
|
|
sampled along its axis at most `spacing` apart (default the barrel's radius) and carried into each body's rest
|
|
frame at each angle; a sample is clear at radius + gap + spacing / 2 or more, which keeps the gap for the surface
|
|
between samples. A distance is signed: negative inside a part, by any depth. The oracle may cap what it returns at
|
|
`Ram.reach(spacing)`, outside a part only; a point inside reads negative however deep it lies. An oracle that
|
|
cannot tell inside from outside raises instead of answering (a nearest-surface query alone reads 0.13 at the
|
|
centre of the R-3 thigh's core, and reads clear when capped); nan is refused. `Fit.pairs` holds the least margin
|
|
and its angle for every pair, `Fit.allowed` the pairs a zone lets near a pin.
|
|
|
|
`search` seats a mechanism from a grid (ram seats; for linkages rocker pivots, child pins, `p` on a polar grid
|
|
about R, and `d` about R for a bell crank, the eye standing at `a`'s place along the axis), refuses a grid over
|
|
`limit` candidates naming the count, runs every gate but clearance on all of them, then clearance in order of
|
|
least arm; a miss returns the tally by gate and the nearest miss. Clearance takes `world(m) -> (parts, touch,
|
|
distance)`: a linkage's brackets and links are the candidate's own, so each candidate that reaches the gate is met
|
|
with the parts its own pins place. What `world` returns is read as a record's: anything but the three, a part on
|
|
no body of the kind, a zone that is not a part, a pin the member rides, a radius and a depth, a zone of a body
|
|
its pin does not join, or a zone wider or deeper than its member is refused.
|
|
`swept` gives the ram's swept surface in any body's frame, for a recess.
|
|
|
|
### The record
|
|
|
|
`record` and `from_record` carry a mechanism as JSON: `schema` (`brokkr.ram`), `version` (2), `kind`, `hinge`,
|
|
`pins`, `offsets`, `ram`, `parts` and `touch` (member -> zones, each `{part, pin, radius, depth}`).
|
|
It holds what is authored; barrel, closed length and link lengths are derived by the reader. It holds nothing of
|
|
how a load-path cylinder settles: that is a slide joint's, in the joint's own record. A
|
|
record of another schema or version (the integer 2: 2.0 and true are not it), with a key version 2 does not know or
|
|
without one it does (at the top, in `ram`, `hinge`, `pins` or a zone), or with a value
|
|
that is not its field's (a finite number, the bore over 0, three numbers for a point), or with a zone of a body
|
|
its pin does not join, or wider or deeper than its member, is refused whole, as a
|
|
`RamError` that names the field: a reader never reads past what it cannot solve. A `Ram` built by hand refuses the
|
|
same numbers.
|
|
|
|
### Readings on the R-3 knee
|
|
|
|
Bore 0.042, range 0..-125. The kinematic rows are tests/test_ram.py's. The clearance rows are
|
|
`tests/live/ram_knee.py`'s, Blender 5.3 (`ram_knee.result.json` is the last run): the knee as closed meshes the
|
|
test generates (thigh with its front plate, shin with caps and armour, the bracket that carries R, the horn that
|
|
carries `c`, twin link plates stacked 5 mm apart at x 0.31..0.345 and 0.35..0.385, pins through the knee's width,
|
|
collars at the eye and a base clevis whose foot runs 0.01 into the thigh; 12 parts) and the package's signed BVH
|
|
oracle, `ram.Signed(shells, cap)`: the nearest face for the depth, the generalized winding number for the side
|
|
(Jacobson, Kavan and Sorkine-Hornung 2013). `ram.winding` sums the signed solid angle of every triangle of the part
|
|
about the point, over 4 pi: about a closed mesh the whole number of times the surface wraps the point, 0 outside, 1
|
|
inside, 2 where two solids overlap. A point is inside the part at 0.5 or more. The joint library's plates are one
|
|
mesh of four bars, a side's two overlapping about the pivot (`tests/fixtures/ram_plates.json`, with 29 points
|
|
inside them, 13 inside two bars): each reads inside, as does the overlap of two boxes welded at a corner and a
|
|
staircase prism a line crosses six times.
|
|
|
|
`Signed` checks what the winding number needs before it answers, and refuses a part by its reason when the oracle is
|
|
made (`ram.solids`, a `RamError` at gate `signed`). Nothing is repaired or guessed. The checks read the mesh as the
|
|
winding number does, by where its faces are and not by how its vertices are numbered.
|
|
|
|
Open. Vertices no farther apart than `WELD` (3e-4) of the part's extent along every axis are one vertex
|
|
(`ram.weld`), and a chain of such is one, so a seam of coincident vertices is no hole. The tolerance is the same
|
|
wherever the part stands: a pair 0.99 of it apart is joined and a pair 1.01 apart is not. A part's faces fall into
|
|
solids, the faces joined across an edge, and every solid is closed: each edge one face runs is run the other way by
|
|
another. A solid with an edge that is not (a boundary edge, or two faces wound against each other) is refused with
|
|
the count of such edges.
|
|
|
|
Each face is read `NUDGE` (1e-6) of the extent before its centroid, along its normal. Before a face of a whole solid
|
|
the number is 0, or more where another solid covers it. A face is turned where the number there is under -0.5: it
|
|
stands before a region that winds -1. Two things put a face there, and they are refused under two names.
|
|
|
|
Inside out. A solid with a turned face whose signed volume is negative (the sum of `a . (b x c) / 6` over its
|
|
triangles, summed exactly) is wound inside out, and is refused with the solid, its volume and its turned faces. The
|
|
bound is zero: a cube of side 0.2 turned over beside a 6 m bar and a turned plate 1e-5 thick are refused as a whole
|
|
part turned over is. A hollow mass, its cavity an inward shell, holds a negative volume there too, but the cavity is
|
|
before those faces and winds 0, and it passes; so does a sliver of two sheets back to back. A solid whose every face
|
|
the weld closes up to a point or a line is a seam's leftover with no volume to read.
|
|
|
|
Crossing. Turned faces where no solid's volume is negative stand where the part's surfaces cut through one another:
|
|
cutters taken out of one solid and never joined, a bevel folded over a corner, a lathe's profile crossing itself, or
|
|
a turned piece welded into a whole one, which the one solid's volume hides. That region is measured, each turned
|
|
face's area by how far out along its normal the number stays under -0.5, and a part whose region holds `THIN`
|
|
(1.1e-4) of its extent cubed or more is refused as crossing itself: the count of turned faces, the first, its solid,
|
|
the number, the share, and where the region lies (the turned faces' centre by area, in the frame the mesh was given
|
|
in, and how far the farthest stands from it). The message never calls such a part inside out: its winding is right
|
|
and its cut is not. A member cannot be seated against it honestly, so it stays refused until its builder is fixed.
|
|
|
|
Mirrored. A shell may be `(vertices, faces, matrix)`: the object's own mesh and the 4 by 4 that carries it to the
|
|
body's rest frame. `ram.placed` carries the vertices and turns each face back where the matrix mirrors, so a part
|
|
mirrored by a negative scale reads as its own mesh does. A caller that carries a mirrored mesh itself and keeps the
|
|
winding hands over a part wound inside out.
|
|
|
|
The bounds stand on real meshes, and the unit suite holds them there (`tests.test_ram.Corpus`). Every part the kits
|
|
build passes at the corners of its params (316 here; 3,224 over the kits of ten other trees). Of the 1,832 mesh objects the
|
|
mech experiments make (r3, mcr3, seraph, spectre, walker, chimera, paladin, kestrel), 42 are refused and 1,790
|
|
pass, the 115 mirrored ones the same in their own frame and placed. 21 are open: marks, recesses and plates with a
|
|
hole. 17 are wound inside out: lathe and ball bodies, the least a solid of -1.4e-3 of the extent cubed (paladin
|
|
Waist.torso). 4 cross themselves with every solid's volume positive: walker's two guns, a box whose bore and cross
|
|
slots were cut and never joined (242 pairs of faces cross), and seraph's two Torso.LowerIn plates, folded at one
|
|
corner by a bevel over a boolean. `tests/fixtures/ram_meshes.npz` holds those 21, three of the open, the parts
|
|
nearest each bound and ten passing parts of each mech drawn at random: 89 that pass, so a change that refuses
|
|
passing parts is seen.
|
|
|
|
| bound | nearest below | nearest above |
|
|
| --- | --- | --- |
|
|
| `WELD` 3e-4 | a plate's seam closes at 3.7e-5 (seraph Torso.SideBlockR; thirteen more from 7.8e-8 up) | a real hole closes at 2.2e-3 (seraph PauldronR.Outer) |
|
|
| `THIN` 1.1e-4 | 6.7e-5 held and let be (chimera CannonBody.gunmetal, 178 turned faces at a bevel's crossings) | 1.88e-4 held and refused as crossing (seraph Torso.LowerInL) |
|
|
| `NUDGE` 1e-6 | a turned cube's faces are held to 1e-8 and four are lost at 1e-9 | plates 1e-5 apart read as one at 1e-4 |
|
|
|
|
What it gives up. A part exported open is capped before it is given. Two sheets nearer than `WELD` are one seam to
|
|
the open check, and a hole that narrow is not seen. A crossing whose region holds under `THIN` is let be: 198 of the
|
|
1,790 passing mech parts have one, the crossing of a bevel or of a lathe's profile, and there the part reads outside
|
|
in what its author took for inside (the phalanges' 10 of 82 faces, 3e-6 to 3e-5 held). `THIN` is on crossings alone:
|
|
a turned piece welded into a whole solid is one solid of positive volume, so it is read as a crossing and one under
|
|
`THIN` passes (a turned plate 1e-4 thick welded to a cube along an edge). What a region holds is measured along its
|
|
faces' normals, not counted: by 60,000 sampled points the region is 2.4e-4 of the extent cubed in Torso.LowerInL,
|
|
2.7e-4 in walker's gun (2.2e-3 held) and 1.2e-5 in CannonBody. A solid turned over inside a whole one is a cavity to
|
|
the winding number and reads so, whatever its author meant. The four crossing parts cannot carry a ram's seat until
|
|
their builders join the gun's cutters and unfold the plate's corner.
|
|
|
|
With every solid closed the number is whole, so `ram.inside` reads the same at any bound over 0 and up to 1; 0.5 is
|
|
pinned in the unit suite on a test-only open cube, where the number is 0.527 under the hole and 0.473 over it.
|
|
|
|
Outside, the distance is to the nearest face of all. Inside, the depth is to the nearest exposed face: one whose
|
|
centroid, set `NUDGE` of the part's extent off the face along its normal, is not inside the part. A face buried in
|
|
another of the part's solids is left out, so a pin sunk 0.056 into a slab with a thin sheet buried along it reads
|
|
0.056 and is refused by a zone of depth 0.01. A face that crosses another solid is kept or left whole by where its
|
|
centroid is, not split: left out, the depth by it reads greater than it is, which the gate takes as a refusal;
|
|
kept, a point by its buried stretch reads shallower than the union's surface is (a boss through a wall: 0.500 for
|
|
0.502 and 0.539 for 0.583 in the live readings).
|
|
|
|
| drive | reading |
|
|
| --- | --- |
|
|
| direct, the joint library's seats, 0..-62 | fits (analytic thigh and shin) |
|
|
| direct, 2,000 seat pairs behind the knee | none fits (analytic thigh and shin) |
|
|
| four-bar behind the knee | passes every gate before clearance: rocker swing 70.5, L 0.722..1.168, arm 0.096..0.265, pin load 1.61, transmission 16.5. Refused on the meshes: the barrel and the rod against the shin's body (the barrel 0.122 inside its clearance, 49 steps), a body the ram is not pinned to |
|
|
| bell crank in front of the knee | fits on the meshes, the plates on either side: rocker swing 105.7, L 0.659..1.038, arm 0.091..0.215, pin load 1.13, transmission 13.8. 60 pairs, 20 of them with a zone. Over 251 steps, uncapped, the least margin of a pair with no zone is 0.034 (the rocker and the eye's pin at -125), then 0.039 (the rod and the rocker's pivot pin at -125) and 0.042 (the coupler and the bracket at 0). With `touch` empty the same gate refuses 19 pairs, each one a zoned pair; each stated zone takes in the least zone that lets its pair. A zone cut to half its radius refuses its pair |
|
|
| the same, a link's x moved | the rocker at x 0.25 (inside the bracket's 0.13..0.35) is refused 0.054 inside the bracket; the coupler at 0.25 (inside the horn's 0.23..0.31) 0.020 inside the horn |
|
|
| bell-crank search on the meshes | 13,824 candidates, each world built from the candidate's pins: 78 pass the gates before clearance, 21 of them are refused on their own parts, the 22nd fits (arm 0.090, swing 99.9, pin load 0.73) and holds at 251 steps |
|
|
|
|
Cost on Starfire, Python 3.13, 100 repetitions paired and interleaved: one candidate's gates before clearance at
|
|
49 steps took 0.79 ms median on the bell crank; its clearance against the analytic parts (50 pairs) took 42 ms
|
|
(5th to 95th percentile 38 to 57) over 97,875 points, of which 23,520 are the samples and the rest the halving in
|
|
zones (the own plates, stated with no slack, to the floor); the samples alone took 11 ms. A search without a world ran 1.6 to 1.8 ms a candidate over 3,456, so `limit`
|
|
(20,000) is 30 to 40 s. On the meshes the bell crank's 60 pairs at 49 steps took 0.80 to 1.00 s capped (two runs), the
|
|
winding number as the plain sum over a part's 124 to 408 triangles in numpy (single precision over double offsets,
|
|
blocks of 32,768 pairs) and the depth a Python loop of BVH queries, and the 13,824-candidate search with its 22
|
|
worlds 34.5 and 38.5 s (two runs) on a quiet machine. With the angles in double precision the search took 47.7 to
|
|
47.9 s (three runs). The live result reports the search's seconds as a reading and no check holds it: beside other
|
|
agents' Blenders at full load the same search took 61 to 94 s. With the refusals and
|
|
the exposed faces found as each of its 22 worlds is made it took 66.8 s, run after 59.3 s for the oracle before
|
|
them under that load (one pair). With the vertices welded and every face read before its centroid it took 45 to 81 s
|
|
under such load (five runs), and reading a 336-face part takes 27 to 37 ms.
|
|
|
|
## The actions
|
|
|
|
| action | fields | what it does |
|
|
| --- | --- | --- |
|
|
| `brokkr_kitbash.describe` | `kit` (default `mechanical`), `part` (default: all) | Parts with their params (type, min, max, default, doc) and sockets in the part frame at default params. Changes nothing. |
|
|
| `brokkr_kitbash.place_part` | `kit`, `part`, `object_name`, `params` | A new mesh object at the origin: the part's mesh, a `Kit Bevel` modifier when the part has a bevel, and the three ID properties. Refuses a name an object already has. |
|
|
| `brokkr_kitbash.set_params` | `object_name`, `params` | Overlays `params` on the stored ones and rebuilds the mesh in the same datablock: modifiers and material slots stay, and the Bevel width follows. Per-face materials are carried by shape: each shape of the part keeps the material most of its faces had, whatever the new face count. Seats the part and the parts attached to it again; refuses a change that breaks a connection or a closure's mate, and a frozen part. Reports the part and `closures`, every closure in the scene as `{part, to, holds}`: its own first, then the broken, then the rest; rows that would not fit a receipt are left off the end and counted in `closuresOmitted`. Each closure in the scene adds a few milliseconds (both its parts are built again to find their sockets). |
|
|
| `brokkr_kitbash.report` | `object_name` (default: every kit part) | Each part as the scene has it: kit, part, params, faces, shells, each socket's world frame, `connection`, `closure` and `frozen`; a frozen part adds `evaluated: {faces}`, and `dirty` (with `frozen` false) when a modifier of it is shown again. `faces` is the live mesh's count. Changes nothing and evaluates no modifier. |
|
|
| `brokkr_kitbash.attach` | `object_name` (the child), `socket`, `parent_name`, `parent_socket`, `roll` (degrees, -360 to 360, default 0) | Seats the child's socket on the parent's and parents it there; the two parts are of one kit or of two whose socket types agree. Reports the child. |
|
|
| `brokkr_kitbash.detach` | `object_name` | Clears the part's connection and the closure it states; it stays where it stands. Refuses a part that has neither. |
|
|
| `brokkr_kitbash.roll` | `object_name`, `roll` (degrees, -360 to 360) | Turns an attached part to that roll where it hangs, and every follower of it with it ("Followers"; the report's `followers` lists each as `{part, value}`). Refuses a part that is not attached, and a follower, naming its driver. Reports the part and `closures` as `set_params` does. |
|
|
| `brokkr_kitbash.aim` | `object_name`, `axis` (`+x`, `-x`, `+y`, `-y`, `+z` or `-z`, the part's own), `direction_x`, `direction_y`, `direction_z` (world, any length) | Solves the roll that turns the axis as far toward the direction as the pin lets it, and turns the part to it. Refuses an axis or direction along the pin. Reports the part, `aimed: {roll, dot}` and `closures`. |
|
|
| `brokkr_kitbash.reach` | `object_name`, `socket` (one of the part's), `height` (metres, -1000 to 1000), `direction_x`, `direction_y`, `direction_z` (world; default 0, 0, 1) | Solves the roll that brings the socket's origin to `height` along the direction, the nearer of the two, and turns the part to it. Refuses a height out of reach, naming the range. Reports the part, `reached: {roll, residual}` and `closures`. |
|
|
| `brokkr_kitbash.joint` | `object_name`, `record` (a JSON object of any of `limits`: `[lo, hi]` or null; `mechanism`: a label or null; `compliance`: `{hertz, damping_ratio}` or null) | States the joint record of an attached part's connection; a key left out keeps what is stated and null clears it. A follower keeps its derived value, and a driver's followers are derived again. Refuses a rigid connection naming its socket type, limits that do not hold the value the joint has, revolute limits over a turn or past 360, prismatic limits past 10 m, and compliance on a revolute joint or without limits. Reports the part and `closures` as `roll` does |
|
|
| `brokkr_kitbash.slide` | `object_name`, `slide` (metres, -10 to 10) | Slides an attached part along its parent socket's normal on a prismatic connection, where it hangs, and every follower of it with it. Refuses a revolute or rigid connection naming its socket type, a slide outside the joint's limits, and a follower. Reports the part and `closures` as `roll` does |
|
|
| `brokkr_kitbash.joints` | `object_name` (the root, a kit part), `after` (default empty: an id, the `next` of the report before) | Reports the joints of the tree attached under the root as `brokkr.joints` version 2: a row per revolute or prismatic connection, parents first and the root's own first when it states one, with `id`, `parent`, `part`, `socket`, `kind`, `axis`, `origin`, `value`, `limits`, `min`, `max`, `held`, `mechanism`, `compliance` and `driven`, in the root's frame, and `unlimited`, `manyDrivers` (the loops with more than one driver) and `next` beside them ("Joint records"). With `after`, the rows after that id. Changes nothing and evaluates no modifier. |
|
|
| `brokkr_kitbash.follow` | `object_name` (the follower; for a loop, the part that states the closure), `record` (JSON: `{driver, kind: "ratio", k, offset}`, `{driver, kind: "loop"}` or null) | States that the part's joint follows the driver's, by a ratio or by keeping its closure closed with its parent's joint, and moves it there at once; null clears the statement, and a loop partner's with it ("Followers"). Refuses a rigid connection, a driver that is the follower, below it or itself a follower, a follower that already follows or drives another, a ratio whose driver states no limits, and a loop without a closure that holds, with both ends or neither moving with the driver, whose ends depend on another driver or on a joint posed by hand, that is not planar or that stands at a dead centre. Reports the part, `followers` and `closures`. |
|
|
| `brokkr_kitbash.close` | `object_name` (the closing part), `socket`, `other_name`, `other_socket` | States that the closing part's socket meets the other part's, closing a loop. Accepted only when they already meet; moves nothing. Reports the closing part. |
|
|
| `brokkr_kitbash.boolean` | `object_name` (any mesh), `cutter`, `operation` (`DIFFERENCE`, `UNION` or `INTERSECT`; default `DIFFERENCE`) | Adds the cutter to the collection of the target's one live Exact Boolean for the operation, above the Bevel. Refuses a cutter that is the target, is not a mesh, or already cuts it, and a scaled target. Reports the part (or `object` for a mesh that is not one), `booleans: [{cutter, operation}]` (difference, union, intersect; each in the order added; `booleansOmitted` counts rows a receipt had no room for) and `evaluated`. |
|
|
| `brokkr_kitbash.cut` | `object_name` (any mesh), `cutter_name`, `part` (`box`, `cyl`, `slot`, `slab`), `params`, `origin_x/y/z`, `direction_x/y/z`, `up_x/y/z` (default 0, 0, 1), `roll` (degrees, default 0), `axis_x/y/z` (default 0, 0, 0: the surface normal) | Places a `cutters` part where the ray meets the target, parented to it, and adds it to the target's difference Boolean. Refuses a ray that misses or has no direction, a name an object has, an `up` along the cutter's axis, an `axis` into the surface and a scaled target. Reports `object`, the `cutter` with its floor sockets, and `booleans` (with `booleansOmitted`, as `boolean`). |
|
|
| `brokkr_kitbash.cut_many` | `object_name` (any mesh), `cuts` (a JSON array of 1 to 64 cutters) | `cut` for several cutters in one action: all placed or none, one evaluation of the target afterwards. Reports `object`, `cutters` (names) and `booleans` (with `booleansOmitted`, as `boolean`). |
|
|
| `brokkr_kitbash.freeze` | `object_name` (any mesh with modifiers) | Makes the evaluated mesh the object's mesh, holds the live mesh in `kit_frozen` and turns every modifier off, keeping the stack, its collections and the cutters. Refuses a frozen object, one with no modifiers, one with a modifier already off and one Blender does not evaluate. Reports the part (or `object`), `frozen`, `faces` (live), `evaluated: {faces, volume, nonManifoldEdges}`, `modifiers` and `booleans`. |
|
|
| `brokkr_kitbash.thaw` | `object_name` | Puts the live mesh back, turns every modifier on and removes the frozen mesh; evaluates nothing. Refuses an object that is not frozen or whose held mesh is gone. Reports `object`, `frozen`, `modifiers` and the live mesh's `faces`. |
|
|
| `brokkr_kitbash.ribs` | `object_name` (the cage), `ribs_name`, `planes` (a JSON array of 1 to 64 `{origin, normal}`, up to 16000 characters), `standoff`, `depth`, `thickness`, `step`, `holes`, `posts`, `post_r`, `bridge`, `clearance`, `longerons` (a JSON array of 0 to 16 `{origin, axis, toward}`, up to 8000 characters), `longeron`, `longeron_w`, `longeron_h`, `longeron_t` | Derives ribs, lightening holes, posts and longerons from the cage as it is cut, as one mesh object under it. Refuses before it writes anything, naming the plane or longeron. Reports `object`, `ribs`, `thickness`, `sections: [{plane, chains, pieces, length, open}]`, `posts`, `holes`, `longerons: [{index, stations}]` (trimmed to a receipt, with `longeronsOmitted`), `faces`, `volume` and `nonManifoldEdges`. |
|
|
| `brokkr_kitbash.shell` | `object_name`, `sheet` (a JSON object `{rings, closed, mirror, creases, rim, flip}`, up to 32000 characters), `thickness`, `offset`, `levels`, `bevel`, `count_folds` | Makes a faceted, hollow armor shell from a loft of rings with crease runs, or rebuilds a shell's cage in place under its cutters and ribs. Refuses before it writes anything, naming the field and index. Reports `object`, `rebuilt`, `rings`, `points`, `cageFaces`, `creases`, `folded` (with `count_folds`, the number of the evaluated wall's inner faces that fold; else null), `corners`, `subdividedFaces`, `facing`, `thickness`, `offset`, `levels` and `children`. |
|
|
| `brokkr_kitbash.hose` | `object_name`, `start`, `end`, `count`, `radius`, `spread`, `clearance`, `bend`, `step`, `sag`, `clamps` (a JSON array of up to 8 `{socket}`), `joint` (empty, or a JSON object `{socket, standoff}`) | Routes a bundle of hoses between two sockets around every other mesh, over clamps and through a pin's axis across its roll range; on a hose's name, rebuilds it in place. Reports `length`, `lengthChange`, `clearance`, `radii`, `sag`, `voxels`, `seed`, `rolls`, `worstRoll`, `faces`, `nonManifoldEdges`. |
|
|
| `brokkr_kitbash.plates` | `table` (a `brokkr.plates.v0` document, JSON), `host`, `frame` (empty, or a JSON 4x4 of rows), `side`, `prefix` | Writes hard plates: each a mesh on its host with `<plate>.fit.<material>` children for panels, bolts and fittings and an empty per anchor; a plate it made is rebuilt in place. Reports `plates` (`name`, `rebuilt`, `corners`, `facets`, `panels`, `bolts`, `anchors`), `host`, `side`. |
|
|
|
|
`params` is `name=value; name=value`; a param left out takes the part's default (`place_part`) or keeps its stored
|
|
value (`set_params`). A value outside its bounds is refused with the bounds in the message.
|
|
|
|
A socket in a report is `{name, type, size, matrix}`: `matrix` is the 4x4 as four rows of 6 decimals, in world
|
|
space for every action that reports a placed part. Column 2 is the outward normal, column 1 up, column 3 the
|
|
origin. A report over 16000 characters (what a receipt carries) is refused with advice to name one part or
|
|
object.
|
|
|
|
Placing a loose part, look, hiding a cutter and export are Brokkr's own rows: `setObjectTransform`,
|
|
`assignMaterial`, `setObjectVisibility`, `exportGltf`. `place_part` has no location or colour fields. Move an
|
|
assembly by its root: an attached part is placed by its connection.
|
|
|
|
## A recipe
|
|
|
|
`tools/run_intents.py` runs this in a background Blender (`install.md`, private user directories required):
|
|
|
|
```json
|
|
{"requestedBy": "nibu/hands", "outputDir": "/work/out", "hostAddons": ["brokkr_mesh_polish", "brokkr_kitbash"],
|
|
"saveBlend": "/work/out/engine.blend",
|
|
"intents": [
|
|
{"action": "brokkr_kitbash.describe", "part": "tank"},
|
|
{"action": "brokkr_kitbash.place_part", "part": "tank", "object_name": "Tank", "params": "radius=0.3; length=1.4"},
|
|
{"action": "setObjectTransform", "targetObjectName": "Tank", "location": [0, 0.6, 0], "rotationEuler": [1.5708, 0, 0]},
|
|
{"action": "assignMaterial", "targetObjectName": "Tank", "materialName": "Machinery", "color": [0.35, 0.35, 0.35]},
|
|
{"action": "brokkr_kitbash.place_part", "part": "pipe_fitting", "object_name": "Tee", "params": "pipe_r=0.06"},
|
|
{"action": "brokkr_kitbash.attach", "object_name": "Tee", "socket": "a", "parent_name": "Tank", "parent_socket": "port_b"},
|
|
{"action": "brokkr_kitbash.place_part", "part": "nozzle", "object_name": "Nozzle", "params": "throat_r=0.06"},
|
|
{"action": "brokkr_kitbash.attach", "object_name": "Nozzle", "socket": "mount", "parent_name": "Tee", "parent_socket": "c", "roll": 90},
|
|
{"action": "brokkr_kitbash.set_params", "object_name": "Tank", "params": "length=1.8"},
|
|
{"action": "createObject", "objectType": "MESH", "name": "Cutter", "location": [0.3, 0.6, 0], "size": 0.2},
|
|
{"action": "brokkr_kitbash.boolean", "object_name": "Tank", "cutter": "Cutter"},
|
|
{"action": "setObjectVisibility", "targetObjectName": "Cutter", "visible": false},
|
|
{"action": "brokkr_kitbash.freeze", "object_name": "Tank"},
|
|
{"action": "brokkr_kitbash.report", "object_name": "Nozzle"},
|
|
{"action": "exportGltf", "filepath": "engine.glb", "selection": ["Tank", "Tee", "Nozzle"]}
|
|
]}
|
|
```
|
|
|
|
The tank's port is 0.4 of its radius across (0.12 m here), so the tee and the nozzle are given the matching
|
|
`pipe_r` and `throat_r`. `set_params` on the tank carries the tee and the nozzle out with its port. The receipts
|
|
file holds each report in `hostResult`. `tools/turntable_recipe.py` renders the saved `.blend`.
|
|
|
|
## The fittings kit
|
|
|
|
`kits/fittings.v0.json`: nine parts that stand on a hard plate's face, placed by `brokkr_kitbash.plate`'s fit rows
|
|
(Hard plates, Anchors and fits). Each stands on +z from z = 0 in its own frame: the origin is the fit's place, z the
|
|
face's normal, y the face's up. One material a part and no sockets. The defaults are the mech tracks' sizes.
|
|
|
|
| part | params | what it is |
|
|
| --- | --- | --- |
|
|
| `bolt` | `r` | a hex head (r to its corners, 0.7 r tall) on a washer 1.55 r; the bolt of a `bolts` row |
|
|
| `slot` | `w`, `h` | the rim of a w by h slot: four bars 0.032 wide, 0.028 tall |
|
|
| `pit` | `w`, `h`, `depth`, `count`, `pitch` | the dark box under an opening, `count` of them `pitch` apart along y, centred. Under a slot: depth 0.012. Under vents: depth 0.01, the vents' count, pitch 2.7 h |
|
|
| `vents` | `w`, `h`, `count` | `count` louvre lips tilted 28 degrees, 2.7 h apart along y, centred |
|
|
| `access_port` | `r` | a turned ring of radius r around a sunk cover with a raised boss, 28 segments |
|
|
| `port_bolts` | `r` | the port's eight hex heads on a circle 0.91 r, standing from the ring's shoulder at z 0.035 |
|
|
| `handle` | `length`, `lift`, `r` | a bar along y on two posts, bent over at `lift`, a washer and a hex foot under each post. `roll` 90 lays it along the face's a |
|
|
| `eye` | `size` | a lifting eye: a pad with two bolts, a neck, and a ring standing in the plane of y and z |
|
|
| `louvres` | `w`, `h`, `n`, `depth`, `frame`, `slant` | a framed bank of n slats tilted `slant` degrees about x; `frame` is under w and h |
|
|
|
|
Each part's points are the tracks' own (`surface.py`'s bolt row, grab handle and lifting eye, `hardplate.py`'s
|
|
slot, vents and port, `hardpoint.py`'s louvres) within 2e-8 m, float32 against float64, with two differences the
|
|
kit format sets: the handle's bar is a square section of side 2 r, mitred at its bends, where the tracks swept an
|
|
octagon; and the eye's pad is a plain box where the tracks' was a rounded outline with a chamfered rim. A handle
|
|
whose bar is thick against its bend (`r` over about a quarter of `min(0.4 lift, 0.2 length)`) may fold on the
|
|
inside of a turn, and is refused.
|
|
|
|
## The mechanical kit
|
|
|
|
`kits/mechanical.v0.json`: thirteen parts, each along +z, with socket types `flange` (equal), `mount` (fits),
|
|
`pivot` (equal, revolute), `slide` (equal, prismatic: a telescoping bore, sized by its diameter) and `hose` (fits:
|
|
a port takes a bundle no wider than its size).
|
|
|
|
| part | params | sockets |
|
|
| --- | --- | --- |
|
|
| `nozzle` | `throat_r`, `exit_r`, `length`, `wall`, `segments` | `mount` (flange) |
|
|
| `tank` | `radius`, `length`, `segments` | `port_a`, `port_b` (flange), `saddle` (mount), `lug_a`, `lug_b`, `lug_a_back`, `lug_b_back` (mount): a lug on each side (+x, and -x for `_back`) of each strap |
|
|
| `ribbed_cylinder` | `radius`, `length`, `ribs`, `rib_depth`, `rib_width`, `segments` | `end_a`, `end_b` (flange) |
|
|
| `strut` | `length`, `width`, `thickness`, `segments` | `end_a`, `end_a_back`, `end_b`, `end_b_back` (pivot): the two end faces of the pin at each end |
|
|
| `actuator` | `body_r`, `body_len`, `rod_r`, `extension`, `segments` | `base`, `base_back`, `rod_end`, `rod_end_back` (pivot); the rod end's two move with `extension`; `port_cap`, `port_rod` (hose, `0.4*body_r` wide) on the end faces of its two port bosses |
|
|
| `ram_barrel` | `body_r`, `body_len`, `rod_r`, `segments` | the actuator up to its gland: `base`, `base_back` (pivot); `bore` (slide, `2*rod_r`) at the closed piston face, its z along the barrel; `port_cap`, `port_rod` (hose) |
|
|
| `ram_rod` | `body_r`, `rod_r`, `length`, `segments` | the actuator from its gland: `piston` (slide, `2*rod_r`); `rod_end`, `rod_end_back` (pivot). In a barrel's bore slide 0 is closed and the slide is the extension; a rod of `length` `body_len + 1.1*body_r` stands as the actuator does |
|
|
| `pipe_fitting` | `pipe_r`, `run`, `branch`, `flange_r`, `flange_t`, `segments` | `a`, `b`, `c` (flange) |
|
|
| `radiator_stack` | `fins`, `fin_w`, `fin_h`, `fin_t`, `pitch`, `segments` | `base` (mount) |
|
|
| `vent` | `width`, `height`, `depth`, `slats`, `slat_t`, `tilt` | `back` (mount) |
|
|
| `plate` | `width`, `height`, `thickness` | `back`, `front` (mount) |
|
|
| `reducer` | `big_r`, `small_r`, `length`, `flange_t`, `segments` | `big`, `small` (flange) |
|
|
| `bracket` | `pin_r`, `height`, `width`, `ear_t`, `segments` | `mount` (mount), `pivot`, `pivot_back` (pivot) |
|
|
|
|
`describe` gives the bounds and docs.
|
|
|
|
Which flanges can meet follows from the sizes: a tank port is `0.4*radius` (0.048 to 0.14), a pipe fitting's
|
|
three faces `2*pipe_r` (0.06 to 0.14), a nozzle's mount `2*throat_r` (0.08 to 0.24), and a ribbed cylinder's ends
|
|
`2*radius` (0.16 to 0.6). So tanks, fittings and nozzles plumb together, and a ribbed cylinder takes a nozzle
|
|
(throat 0.08 and up) or another ribbed cylinder face to face: its smallest flange is larger than the largest
|
|
pipe. A reducer joins the two: its `big` face is `2*big_r` (0.16 to 0.6, a ribbed cylinder's whole range) and
|
|
its `small` face `2*small_r` (0.048 to 0.14): a tank port over that whole range, and a fitting's face only from
|
|
`small_r` 0.03, the smallest pipe. So a chamber hangs in a tank's
|
|
tree as tank, tee, reducer, ribbed cylinder, nozzle. Mounts (`fits`) take any part whose seat is no larger than
|
|
theirs.
|
|
|
|
Pins: a strut's are `0.6*width` across (0.024 to 0.072), an actuator's `0.9*body_r` (0.045 to 0.108) and a
|
|
bracket's `2*pin_r` (0.024 to 0.108), so a bracket can be sized to either, and a strut pins to an actuator when
|
|
`0.6*width` equals `0.9*body_r`. Pinned parts hinge: the roll is the angle between them. A bracket is how a pin
|
|
meets a flat seat: its `mount` sits on a plate, a saddle or a tank lug (a lug seats a plate up to `0.3*radius`
|
|
wide), and its pin runs across the seat's up axis, so on a tank lug at roll 0 a leg swings in a plane through
|
|
the tank's axis. The bracket's `pivot` face lies on its plate's centre plane, so a bracket on a second lug of
|
|
the same side, turned half (roll 180), pins on the same plane facing the first. An actuator on one and a strut
|
|
on the other then lie in one plane and can meet at a pin: a braced leg.
|
|
|
|
## The frame kit
|
|
|
|
`kits/frame.v0.json`: nine parts of chassis structure, every shell an extrude. Its socket types are `mount` (fits)
|
|
and `pivot` (equal, revolute), the same two lines as `mechanical`'s, so a frame part seats on a mechanical one and the other
|
|
way round (`place_part` and `describe` take `kit: "frame"`).
|
|
|
|
| part | params | what it is | sockets |
|
|
| --- | --- | --- | --- |
|
|
| `beam_i`, `channel`, `tee`, `angle` | `length`, `w`, `h`, `t` | An I, C, T or L section along +z from 0 to `length`, `w` across x and `h` along y. `t` is held under 0.45 of the smaller of `w` and `h`. | `end_a` (z -z) and `end_b` (z +z), `mount`, size the smaller of `w` and `h`. On a channel and an angle they sit on the web at -x, where the end face is. |
|
|
| `box_beam` | `length`, `w`, `h` | A solid rectangular bar along +z. | `end_a`, `end_b`, as a beam's |
|
|
| `truss` | `length`, `height`, `pairs`, `chord`, `web` | A plane truss along +x in the xz plane: two square chords at z 0 and z `height`, `2*pairs + 1` verticals and `2*pairs` diagonals, rising then falling: `4*pairs + 3` shells. Bays come in pairs (1 to 16) because an expression has no floor: the diagonals are two repeats a double bay apart. | `end_a` (z -x) and `end_b` (z +x) on the end verticals at mid-height, `mount`, size `height` |
|
|
| `portal` | `width`, `height`, `w`, `h`, `t` | One I section up a leg, across and down the other in the xz plane, mitred at both corners. Its web stands in the frame's plane: `h` is the section's height in that plane, flange to flange, and `w` the flanges' width across y. | `foot_a`, `foot_b` (z -z), `mount` |
|
|
| `gusset` | `w`, `h`, `t`, `thickness` | A corner plate in the xy plane with its right angle at the origin, legs along +x and +y, `thickness` along +z. | `leg_a` on the x leg's edge (z -y) and `leg_b` on the y leg's (z -x), `mount`, size `thickness` |
|
|
| `wedge` | `length`, `w`, `h`, `t` | A toe cap, ramp or chock along +x: base on z 0, back `h` tall at -y, sloping to a front `t` tall at +y (`t` held under 0.9 of `h`). | `base` (z -z) and `back` (z -y), `mount` |
|
|
|
|
No frame part has a bevel. `core.build` costs, as medians of 21 interleaved builds on the workstation beside the
|
|
mechanical actuator's 2.3 ms: a beam, the portal, the gusset or the wedge 0.7 to 0.9 ms; the truss 2.8 ms at
|
|
`pairs` 4 (19 shells) and 3.8 ms at `pairs` 16 (67 shells). A repeat sweeps its one shape once and copies it, so
|
|
a truss costs four sweeps whatever its bays; the same 19 and 67 shells swept one by one measured 5.9 ms and 20.7 ms.
|
|
|
|
## Adding a part or a kit
|
|
|
|
Edit the kit's JSON (or add `kits/<name>.v0.json`, whose `kit` field is `<name>`), then run the tests:
|
|
|
|
```text
|
|
python -m unittest discover -s surfaces/blender/tests -p "test_kitbash.py" -v
|
|
```
|
|
|
|
`MechanicalKitTests` builds every part of `mechanical` at its default, all-minimum and all-maximum params and at
|
|
16 seeded draws, and checks that every shell is closed and wound outward, every socket frame is right-handed and
|
|
seated on a face that faces its `z`, and no build passes 20000 faces. Choose param ranges so every combination
|
|
builds: a `min` or `max` in an expression keeps a derived length positive where two params could cross. A new
|
|
part of `mechanical` also joins the part and socket list in `test_the_kit_is_the_thirteen_parts_and_five_socket_types`.
|
|
`FrameKitTests` holds `frame` to the same (the seat check reads a cap that is not convex, an I section's, as it
|
|
reads a convex one), with the truss's shells and chords, the portal's mitres, its web in the frame's plane and its
|
|
feet apart, each beam's `w` across x and `h` along y, and a beam seated on a mechanical
|
|
bracket. Its bounds `SEATED`, `VOLUME` and `PLACED` carry their shipped and mutant readings in `tests/test_kitbash.py`. `CuttersKitTests` holds `cutters` to the same, with each floor on its cutter's bottom, and `SurfaceFrameTests` the
|
|
frame `cut` gives a cutter. `MateTests` covers the mate arithmetic and what may mate, within a kit and across two,
|
|
`PoseTests` the closed-form rolls. The operators are exercised in a real Blender by
|
|
`tests/live/kitbash.py` (placing and re-parameterising, and the frame kit: its nine parts placed, the truss
|
|
re-parameterised, a beam seated on a bracket), `tests/live/kitbash_assembly.py` (attach, detach,
|
|
`set_params` on assemblies, a braced leg closed by `close`, boolean, and freeze and thaw with what a frozen part costs), `tests/live/kitbash_shell.py`
|
|
(`cut` and `cut_many` on a cage that is not a kit part, a part on a cutter's floor, the three Boolean modifiers, an object in no
|
|
collection), `tests/live/kitbash_pose.py` (roll, aim, reach and joint records) and `tests/live/kitbash_follows.py`
|
|
(followers: a four-bar, a ram closing on its rocker, ratios, a torque link, the one-driver refusals, and a joints report in pages).
|