- A joint of two cars (a rooted bonebend whose head is held to the whole turn of the next car) keeps the pieces of
its spine as long as made (bones::keep_lengths): the bellows and the roof cables turn with the cars, no longer
stretched and pressed by the play of the articulated coupling as the train brakes and pulls.
- The turn is spread evenly along a rooted bend only for such a joint; a hose hanging from its cock (rooted, its
head held to a line) turns along its chain, and is halved into small triangles like any other hose.
- Each buffer is pressed in by the deflection of its end as the coupling has it (half the distance of the
couplers, or that of the end in the physical model of the coupling) and by half of what its head stands nearer
to the one it meets than the axis does: on the straight as before, on a curve the inside more.
Assets (SVN pctga, scratchpad tool weze.py, not committed there yet): the .mmd of 404 vehicles get hose chains
(hz_*: from each cock of pneumatic<n>[r]_On and cpneumatic<n>[r]_On to the point the heads share with the next
vehicle), and those with automatic couplers a bone turning coupler<n>/cctrl<n>_on towards the pivot of the next
one; the EN57 through a new attachments_<stem>_w.inc. The whole control cables of ukrotnienie.py are rehung
smoothly from socket to socket. Without them the vehicles are drawn as before.
- bonebend: an optional third point after head holds the head to the whole turn of the next car; on a rooted
bend the turn is spread along the spine by its length, so a joint bends the same from both cars and two halves
meeting at it (bellows, rubber collars) stand on the plane halving the angle.
- Control cables: cctrl1/cctrl2 are AirCoupler buttons now. Where both coupled vehicles have cctrl<n>_xon at the
ends that meet, the coupling owner (Render) shows _on, a cable modelled whole from socket to socket, and the
other _xon, its plugs alone; otherwise both show _on as before. No model has _xon yet, so nothing changes for
the data as it is.
- Buffers: each buffer of a coupled end is pressed in by half its overlap with the nearest head of the next
vehicle on the track, so the inside of a curve presses in and the outside stands clear. gfx.buffers.curve no
in eu07.ini keeps both alike, by half the distance of the couplers, as before.
- bones_doc.md describes them.
Assets (SVN pctga, made by scratchpad tools harmonijki.py, ukrotnienie.py and gumy.py, not committed there yet):
- new <stem>_h.t3d, przegub_<stem>_h.t3d and reworked *_h.t3d components for elf_v1 (27web without its e-f
joint), impuls_v1, sa134_v1 and 21xm_v1, the .mmd pointing at them with bone entries;
- new <stem>_u.t3d and ukrotnienie_<stem>_u.t3d (whole cables in cctrl<n>_on_kable, plugs in cctrl<n>_xon) for
4e_v1, en57_v1, 303e_v1, br285_v1, ep05_v2, et41_v2, ew58_v1, ew60_v1, m62_mod_v1, sm42_v1, sp42_v1, sp45_v1,
st44_v1, st44_v2, su42_v1, su45_v2, su46_v2, tem2_v2, tem2u_v2; the EN57 .mmd name them by their parameters and a
new attachments_<stem>_u.inc holding the bone entries;
- new <stem>_g.t3d and gumy_<stem>_g.t3d (gangway_rubber1/2) for 110a_v2, 11xa_v2, 111arow_v1, 113aa_v1, 14xa_v1,
16xa_v1 and 168a_v1.
Without them the vehicles are drawn as before.
A long hose (the 33 nodes of the test EU07's) trembled by about 2 mm a frame when standing. The solver keeps its
lengths only nearly in 40 passes, so where it settles depends on the length of the substep, and the substeps took the
length of each frame: 4 to 9 ms frames gave a slightly different hang each frame. Steady frames left it still.
- The chains now take substeps of 1/240 s whatever the frames. The time short of a substep waits for the next frame,
and the nodes as drawn go along with their ends meanwhile (bones::drawn()), so a running vehicle doesn't leave
them behind. At high frame rates that is fewer substeps than before, when every frame took at least one.
- A chain whose nodes and ends stand still for a second is left at rest, not simulated, until an end moves 0.1 mm.
With nothing moved, its bent hose isn't posed or uploaded either.
In the game, a standing EU07 of test/4e_kosci: the middle of a hose moves 0.0 mm a frame, its chain at rest.
Assets: none.
A bonebend can be rooted (`bonebend: ... head <point> <point> rooted end`): the first point of its spine sits on the
face of a car body, everything at or behind it stays as made, and the root does not turn. The part past it, the half
of a gangway bellows on the end of the car, bends from the body to its head. `head` holds the head to the line from
a point inside this car to one as far inside the next. That line halves the angle between the two cars, so the faces
of the two halves stay on one plane round a curve rather than crossing at the joint.
- Several bends of one submodel (the bellows on both ends of a middle car) bend one copy of it, each bend its own
part. A rooted submodel is not cut into smaller triangles.
- A bent submodel whose spines stand still (a train standing, or on a straight or one radius) is not posed and
uploaded again.
- `rooted` may stand before or after the head.
Without the new entries nothing changes.
Assets: none needed. The Elf EN76 (pkp/elf_v1) shows it once its 22wee-a, 22wee-b, 22wee-c and 22wee-d .mmd get
the entries in bones_doc.md, before endmodels. The middle cars need a root, a joint and a head line on each end of
model_glowny; the end cars need them on the inner end of pudlo. They are added in the local SVN working copy, not
committed yet.
Measured on two coupled EU07 with their 16 bent hoses, the camera at the coupling: the bones of the two cost 17 ms a
frame, 13.7 of them bending 171 000 vertices of the hoses and 3.4 the chains. Now 3.0 ms (1.9 and 1.0), and 0.08 ms
with the camera 100 m off:
- the triangles of a bent submodel halved down to 6 cm rather than 2.5: a hose of the EU07 has 3200 vertices rather
than 10 700, still finer than the 5.6 cm between the nodes of its chain;
- each vertex turned in single precision by the mixed and normalised quaternions of its nodes (as good as a slerp for
the small angles between neighbouring nodes), not by a matrix made for it from a slerp in double precision;
- the chain solver keeps the points and the pulls of its passes rather than making them anew in each of them;
- bent submodels bent and drawn only within 50 m of the camera, the model's own drawn farther; the chains moved only
within 75 m, starting again where made when the vehicle comes near (a chain the next vehicle shares is moved
whenever that one needs it, however far or out of sight this one is).
Looks as before up close; the unit tests and the scenario cases pass as they did.
Assets: none.
At a wide swing to the side the coupled heads seemed to come apart:
- The chain hung on pins at its ends and swung about the line between the cocks like a pendulum, over 30 cm to the
side. The rigid head then turned far against the rubber.
- Since the hose is halved into small triangles, part of each head's vertices lay nearest the last but one piece of
the spine. Those followed the rubber, not the head, and the head bent apart.
Now:
- An end of a chain at a fixed or coupler point is clamped: the node next to it is drawn to where it is as made, held
to that vehicle (for a coupler point, to the next one). The hose leaves its cock as made. In a unit test a hose swung
40 degrees to the side goes 1.8 cm to the side clamped, where it went 13.2 cm on pins.
- All of a coupling head within 8 cm of where the heads meet is held to the head as one, whichever piece it lies
nearest.
- Measured in a drive of two EU07, the centres of the two heads keep 55.9 mm apart (their place side by side in the
coupling) with no change at all over 784 frames.
Assets: none.
Driving on uneven track, the hoses between two coupled vehicles flew up and the coupled heads came apart:
- The chain started at rest under a vehicle already running, and was left behind by it: the head flew 1 m up.
- A frame longer than 0.1 s was cut short while the ends moved all the way, a jolt against the vehicle.
- The substeps change their length from frame to frame, and the move of the last one was taken as it was: a jolt
of some centimetres a substep at 50 km/h (12.8 cm of swing in the new unit test, under 5 mm now).
- Each of the two vehicles moved its own copy of the hose; started apart or jolted, the copies drifted up to 25 cm.
Now a chain starts going along with its ends, the move of the last substep is scaled to the next one, the chains
move by the whole frame time and start again after a gap of more than 0.5 s, and a hose from cock to cock is moved
by one of the two coupled vehicles, the other drawing the same chain from its end. Measured on two EU07 at 50 km/h
on uneven track: the heads of the two vehicles 0.0 mm apart, the head within 0.40..0.67 m of height (it was
0.38..1.55 m).
Assets: none.
A new .mmd entry, bonebend, bends a submodel made in one piece (the hoses of the existing models, pneumatic*) along
a spine of points: each vertex follows the nearest piece of the spine, the turn carried along it from the cock so
the rubber twists evenly. With head, the coupling head is held as one to the line between two points and the
vertical of the world, so the heads of two coupled hoses stay together on one plane. The vertices are bent on the
CPU into the vehicle's own copy of the submodel, drawn in its place.
The chains (bonechain) now:
- keep every other node at its distance as made, so a hose keeps its curve rather than folding;
- damp only the swing against the vehicle, so a hose goes along with the vehicle's own motion;
- average what the lengths ask of each node: the plain sum overshot, and a chain shivered and stretched by a fifth;
- take up to 64 nodes, enough for one chain from a cock to the cock of the next vehicle with the head node
between: both vehicles get the same chain, and the coupled heads lag and swing with the hoses;
- move once a frame, by the render time, not once a render pass.
Assets: none needed. A vehicle without bonebend lines in its .mmd is drawn as before; bones_doc.md has the entries
for an EU07 hose. Tried on a local test copy of the EU07 (dynamic/test/4e_kosci, not in the SVN), not on a vehicle
of the SVN yet.
A vehicle's .mmd can pin submodels of its model to points that move and turn them to keep facing another point
(vehicle/bones.h, TDynamicObject::update_bones(), run with the wheels):
- bonepoint: fixed, crank (going round with a wheel submodel of animwheelprefix:), slide (a crosshead on its
guide keeping the length of the connecting rod), coupler (the next vehicle's hook, following it round a curve,
over uneven track and with the buffers pressed in), mid (halfway between two points);
- bonechain: a chain hanging between two points, its nodes swinging with gravity and inertia (Verlet
integration in the world frame, substeps of 1/240 s at most), so a hose made of pieces swings when the vehicle
jerks or rocks and sags as the buffers close up;
- bone: a submodel moved with its anchor point and turned about it to face another point, or only moved.
The submodels are posed with TSubModel::SetTranslate() and SetRotateXYZ(), in their own frame whatever their
origin and axes, and get their future_transform for the motion blur. A model without these entries is drawn as
before; the old entries animpistonprefix:, animconrodprefix:, animreturnprefix: and pistonfactors: still do
nothing. bones_doc.md describes them, with examples.
Unit tests (tests/unit/test_bones.cpp): the crank and the crosshead (the stroke twice the crank), the connecting
rod keeping both its ends for a submodel turned in its frame, the angles giving what TSubModel::RaAnimation()
does, the coupler, the hose meeting point, a chain hanging and swinging after a jerk, and the .mmd errors.
Game data: the placeholder Ty2 of dynamic/pkp/ty2_v1 (SVN working copy, not committed) has its rods and its brake
hose to the tender as bones in ty2.mmd. The EU07 (dynamic/pkp/4e_v1/4e.mmd) could take the six coupler lines of
bones_doc.md, which were tried on a copy in a test folder; the data in the SVN isn't changed.