18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-02 00:22:42 +01:00
Commit Graph

2 Commits

Author SHA1 Message Date
maj00r c8068d8f3d feat(model): animation clips of EU07M models, played on scenery instances
Stage 8 of the EU07M model format. A model can carry animation clips; each track of a clip sets the translation, the
rotation or the scale of a node at a time of the clip, and the parts of a node without a track keep its TRS.

- Format, five optional sections: ACLP (clips: name, duration, flags 0x1 loop and 0x2 autoplay, range of tracks), ATRK
  (tracks: node, part, interpolation step / linear / cubic, ranges of keys), ATIM (key times), AVEC (vectors; with cubic
  the in-tangent, value and out-tangent of glTF) and AROT (rotations in 8 bytes, "smallest three": the three smaller
  components as snorm16 scaled by sqrt(2) and the index of the largest; eu07m::encode_rotation / decode_rotation).
  The validator refuses a node out of range, keys out of their arrays, times which aren't numbers from 0 up, a cubic
  rotation and tracks out of the range of the clip. -eu07m dump lists the clips and their tracks. The current release
  doesn't read these sections; a file without them loads as before.
- Sampling (model/clip.cpp): step, lerp / slerp the shorter way, the Hermite spline of glTF with tangents per second;
  the first and the last key held outside of them; a looped clip goes around its duration, another stops at its end.
- In the game: the clips play by the simulation time, from TAnimModel::play_clip(name, speed) or, flagged autoplay, from
  the first time the instance is drawn. RaPrepare() samples them for the instance drawn and sets the transforms of the
  nodes (TSubModel::SetClipTransform(), the new animation type at_Clip, gated by the instance like the others), so a clip
  moving the joints of a skin bends the skinned parts. The nodes a clip moves are flagged animated at load, which keeps
  the model out of the instancing. stop_clips() stops them.
- The editor self-test gets "clip <node> <name> [speed]".

Not yet: a scenery event starting a clip, and the CHNL channels bound to the time of a clip.

Checked: a skinned tube with an autoplay clip (the tip to 60 degrees and back in 2 s, looped) beside a still one, six
screenshots in Vulkan and in GL 4.6 go from straight to fully bent while the other stays (time let run in the editor for
the test only). Unit tests 1200/1200, 6 new ones for the packing, the interpolations, the time and the file. Not built
with GCC here.
2026-11-29 00:49:44 +01:00
maj00r d324c53233 feat(model): skinned parts of EU07M models move with their joints, skinned on the CPU
Stage 4 of the EU07M model format. A primitive with a skin (SKIN, SKJT, weights in VSKN or VSKW) was drawn in its bind
pose. Now it follows the joints of its skin, in both renderers.

- The joints are nodes of the model, so they're posed as before: animation events, the .mmd, SetRotate / SetTranslate
  from the vehicle code. The matrix of a joint is world(joint) * inverse bind(joint), world being the transform of the
  joint from the root of the model with the animations of the instance drawn (TSubModel::posed_transform()); the
  vertices lie in the bind pose in the space of the model, the transform of the node of the mesh left out, as in glTF.
- The loader keeps the bind pose and the weights of a skinned primitive (skinning::skinned_geometry on the submodel) and
  the skins of the model (TModel3d::skins()).
- The first pass of a frame to draw a skinned submodel of an instance works out the palette and, when it changed, moves
  the vertices on the CPU: positions by the blended matrix, normals and tangents by its rotation (model/skinning.cpp,
  gfx::skin_cache in rendering/common/skincache.cpp). The geometry of the instance is made or replaced before the passes
  of the next frame (flush() in the frame setup of both renderers), as nothing the passes draw may change while they draw
  (gfx::walk_sync): the vertices follow the joints a frame late. In the bind pose the shared geometry of the model is
  drawn; an instance not drawn for 600 frames lets go of its own.
- Fix: a node with range_max_sq 0, which the spec gives as no limit, was never drawn (a model made anew rather than
  converted from E3D); it keeps the default range of a submodel now.
- The editor self-test gets "animate <node> <submodel> <x> <y> <z>", which turns a submodel of an instance as an
  animation event does, since the editor doesn't run the events.

Not in this commit: the skinning in a compute shader, bounds of the posed submodel, motion vectors and ray tracing of the
moved vertices.

Checked: a tube of two joints in two instances, one turned by 60 degrees at its middle, bends smoothly while the other
stays straight, in Vulkan and GL 4.6, with gfx.gpucull 0 and 1 (time let run in the editor for the test only). Unit
tests 1194/1194, 5 new ones for the weights, the bind pose, the blending and the file. Not built with GCC here.
2026-11-28 23:52:35 +01:00